Chromium Code Reviews| 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_EXTENSIONS_API_EXTENSION_ACTION_EXTENSION_ACTION_API_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_EXTENSION_ACTION_EXTENSION_ACTION_API_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_API_EXTENSION_ACTION_EXTENSION_ACTION_API_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_EXTENSION_ACTION_EXTENSION_ACTION_API_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 37 public: | 37 public: |
| 38 // Called when there is a change to the given |extension_action|. | 38 // Called when there is a change to the given |extension_action|. |
| 39 // |web_contents| is the web contents that was affected, and | 39 // |web_contents| is the web contents that was affected, and |
| 40 // |browser_context| is the associated BrowserContext. (The latter is | 40 // |browser_context| is the associated BrowserContext. (The latter is |
| 41 // included because ExtensionActionAPI is shared between normal and | 41 // included because ExtensionActionAPI is shared between normal and |
| 42 // incognito contexts, so |browser_context| may not equal | 42 // incognito contexts, so |browser_context| may not equal |
| 43 // |browser_context_|.) | 43 // |browser_context_|.) |
| 44 virtual void OnExtensionActionUpdated( | 44 virtual void OnExtensionActionUpdated( |
| 45 ExtensionAction* extension_action, | 45 ExtensionAction* extension_action, |
| 46 content::WebContents* web_contents, | 46 content::WebContents* web_contents, |
| 47 content::BrowserContext* browser_context) = 0; | 47 content::BrowserContext* browser_context) {} |
| 48 | |
| 49 // Called when the page actions have been refreshed do to a possible change | |
| 50 // in count or visibility. | |
| 51 virtual void OnPageActionsUpdated(content::WebContents* web_contents) {} | |
| 48 | 52 |
| 49 // Called when the ExtensionActionAPI is shutting down, giving observers a | 53 // Called when the ExtensionActionAPI is shutting down, giving observers a |
| 50 // chance to unregister themselves if there is not a definitive lifecycle. | 54 // chance to unregister themselves if there is not a definitive lifecycle. |
| 51 virtual void OnExtensionActionAPIShuttingDown() {} | 55 virtual void OnExtensionActionAPIShuttingDown() {} |
|
Finnur
2014/08/25 13:47:56
nit: Can you move these {} to the .cc file?
Devlin
2014/08/25 16:57:36
yep.
| |
| 52 | 56 |
| 53 protected: | 57 protected: |
| 54 virtual ~Observer() {} | 58 virtual ~Observer() {} |
| 55 }; | 59 }; |
| 56 | 60 |
| 57 explicit ExtensionActionAPI(content::BrowserContext* context); | 61 explicit ExtensionActionAPI(content::BrowserContext* context); |
| 58 virtual ~ExtensionActionAPI(); | 62 virtual ~ExtensionActionAPI(); |
| 59 | 63 |
| 60 // Convenience method to get the instance for a profile. | 64 // Convenience method to get the instance for a profile. |
| 61 static ExtensionActionAPI* Get(content::BrowserContext* context); | 65 static ExtensionActionAPI* Get(content::BrowserContext* context); |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 79 content::WebContents* web_contents); | 83 content::WebContents* web_contents); |
| 80 | 84 |
| 81 // BrowserContextKeyedAPI implementation. | 85 // BrowserContextKeyedAPI implementation. |
| 82 static BrowserContextKeyedAPIFactory<ExtensionActionAPI>* | 86 static BrowserContextKeyedAPIFactory<ExtensionActionAPI>* |
| 83 GetFactoryInstance(); | 87 GetFactoryInstance(); |
| 84 | 88 |
| 85 // Add or remove observers. | 89 // Add or remove observers. |
| 86 void AddObserver(Observer* observer); | 90 void AddObserver(Observer* observer); |
| 87 void RemoveObserver(Observer* observer); | 91 void RemoveObserver(Observer* observer); |
| 88 | 92 |
| 93 // Notifies that there has been a change in the given |extension_action|. | |
| 89 void NotifyChange(ExtensionAction* extension_action, | 94 void NotifyChange(ExtensionAction* extension_action, |
| 90 content::WebContents* web_contents, | 95 content::WebContents* web_contents, |
| 91 content::BrowserContext* browser_context); | 96 content::BrowserContext* browser_context); |
| 92 | 97 |
| 93 // Clears the values for all ExtensionActions for the tab associated with the | 98 // Clears the values for all ExtensionActions for the tab associated with the |
| 94 // given |web_contents|. | 99 // given |web_contents| (and signals that page actions changed). |
| 95 void ClearAllValuesForTab(content::WebContents* web_contents); | 100 void ClearAllValuesForTab(content::WebContents* web_contents); |
| 96 | 101 |
| 102 // Notifies that the current set of page actions for |web_contents| has | |
| 103 // changed, and signals the browser to update. | |
| 104 void NotifyPageActionsChanged(content::WebContents* web_contents); | |
| 105 | |
| 97 private: | 106 private: |
| 98 friend class BrowserContextKeyedAPIFactory<ExtensionActionAPI>; | 107 friend class BrowserContextKeyedAPIFactory<ExtensionActionAPI>; |
| 99 | 108 |
| 100 // The DispatchEvent methods forward events to the |profile|'s event router. | 109 // The DispatchEvent methods forward events to the |profile|'s event router. |
| 101 static void DispatchEventToExtension(content::BrowserContext* context, | 110 static void DispatchEventToExtension(content::BrowserContext* context, |
| 102 const std::string& extension_id, | 111 const std::string& extension_id, |
| 103 const std::string& event_name, | 112 const std::string& event_name, |
| 104 scoped_ptr<base::ListValue> event_args); | 113 scoped_ptr<base::ListValue> event_args); |
| 105 | 114 |
| 106 // Called when either a browser or page action is executed. Figures out which | 115 // Called when either a browser or page action is executed. Figures out which |
| (...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 468 class PageActionGetPopupFunction | 477 class PageActionGetPopupFunction |
| 469 : public extensions::ExtensionActionGetPopupFunction { | 478 : public extensions::ExtensionActionGetPopupFunction { |
| 470 public: | 479 public: |
| 471 DECLARE_EXTENSION_FUNCTION("pageAction.getPopup", PAGEACTION_GETPOPUP) | 480 DECLARE_EXTENSION_FUNCTION("pageAction.getPopup", PAGEACTION_GETPOPUP) |
| 472 | 481 |
| 473 protected: | 482 protected: |
| 474 virtual ~PageActionGetPopupFunction() {} | 483 virtual ~PageActionGetPopupFunction() {} |
| 475 }; | 484 }; |
| 476 | 485 |
| 477 #endif // CHROME_BROWSER_EXTENSIONS_API_EXTENSION_ACTION_EXTENSION_ACTION_API_H _ | 486 #endif // CHROME_BROWSER_EXTENSIONS_API_EXTENSION_ACTION_EXTENSION_ACTION_API_H _ |
| OLD | NEW |