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

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

Issue 9235072: Adding Mouse Support for new GTK Autofill (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 11 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 "chrome/browser/autofill/autofill_external_delegate.h"
7 #include "content/public/browser/web_contents.h" 8 #include "content/public/browser/web_contents.h"
8 #include "content/public/browser/navigation_controller.h" 9 #include "content/public/browser/navigation_controller.h"
9 #include "content/public/browser/notification_service.h" 10 #include "content/public/browser/notification_service.h"
10 #include "content/public/browser/notification_source.h" 11 #include "content/public/browser/notification_source.h"
11 #include "content/public/browser/notification_types.h" 12 #include "content/public/browser/notification_types.h"
12 13
13 AutofillPopupView::AutofillPopupView(content::WebContents* web_contents) { 14 AutofillPopupView::AutofillPopupView(
15 content::WebContents* web_contents,
16 AutofillExternalDelegate* external_delegate)
17 : external_delegate_(external_delegate),
18 selected_line_(-1) {
14 registrar_.Add(this, 19 registrar_.Add(this,
15 content::NOTIFICATION_WEB_CONTENTS_HIDDEN, 20 content::NOTIFICATION_WEB_CONTENTS_HIDDEN,
16 content::Source<content::WebContents>(web_contents)); 21 content::Source<content::WebContents>(web_contents));
17 registrar_.Add( 22 registrar_.Add(
18 this, 23 this,
19 content::NOTIFICATION_NAV_ENTRY_COMMITTED, 24 content::NOTIFICATION_NAV_ENTRY_COMMITTED,
20 content::Source<content::NavigationController>( 25 content::Source<content::NavigationController>(
21 &(web_contents->GetController()))); 26 &(web_contents->GetController())));
22 } 27 }
23 28
24 AutofillPopupView::~AutofillPopupView() {} 29 AutofillPopupView::~AutofillPopupView() {}
25 30
26 void AutofillPopupView::Show(const std::vector<string16>& autofill_values, 31 void AutofillPopupView::Show(const std::vector<string16>& autofill_values,
27 const std::vector<string16>& autofill_labels, 32 const std::vector<string16>& autofill_labels,
28 const std::vector<string16>& autofill_icons, 33 const std::vector<string16>& autofill_icons,
29 const std::vector<int>& autofill_unique_ids, 34 const std::vector<int>& autofill_unique_ids,
30 int separator_index) { 35 int separator_index) {
31 autofill_values_ = autofill_values; 36 autofill_values_ = autofill_values;
32 autofill_labels_ = autofill_labels; 37 autofill_labels_ = autofill_labels;
33 autofill_icons_ = autofill_icons; 38 autofill_icons_ = autofill_icons;
34 autofill_unique_ids_ = autofill_unique_ids; 39 autofill_unique_ids_ = autofill_unique_ids;
35 40
36 separator_index_ = separator_index; 41 separator_index_ = separator_index;
37 42
38 ShowInternal(); 43 ShowInternal();
39 } 44 }
40 45
46 void AutofillPopupView::SetSelectedLine(size_t selected_line) {
47 if (selected_line_ == selected_line)
48 return;
49
50 InvalidateRow(selected_line_);
51 InvalidateRow(selected_line);
52
53 selected_line_ = selected_line;
54
55 external_delegate_->SelectAutofillSuggestionAtIndex(
56 autofill_unique_ids_[selected_line_],
57 selected_line);
58 }
59
41 void AutofillPopupView::Observe(int type, 60 void AutofillPopupView::Observe(int type,
42 const content::NotificationSource& source, 61 const content::NotificationSource& source,
43 const content::NotificationDetails& details) { 62 const content::NotificationDetails& details) {
44 if (type == content::NOTIFICATION_WEB_CONTENTS_HIDDEN 63 if (type == content::NOTIFICATION_WEB_CONTENTS_HIDDEN
45 || type == content::NOTIFICATION_NAV_ENTRY_COMMITTED) 64 || type == content::NOTIFICATION_NAV_ENTRY_COMMITTED)
46 Hide(); 65 Hide();
47 } 66 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698