Roll src/third_party/WebKit d9c6159:8139f33 (svn 201974:201975)
[chromium-blink-merge.git] / extensions / browser / declarative_user_script_master.cc
blob68fc0c6534319cc358c0a4709e464f6dae1c5f36
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
3 // found in the LICENSE file.
5 #include "extensions/browser/declarative_user_script_master.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"
13 namespace extensions {
15 DeclarativeUserScriptMaster::DeclarativeUserScriptMaster(
16 content::BrowserContext* browser_context,
17 const HostID& host_id)
18 : host_id_(host_id) {
19 switch (host_id_.type()) {
20 case HostID::EXTENSIONS:
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;
31 DeclarativeUserScriptMaster::~DeclarativeUserScriptMaster() {
34 void DeclarativeUserScriptMaster::AddScript(const UserScript& script) {
35 std::set<UserScript> set;
36 set.insert(script);
37 loader_->AddScripts(set);
40 void DeclarativeUserScriptMaster::AddScripts(
41 const std::set<UserScript>& scripts,
42 int render_process_id,
43 int render_view_id) {
44 loader_->AddScripts(scripts, render_process_id, render_view_id);
47 void DeclarativeUserScriptMaster::RemoveScript(const UserScript& script) {
48 std::set<UserScript> set;
49 set.insert(script);
50 loader_->RemoveScripts(set);
53 void DeclarativeUserScriptMaster::RemoveScripts(
54 const std::set<UserScript>& scripts) {
55 loader_->RemoveScripts(scripts);
58 void DeclarativeUserScriptMaster::ClearScripts() {
59 loader_->ClearScripts();
62 } // namespace extensions