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_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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 57 virtual ~ScriptBadgeController(); | 57 virtual ~ScriptBadgeController(); |
| 58 | 58 |
| 59 // LocationBarController implementation. | 59 // LocationBarController implementation. |
| 60 virtual std::vector<ExtensionAction*> GetCurrentActions() const OVERRIDE; | 60 virtual std::vector<ExtensionAction*> GetCurrentActions() const OVERRIDE; |
| 61 virtual void GetAttentionFor(const std::string& extension_id) OVERRIDE; | 61 virtual void GetAttentionFor(const std::string& extension_id) OVERRIDE; |
| 62 virtual Action OnClicked(const std::string& extension_id, | 62 virtual Action OnClicked(const std::string& extension_id, |
| 63 int mouse_button) OVERRIDE; | 63 int mouse_button) OVERRIDE; |
| 64 virtual void NotifyChange() OVERRIDE; | 64 virtual void NotifyChange() OVERRIDE; |
| 65 | 65 |
| 66 // ScriptExecutor::Observer implementation. | 66 // ScriptExecutor::Observer implementation. |
| 67 // Public to be called from tests. | |
| 67 virtual void OnExecuteScriptFinished( | 68 virtual void OnExecuteScriptFinished( |
| 68 const std::string& extension_id, bool success, int32 page_id, | 69 const std::string& extension_id, bool success, int32 page_id, |
| 69 const std::string& error, const base::ListValue& script_result) OVERRIDE; | 70 const std::string& error, const base::ListValue& script_result) OVERRIDE; |
| 70 | 71 |
| 72 // IPC::Message handlers. | |
| 73 // Public to be called from tests. | |
|
Jeffrey Yasskin
2012/07/25 22:22:39
<obligatory-c++-trivia>
Because these implement pu
not at google - send to devlin
2012/07/26 08:52:46
I was going to say "I like it" and started changin
| |
| 74 void OnContentScriptsExecuting(const std::set<std::string>& extension_ids, | |
| 75 int32 page_id); | |
| 76 | |
| 71 private: | 77 private: |
| 72 // Gets the ExtensionService for |tab_contents_|. | 78 // Gets the ExtensionService for |tab_contents_|. |
| 73 ExtensionService* GetExtensionService(); | 79 ExtensionService* GetExtensionService(); |
| 74 | 80 |
| 75 // Gets the current page ID. | 81 // Gets the current page ID, or -1 if there isn't one yet. |
| 76 int32 GetPageID(); | 82 int32 GetPageID(); |
| 77 | 83 |
| 78 // content::WebContentsObserver implementation. | 84 // content::WebContentsObserver implementation. |
| 79 virtual void DidNavigateMainFrame( | 85 virtual void DidNavigateMainFrame( |
| 80 const content::LoadCommittedDetails& details, | 86 const content::LoadCommittedDetails& details, |
| 81 const content::FrameNavigateParams& params) OVERRIDE; | 87 const content::FrameNavigateParams& params) OVERRIDE; |
| 82 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 88 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
| 83 | 89 |
| 84 // content::NotificationObserver implementation. | 90 // content::NotificationObserver implementation. |
| 85 virtual void Observe(int type, | 91 virtual void Observe(int type, |
| 86 const content::NotificationSource& source, | 92 const content::NotificationSource& source, |
| 87 const content::NotificationDetails& details) OVERRIDE; | 93 const content::NotificationDetails& details) OVERRIDE; |
| 88 | 94 |
| 89 // IPC::Message handlers. | |
| 90 void OnContentScriptsExecuting(const std::set<std::string>& extension_ids, | |
| 91 int32 page_id); | |
| 92 | |
| 93 // Adds the extension's icon to the list of script badges. Returns | 95 // Adds the extension's icon to the list of script badges. Returns |
| 94 // the script badge ExtensionAction that was added, or NULL if | 96 // the script badge ExtensionAction that was added, or NULL if |
| 95 // extension_id isn't valid. | 97 // extension_id isn't valid. |
| 96 ExtensionAction* AddExtensionToCurrentActions( | 98 ExtensionAction* AddExtensionToCurrentActions( |
| 97 const std::string& extension_id); | 99 const std::string& extension_id); |
| 98 | 100 |
| 99 // Called when an extension is running script on the current tab, | 101 // Called when an extension is running script on the current tab, |
| 100 // and tries to insert an extension into the relevant collections. | 102 // and tries to insert an extension into the relevant collections. |
| 101 // Returns true if any change was made. | 103 // Returns true if any change was made. |
| 102 bool MarkExtensionExecuting(const std::string& extension_id); | 104 bool MarkExtensionExecuting(const std::string& extension_id); |
| 103 | 105 |
| 104 // Tries to erase an extension from the relevant collections, and returns | 106 // Tries to erase an extension from the relevant collections, and returns |
| 105 // whether any change was made. | 107 // whether any change was made. |
| 106 bool EraseExtension(const Extension* extension); | 108 bool EraseExtension(const Extension* extension); |
| 107 | 109 |
| 108 // Our parent TabContents. | 110 // Our parent TabContents. |
| 109 TabContents* tab_contents_; | 111 TabContents* tab_contents_; |
| 110 | 112 |
| 111 // The current extension actions in the order they appeared. These come from | 113 // The current extension actions in the order they appeared. These come from |
| 112 // calls to ExecuteScript or getAttention on the current frame. | 114 // calls to ExecuteScript or getAttention on the current frame. |
| 113 std::vector<ExtensionAction*> current_actions_; | 115 std::vector<ExtensionAction*> current_actions_; |
| 114 | 116 |
| 115 // The extensions that have actions in current_actions_. | 117 // The extensions that have actions in current_actions_. |
| 116 std::set<std::string> extensions_in_current_actions_; | 118 std::set<std::string> extensions_in_current_actions_; |
| 117 | 119 |
| 120 // Extensions that have actions in a page ID that hasn't been reached yet. | |
|
Jeffrey Yasskin
2012/07/25 22:22:39
This feels like something that will bite us later
not at google - send to devlin
2012/07/26 08:52:46
Yeah, so the crash was from OnContentScriptExecuti
| |
| 121 typedef std::map<int, std::vector<std::string> > FutureActionsMap; | |
| 122 FutureActionsMap future_actions_; | |
| 123 | |
| 118 // Listen to extension unloaded notifications. | 124 // Listen to extension unloaded notifications. |
| 119 content::NotificationRegistrar registrar_; | 125 content::NotificationRegistrar registrar_; |
| 120 | 126 |
| 121 DISALLOW_COPY_AND_ASSIGN(ScriptBadgeController); | 127 DISALLOW_COPY_AND_ASSIGN(ScriptBadgeController); |
| 122 }; | 128 }; |
| 123 | 129 |
| 124 } // namespace extensions | 130 } // namespace extensions |
| 125 | 131 |
| 126 #endif // CHROME_BROWSER_EXTENSIONS_SCRIPT_BADGE_CONTROLLER_H_ | 132 #endif // CHROME_BROWSER_EXTENSIONS_SCRIPT_BADGE_CONTROLLER_H_ |
| OLD | NEW |