Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(115)

Side by Side Diff: chrome/browser/ui/autofill/autofill_dialog_types.cc

Issue 1931043002: Remove requestAutocomplete (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/ui/autofill/autofill_dialog_types.h"
6
7 #include <stddef.h>
8
9 #include "base/logging.h"
10 #include "base/strings/string_split.h"
11 #include "base/strings/string_util.h"
12 #include "ui/gfx/color_palette.h"
13
14 namespace {
15
16 bool IsSureError(const autofill::ValidityMessage& message) {
17 return message.sure && !message.text.empty();
18 }
19
20 } // namespace
21
22 namespace autofill {
23
24 static const base::char16 kRangeSeparator = '|';
25
26 DialogNotification::DialogNotification() : type_(NONE) {}
27
28 DialogNotification::DialogNotification(Type type,
29 const base::string16& display_text)
30 : type_(type),
31 display_text_(display_text),
32 checked_(false) {
33 // If there's a range separated by bars, mark that as the anchor text.
34 std::vector<base::string16> pieces = base::SplitString(
35 display_text, base::string16(1, kRangeSeparator),
36 base::KEEP_WHITESPACE, base::SPLIT_WANT_ALL);
37 if (pieces.size() > 1) {
38 size_t start = pieces[0].size();
39 size_t end = start + pieces[1].size();
40 link_range_ = gfx::Range(start, end);
41 display_text_ = base::JoinString(pieces, base::StringPiece16());
42 }
43 }
44
45 DialogNotification::DialogNotification(const DialogNotification& other) =
46 default;
47
48 DialogNotification::~DialogNotification() {}
49
50 SkColor DialogNotification::GetBackgroundColor() const {
51 switch (type_) {
52 case DialogNotification::WALLET_USAGE_CONFIRMATION:
53 return SkColorSetRGB(0xf5, 0xf5, 0xf5);
54 case DialogNotification::REQUIRED_ACTION:
55 case DialogNotification::WALLET_ERROR:
56 return SkColorSetRGB(0xfc, 0xf3, 0xbf);
57 case DialogNotification::DEVELOPER_WARNING:
58 case DialogNotification::SECURITY_WARNING:
59 return kWarningColor;
60 case DialogNotification::NONE:
61 return SK_ColorTRANSPARENT;
62 }
63
64 NOTREACHED();
65 return SK_ColorTRANSPARENT;
66 }
67
68 SkColor DialogNotification::GetBorderColor() const {
69 switch (type_) {
70 case DialogNotification::WALLET_USAGE_CONFIRMATION:
71 return SkColorSetRGB(0xe5, 0xe5, 0xe5);
72 case DialogNotification::REQUIRED_ACTION:
73 case DialogNotification::WALLET_ERROR:
74 case DialogNotification::DEVELOPER_WARNING:
75 case DialogNotification::SECURITY_WARNING:
76 case DialogNotification::NONE:
77 return GetBackgroundColor();
78 }
79
80 NOTREACHED();
81 return SK_ColorTRANSPARENT;
82 }
83
84 SkColor DialogNotification::GetTextColor() const {
85 switch (type_) {
86 case DialogNotification::REQUIRED_ACTION:
87 case DialogNotification::WALLET_ERROR:
88 case DialogNotification::WALLET_USAGE_CONFIRMATION:
89 return SkColorSetRGB(102, 102, 102);
90 case DialogNotification::DEVELOPER_WARNING:
91 case DialogNotification::SECURITY_WARNING:
92 return SK_ColorWHITE;
93 case DialogNotification::NONE:
94 return SK_ColorTRANSPARENT;
95 }
96
97 NOTREACHED();
98 return SK_ColorTRANSPARENT;
99 }
100
101 bool DialogNotification::HasArrow() const {
102 return type_ == DialogNotification::WALLET_ERROR ||
103 type_ == DialogNotification::WALLET_USAGE_CONFIRMATION;
104 }
105
106 bool DialogNotification::HasCheckbox() const {
107 return type_ == DialogNotification::WALLET_USAGE_CONFIRMATION;
108 }
109
110 SkColor const kWarningColor = gfx::kGoogleRed700;
111 SkColor const kLightShadingColor = SkColorSetARGB(7, 0, 0, 0);
112 SkColor const kSubtleBorderColor = SkColorSetARGB(10, 0, 0, 0);
113
114 SuggestionState::SuggestionState()
115 : visible(false) {}
116 SuggestionState::SuggestionState(
117 bool visible,
118 const base::string16& vertically_compact_text,
119 const base::string16& horizontally_compact_text,
120 const gfx::Image& icon,
121 const base::string16& extra_text,
122 const gfx::Image& extra_icon)
123 : visible(visible),
124 vertically_compact_text(vertically_compact_text),
125 horizontally_compact_text(horizontally_compact_text),
126 icon(icon),
127 extra_text(extra_text),
128 extra_icon(extra_icon) {}
129 SuggestionState::SuggestionState(const SuggestionState& other) = default;
130 SuggestionState::~SuggestionState() {}
131
132 DialogOverlayString::DialogOverlayString() {}
133 DialogOverlayString::~DialogOverlayString() {}
134
135 DialogOverlayState::DialogOverlayState() {}
136 DialogOverlayState::~DialogOverlayState() {}
137
138 ValidityMessage::ValidityMessage(const base::string16& text, bool sure)
139 : text(text), sure(sure) {}
140 ValidityMessage::~ValidityMessage() {}
141
142 ValidityMessages::ValidityMessages()
143 : default_message_(ValidityMessage(base::string16(), false)) {}
144 ValidityMessages::ValidityMessages(const ValidityMessages& other) = default;
145 ValidityMessages::~ValidityMessages() {}
146
147 void ValidityMessages::Set(
148 ServerFieldType field, const ValidityMessage& message) {
149 MessageMap::iterator iter = messages_.find(field);
150 if (iter != messages_.end()) {
151 if (!iter->second.text.empty())
152 return;
153
154 messages_.erase(iter);
155 }
156
157 messages_.insert(MessageMap::value_type(field, message));
158 }
159
160 const ValidityMessage& ValidityMessages::GetMessageOrDefault(
161 ServerFieldType field) const {
162 MessageMap::const_iterator iter = messages_.find(field);
163 return iter != messages_.end() ? iter->second : default_message_;
164 }
165
166 bool ValidityMessages::HasSureError(ServerFieldType field) const {
167 return IsSureError(GetMessageOrDefault(field));
168 }
169
170 bool ValidityMessages::HasErrors() const {
171 for (MessageMap::const_iterator iter = messages_.begin();
172 iter != messages_.end(); ++iter) {
173 if (!iter->second.text.empty())
174 return true;
175 }
176 return false;
177 }
178
179 bool ValidityMessages::HasSureErrors() const {
180 for (MessageMap::const_iterator iter = messages_.begin();
181 iter != messages_.end(); ++iter) {
182 if (IsSureError(iter->second))
183 return true;
184 }
185 return false;
186 }
187
188 } // namespace autofill
OLDNEW
« no previous file with comments | « chrome/browser/ui/autofill/autofill_dialog_types.h ('k') | chrome/browser/ui/autofill/autofill_dialog_types_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698