| 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> |
| 11 | 11 |
| 12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 13 #include "base/memory/linked_ptr.h" | 13 #include "base/memory/linked_ptr.h" |
| 14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
| 15 #include "chrome/browser/extensions/location_bar_controller.h" | 15 #include "chrome/browser/extensions/location_bar_controller.h" |
| 16 #include "chrome/browser/extensions/script_executor.h" | 16 #include "chrome/browser/extensions/script_executor.h" |
| 17 #include "content/public/browser/notification_observer.h" | 17 #include "content/public/browser/notification_observer.h" |
| 18 #include "content/public/browser/notification_registrar.h" | 18 #include "content/public/browser/notification_registrar.h" |
| 19 #include "content/public/browser/web_contents_observer.h" | 19 #include "content/public/browser/web_contents_observer.h" |
| 20 | 20 |
| 21 class ExtensionAction; | 21 class ExtensionAction; |
| 22 class ExtensionService; | 22 class ExtensionService; |
| 23 class GURL; |
| 23 class TabContents; | 24 class TabContents; |
| 24 | 25 |
| 25 namespace base { | 26 namespace base { |
| 26 class ListValue; | 27 class ListValue; |
| 27 } // namespace base | 28 } // namespace base |
| 28 | 29 |
| 29 namespace IPC { | 30 namespace IPC { |
| 30 class Message; | 31 class Message; |
| 31 } | 32 } |
| 32 | 33 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 58 | 59 |
| 59 // LocationBarController implementation. | 60 // LocationBarController implementation. |
| 60 virtual std::vector<ExtensionAction*> GetCurrentActions() const OVERRIDE; | 61 virtual std::vector<ExtensionAction*> GetCurrentActions() const OVERRIDE; |
| 61 virtual void GetAttentionFor(const std::string& extension_id) OVERRIDE; | 62 virtual void GetAttentionFor(const std::string& extension_id) OVERRIDE; |
| 62 virtual Action OnClicked(const std::string& extension_id, | 63 virtual Action OnClicked(const std::string& extension_id, |
| 63 int mouse_button) OVERRIDE; | 64 int mouse_button) OVERRIDE; |
| 64 virtual void NotifyChange() OVERRIDE; | 65 virtual void NotifyChange() OVERRIDE; |
| 65 | 66 |
| 66 // ScriptExecutor::Observer implementation. | 67 // ScriptExecutor::Observer implementation. |
| 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, |
| 69 const std::string& error, const base::ListValue& script_result) OVERRIDE; | 70 const std::string& error, |
| 71 int32 on_page_id, |
| 72 const GURL& on_url, |
| 73 const base::ListValue& script_result) OVERRIDE; |
| 70 | 74 |
| 71 private: | 75 private: |
| 72 // Gets the ExtensionService for |tab_contents_|. | 76 // Gets the ExtensionService for |tab_contents_|. |
| 73 ExtensionService* GetExtensionService(); | 77 ExtensionService* GetExtensionService(); |
| 74 | 78 |
| 75 // Gets the current page ID. | 79 // Gets the current page ID, or -1 if no navigation entry has been committed. |
| 76 int32 GetPageID(); | 80 int32 GetPageID(); |
| 77 | 81 |
| 78 // content::WebContentsObserver implementation. | 82 // content::WebContentsObserver implementation. |
| 79 virtual void DidNavigateMainFrame( | 83 virtual void DidNavigateMainFrame( |
| 80 const content::LoadCommittedDetails& details, | 84 const content::LoadCommittedDetails& details, |
| 81 const content::FrameNavigateParams& params) OVERRIDE; | 85 const content::FrameNavigateParams& params) OVERRIDE; |
| 82 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 86 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
| 83 | 87 |
| 84 // content::NotificationObserver implementation. | 88 // content::NotificationObserver implementation. |
| 85 virtual void Observe(int type, | 89 virtual void Observe(int type, |
| 86 const content::NotificationSource& source, | 90 const content::NotificationSource& source, |
| 87 const content::NotificationDetails& details) OVERRIDE; | 91 const content::NotificationDetails& details) OVERRIDE; |
| 88 | 92 |
| 89 // IPC::Message handlers. | 93 // IPC::Message handlers. |
| 90 void OnContentScriptsExecuting(const std::set<std::string>& extension_ids, | 94 void OnContentScriptsExecuting(const std::set<std::string>& extension_ids, |
| 91 int32 page_id); | 95 int32 page_id, |
| 96 const GURL& on_url); |
| 92 | 97 |
| 93 // Adds the extension's icon to the list of script badges. Returns | 98 // Adds the extension's icon to the list of script badges. Returns |
| 94 // the script badge ExtensionAction that was added, or NULL if | 99 // the script badge ExtensionAction that was added, or NULL if |
| 95 // extension_id isn't valid. | 100 // extension_id isn't valid. |
| 96 ExtensionAction* AddExtensionToCurrentActions( | 101 ExtensionAction* AddExtensionToCurrentActions( |
| 97 const std::string& extension_id); | 102 const std::string& extension_id); |
| 98 | 103 |
| 99 // Called when an extension is running script on the current tab, | 104 // Called when an extension is running script on the current tab, |
| 100 // and tries to insert an extension into the relevant collections. | 105 // and tries to insert an extension into the relevant collections. |
| 101 // Returns true if any change was made. | 106 // Returns true if any change was made. |
| (...skipping 15 matching lines...) Expand all Loading... |
| 117 | 122 |
| 118 // Listen to extension unloaded notifications. | 123 // Listen to extension unloaded notifications. |
| 119 content::NotificationRegistrar registrar_; | 124 content::NotificationRegistrar registrar_; |
| 120 | 125 |
| 121 DISALLOW_COPY_AND_ASSIGN(ScriptBadgeController); | 126 DISALLOW_COPY_AND_ASSIGN(ScriptBadgeController); |
| 122 }; | 127 }; |
| 123 | 128 |
| 124 } // namespace extensions | 129 } // namespace extensions |
| 125 | 130 |
| 126 #endif // CHROME_BROWSER_EXTENSIONS_SCRIPT_BADGE_CONTROLLER_H_ | 131 #endif // CHROME_BROWSER_EXTENSIONS_SCRIPT_BADGE_CONTROLLER_H_ |
| OLD | NEW |