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

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

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

Powered by Google App Engine
This is Rietveld 408576698