| 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_COCOA_LOCATION_BAR_PAGE_ACTION_DECORATION_H_ | 5 #ifndef CHROME_BROWSER_UI_COCOA_LOCATION_BAR_PAGE_ACTION_DECORATION_H_ |
| 6 #define CHROME_BROWSER_UI_COCOA_LOCATION_BAR_PAGE_ACTION_DECORATION_H_ | 6 #define CHROME_BROWSER_UI_COCOA_LOCATION_BAR_PAGE_ACTION_DECORATION_H_ |
| 7 | 7 |
| 8 #include "chrome/browser/extensions/extension_action.h" | 8 #include "chrome/browser/extensions/extension_action.h" |
| 9 #include "chrome/browser/extensions/extension_action_icon_factory.h" | 9 #include "chrome/browser/extensions/extension_action_icon_factory.h" |
| 10 #import "chrome/browser/ui/cocoa/location_bar/image_decoration.h" | 10 #import "chrome/browser/ui/cocoa/location_bar/image_decoration.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 // PageActionDecoration is used to display the icon for a given Page | 27 // PageActionDecoration is used to display the icon for a given Page |
| 28 // Action and notify the extension when the icon is clicked. | 28 // Action and notify the extension when the icon is clicked. |
| 29 | 29 |
| 30 class PageActionDecoration : public ImageDecoration, | 30 class PageActionDecoration : public ImageDecoration, |
| 31 public ExtensionActionIconFactory::Observer, | 31 public ExtensionActionIconFactory::Observer, |
| 32 public content::NotificationObserver { | 32 public content::NotificationObserver { |
| 33 public: | 33 public: |
| 34 PageActionDecoration(LocationBarViewMac* owner, | 34 PageActionDecoration(LocationBarViewMac* owner, |
| 35 Browser* browser, | 35 Browser* browser, |
| 36 ExtensionAction* page_action); | 36 ExtensionAction* page_action); |
| 37 virtual ~PageActionDecoration(); | 37 ~PageActionDecoration() override; |
| 38 | 38 |
| 39 ExtensionAction* page_action() { return page_action_; } | 39 ExtensionAction* page_action() { return page_action_; } |
| 40 int current_tab_id() { return current_tab_id_; } | 40 int current_tab_id() { return current_tab_id_; } |
| 41 void set_preview_enabled(bool enabled) { preview_enabled_ = enabled; } | 41 void set_preview_enabled(bool enabled) { preview_enabled_ = enabled; } |
| 42 bool preview_enabled() const { return preview_enabled_; } | 42 bool preview_enabled() const { return preview_enabled_; } |
| 43 | 43 |
| 44 // Overridden from |ExtensionActionIconFactory::Observer|. | 44 // Overridden from |ExtensionActionIconFactory::Observer|. |
| 45 virtual void OnIconUpdated() override; | 45 void OnIconUpdated() override; |
| 46 | 46 |
| 47 // Called to notify the Page Action that it should determine whether | 47 // Called to notify the Page Action that it should determine whether |
| 48 // to be visible or hidden. |contents| is the WebContents that is | 48 // to be visible or hidden. |contents| is the WebContents that is |
| 49 // active, |url| is the current page URL. | 49 // active, |url| is the current page URL. |
| 50 void UpdateVisibility(content::WebContents* contents, const GURL& url); | 50 void UpdateVisibility(content::WebContents* contents, const GURL& url); |
| 51 | 51 |
| 52 // Sets the tooltip for this Page Action image. | 52 // Sets the tooltip for this Page Action image. |
| 53 void SetToolTip(NSString* tooltip); | 53 void SetToolTip(NSString* tooltip); |
| 54 void SetToolTip(std::string tooltip); | 54 void SetToolTip(std::string tooltip); |
| 55 | 55 |
| 56 // Overridden from |LocationBarDecoration| | 56 // Overridden from |LocationBarDecoration| |
| 57 virtual CGFloat GetWidthForSpace(CGFloat width) override; | 57 CGFloat GetWidthForSpace(CGFloat width) override; |
| 58 virtual bool AcceptsMousePress() override; | 58 bool AcceptsMousePress() override; |
| 59 virtual bool OnMousePressed(NSRect frame, NSPoint location) override; | 59 bool OnMousePressed(NSRect frame, NSPoint location) override; |
| 60 virtual NSString* GetToolTip() override; | 60 NSString* GetToolTip() override; |
| 61 virtual NSMenu* GetMenu() override; | 61 NSMenu* GetMenu() override; |
| 62 virtual NSPoint GetBubblePointInFrame(NSRect frame) override; | 62 NSPoint GetBubblePointInFrame(NSRect frame) override; |
| 63 | 63 |
| 64 // Activates the page action in its default frame, and, if |grant_active_tab| | 64 // Activates the page action in its default frame, and, if |grant_active_tab| |
| 65 // is true, grants active tab permission to the extension. Returns true if | 65 // is true, grants active tab permission to the extension. Returns true if |
| 66 // a popup was shown. | 66 // a popup was shown. |
| 67 bool ActivatePageAction(bool grant_active_tab); | 67 bool ActivatePageAction(bool grant_active_tab); |
| 68 | 68 |
| 69 private: | 69 private: |
| 70 // Activate the page action in the given |frame|. | 70 // Activate the page action in the given |frame|. |
| 71 bool ActivatePageAction(NSRect frame, bool grant_active_tab); | 71 bool ActivatePageAction(NSRect frame, bool grant_active_tab); |
| 72 | 72 |
| 73 // Show the popup in the frame, with the given URL. | 73 // Show the popup in the frame, with the given URL. |
| 74 void ShowPopup(const NSRect& frame, const GURL& popup_url); | 74 void ShowPopup(const NSRect& frame, const GURL& popup_url); |
| 75 | 75 |
| 76 // Returns the extension associated with the page action. | 76 // Returns the extension associated with the page action. |
| 77 const extensions::Extension* GetExtension(); | 77 const extensions::Extension* GetExtension(); |
| 78 | 78 |
| 79 // Overridden from NotificationObserver: | 79 // Overridden from NotificationObserver: |
| 80 virtual void Observe(int type, | 80 void Observe(int type, |
| 81 const content::NotificationSource& source, | 81 const content::NotificationSource& source, |
| 82 const content::NotificationDetails& details) override; | 82 const content::NotificationDetails& details) override; |
| 83 | 83 |
| 84 // The location bar view that owns us. | 84 // The location bar view that owns us. |
| 85 LocationBarViewMac* owner_; | 85 LocationBarViewMac* owner_; |
| 86 | 86 |
| 87 // The current browser (not owned by us). | 87 // The current browser (not owned by us). |
| 88 Browser* browser_; | 88 Browser* browser_; |
| 89 | 89 |
| 90 // The Page Action that this view represents. The Page Action is not | 90 // The Page Action that this view represents. The Page Action is not |
| 91 // owned by us, it resides in the extension of this particular | 91 // owned by us, it resides in the extension of this particular |
| 92 // profile. | 92 // profile. |
| (...skipping 24 matching lines...) Expand all Loading... |
| 117 bool preview_enabled_; | 117 bool preview_enabled_; |
| 118 | 118 |
| 119 // Used to register for notifications received by | 119 // Used to register for notifications received by |
| 120 // NotificationObserver. | 120 // NotificationObserver. |
| 121 content::NotificationRegistrar registrar_; | 121 content::NotificationRegistrar registrar_; |
| 122 | 122 |
| 123 DISALLOW_COPY_AND_ASSIGN(PageActionDecoration); | 123 DISALLOW_COPY_AND_ASSIGN(PageActionDecoration); |
| 124 }; | 124 }; |
| 125 | 125 |
| 126 #endif // CHROME_BROWSER_UI_COCOA_LOCATION_BAR_PAGE_ACTION_DECORATION_H_ | 126 #endif // CHROME_BROWSER_UI_COCOA_LOCATION_BAR_PAGE_ACTION_DECORATION_H_ |
| OLD | NEW |