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

Side by Side Diff: extensions/browser/declarative_user_script_master.cc

Issue 1056533002: Implement <webview>.addContentScript/removeContentScript API [2] (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@webview_addremove_contentscripts_2
Patch Set: nits. Created 5 years, 8 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
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 #include "extensions/browser/declarative_user_script_master.h" 5 #include "extensions/browser/declarative_user_script_master.h"
6 6
7 #include <set>
8
9 #include "content/public/browser/browser_context.h" 7 #include "content/public/browser/browser_context.h"
8 #include "extensions/browser/extension_user_script_loader.h"
9 #include "extensions/browser/user_script_loader.h"
10 #include "extensions/browser/web_ui_user_script_loader.h"
11 #include "extensions/common/user_script.h"
10 12
11 namespace extensions { 13 namespace extensions {
12 14
13 DeclarativeUserScriptMaster::DeclarativeUserScriptMaster( 15 DeclarativeUserScriptMaster::DeclarativeUserScriptMaster(
14 content::BrowserContext* browser_context, 16 content::BrowserContext* browser_context,
15 const HostID& host_id) 17 const HostID& host_id)
16 : host_id_(host_id), 18 : host_id_(host_id) {
17 loader_(browser_context, 19 switch (host_id_.type()) {
18 host_id, 20 case HostID::EXTENSIONS:
19 false /* listen_for_extension_system_loaded */) { 21 loader_.reset(new ExtensionUserScriptLoader(
22 browser_context, host_id,
23 false /* listen_for_extension_system_loaded */));
24 break;
25 case HostID::WEBUI:
26 loader_.reset(new WebUIUserScriptLoader(browser_context, host_id));
27 break;
28 }
20 } 29 }
21 30
22 DeclarativeUserScriptMaster::~DeclarativeUserScriptMaster() { 31 DeclarativeUserScriptMaster::~DeclarativeUserScriptMaster() {
23 } 32 }
24 33
25 void DeclarativeUserScriptMaster::AddScript(const UserScript& script) { 34 void DeclarativeUserScriptMaster::AddScript(const UserScript& script) {
26 std::set<UserScript> set; 35 std::set<UserScript> set;
27 set.insert(script); 36 set.insert(script);
28 loader_.AddScripts(set); 37 loader_->AddScripts(set);
29 } 38 }
30 39
31 void DeclarativeUserScriptMaster::AddScripts( 40 void DeclarativeUserScriptMaster::AddScripts(
32 const std::set<UserScript>& scripts) { 41 const std::set<UserScript>& scripts,
33 loader_.AddScripts(scripts); 42 int render_process_id,
43 int render_view_id) {
44 loader_->AddScripts(scripts, render_process_id, render_view_id);
34 } 45 }
35 46
36 void DeclarativeUserScriptMaster::RemoveScript(const UserScript& script) { 47 void DeclarativeUserScriptMaster::RemoveScript(const UserScript& script) {
37 std::set<UserScript> set; 48 std::set<UserScript> set;
38 set.insert(script); 49 set.insert(script);
39 loader_.RemoveScripts(set); 50 loader_->RemoveScripts(set);
40 } 51 }
41 52
42 void DeclarativeUserScriptMaster::RemoveScripts( 53 void DeclarativeUserScriptMaster::RemoveScripts(
43 const std::set<UserScript>& scripts) { 54 const std::set<UserScript>& scripts) {
44 loader_.RemoveScripts(scripts); 55 loader_->RemoveScripts(scripts);
45 } 56 }
46 57
47 void DeclarativeUserScriptMaster::ClearScripts() { 58 void DeclarativeUserScriptMaster::ClearScripts() {
48 loader_.ClearScripts(); 59 loader_->ClearScripts();
49 } 60 }
50 61
51 } // namespace extensions 62 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/browser/declarative_user_script_master.h ('k') | extensions/browser/extension_user_script_loader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698