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

Side by Side Diff: chrome/browser/autofill/autofill_popup_view.cc

Issue 10408070: Upgrade Seperator in New Autofill UI (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/autofill/autofill_popup_view.h" 5 #include "chrome/browser/autofill/autofill_popup_view.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "chrome/browser/autofill/autofill_external_delegate.h" 9 #include "chrome/browser/autofill/autofill_external_delegate.h"
10 #include "content/public/browser/web_contents.h" 10 #include "content/public/browser/web_contents.h"
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 SetSelectedLine(new_selected_line); 114 SetSelectedLine(new_selected_line);
115 } 115 }
116 116
117 bool AutofillPopupView::AcceptSelectedLine() { 117 bool AutofillPopupView::AcceptSelectedLine() {
118 if (selected_line_ == kNoSelection) 118 if (selected_line_ == kNoSelection)
119 return false; 119 return false;
120 120
121 DCHECK_GE(selected_line_, 0); 121 DCHECK_GE(selected_line_, 0);
122 DCHECK_LT(selected_line_, static_cast<int>(autofill_values_.size())); 122 DCHECK_LT(selected_line_, static_cast<int>(autofill_values_.size()));
123 123
124 if (!CanAccept(autofill_unique_ids_[selected_line_]))
125 return false;
126
124 return external_delegate()->DidAcceptAutofillSuggestions( 127 return external_delegate()->DidAcceptAutofillSuggestions(
125 autofill_values_[selected_line_], 128 autofill_values_[selected_line_],
126 autofill_unique_ids_[selected_line_], 129 autofill_unique_ids_[selected_line_],
127 selected_line_); 130 selected_line_);
128 } 131 }
129 132
130 bool AutofillPopupView::RemoveSelectedLine() { 133 bool AutofillPopupView::RemoveSelectedLine() {
131 if (selected_line_ == kNoSelection) 134 if (selected_line_ == kNoSelection)
132 return false; 135 return false;
133 136
(...skipping 21 matching lines...) Expand all
155 ResizePopup(); 158 ResizePopup();
156 159
157 SetSelectedLine(kNoSelection); 160 SetSelectedLine(kNoSelection);
158 161
159 if (!HasAutofillEntries()) 162 if (!HasAutofillEntries())
160 Hide(); 163 Hide();
161 164
162 return true; 165 return true;
163 } 166 }
164 167
165 bool AutofillPopupView::IsSeparatorIndex(int index) {
166 // TODO(csharp): Use WebAutofillClient::MenuItemIDSeparator instead.
167 // http://crbug.com/125001
168 return (index > 0 && autofill_unique_ids_[index - 1] >= 0 &&
169 autofill_unique_ids_[index] < 0);
170 }
171
172 int AutofillPopupView::GetIconResourceID(const string16& resource_name) { 168 int AutofillPopupView::GetIconResourceID(const string16& resource_name) {
173 for (size_t i = 0; i < arraysize(kDataResources); ++i) { 169 for (size_t i = 0; i < arraysize(kDataResources); ++i) {
174 if (resource_name == ASCIIToUTF16(kDataResources[i].name)) 170 if (resource_name == ASCIIToUTF16(kDataResources[i].name))
175 return kDataResources[i].id; 171 return kDataResources[i].id;
176 } 172 }
177 173
178 return -1; 174 return -1;
179 } 175 }
180 176
177 bool AutofillPopupView::CanAccept(int id) {
178 return id != WebAutofillClient::MenuItemIDSeparator;
179 }
180
181 bool AutofillPopupView::CanDelete(int id) { 181 bool AutofillPopupView::CanDelete(int id) {
182 return id > 0 || 182 return id > 0 ||
183 id == WebAutofillClient::MenuItemIDAutocompleteEntry || 183 id == WebAutofillClient::MenuItemIDAutocompleteEntry ||
184 id == WebAutofillClient::MenuItemIDPasswordEntry; 184 id == WebAutofillClient::MenuItemIDPasswordEntry;
185 } 185 }
186 186
187 bool AutofillPopupView::HasAutofillEntries() { 187 bool AutofillPopupView::HasAutofillEntries() {
188 return autofill_values_.size() != 0 && 188 return autofill_values_.size() != 0 &&
189 (autofill_unique_ids_[0] > 0 || 189 (autofill_unique_ids_[0] > 0 ||
190 autofill_unique_ids_[0] == 190 autofill_unique_ids_[0] ==
191 WebAutofillClient::MenuItemIDAutocompleteEntry || 191 WebAutofillClient::MenuItemIDAutocompleteEntry ||
192 autofill_unique_ids_[0] == WebAutofillClient::MenuItemIDPasswordEntry || 192 autofill_unique_ids_[0] == WebAutofillClient::MenuItemIDPasswordEntry ||
193 autofill_unique_ids_[0] == WebAutofillClient::MenuItemIDDataListEntry); 193 autofill_unique_ids_[0] == WebAutofillClient::MenuItemIDDataListEntry);
194 } 194 }
195 195
196 void AutofillPopupView::Observe(int type, 196 void AutofillPopupView::Observe(int type,
197 const content::NotificationSource& source, 197 const content::NotificationSource& source,
198 const content::NotificationDetails& details) { 198 const content::NotificationDetails& details) {
199 if (type == content::NOTIFICATION_WEB_CONTENTS_VISIBILITY_CHANGED) { 199 if (type == content::NOTIFICATION_WEB_CONTENTS_VISIBILITY_CHANGED) {
200 if (!*content::Details<bool>(details).ptr()) 200 if (!*content::Details<bool>(details).ptr())
201 Hide(); 201 Hide();
202 } else if (type == content::NOTIFICATION_NAV_ENTRY_COMMITTED) { 202 } else if (type == content::NOTIFICATION_NAV_ENTRY_COMMITTED) {
203 Hide(); 203 Hide();
204 } 204 }
205 } 205 }
OLDNEW
« no previous file with comments | « chrome/browser/autofill/autofill_popup_view.h ('k') | chrome/browser/ui/gtk/autofill/autofill_popup_view_gtk.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698