| 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_controller.h" | |
| 10 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" | 9 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" |
| 11 #include "ui/views/controls/image_view.h" | 10 #include "ui/views/controls/image_view.h" |
| 12 | 11 |
| 13 class ManagePasswordsIconController; | 12 class ManagePasswordsController; |
| 14 | 13 |
| 15 // View for the password icon in the Omnibox. | 14 // View for the password icon in the Omnibox. |
| 16 class ManagePasswordsIconView : public views::ImageView { | 15 class ManagePasswordsIconView : public views::ImageView { |
| 17 public: | 16 public: |
| 18 // Clicking on the ManagePasswordsIconView shows a ManagePasswordsBubbleView, | 17 // Clicking on the ManagePasswordsIconView shows a ManagePasswordsBubbleView, |
| 19 // which requires the current WebContents. Because the current WebContents | 18 // which requires the current WebContents. Because the current WebContents |
| 20 // changes as the user switches tabs, it cannot be provided in the | 19 // changes as the user switches tabs, it cannot be provided in the |
| 21 // constructor. Instead, a LocationBarView::Delegate is passed here so that it | 20 // constructor. Instead, a LocationBarView::Delegate is passed here so that it |
| 22 // can be queried for the current WebContents as needed. | 21 // can be queried for the current WebContents as needed. |
| 23 explicit ManagePasswordsIconView( | 22 explicit ManagePasswordsIconView( |
| 24 LocationBarView::Delegate* location_bar_delegate); | 23 LocationBarView::Delegate* location_bar_delegate); |
| 25 virtual ~ManagePasswordsIconView(); | 24 virtual ~ManagePasswordsIconView(); |
| 26 | 25 |
| 27 // Updates the image and its tooltip appropriately, hiding or showing the icon | 26 // Updates the image and its tooltip appropriately, hiding or showing the icon |
| 28 // as needed. | 27 // as needed. |
| 29 void Update(ManagePasswordsIconController* manage_passwords_icon_controller); | 28 void Update(ManagePasswordsController* manage_passwords_controller); |
| 30 | 29 |
| 31 // Shows a bubble from the icon if a password form was submitted. | 30 // Shows a bubble from the icon if a password form was submitted. |
| 32 void ShowBubbleIfNeeded( | 31 void ShowBubbleIfNeeded( |
| 33 ManagePasswordsIconController* manage_passwords_icon_controller); | 32 ManagePasswordsController* manage_passwords_controller); |
| 34 | 33 |
| 35 void SetTooltip(bool password_to_be_saved); | 34 void SetTooltip(bool password_to_be_saved); |
| 36 | 35 |
| 37 private: | 36 private: |
| 38 // views::ImageView: | 37 // views::ImageView: |
| 39 virtual bool GetTooltipText(const gfx::Point& p, | 38 virtual bool GetTooltipText(const gfx::Point& p, |
| 40 string16* tooltip) const OVERRIDE; | 39 string16* tooltip) const OVERRIDE; |
| 41 virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; | 40 virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; |
| 42 virtual bool OnMousePressed(const ui::MouseEvent& event) OVERRIDE; | 41 virtual bool OnMousePressed(const ui::MouseEvent& event) OVERRIDE; |
| 43 virtual void OnMouseReleased(const ui::MouseEvent& event) OVERRIDE; | 42 virtual void OnMouseReleased(const ui::MouseEvent& event) OVERRIDE; |
| 44 | 43 |
| 45 // The delegate used to get the currently visible WebContents. | 44 // The delegate used to get the currently visible WebContents. |
| 46 LocationBarView::Delegate* location_bar_delegate_; | 45 LocationBarView::Delegate* location_bar_delegate_; |
| 47 | 46 |
| 48 DISALLOW_COPY_AND_ASSIGN(ManagePasswordsIconView); | 47 DISALLOW_COPY_AND_ASSIGN(ManagePasswordsIconView); |
| 49 }; | 48 }; |
| 50 | 49 |
| 51 #endif // CHROME_BROWSER_UI_VIEWS_PASSWORDS_MANAGE_PASSWORDS_ICON_VIEW_H_ | 50 #endif // CHROME_BROWSER_UI_VIEWS_PASSWORDS_MANAGE_PASSWORDS_ICON_VIEW_H_ |
| OLD | NEW |