| 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" |
| 10 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" | 11 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" |
| 11 #include "ui/views/controls/image_view.h" | 12 #include "ui/views/controls/image_view.h" |
| 12 | 13 |
| 14 class CommandUpdater; |
| 13 class ManagePasswordsBubbleUIController; | 15 class ManagePasswordsBubbleUIController; |
| 14 | 16 |
| 15 // View for the password icon in the Omnibox. | 17 // View for the password icon in the Omnibox. |
| 16 class ManagePasswordsIconView : public ManagePasswordsIcon, | 18 class ManagePasswordsIconView : public ManagePasswordsIcon, |
| 17 public views::ImageView { | 19 public BubbleIconView { |
| 18 public: | 20 public: |
| 19 // Clicking on the ManagePasswordsIconView shows a ManagePasswordsBubbleView, | 21 // Clicking on the ManagePasswordsIconView shows a ManagePasswordsBubbleView, |
| 20 // which requires the current WebContents. Because the current WebContents | 22 // which requires the current WebContents. Because the current WebContents |
| 21 // changes as the user switches tabs, it cannot be provided in the | 23 // changes as the user switches tabs, it cannot be provided in the |
| 22 // constructor. Instead, a LocationBarView::Delegate is passed here so that it | 24 // constructor. Instead, a LocationBarView::Delegate is passed here so that it |
| 23 // can be queried for the current WebContents as needed. | 25 // can be queried for the current WebContents as needed. |
| 24 explicit ManagePasswordsIconView( | 26 ManagePasswordsIconView(LocationBarView::Delegate* location_bar_delegate, |
| 25 LocationBarView::Delegate* location_bar_delegate); | 27 CommandUpdater* command_updater); |
| 26 virtual ~ManagePasswordsIconView(); | 28 virtual ~ManagePasswordsIconView(); |
| 27 | 29 |
| 28 // ManagePasswordsIcon: | 30 // ManagePasswordsIcon: |
| 31 // |
| 32 // TODO(mkwst): Remove this once we get rid of the single call to |
| 33 // ShowBubbleWithoutUserInteraction in ManagePasswordsBubbleUIController. |
| 29 virtual void ShowBubbleWithoutUserInteraction() OVERRIDE; | 34 virtual void ShowBubbleWithoutUserInteraction() OVERRIDE; |
| 30 | 35 |
| 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 |
| 31 protected: | 45 protected: |
| 32 // ManagePasswordsIcon: | 46 // ManagePasswordsIcon: |
| 33 virtual void SetStateInternal(ManagePasswordsIcon::State state) OVERRIDE; | 47 virtual void UpdateVisibleUI() OVERRIDE; |
| 34 | 48 |
| 35 private: | 49 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 | |
| 43 // The delegate used to get the currently visible WebContents. | 50 // The delegate used to get the currently visible WebContents. |
| 44 LocationBarView::Delegate* location_bar_delegate_; | 51 LocationBarView::Delegate* location_bar_delegate_; |
| 45 | 52 |
| 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 |
| 46 DISALLOW_COPY_AND_ASSIGN(ManagePasswordsIconView); | 64 DISALLOW_COPY_AND_ASSIGN(ManagePasswordsIconView); |
| 47 }; | 65 }; |
| 48 | 66 |
| 49 #endif // CHROME_BROWSER_UI_VIEWS_PASSWORDS_MANAGE_PASSWORDS_ICON_VIEW_H_ | 67 #endif // CHROME_BROWSER_UI_VIEWS_PASSWORDS_MANAGE_PASSWORDS_ICON_VIEW_H_ |
| OLD | NEW |