OLD | NEW |
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" | 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 "components/password_manager/core/common/password_manager_ui.h" | 11 #include "components/password_manager/core/common/password_manager_ui.h" |
12 #include "ui/base/l10n/l10n_util.h" | 12 #include "ui/base/l10n/l10n_util.h" |
13 #include "ui/base/resource/resource_bundle.h" | 13 #include "ui/base/resource/resource_bundle.h" |
14 | 14 |
15 ManagePasswordsIconView::ManagePasswordsIconView(CommandUpdater* updater) | 15 ManagePasswordsIconView::ManagePasswordsIconView(CommandUpdater* updater) |
16 : BubbleIconView(updater, IDC_MANAGE_PASSWORDS_FOR_PAGE) { | 16 : BubbleIconView(updater, IDC_MANAGE_PASSWORDS_FOR_PAGE) { |
17 SetFocusable(true); | 17 SetFocusable(true); |
18 UpdateVisibleUI(); | 18 UpdateVisibleUI(); |
19 } | 19 } |
20 | 20 |
21 ManagePasswordsIconView::~ManagePasswordsIconView() {} | 21 ManagePasswordsIconView::~ManagePasswordsIconView() {} |
22 | 22 |
23 void ManagePasswordsIconView::UpdateVisibleUI() { | 23 void ManagePasswordsIconView::UpdateVisibleUI() { |
24 if (state() == password_manager::ui::INACTIVE_STATE) { | 24 if (state() == password_manager::ui::INACTIVE_STATE) { |
25 SetVisible(false); | 25 SetVisible(false); |
26 if (ManagePasswordsBubbleView::IsShowing()) | |
27 ManagePasswordsBubbleView::CloseBubble(); | |
28 return; | 26 return; |
29 } | 27 } |
30 | 28 |
31 SetVisible(true); | 29 SetVisible(true); |
32 SetImage(ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(icon_id_)); | 30 SetImage(ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(icon_id_)); |
33 SetTooltipText(l10n_util::GetStringUTF16(tooltip_text_id_)); | 31 SetTooltipText(l10n_util::GetStringUTF16(tooltip_text_id_)); |
34 | 32 |
35 // We may be about to automatically pop up a ManagePasswordsBubbleView. | 33 // We may be about to automatically pop up a ManagePasswordsBubbleView. |
36 // Force layout of the icon's parent now; the bubble will be incorrectly | 34 // Force layout of the icon's parent now; the bubble will be incorrectly |
37 // positioned otherwise, as the icon won't have been drawn into position. | 35 // positioned otherwise, as the icon won't have been drawn into position. |
38 parent()->Layout(); | 36 parent()->Layout(); |
39 } | 37 } |
40 | 38 |
| 39 void ManagePasswordsIconView::OnChangingState() { |
| 40 // If there is an opened bubble for the current icon it should go away. |
| 41 if (active()) |
| 42 ManagePasswordsBubbleView::CloseBubble(); |
| 43 } |
| 44 |
41 bool ManagePasswordsIconView::IsBubbleShowing() const { | 45 bool ManagePasswordsIconView::IsBubbleShowing() const { |
42 // If the bubble is being destroyed, it's considered showing though it may be | 46 // If the bubble is being destroyed, it's considered showing though it may be |
43 // already invisible currently. | 47 // already invisible currently. |
44 return ManagePasswordsBubbleView::manage_password_bubble() != NULL; | 48 return ManagePasswordsBubbleView::manage_password_bubble() != NULL; |
45 } | 49 } |
46 | 50 |
47 void ManagePasswordsIconView::OnExecuting( | 51 void ManagePasswordsIconView::OnExecuting( |
48 BubbleIconView::ExecuteSource source) { | 52 BubbleIconView::ExecuteSource source) { |
49 } | 53 } |
50 | 54 |
(...skipping 16 matching lines...) Expand all Loading... |
67 return true; | 71 return true; |
68 } | 72 } |
69 return BubbleIconView::OnKeyPressed(event); | 73 return BubbleIconView::OnKeyPressed(event); |
70 } | 74 } |
71 | 75 |
72 void ManagePasswordsIconView::AboutToRequestFocusFromTabTraversal( | 76 void ManagePasswordsIconView::AboutToRequestFocusFromTabTraversal( |
73 bool reverse) { | 77 bool reverse) { |
74 if (active()) | 78 if (active()) |
75 ManagePasswordsBubbleView::ActivateBubble(); | 79 ManagePasswordsBubbleView::ActivateBubble(); |
76 } | 80 } |
OLD | NEW |