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 #ifndef CHROME_BROWSER_UI_VIEWS_PASSWORDS_MANAGE_PASSWORDS_ICON_VIEW_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_PASSWORDS_MANAGE_PASSWORDS_ICON_VIEW_H_ |
6 #define CHROME_BROWSER_UI_VIEWS_PASSWORDS_MANAGE_PASSWORDS_ICON_VIEW_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_PASSWORDS_MANAGE_PASSWORDS_ICON_VIEW_H_ |
7 | 7 |
8 #include "chrome/browser/ui/passwords/manage_passwords_bubble_model.h" | 8 #include "chrome/browser/ui/passwords/manage_passwords_bubble_model.h" |
9 #include "chrome/browser/ui/passwords/manage_passwords_icon.h" | 9 #include "chrome/browser/ui/passwords/manage_passwords_icon.h" |
10 #include "chrome/browser/ui/views/location_bar/bubble_icon_view.h" | |
11 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" | 10 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" |
12 #include "ui/views/controls/image_view.h" | 11 #include "ui/views/controls/image_view.h" |
13 | 12 |
14 class CommandUpdater; | |
15 class ManagePasswordsBubbleUIController; | 13 class ManagePasswordsBubbleUIController; |
16 | 14 |
17 // View for the password icon in the Omnibox. | 15 // View for the password icon in the Omnibox. |
18 class ManagePasswordsIconView : public ManagePasswordsIcon, | 16 class ManagePasswordsIconView : public ManagePasswordsIcon, |
19 public BubbleIconView { | 17 public views::ImageView { |
20 public: | 18 public: |
21 // Clicking on the ManagePasswordsIconView shows a ManagePasswordsBubbleView, | 19 // Clicking on the ManagePasswordsIconView shows a ManagePasswordsBubbleView, |
22 // which requires the current WebContents. Because the current WebContents | 20 // which requires the current WebContents. Because the current WebContents |
23 // changes as the user switches tabs, it cannot be provided in the | 21 // changes as the user switches tabs, it cannot be provided in the |
24 // constructor. Instead, a LocationBarView::Delegate is passed here so that it | 22 // constructor. Instead, a LocationBarView::Delegate is passed here so that it |
25 // can be queried for the current WebContents as needed. | 23 // can be queried for the current WebContents as needed. |
26 ManagePasswordsIconView(LocationBarView::Delegate* location_bar_delegate, | 24 explicit ManagePasswordsIconView( |
27 CommandUpdater* command_updater); | 25 LocationBarView::Delegate* location_bar_delegate); |
28 virtual ~ManagePasswordsIconView(); | 26 virtual ~ManagePasswordsIconView(); |
29 | 27 |
30 // ManagePasswordsIcon: | 28 // ManagePasswordsIcon: |
31 // | |
32 // TODO(mkwst): Remove this once we get rid of the single call to | |
33 // ShowBubbleWithoutUserInteraction in ManagePasswordsBubbleUIController. | |
34 virtual void ShowBubbleWithoutUserInteraction() OVERRIDE; | 29 virtual void ShowBubbleWithoutUserInteraction() OVERRIDE; |
35 | 30 |
36 // BubbleIconView: | |
37 virtual bool IsBubbleShowing() const OVERRIDE; | |
38 virtual void OnExecuting(BubbleIconView::ExecuteSource source) OVERRIDE; | |
39 | |
40 #if defined(UNIT_TEST) | |
41 int icon_id() const { return icon_id_; } | |
42 int tooltip_text_id() const { return tooltip_text_id_; } | |
43 #endif | |
44 | |
45 protected: | 31 protected: |
46 // ManagePasswordsIcon: | 32 // ManagePasswordsIcon: |
47 virtual void UpdateVisibleUI() OVERRIDE; | 33 virtual void SetStateInternal(ManagePasswordsIcon::State state) OVERRIDE; |
48 | 34 |
49 private: | 35 private: |
| 36 // views::ImageView: |
| 37 virtual bool GetTooltipText(const gfx::Point& p, |
| 38 base::string16* tooltip) const OVERRIDE; |
| 39 virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; |
| 40 virtual bool OnMousePressed(const ui::MouseEvent& event) OVERRIDE; |
| 41 virtual void OnMouseReleased(const ui::MouseEvent& event) OVERRIDE; |
| 42 |
50 // The delegate used to get the currently visible WebContents. | 43 // The delegate used to get the currently visible WebContents. |
51 LocationBarView::Delegate* location_bar_delegate_; | 44 LocationBarView::Delegate* location_bar_delegate_; |
52 | 45 |
53 // The updater used to deliver commands to the browser; we'll use this to | |
54 // pop open the bubble when necessary. | |
55 // | |
56 // TODO(mkwst): Remove this once we get rid of the single call to | |
57 // ShowBubbleWithoutUserInteraction in ManagePasswordsBubbleUIController. | |
58 CommandUpdater* command_updater_; | |
59 | |
60 // The ID of the icon and text resources that are currently displayed. | |
61 int icon_id_; | |
62 int tooltip_text_id_; | |
63 | |
64 DISALLOW_COPY_AND_ASSIGN(ManagePasswordsIconView); | 46 DISALLOW_COPY_AND_ASSIGN(ManagePasswordsIconView); |
65 }; | 47 }; |
66 | 48 |
67 #endif // CHROME_BROWSER_UI_VIEWS_PASSWORDS_MANAGE_PASSWORDS_ICON_VIEW_H_ | 49 #endif // CHROME_BROWSER_UI_VIEWS_PASSWORDS_MANAGE_PASSWORDS_ICON_VIEW_H_ |
OLD | NEW |