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/view_ids.h" | 10 #include "chrome/browser/ui/view_ids.h" |
11 #include "chrome/browser/ui/views/passwords/manage_passwords_bubble_view.h" | 11 #include "chrome/browser/ui/views/passwords/manage_passwords_bubble_view.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 | 15 |
16 ManagePasswordsIconView::ManagePasswordsIconView(CommandUpdater* updater) | 16 ManagePasswordsIconView::ManagePasswordsIconView(CommandUpdater* updater) |
17 : BubbleIconView(updater, IDC_MANAGE_PASSWORDS_FOR_PAGE) { | 17 : BubbleIconView(updater, IDC_MANAGE_PASSWORDS_FOR_PAGE) { |
18 set_id(VIEW_ID_MANAGE_PASSWORDS_ICON_BUTTON); | 18 set_id(VIEW_ID_MANAGE_PASSWORDS_ICON_BUTTON); |
19 SetAccessibilityFocusable(true); | 19 SetFocusable(true); |
20 UpdateVisibleUI(); | 20 UpdateVisibleUI(); |
21 } | 21 } |
22 | 22 |
23 ManagePasswordsIconView::~ManagePasswordsIconView() {} | 23 ManagePasswordsIconView::~ManagePasswordsIconView() {} |
24 | 24 |
25 void ManagePasswordsIconView::UpdateVisibleUI() { | 25 void ManagePasswordsIconView::UpdateVisibleUI() { |
26 if (state() == password_manager::ui::INACTIVE_STATE) { | 26 if (state() == password_manager::ui::INACTIVE_STATE) { |
27 SetVisible(false); | 27 SetVisible(false); |
28 if (ManagePasswordsBubbleView::IsShowing()) | 28 if (ManagePasswordsBubbleView::IsShowing()) |
29 ManagePasswordsBubbleView::CloseBubble(); | 29 ManagePasswordsBubbleView::CloseBubble(); |
(...skipping 19 matching lines...) Expand all Loading... |
49 void ManagePasswordsIconView::OnExecuting( | 49 void ManagePasswordsIconView::OnExecuting( |
50 BubbleIconView::ExecuteSource source) { | 50 BubbleIconView::ExecuteSource source) { |
51 } | 51 } |
52 | 52 |
53 bool ManagePasswordsIconView::OnMousePressed(const ui::MouseEvent& event) { | 53 bool ManagePasswordsIconView::OnMousePressed(const ui::MouseEvent& event) { |
54 bool result = BubbleIconView::OnMousePressed(event); | 54 bool result = BubbleIconView::OnMousePressed(event); |
55 if (IsBubbleShowing()) | 55 if (IsBubbleShowing()) |
56 ManagePasswordsBubbleView::CloseBubble(); | 56 ManagePasswordsBubbleView::CloseBubble(); |
57 return result; | 57 return result; |
58 } | 58 } |
| 59 |
| 60 bool ManagePasswordsIconView::OnKeyPressed(const ui::KeyEvent& event) { |
| 61 // Space is always ignored because otherwise the bubble appears with the |
| 62 // default button down. Releasing the space is equivalent to clicking this |
| 63 // button. |
| 64 if (event.key_code() == ui::VKEY_SPACE) |
| 65 return true; |
| 66 if (event.key_code() == ui::VKEY_RETURN && active()) { |
| 67 // If the icon is active, it should transfer its focus to the bubble. |
| 68 // If it still somehow got this key event, the bubble shouldn't be reopened. |
| 69 return true; |
| 70 } |
| 71 return BubbleIconView::OnKeyPressed(event); |
| 72 } |
| 73 |
| 74 void ManagePasswordsIconView::AboutToRequestFocusFromTabTraversal( |
| 75 bool reverse) { |
| 76 if (active()) |
| 77 ManagePasswordsBubbleView::ActivateBubble(); |
| 78 } |
OLD | NEW |