| 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_SCRIPT_BADGE_CONTROLLER_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_SCRIPT_BADGE_CONTROLLER_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_SCRIPT_BADGE_CONTROLLER_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_SCRIPT_BADGE_CONTROLLER_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 public ScriptExecutor::Observer, | 47 public ScriptExecutor::Observer, |
| 48 public content::WebContentsObserver, | 48 public content::WebContentsObserver, |
| 49 public content::NotificationObserver { | 49 public content::NotificationObserver { |
| 50 public: | 50 public: |
| 51 explicit ScriptBadgeController(TabContents* tab_contents, | 51 explicit ScriptBadgeController(TabContents* tab_contents, |
| 52 ScriptExecutor* script_executor); | 52 ScriptExecutor* script_executor); |
| 53 virtual ~ScriptBadgeController(); | 53 virtual ~ScriptBadgeController(); |
| 54 | 54 |
| 55 // LocationBarController implementation. | 55 // LocationBarController implementation. |
| 56 virtual std::vector<ExtensionAction*> GetCurrentActions() const OVERRIDE; | 56 virtual std::vector<ExtensionAction*> GetCurrentActions() const OVERRIDE; |
| 57 virtual void GetAttentionFor(const std::string& extension_id) OVERRIDE; |
| 57 virtual Action OnClicked(const std::string& extension_id, | 58 virtual Action OnClicked(const std::string& extension_id, |
| 58 int mouse_button) OVERRIDE; | 59 int mouse_button) OVERRIDE; |
| 59 virtual void NotifyChange() OVERRIDE; | 60 virtual void NotifyChange() OVERRIDE; |
| 60 | 61 |
| 61 // ScriptExecutor::Observer implementation. | 62 // ScriptExecutor::Observer implementation. |
| 62 virtual void OnExecuteScriptFinished(const std::string& extension_id, | 63 virtual void OnExecuteScriptFinished(const std::string& extension_id, |
| 63 bool success, | 64 bool success, |
| 64 int32 page_id, | 65 int32 page_id, |
| 65 const std::string& error) OVERRIDE; | 66 const std::string& error) OVERRIDE; |
| 66 | 67 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 79 | 80 |
| 80 // content::NotificationObserver implementation. | 81 // content::NotificationObserver implementation. |
| 81 virtual void Observe(int type, | 82 virtual void Observe(int type, |
| 82 const content::NotificationSource& source, | 83 const content::NotificationSource& source, |
| 83 const content::NotificationDetails& details) OVERRIDE; | 84 const content::NotificationDetails& details) OVERRIDE; |
| 84 | 85 |
| 85 // IPC::Message handlers. | 86 // IPC::Message handlers. |
| 86 void OnContentScriptsExecuting(const std::set<std::string>& extension_ids, | 87 void OnContentScriptsExecuting(const std::set<std::string>& extension_ids, |
| 87 int32 page_id); | 88 int32 page_id); |
| 88 | 89 |
| 89 // Tries to insert an extension into the relevant collections, and returns | 90 // Adds the extension's icon to the list of script badges. Returns |
| 90 // whether any change was made. | 91 // the script badge ExtensionAction that was added, or NULL if |
| 91 bool InsertExtension(const std::string& extension_id); | 92 // extension_id isn't valid. |
| 93 ExtensionAction* AddExtensionToCurrentActions( |
| 94 const std::string& extension_id); |
| 95 |
| 96 // Called when an extension is running script on the current tab, |
| 97 // and tries to insert an extension into the relevant collections. |
| 98 // Returns true if any change was made. |
| 99 bool MarkExtensionExecuting(const std::string& extension_id); |
| 92 | 100 |
| 93 // Tries to erase an extension from the relevant collections, and returns | 101 // Tries to erase an extension from the relevant collections, and returns |
| 94 // whether any change was made. | 102 // whether any change was made. |
| 95 bool EraseExtension(const Extension* extension); | 103 bool EraseExtension(const Extension* extension); |
| 96 | 104 |
| 97 // Our parent TabContents. | 105 // Our parent TabContents. |
| 98 TabContents* tab_contents_; | 106 TabContents* tab_contents_; |
| 99 | 107 |
| 100 // The current extension actions in the order they appeared. | 108 // The current extension actions in the order they appeared. These come from |
| 109 // calls to ExecuteScript or getAttention on the current frame. |
| 101 std::vector<ExtensionAction*> current_actions_; | 110 std::vector<ExtensionAction*> current_actions_; |
| 102 | 111 |
| 103 // The extensions that have called ExecuteScript on the current frame. | 112 // The extensions that have actions in current_actions_. |
| 104 std::set<std::string> extensions_executing_scripts_; | 113 std::set<std::string> extensions_in_current_actions_; |
| 105 | 114 |
| 106 // Listen to extension unloaded notifications. | 115 // Listen to extension unloaded notifications. |
| 107 content::NotificationRegistrar registrar_; | 116 content::NotificationRegistrar registrar_; |
| 108 | 117 |
| 109 DISALLOW_COPY_AND_ASSIGN(ScriptBadgeController); | 118 DISALLOW_COPY_AND_ASSIGN(ScriptBadgeController); |
| 110 }; | 119 }; |
| 111 | 120 |
| 112 } // namespace extensions | 121 } // namespace extensions |
| 113 | 122 |
| 114 #endif // CHROME_BROWSER_EXTENSIONS_SCRIPT_BADGE_CONTROLLER_H_ | 123 #endif // CHROME_BROWSER_EXTENSIONS_SCRIPT_BADGE_CONTROLLER_H_ |
| OLD | NEW |