Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1030)

Side by Side Diff: chrome/browser/extensions/script_badge_controller.h

Issue 10695070: Implement scriptBadge.requestToAct. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 #pragma once 7 #pragma once
8 8
9 #include <map> 9 #include <map>
10 #include <set> 10 #include <set>
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 : public base::RefCountedThreadSafe<ScriptBadgeController>, 50 : public base::RefCountedThreadSafe<ScriptBadgeController>,
51 public LocationBarController, 51 public LocationBarController,
52 public ScriptExecutor, 52 public ScriptExecutor,
53 public content::WebContentsObserver, 53 public content::WebContentsObserver,
54 public content::NotificationObserver { 54 public content::NotificationObserver {
55 public: 55 public:
56 explicit ScriptBadgeController(TabContents* tab_contents); 56 explicit ScriptBadgeController(TabContents* tab_contents);
57 57
58 // LocationBarController implementation. 58 // LocationBarController implementation.
59 virtual std::vector<ExtensionAction*> GetCurrentActions() const OVERRIDE; 59 virtual std::vector<ExtensionAction*> GetCurrentActions() const OVERRIDE;
60 virtual void RequestScriptPermission(
61 const std::string& extension_id) OVERRIDE;
60 virtual Action OnClicked(const std::string& extension_id, 62 virtual Action OnClicked(const std::string& extension_id,
61 int mouse_button) OVERRIDE; 63 int mouse_button) OVERRIDE;
62 virtual void NotifyChange() OVERRIDE; 64 virtual void NotifyChange() OVERRIDE;
63 65
64 // ScriptExecutor implementation. 66 // ScriptExecutor implementation.
65 virtual void ExecuteScript(const std::string& extension_id, 67 virtual void ExecuteScript(const std::string& extension_id,
66 ScriptType script_type, 68 ScriptType script_type,
67 const std::string& code, 69 const std::string& code,
68 FrameScope frame_scope, 70 FrameScope frame_scope,
69 UserScript::RunLocation run_at, 71 UserScript::RunLocation run_at,
(...skipping 26 matching lines...) Expand all
96 98
97 // content::NotificationObserver implementation. 99 // content::NotificationObserver implementation.
98 virtual void Observe(int type, 100 virtual void Observe(int type,
99 const content::NotificationSource& source, 101 const content::NotificationSource& source,
100 const content::NotificationDetails& details) OVERRIDE; 102 const content::NotificationDetails& details) OVERRIDE;
101 103
102 // IPC::Message handlers. 104 // IPC::Message handlers.
103 void OnContentScriptsExecuting(const std::set<std::string>& extension_ids, 105 void OnContentScriptsExecuting(const std::set<std::string>& extension_ids,
104 int32 page_id); 106 int32 page_id);
105 107
106 // Tries to insert an extension into the relevant collections, and returns 108 // Adds the extension's icon to the list of script badges. Returns
107 // whether any change was made. 109 // the script badge ExtensionAction that was added, or NULL if
108 bool InsertExtension(const std::string& extension_id); 110 // extension_id isn't valid.
111 ExtensionAction* AddExtensionToCurrentActions(
112 const std::string& extension_id);
113
114 // Called when an extension is running script on the current tab,
115 // and tries to insert an extension into the relevant collections.
116 // Returns true if any change was made.
117 bool MarkExtensionExecuting(const std::string& extension_id);
109 118
110 // Tries to erase an extension from the relevant collections, and returns 119 // Tries to erase an extension from the relevant collections, and returns
111 // whether any change was made. 120 // whether any change was made.
112 bool EraseExtension(const Extension* extension); 121 bool EraseExtension(const Extension* extension);
113 122
114 // Delegate ScriptExecutorImpl for running ExecuteScript. 123 // Delegate ScriptExecutorImpl for running ExecuteScript.
115 ScriptExecutorImpl script_executor_; 124 ScriptExecutorImpl script_executor_;
116 125
117 // Our parent TabContents. 126 // Our parent TabContents.
118 TabContents* tab_contents_; 127 TabContents* tab_contents_;
119 128
120 // The current extension actions in the order they appeared. 129 // The current extension actions in the order they appeared. These come from
130 // calls to ExecuteScript or requestToAct on the current frame.
121 std::vector<ExtensionAction*> current_actions_; 131 std::vector<ExtensionAction*> current_actions_;
122 132
123 // The extensions that have called ExecuteScript on the current frame. 133 // The extensions that have actions in current_actions_.
124 std::set<std::string> extensions_executing_scripts_; 134 std::set<std::string> extensions_in_current_actions_;
125 135
126 // Listen to extension unloaded notifications. 136 // Listen to extension unloaded notifications.
127 content::NotificationRegistrar registrar_; 137 content::NotificationRegistrar registrar_;
128 138
129 DISALLOW_COPY_AND_ASSIGN(ScriptBadgeController); 139 DISALLOW_COPY_AND_ASSIGN(ScriptBadgeController);
130 }; 140 };
131 141
132 } // namespace extensions 142 } // namespace extensions
133 143
134 #endif // CHROME_BROWSER_EXTENSIONS_SCRIPT_BADGE_CONTROLLER_H_ 144 #endif // CHROME_BROWSER_EXTENSIONS_SCRIPT_BADGE_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698