File: mahi_constants.h

package info (click to toggle)
chromium 139.0.7258.127-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 6,122,068 kB
  • sloc: cpp: 35,100,771; ansic: 7,163,530; javascript: 4,103,002; python: 1,436,920; asm: 946,517; xml: 746,709; pascal: 187,653; perl: 88,691; sh: 88,436; objc: 79,953; sql: 51,488; cs: 44,583; fortran: 24,137; makefile: 22,147; tcl: 15,277; php: 13,980; yacc: 8,984; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (164 lines) | stat: -rw-r--r-- 6,229 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
// Copyright 2024 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef ASH_SYSTEM_MAHI_MAHI_CONSTANTS_H_
#define ASH_SYSTEM_MAHI_MAHI_CONSTANTS_H_

#include "base/time/time.h"
#include "ui/gfx/geometry/insets.h"
#include "ui/gfx/geometry/size.h"
#include "ui/views/highlight_border.h"

namespace ash::mahi_constants {

// The view ids that will be used for all children views within the Mahi panel.
enum ViewId {
  kMahiPanelMainContainer = 1,
  kCloseButton,
  kContentSourceButton,
  kScrollView,
  kScrollViewContents,
  kSummaryLabel,
  kFeedbackButtonsContainer,
  kThumbsUpButton,
  kThumbsDownButton,
  kFooterLabel,
  kRefreshView,
  kMahiPanelView,
  kSummaryOutlinesSection,
  kQuestionAnswerView,
  kAskQuestionSendButton,
  kGoToQuestionAndAnswerButton,
  kGoToSummaryOutlinesButton,
  kOutlinesContainer,
  kSummaryLoadingAnimatedImage,
  kOutlinesLoadingAnimatedImage,
  kAnswerLoadingAnimatedImage,
  kPanelContentsContainer,
  kQuestionTextfield,
  // Since every text bubble label has this ID, the view lookup will
  // only be performed from one parent above.
  kQuestionAnswerTextBubbleLabel,
  // TODO(b/330643995): Remove this when outlines are shown by default.
  kOutlinesSectionContainer,
  kBannerTitleLabel,
  kRefreshButton,
  kErrorStatusView,
  kErrorStatusLabel,
  kErrorStatusRetryLink,
  kQuestionAnswerErrorImage,
  kQuestionAnswerErrorLabel,
  kInfoSparkIcon,
  kSummaryElucidationIndicator,
  kDragHandleIcon,
};

// The size of the icon that appears in the panel's source row.
inline constexpr gfx::Size kContentIconSize = gfx::Size(16, 16);

inline constexpr int kPanelDefaultWidth = 360;
inline constexpr int kPanelDefaultHeight = 492;
inline constexpr gfx::Insets kPanelPadding = gfx::Insets::TLBR(12, 15, 15, 15);

// The maximum height and width the panel can be resized to.
inline constexpr int kPanelMaximumWidth = 540;
inline constexpr int kPanelMaximumHeight = 600;

inline constexpr int kPanelBorderAndPadding =
    views::kHighlightBorderThickness * 2 + kPanelPadding.width();
inline constexpr int kScrollViewDefaultWidth =
    kPanelDefaultWidth - kPanelBorderAndPadding;

inline constexpr int kScrollContentsViewBottomPadding = 40;

inline constexpr int kRefreshBannerStackDepth = 25;
inline constexpr int kPanelCornerRadius = 16;

inline constexpr SkScalar kContentScrollViewCornerRadius = 16;

inline constexpr int kFeedbackButtonIconSize = 20;
inline constexpr int kFeedbackButtonIconPaddingAbove = 8;
inline constexpr int kFeedbackButtonIconPaddingBetween = 16;
inline constexpr int kFeedbackButtonIconPaddingLeft = 12;
inline constexpr int kFeedbackButtonIconPaddingRight = 8;

// A feedback button is a "small" `IconButton`, meaning it has a button (view)
// size of 24px and an icon size of 20px. The feedback button's icon is aligned
// to the rightmost edge of the view, creating 4px of padding to the left of the
// icon. Subtract that padding from the expected space between the two icons.
// NOTE: Changes to the feedback buttons' size will affect this constant.
inline constexpr int kFeedbackButtonSpacing =
    kFeedbackButtonIconPaddingBetween - 4;

// Height of the cutout in the content section's bottom-right corner, not
// including the rounded corner immediately above it.
inline constexpr int kCutoutHeight =
    kFeedbackButtonIconSize + kFeedbackButtonIconPaddingAbove;

// Width of the cutout in the content section's bottom-right corner, not
// including the rounded corner immediately to its left.
inline constexpr int kCutoutWidth =
    kFeedbackButtonIconPaddingLeft + kFeedbackButtonIconPaddingRight +
    kFeedbackButtonIconSize * 2 + kFeedbackButtonIconPaddingBetween;

// Radius of the cutout's first and third curves of the cutout region in the
// Mahi panel.
inline constexpr SkScalar kCutoutConvexRadius = 10.f;
// Radius of the cutout's second curve.
inline constexpr SkScalar kCutoutConcaveRadius = 12.f;

// Delays used in `FakeMahiManager` for testing.
inline constexpr int kFakeMahiManagerGetContentDelaySeconds = 2;
inline constexpr int kFakeMahiManagerLoadAnswerDelaySeconds = 3;
inline constexpr int kFakeMahiManagerLoadSummaryDelaySeconds = 4;
inline constexpr int kFakeMahiManagerLoadElucidationDelaySeconds = 4;
inline constexpr int kFakeMahiManagerLoadOutlinesDelaySeconds = 6;

inline constexpr gfx::Insets kSummaryOutlinesElucidationSectionPadding =
    gfx::Insets(16);

// Nudge constants
inline constexpr char kMahiNudgeId[] = "mahi.nudge";
inline constexpr base::TimeDelta kNudgeTimeBetweenShown = base::Hours(24);
inline constexpr int kNudgeMaxShownCount = 3;

// Metrics
// Contains the types of button existed in Mahi Panel widget. Note: this should
// be kept in sync with `PanelButton` enum in
// tools/metrics/histograms/metadata/ash/enums.xml
enum class PanelButton {
  kCloseButton = 0,
  kLearnMoreLink = 1,
  kAskQuestionSendButton = 2,
  kGoToSummaryOutlinesButton = 3,
  kRefreshButton = 4,
  kGoToQuestionAndAnswerButton = 5,
  kMaxValue = kGoToQuestionAndAnswerButton,
};

inline constexpr char kMahiFeedbackHistogramName[] = "Ash.Mahi.Feedback";
inline constexpr char kMahiButtonClickHistogramName[] =
    "Ash.Mahi.ButtonClicked";
inline constexpr char kAnswerLoadingTimeHistogramName[] =
    "Ash.Mahi.QuestionAnswer.LoadingTime";
inline constexpr char kSummaryLoadingTimeHistogramName[] =
    "Ash.Mahi.Summary.LoadingTime";
inline constexpr char kElucidationLoadingTimeHistogramName[] =
    "Ash.Mahi.Elucidation.LoadingTime";
inline constexpr char kMahiUserJourneyTimeHistogramName[] =
    "Ash.Mahi.UserJourneyTime";
inline constexpr char kMahiQuestionSourceHistogramName[] =
    "Ash.Mahi.QuestionSource";
inline constexpr char kQuestionCountPerMahiSessionHistogramName[] =
    "Ash.Mahi.QuestionCountPerMahiSession";
inline constexpr char kTimesMahiPanelOpenedPerSessionHistogramName[] =
    "Ash.Mahi.TimesPanelOpenedPerSession";
inline constexpr char kMahiPanelResizingHistogram[] =
    "Ash.Mahi.PresentationTime.Resize";
inline constexpr char kMahiPanelResizingMaxLatencyHistogram[] =
    "Ash.Mahi.PresentationTime.MaxLatency.Resize";

}  // namespace ash::mahi_constants

#endif  // ASH_SYSTEM_MAHI_MAHI_CONSTANTS_H_