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

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

Issue 1402363013: Update location bar bubble/icon behavior. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years, 1 month 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 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_views.h" 5 #include "chrome/browser/ui/views/passwords/manage_passwords_icon_views.h"
6 6
7 #include "chrome/app/chrome_command_ids.h" 7 #include "chrome/app/chrome_command_ids.h"
8 #include "chrome/browser/command_updater.h" 8 #include "chrome/browser/command_updater.h"
9 #include "chrome/browser/ui/passwords/manage_passwords_ui_controller.h" 9 #include "chrome/browser/ui/passwords/manage_passwords_ui_controller.h"
10 #include "chrome/browser/ui/views/passwords/manage_passwords_bubble_view.h" 10 #include "chrome/browser/ui/views/passwords/manage_passwords_bubble_view.h"
11 #include "chrome/grit/generated_resources.h" 11 #include "chrome/grit/generated_resources.h"
12 #include "components/password_manager/core/common/password_manager_ui.h" 12 #include "components/password_manager/core/common/password_manager_ui.h"
13 #include "ui/base/l10n/l10n_util.h" 13 #include "ui/base/l10n/l10n_util.h"
14 #include "ui/base/resource/resource_bundle.h" 14 #include "ui/base/resource/resource_bundle.h"
15 #include "ui/gfx/vector_icons_public.h" 15 #include "ui/gfx/vector_icons_public.h"
16 16
17 ManagePasswordsIconViews::ManagePasswordsIconViews(CommandUpdater* updater) 17 ManagePasswordsIconViews::ManagePasswordsIconViews(CommandUpdater* updater)
18 : BubbleIconView(updater, IDC_MANAGE_PASSWORDS_FOR_PAGE), 18 : BubbleIconView(updater, IDC_MANAGE_PASSWORDS_FOR_PAGE),
19 state_(password_manager::ui::INACTIVE_STATE) { 19 state_(password_manager::ui::INACTIVE_STATE) {
20 SetFocusable(true); 20 SetFocusable(true);
21 UpdateUiForState(); 21 UpdateUiForState();
22 } 22 }
23 23
24 ManagePasswordsIconViews::~ManagePasswordsIconViews() {} 24 ManagePasswordsIconViews::~ManagePasswordsIconViews() {}
25 25
26 void ManagePasswordsIconViews::SetActive(bool active) {
27 SetActiveInternal(active);
28 }
29
30 void ManagePasswordsIconViews::SetState(password_manager::ui::State state) { 26 void ManagePasswordsIconViews::SetState(password_manager::ui::State state) {
31 if (state_ == state) 27 if (state_ == state)
32 return; 28 return;
33 // If there is an opened bubble for the current icon it should go away. 29 // If there is an opened bubble for the current icon it should go away.
34 if (active()) 30 ManagePasswordsBubbleView::CloseBubble();
35 ManagePasswordsBubbleView::CloseBubble();
36 state_ = state; 31 state_ = state;
37 UpdateUiForState(); 32 UpdateUiForState();
38 } 33 }
39 34
40 void ManagePasswordsIconViews::UpdateUiForState() { 35 void ManagePasswordsIconViews::UpdateUiForState() {
41 if (state_ == password_manager::ui::INACTIVE_STATE) { 36 if (state_ == password_manager::ui::INACTIVE_STATE) {
42 SetVisible(false); 37 SetVisible(false);
43 return; 38 return;
44 } 39 }
45 40
46 SetTooltipText(l10n_util::GetStringUTF16( 41 SetTooltipText(l10n_util::GetStringUTF16(
47 state_ == password_manager::ui::PENDING_PASSWORD_STATE 42 state_ == password_manager::ui::PENDING_PASSWORD_STATE
48 ? IDS_PASSWORD_MANAGER_TOOLTIP_SAVE 43 ? IDS_PASSWORD_MANAGER_TOOLTIP_SAVE
49 : IDS_PASSWORD_MANAGER_TOOLTIP_MANAGE)); 44 : IDS_PASSWORD_MANAGER_TOOLTIP_MANAGE));
50 45
51 SetVisible(true); 46 SetVisible(true);
52 47
53 // We may be about to automatically pop up a ManagePasswordsBubbleView. 48 // We may be about to automatically pop up a ManagePasswordsBubbleView.
54 // Force layout of the icon's parent now; the bubble will be incorrectly 49 // Force layout of the icon's parent now; the bubble will be incorrectly
55 // positioned otherwise, as the icon won't have been drawn into position. 50 // positioned otherwise, as the icon won't have been drawn into position.
56 parent()->Layout(); 51 parent()->Layout();
57 } 52 }
58 53
59 void ManagePasswordsIconViews::OnExecuting( 54 void ManagePasswordsIconViews::OnExecuting(
60 BubbleIconView::ExecuteSource source) {} 55 BubbleIconView::ExecuteSource source) {}
61 56
62 bool ManagePasswordsIconViews::OnMousePressed(const ui::MouseEvent& event) { 57 bool ManagePasswordsIconViews::OnMousePressed(const ui::MouseEvent& event) {
63 bool result = BubbleIconView::OnMousePressed(event); 58 bool result = BubbleIconView::OnMousePressed(event);
64 if (IsBubbleShowing()) 59 ManagePasswordsBubbleView::CloseBubble();
65 ManagePasswordsBubbleView::CloseBubble();
66 return result; 60 return result;
67 } 61 }
68 62
69 bool ManagePasswordsIconViews::OnKeyPressed(const ui::KeyEvent& event) { 63 bool ManagePasswordsIconViews::OnKeyPressed(const ui::KeyEvent& event) {
70 // Space is always ignored because otherwise the bubble appears with the 64 // Space is always ignored because otherwise the bubble appears with the
71 // default button down. Releasing the space is equivalent to clicking this 65 // default button down. Releasing the space is equivalent to clicking this
72 // button. 66 // button.
73 if (event.key_code() == ui::VKEY_SPACE) 67 if (event.key_code() == ui::VKEY_SPACE)
74 return true; 68 return true;
75 if (event.key_code() == ui::VKEY_RETURN && active()) { 69 if (event.key_code() == ui::VKEY_RETURN && IsBubbleShowing()) {
76 // If the icon is active, it should transfer its focus to the bubble. 70 // If the bubble's open, the icon should transfer its focus to the bubble.
77 // If it still somehow got this key event, the bubble shouldn't be reopened. 71 // If it still somehow got this key event, the bubble shouldn't be reopened.
78 return true; 72 return true;
79 } 73 }
80 return BubbleIconView::OnKeyPressed(event); 74 return BubbleIconView::OnKeyPressed(event);
81 } 75 }
82 76
83 views::BubbleDelegateView* ManagePasswordsIconViews::GetBubble() const { 77 views::BubbleDelegateView* ManagePasswordsIconViews::GetBubble() const {
84 return ManagePasswordsBubbleView::manage_password_bubble(); 78 return ManagePasswordsBubbleView::manage_password_bubble();
85 } 79 }
86 80
87 gfx::VectorIconId ManagePasswordsIconViews::GetVectorIcon() const { 81 gfx::VectorIconId ManagePasswordsIconViews::GetVectorIcon() const {
88 return gfx::VectorIconId::AUTOLOGIN; 82 return gfx::VectorIconId::AUTOLOGIN;
89 } 83 }
90 84
91 void ManagePasswordsIconViews::AboutToRequestFocusFromTabTraversal( 85 void ManagePasswordsIconViews::AboutToRequestFocusFromTabTraversal(
92 bool reverse) { 86 bool reverse) {
93 if (active()) 87 if (IsBubbleShowing())
94 ManagePasswordsBubbleView::ActivateBubble(); 88 ManagePasswordsBubbleView::ActivateBubble();
95 } 89 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/passwords/manage_passwords_icon_views.h ('k') | chrome/browser/ui/views/tab_dialogs_views.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698