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

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

Issue 296483011: Run any pending injections in ActiveScriptController if permission is granted (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Ben's Created 6 years, 7 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
« no previous file with comments | « no previous file | chrome/browser/extensions/active_script_controller.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_ACTIVE_SCRIPT_CONTROLLER_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_ACTIVE_SCRIPT_CONTROLLER_H_
6 #define CHROME_BROWSER_EXTENSIONS_ACTIVE_SCRIPT_CONTROLLER_H_ 6 #define CHROME_BROWSER_EXTENSIONS_ACTIVE_SCRIPT_CONTROLLER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 // via RequestScriptInjection(). 49 // via RequestScriptInjection().
50 bool RequiresUserConsentForScriptInjection(const Extension* extension); 50 bool RequiresUserConsentForScriptInjection(const Extension* extension);
51 51
52 // Register a request for a script injection, to be executed by running 52 // Register a request for a script injection, to be executed by running
53 // |callback|. The only assumption that can be made about when (or if) 53 // |callback|. The only assumption that can be made about when (or if)
54 // |callback| is run is that, if it is run, it will run on the current page. 54 // |callback| is run is that, if it is run, it will run on the current page.
55 void RequestScriptInjection(const Extension* extension, 55 void RequestScriptInjection(const Extension* extension,
56 int page_id, 56 int page_id,
57 const base::Closure& callback); 57 const base::Closure& callback);
58 58
59 // Notifies the ActiveScriptController that an extension has been granted
60 // active tab permissions. This will run any pending injections for that
61 // extension.
62 void OnActiveTabPermissionGranted(const Extension* extension);
63
59 // Notifies the ActiveScriptController of detected ad injection. 64 // Notifies the ActiveScriptController of detected ad injection.
60 void OnAdInjectionDetected(const std::vector<std::string> ad_injectors); 65 void OnAdInjectionDetected(const std::vector<std::string> ad_injectors);
61 66
62 // LocationBarControllerProvider implementation. 67 // LocationBarControllerProvider implementation.
63 virtual ExtensionAction* GetActionForExtension( 68 virtual ExtensionAction* GetActionForExtension(
64 const Extension* extension) OVERRIDE; 69 const Extension* extension) OVERRIDE;
65 virtual LocationBarController::Action OnClicked( 70 virtual LocationBarController::Action OnClicked(
66 const Extension* extension) OVERRIDE; 71 const Extension* extension) OVERRIDE;
67 virtual void OnNavigated() OVERRIDE; 72 virtual void OnNavigated() OVERRIDE;
68 73
69 private: 74 private:
70 // A single pending request. This could be a pair, but we'd have way too many 75 // A single pending request. This could be a pair, but we'd have way too many
71 // stl typedefs, and "request.closure" is nicer than "request.first". 76 // stl typedefs, and "request.closure" is nicer than "request.first".
72 struct PendingRequest { 77 struct PendingRequest {
73 PendingRequest(); // For STL. 78 PendingRequest(); // For STL.
74 PendingRequest(const base::Closure& closure, int page_id); 79 PendingRequest(const base::Closure& closure, int page_id);
75 ~PendingRequest(); 80 ~PendingRequest();
76 81
77 base::Closure closure; 82 base::Closure closure;
78 int page_id; 83 int page_id;
79 }; 84 };
80 typedef std::vector<PendingRequest> PendingRequestList; 85 typedef std::vector<PendingRequest> PendingRequestList;
81 typedef std::map<std::string, PendingRequestList> PendingRequestMap; 86 typedef std::map<std::string, PendingRequestList> PendingRequestMap;
82 87
88 // Runs any pending injections for the corresponding extension.
89 void RunPendingForExtension(const Extension* extension);
90
83 // Handles the NotifyExtensionScriptExecution message. 91 // Handles the NotifyExtensionScriptExecution message.
84 void OnNotifyExtensionScriptExecution(const std::string& extension_id, 92 void OnNotifyExtensionScriptExecution(const std::string& extension_id,
85 int page_id); 93 int page_id);
86 94
87 // content::WebContentsObserver implementation. 95 // content::WebContentsObserver implementation.
88 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; 96 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
89 97
90 // Log metrics. 98 // Log metrics.
91 void LogUMA() const; 99 void LogUMA() const;
92 100
(...skipping 16 matching lines...) Expand all
109 // that get generated for extensions that haven't declared anything. 117 // that get generated for extensions that haven't declared anything.
110 typedef std::map<std::string, linked_ptr<ExtensionAction> > ActiveScriptMap; 118 typedef std::map<std::string, linked_ptr<ExtensionAction> > ActiveScriptMap;
111 ActiveScriptMap active_script_actions_; 119 ActiveScriptMap active_script_actions_;
112 120
113 DISALLOW_COPY_AND_ASSIGN(ActiveScriptController); 121 DISALLOW_COPY_AND_ASSIGN(ActiveScriptController);
114 }; 122 };
115 123
116 } // namespace extensions 124 } // namespace extensions
117 125
118 #endif // CHROME_BROWSER_EXTENSIONS_ACTIVE_SCRIPT_CONTROLLER_H_ 126 #endif // CHROME_BROWSER_EXTENSIONS_ACTIVE_SCRIPT_CONTROLLER_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/active_script_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698