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