| 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 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 #include <string> | 10 #include <string> |
| 11 | 11 |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "chrome/browser/extensions/extension_context_menu_model.h" | |
| 14 #include "chrome/browser/extensions/image_loading_tracker.h" | 13 #include "chrome/browser/extensions/image_loading_tracker.h" |
| 15 #include "chrome/browser/ui/views/extensions/extension_popup.h" | 14 #include "chrome/browser/ui/views/extensions/extension_popup.h" |
| 16 #include "ui/views/controls/image_view.h" | 15 #include "ui/views/controls/image_view.h" |
| 17 | 16 |
| 18 class Browser; | 17 class Browser; |
| 18 class ExtensionAction; |
| 19 class LocationBarView; | 19 class LocationBarView; |
| 20 | 20 |
| 21 namespace content { | 21 namespace content { |
| 22 class WebContents; | 22 class WebContents; |
| 23 } | 23 } |
| 24 namespace views { | 24 namespace views { |
| 25 class MenuRunner; | 25 class MenuRunner; |
| 26 } | 26 } |
| 27 | 27 |
| 28 // PageActionImageView is used by the LocationBarView to display the icon for a | 28 // PageActionImageView is used by the LocationBarView to display the icon for a |
| 29 // given PageAction and notify the extension when the icon is clicked. | 29 // given PageAction and notify the extension when the icon is clicked. |
| 30 class PageActionImageView : public views::ImageView, | 30 class PageActionImageView : public views::ImageView, |
| 31 public ImageLoadingTracker::Observer, | 31 public ImageLoadingTracker::Observer, |
| 32 public ExtensionContextMenuModel::PopupDelegate, | |
| 33 public views::Widget::Observer, | 32 public views::Widget::Observer, |
| 34 public content::NotificationObserver { | 33 public content::NotificationObserver { |
| 35 public: | 34 public: |
| 36 PageActionImageView(LocationBarView* owner, | 35 PageActionImageView(LocationBarView* owner, |
| 37 ExtensionAction* page_action, | 36 ExtensionAction* page_action, |
| 38 Browser* browser); | 37 Browser* browser); |
| 39 virtual ~PageActionImageView(); | 38 virtual ~PageActionImageView(); |
| 40 | 39 |
| 41 ExtensionAction* page_action() { return page_action_; } | 40 ExtensionAction* page_action() { return page_action_; } |
| 42 | 41 |
| 43 int current_tab_id() { return current_tab_id_; } | 42 int current_tab_id() { return current_tab_id_; } |
| 44 | 43 |
| 45 void set_preview_enabled(bool preview_enabled) { | 44 void set_preview_enabled(bool preview_enabled) { |
| 46 preview_enabled_ = preview_enabled; | 45 preview_enabled_ = preview_enabled; |
| 47 } | 46 } |
| 48 | 47 |
| 49 // Overridden from view. | 48 // Overridden from view. |
| 50 virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; | 49 virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; |
| 51 virtual bool OnMousePressed(const views::MouseEvent& event) OVERRIDE; | 50 virtual bool OnMousePressed(const views::MouseEvent& event) OVERRIDE; |
| 52 virtual void OnMouseReleased(const views::MouseEvent& event) OVERRIDE; | 51 virtual void OnMouseReleased(const views::MouseEvent& event) OVERRIDE; |
| 53 virtual bool OnKeyPressed(const views::KeyEvent& event) OVERRIDE; | 52 virtual bool OnKeyPressed(const views::KeyEvent& event) OVERRIDE; |
| 54 virtual void ShowContextMenu(const gfx::Point& p, | 53 virtual void ShowContextMenu(const gfx::Point& p, |
| 55 bool is_mouse_gesture) OVERRIDE; | 54 bool is_mouse_gesture) OVERRIDE; |
| 56 | 55 |
| 57 // Overridden from ImageLoadingTracker. | 56 // Overridden from ImageLoadingTracker. |
| 58 virtual void OnImageLoaded(const gfx::Image& image, | 57 virtual void OnImageLoaded(const gfx::Image& image, |
| 59 const std::string& extension_id, | 58 const std::string& extension_id, |
| 60 int index) OVERRIDE; | 59 int index) OVERRIDE; |
| 61 | 60 |
| 62 // Overridden from ExtensionContextMenuModelModel::Delegate | |
| 63 virtual void InspectPopup(ExtensionAction* action) OVERRIDE; | |
| 64 | |
| 65 // Overridden from views::Widget::Observer | 61 // Overridden from views::Widget::Observer |
| 66 virtual void OnWidgetClosing(views::Widget* widget) OVERRIDE; | 62 virtual void OnWidgetClosing(views::Widget* widget) OVERRIDE; |
| 67 | 63 |
| 68 // content::NotificationObserver implementation. | 64 // content::NotificationObserver implementation. |
| 69 virtual void Observe(int type, | 65 virtual void Observe(int type, |
| 70 const content::NotificationSource& source, | 66 const content::NotificationSource& source, |
| 71 const content::NotificationDetails& details) OVERRIDE; | 67 const content::NotificationDetails& details) OVERRIDE; |
| 72 | 68 |
| 73 // Overridden from ui::AcceleratorTarget. | 69 // Overridden from ui::AcceleratorTarget. |
| 74 virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) OVERRIDE; | 70 virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) OVERRIDE; |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 // The extension keybinding accelerator this page action is listening for (to | 121 // The extension keybinding accelerator this page action is listening for (to |
| 126 // show the popup). | 122 // show the popup). |
| 127 scoped_ptr<ui::Accelerator> keybinding_; | 123 scoped_ptr<ui::Accelerator> keybinding_; |
| 128 | 124 |
| 129 scoped_ptr<views::MenuRunner> menu_runner_; | 125 scoped_ptr<views::MenuRunner> menu_runner_; |
| 130 | 126 |
| 131 DISALLOW_IMPLICIT_CONSTRUCTORS(PageActionImageView); | 127 DISALLOW_IMPLICIT_CONSTRUCTORS(PageActionImageView); |
| 132 }; | 128 }; |
| 133 | 129 |
| 134 #endif // CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_PAGE_ACTION_IMAGE_VIEW_H_ | 130 #endif // CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_PAGE_ACTION_IMAGE_VIEW_H_ |
| OLD | NEW |