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

Side by Side Diff: chrome/browser/ui/views/passwords/manage_passwords_icon_view.cc

Issue 246393004: Password bubble: Introduce a command to open the bubble. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/ui/views/passwords/manage_passwords_icon_view.h" 5 #include "chrome/browser/ui/views/passwords/manage_passwords_icon_view.h"
6 6
7 #include "chrome/app/chrome_command_ids.h"
8 #include "chrome/browser/command_updater.h"
7 #include "chrome/browser/ui/passwords/manage_passwords_bubble_ui_controller.h" 9 #include "chrome/browser/ui/passwords/manage_passwords_bubble_ui_controller.h"
8 #include "chrome/browser/ui/views/passwords/manage_passwords_bubble_view.h" 10 #include "chrome/browser/ui/views/passwords/manage_passwords_bubble_view.h"
9 #include "grit/generated_resources.h" 11 #include "grit/generated_resources.h"
10 #include "grit/theme_resources.h" 12 #include "grit/theme_resources.h"
11 #include "ui/base/l10n/l10n_util.h" 13 #include "ui/base/l10n/l10n_util.h"
12 #include "ui/base/resource/resource_bundle.h" 14 #include "ui/base/resource/resource_bundle.h"
13 15
14 ManagePasswordsIconView::ManagePasswordsIconView( 16 ManagePasswordsIconView::ManagePasswordsIconView(
15 LocationBarView::Delegate* location_bar_delegate) 17 LocationBarView::Delegate* location_bar_delegate,
16 : location_bar_delegate_(location_bar_delegate) { 18 CommandUpdater* command_updater)
19 : location_bar_delegate_(location_bar_delegate),
20 command_updater_(command_updater) {
17 SetAccessibilityFocusable(true); 21 SetAccessibilityFocusable(true);
18 Update(NULL); 22 Update(NULL);
19 LocationBarView::InitTouchableLocationBarChildView(this); 23 LocationBarView::InitTouchableLocationBarChildView(this);
20 } 24 }
21 25
22 ManagePasswordsIconView::~ManagePasswordsIconView() {} 26 ManagePasswordsIconView::~ManagePasswordsIconView() {}
23 27
24 void ManagePasswordsIconView::Update( 28 void ManagePasswordsIconView::Update(
25 ManagePasswordsBubbleUIController* manage_passwords_bubble_ui_controller) { 29 ManagePasswordsBubbleUIController* manage_passwords_bubble_ui_controller) {
26 SetVisible(manage_passwords_bubble_ui_controller && 30 SetVisible(manage_passwords_bubble_ui_controller &&
(...skipping 12 matching lines...) Expand all
39 icon_to_display)); 43 icon_to_display));
40 SetTooltip(manage_passwords_bubble_ui_controller->password_to_be_saved()); 44 SetTooltip(manage_passwords_bubble_ui_controller->password_to_be_saved());
41 } 45 }
42 46
43 void ManagePasswordsIconView::ShowBubbleIfNeeded( 47 void ManagePasswordsIconView::ShowBubbleIfNeeded(
44 ManagePasswordsBubbleUIController* manage_passwords_bubble_ui_controller) { 48 ManagePasswordsBubbleUIController* manage_passwords_bubble_ui_controller) {
45 if (manage_passwords_bubble_ui_controller-> 49 if (manage_passwords_bubble_ui_controller->
46 manage_passwords_bubble_needs_showing() && 50 manage_passwords_bubble_needs_showing() &&
47 visible() && 51 visible() &&
48 !ManagePasswordsBubbleView::IsShowing()) { 52 !ManagePasswordsBubbleView::IsShowing()) {
49 ManagePasswordsBubbleView::ShowBubble( 53 command_updater_->ExecuteCommand(IDC_MANAGE_PASSWORDS_FOR_PAGE);
50 location_bar_delegate_->GetWebContents(),
51 ManagePasswordsBubbleView::AUTOMATIC);
52 manage_passwords_bubble_ui_controller->OnBubbleShown(); 54 manage_passwords_bubble_ui_controller->OnBubbleShown();
53 } 55 }
54 } 56 }
55 57
56 void ManagePasswordsIconView::SetTooltip(bool password_to_be_saved) { 58 void ManagePasswordsIconView::SetTooltip(bool password_to_be_saved) {
57 SetTooltipText(l10n_util::GetStringUTF16( 59 SetTooltipText(l10n_util::GetStringUTF16(
58 (password_to_be_saved ? 60 (password_to_be_saved ?
59 IDS_PASSWORD_MANAGER_TOOLTIP_SAVE : 61 IDS_PASSWORD_MANAGER_TOOLTIP_SAVE :
60 IDS_PASSWORD_MANAGER_TOOLTIP_MANAGE))); 62 IDS_PASSWORD_MANAGER_TOOLTIP_MANAGE)));
61 } 63 }
62 64
63 bool ManagePasswordsIconView::GetTooltipText(const gfx::Point& p, 65 bool ManagePasswordsIconView::GetTooltipText(const gfx::Point& p,
64 base::string16* tooltip) const { 66 base::string16* tooltip) const {
65 // Don't show tooltip if the password bubble is displayed. 67 // Don't show tooltip if the password bubble is displayed.
66 return !ManagePasswordsBubbleView::IsShowing() && 68 return !ManagePasswordsBubbleView::IsShowing() &&
67 ImageView::GetTooltipText(p, tooltip); 69 ImageView::GetTooltipText(p, tooltip);
68 } 70 }
69 71
70 void ManagePasswordsIconView::OnGestureEvent(ui::GestureEvent* event) { 72 void ManagePasswordsIconView::OnGestureEvent(ui::GestureEvent* event) {
71 if (event->type() == ui::ET_GESTURE_TAP) { 73 if (event->type() == ui::ET_GESTURE_TAP) {
72 ManagePasswordsBubbleView::ShowBubble( 74 command_updater_->ExecuteCommand(IDC_MANAGE_PASSWORDS_FOR_PAGE);
73 location_bar_delegate_->GetWebContents(),
74 ManagePasswordsBubbleView::USER_ACTION);
75 event->SetHandled(); 75 event->SetHandled();
76 } 76 }
77 } 77 }
78 78
79 bool ManagePasswordsIconView::OnMousePressed(const ui::MouseEvent& event) { 79 bool ManagePasswordsIconView::OnMousePressed(const ui::MouseEvent& event) {
80 // Do nothing until the mouse button is released. 80 // Do nothing until the mouse button is released.
81 return true; 81 return true;
82 } 82 }
83 83
84 void ManagePasswordsIconView::OnMouseReleased(const ui::MouseEvent& event) { 84 void ManagePasswordsIconView::OnMouseReleased(const ui::MouseEvent& event) {
85 if (event.IsOnlyLeftMouseButton() && HitTestPoint(event.location())) { 85 if (event.IsOnlyLeftMouseButton() && HitTestPoint(event.location())) {
86 ManagePasswordsBubbleView::ShowBubble( 86 command_updater_->ExecuteCommand(IDC_MANAGE_PASSWORDS_FOR_PAGE);
87 location_bar_delegate_->GetWebContents(),
88 ManagePasswordsBubbleView::USER_ACTION);
89 } 87 }
90 } 88 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698