| 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 GURL; |
| 24 class TabContents; | |
| 25 | 24 |
| 26 namespace base { | 25 namespace base { |
| 27 class ListValue; | 26 class ListValue; |
| 28 } // namespace base | 27 } // namespace base |
| 29 | 28 |
| 30 namespace IPC { | 29 namespace IPC { |
| 31 class Message; | 30 class Message; |
| 32 } | 31 } |
| 33 | 32 |
| 34 namespace extensions { | 33 namespace extensions { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 46 // | 45 // |
| 47 // When extension IDs are recorded a NOTIFICATION_EXTENSION_LOCATION_BAR_UPDATED | 46 // When extension IDs are recorded a NOTIFICATION_EXTENSION_LOCATION_BAR_UPDATED |
| 48 // is sent, and those extensions will be returned from GetCurrentActions until | 47 // is sent, and those extensions will be returned from GetCurrentActions until |
| 49 // the next page navigation. | 48 // the next page navigation. |
| 50 class ScriptBadgeController | 49 class ScriptBadgeController |
| 51 : public LocationBarController, | 50 : public LocationBarController, |
| 52 public ScriptExecutor::Observer, | 51 public ScriptExecutor::Observer, |
| 53 public content::WebContentsObserver, | 52 public content::WebContentsObserver, |
| 54 public content::NotificationObserver { | 53 public content::NotificationObserver { |
| 55 public: | 54 public: |
| 56 explicit ScriptBadgeController(TabContents* tab_contents, | 55 explicit ScriptBadgeController(content::WebContents* web_contents, |
| 57 ScriptExecutor* script_executor); | 56 ScriptExecutor* script_executor); |
| 58 virtual ~ScriptBadgeController(); | 57 virtual ~ScriptBadgeController(); |
| 59 | 58 |
| 60 // LocationBarController implementation. | 59 // LocationBarController implementation. |
| 61 virtual std::vector<ExtensionAction*> GetCurrentActions() const OVERRIDE; | 60 virtual std::vector<ExtensionAction*> GetCurrentActions() const OVERRIDE; |
| 62 virtual void GetAttentionFor(const std::string& extension_id) OVERRIDE; | 61 virtual void GetAttentionFor(const std::string& extension_id) OVERRIDE; |
| 63 virtual Action OnClicked(const std::string& extension_id, | 62 virtual Action OnClicked(const std::string& extension_id, |
| 64 int mouse_button) OVERRIDE; | 63 int mouse_button) OVERRIDE; |
| 65 virtual void NotifyChange() OVERRIDE; | 64 virtual void NotifyChange() OVERRIDE; |
| 66 | 65 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 | 102 |
| 104 // Called when an extension is running script on the current tab, | 103 // Called when an extension is running script on the current tab, |
| 105 // and tries to insert an extension into the relevant collections. | 104 // and tries to insert an extension into the relevant collections. |
| 106 // Returns true if any change was made. | 105 // Returns true if any change was made. |
| 107 bool MarkExtensionExecuting(const std::string& extension_id); | 106 bool MarkExtensionExecuting(const std::string& extension_id); |
| 108 | 107 |
| 109 // Tries to erase an extension from the relevant collections, and returns | 108 // Tries to erase an extension from the relevant collections, and returns |
| 110 // whether any change was made. | 109 // whether any change was made. |
| 111 bool EraseExtension(const Extension* extension); | 110 bool EraseExtension(const Extension* extension); |
| 112 | 111 |
| 113 // Our parent TabContents. | |
| 114 TabContents* tab_contents_; | |
| 115 | |
| 116 // The current extension actions in the order they appeared. These come from | 112 // The current extension actions in the order they appeared. These come from |
| 117 // calls to ExecuteScript or getAttention on the current frame. | 113 // calls to ExecuteScript or getAttention on the current frame. |
| 118 std::vector<ExtensionAction*> current_actions_; | 114 std::vector<ExtensionAction*> current_actions_; |
| 119 | 115 |
| 120 // The extensions that have actions in current_actions_. | 116 // The extensions that have actions in current_actions_. |
| 121 std::set<std::string> extensions_in_current_actions_; | 117 std::set<std::string> extensions_in_current_actions_; |
| 122 | 118 |
| 123 // Listen to extension unloaded notifications. | 119 // Listen to extension unloaded notifications. |
| 124 content::NotificationRegistrar registrar_; | 120 content::NotificationRegistrar registrar_; |
| 125 | 121 |
| 126 DISALLOW_COPY_AND_ASSIGN(ScriptBadgeController); | 122 DISALLOW_COPY_AND_ASSIGN(ScriptBadgeController); |
| 127 }; | 123 }; |
| 128 | 124 |
| 129 } // namespace extensions | 125 } // namespace extensions |
| 130 | 126 |
| 131 #endif // CHROME_BROWSER_EXTENSIONS_SCRIPT_BADGE_CONTROLLER_H_ | 127 #endif // CHROME_BROWSER_EXTENSIONS_SCRIPT_BADGE_CONTROLLER_H_ |
| OLD | NEW |