| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_LOCATION_BAR_PAGE_ACTION_IMAGE_VIEW_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_PAGE_ACTION_IMAGE_VIEW_H_ |
| 6 #define CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_PAGE_ACTION_IMAGE_VIEW_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_PAGE_ACTION_IMAGE_VIEW_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "chrome/browser/ui/views/extensions/extension_action_view_controller.h" | 11 #include "chrome/browser/ui/extensions/extension_action_view_controller.h" |
| 12 #include "chrome/browser/ui/views/toolbar/toolbar_action_view_delegate.h" | 12 #include "chrome/browser/ui/views/toolbar/toolbar_action_view_delegate_views.h" |
| 13 #include "ui/views/controls/image_view.h" | 13 #include "ui/views/controls/image_view.h" |
| 14 | 14 |
| 15 class Browser; | 15 class Browser; |
| 16 class ExtensionAction; | 16 class ExtensionAction; |
| 17 class ExtensionActionViewController; |
| 17 class LocationBarView; | 18 class LocationBarView; |
| 18 | 19 |
| 19 namespace content { | 20 namespace content { |
| 20 class WebContents; | 21 class WebContents; |
| 21 } | 22 } |
| 22 | 23 |
| 23 // PageActionImageView is used by the LocationBarView to display the icon for a | 24 // PageActionImageView is used by the LocationBarView to display the icon for a |
| 24 // given PageAction and notify the extension when the icon is clicked. | 25 // given PageAction and notify the extension when the icon is clicked. |
| 25 class PageActionImageView : public ToolbarActionViewDelegate, | 26 class PageActionImageView : public ToolbarActionViewDelegateViews, |
| 26 public views::ImageView { | 27 public views::ImageView { |
| 27 public: | 28 public: |
| 28 PageActionImageView(LocationBarView* owner, | 29 PageActionImageView(LocationBarView* owner, |
| 29 ExtensionAction* page_action, | 30 ExtensionAction* page_action, |
| 30 Browser* browser); | 31 Browser* browser); |
| 31 virtual ~PageActionImageView(); | 32 ~PageActionImageView() override; |
| 32 | 33 |
| 33 void set_preview_enabled(bool preview_enabled) { | 34 void set_preview_enabled(bool preview_enabled) { |
| 34 preview_enabled_ = preview_enabled; | 35 preview_enabled_ = preview_enabled; |
| 35 } | 36 } |
| 36 ExtensionAction* extension_action() { | 37 ExtensionAction* extension_action() { |
| 37 return view_controller_->extension_action(); | 38 return view_controller_->extension_action(); |
| 38 } | 39 } |
| 39 ExtensionActionViewController* view_controller() { | 40 ExtensionActionViewController* view_controller() { |
| 40 return view_controller_.get(); | 41 return view_controller_.get(); |
| 41 } | 42 } |
| 42 | 43 |
| 43 // Overridden from views::View: | 44 // Overridden from views::View: |
| 44 virtual const char* GetClassName() const override; | 45 const char* GetClassName() const override; |
| 45 virtual void GetAccessibleState(ui::AXViewState* state) override; | 46 void GetAccessibleState(ui::AXViewState* state) override; |
| 46 virtual bool OnMousePressed(const ui::MouseEvent& event) override; | 47 bool OnMousePressed(const ui::MouseEvent& event) override; |
| 47 virtual void OnMouseReleased(const ui::MouseEvent& event) override; | 48 void OnMouseReleased(const ui::MouseEvent& event) override; |
| 48 virtual bool OnKeyPressed(const ui::KeyEvent& event) override; | 49 bool OnKeyPressed(const ui::KeyEvent& event) override; |
| 49 virtual void OnGestureEvent(ui::GestureEvent* event) override; | 50 void OnGestureEvent(ui::GestureEvent* event) override; |
| 50 | 51 |
| 51 // Called to notify the PageAction that it should determine whether to be | 52 // Called to notify the PageAction that it should determine whether to be |
| 52 // visible or hidden. |contents| is the WebContents that is active. | 53 // visible or hidden. |contents| is the WebContents that is active. |
| 53 void UpdateVisibility(content::WebContents* contents); | 54 void UpdateVisibility(content::WebContents* contents); |
| 54 | 55 |
| 55 private: | 56 private: |
| 56 static const char kViewClassName[]; | 57 static const char kViewClassName[]; |
| 57 | 58 |
| 58 // Overridden from View. | 59 // Overridden from View. |
| 59 virtual void PaintChildren(gfx::Canvas* canvas, | 60 void PaintChildren(gfx::Canvas* canvas, |
| 60 const views::CullSet& cull_set) override; | 61 const views::CullSet& cull_set) override; |
| 61 | 62 |
| 62 // ToolbarActionViewDelegate: | 63 // ToolbarActionViewDelegateViews: |
| 63 virtual void OnIconUpdated() override; | 64 void UpdateState() override; |
| 64 virtual views::View* GetAsView() override; | 65 views::View* GetAsView() override; |
| 65 virtual bool IsShownInMenu() override; | 66 bool IsShownInMenu() override; |
| 66 virtual views::FocusManager* GetFocusManagerForAccelerator() override; | 67 views::FocusManager* GetFocusManagerForAccelerator() override; |
| 67 virtual views::Widget* GetParentForContextMenu() override; | 68 views::Widget* GetParentForContextMenu() override; |
| 68 virtual ExtensionActionViewController* GetPreferredPopupViewController() | 69 ToolbarActionViewController* GetPreferredPopupViewController() override; |
| 69 override; | 70 views::View* GetReferenceViewForPopup() override; |
| 70 virtual views::View* GetReferenceViewForPopup() override; | 71 views::MenuButton* GetContextMenuButton() override; |
| 71 virtual views::MenuButton* GetContextMenuButton() override; | 72 content::WebContents* GetCurrentWebContents() const override; |
| 72 virtual content::WebContents* GetCurrentWebContents() const override; | 73 void HideActivePopup() override; |
| 73 virtual void HideActivePopup() override; | |
| 74 | 74 |
| 75 // The controller for this ExtensionAction view. | 75 // The controller for this ExtensionAction view. |
| 76 scoped_ptr<ExtensionActionViewController> view_controller_; | 76 scoped_ptr<ExtensionActionViewController> view_controller_; |
| 77 | 77 |
| 78 // The location bar view that owns us. | 78 // The location bar view that owns us. |
| 79 LocationBarView* owner_; | 79 LocationBarView* owner_; |
| 80 | 80 |
| 81 // The string to show for a tooltip; | 81 // The string to show for a tooltip; |
| 82 std::string tooltip_; | 82 std::string tooltip_; |
| 83 | 83 |
| 84 // This is used for post-install visual feedback. The page_action icon is | 84 // This is used for post-install visual feedback. The page_action icon is |
| 85 // briefly shown even if it hasn't been enabled by its extension. | 85 // briefly shown even if it hasn't been enabled by its extension. |
| 86 bool preview_enabled_; | 86 bool preview_enabled_; |
| 87 | 87 |
| 88 DISALLOW_IMPLICIT_CONSTRUCTORS(PageActionImageView); | 88 DISALLOW_IMPLICIT_CONSTRUCTORS(PageActionImageView); |
| 89 }; | 89 }; |
| 90 | 90 |
| 91 #endif // CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_PAGE_ACTION_IMAGE_VIEW_H_ | 91 #endif // CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_PAGE_ACTION_IMAGE_VIEW_H_ |
| OLD | NEW |