summaryrefslogtreecommitdiffstats
path: root/extensions/browser/declarative_user_script_master.cc
diff options
context:
space:
mode:
authorhanxi <hanxi@chromium.org>2015-04-24 12:21:40 -0700
committerCommit bot <commit-bot@chromium.org>2015-04-24 19:21:56 +0000
commitfeb6a64f153422f71952ec3a7cd4fc3c1a90e272 (patch)
treec76f11036f15c16c49895f37991828799982449f /extensions/browser/declarative_user_script_master.cc
parent79a9a66e3152beef0545632aa30315456f2ebe74 (diff)
downloadchromium_src-feb6a64f153422f71952ec3a7cd4fc3c1a90e272.zip
chromium_src-feb6a64f153422f71952ec3a7cd4fc3c1a90e272.tar.gz
chromium_src-feb6a64f153422f71952ec3a7cd4fc3c1a90e272.tar.bz2
Implement <webview>.addContentScript/removeContentScript API [2]
This patch includes the changes that enables <webview>.addContentScript/removeContentScript API work on WebUI. -- Introduce WebUIURLFetcherGroup to manage a set of WebUIURLFetcher and response after all fetches are done. -- Move WebUIURLFetcher from web_view_internal_api.cc to a separate file. -- A refactoring is done in UserScriptLoader and ExtensionUserScriptLoader. Since webUI has different ways to load user script as extension does, so I revert some old refactoring in ExtensionUserScriptLoader and move all the loading related code from UserScriptLoader to ExtensionUserScriptLoader. This is the second patch in a series of patches: 1) Implement <webview>.addContentScript/removeContentScript API [1] (https://codereview.chromium.org/959413003) 2) Implement <webview>.addContentScript/removeContentScript API [2] (https://codereview.chromium.org/1056533002) 3) Implement <webview>.addContentScript/removeContentScript API [3] (https://codereview.chromium.org/1058113002) BUG=461052 Review URL: https://codereview.chromium.org/1056533002 Cr-Commit-Position: refs/heads/master@{#326854}
Diffstat (limited to 'extensions/browser/declarative_user_script_master.cc')
-rw-r--r--extensions/browser/declarative_user_script_master.cc35
1 files changed, 23 insertions, 12 deletions
diff --git a/extensions/browser/declarative_user_script_master.cc b/extensions/browser/declarative_user_script_master.cc
index 130e9ba..68fc0c6 100644
--- a/extensions/browser/declarative_user_script_master.cc
+++ b/extensions/browser/declarative_user_script_master.cc
@@ -4,19 +4,28 @@
#include "extensions/browser/declarative_user_script_master.h"
-#include <set>
-
#include "content/public/browser/browser_context.h"
+#include "extensions/browser/extension_user_script_loader.h"
+#include "extensions/browser/user_script_loader.h"
+#include "extensions/browser/web_ui_user_script_loader.h"
+#include "extensions/common/user_script.h"
namespace extensions {
DeclarativeUserScriptMaster::DeclarativeUserScriptMaster(
content::BrowserContext* browser_context,
const HostID& host_id)
- : host_id_(host_id),
- loader_(browser_context,
- host_id,
- false /* listen_for_extension_system_loaded */) {
+ : host_id_(host_id) {
+ switch (host_id_.type()) {
+ case HostID::EXTENSIONS:
+ loader_.reset(new ExtensionUserScriptLoader(
+ browser_context, host_id,
+ false /* listen_for_extension_system_loaded */));
+ break;
+ case HostID::WEBUI:
+ loader_.reset(new WebUIUserScriptLoader(browser_context, host_id));
+ break;
+ }
}
DeclarativeUserScriptMaster::~DeclarativeUserScriptMaster() {
@@ -25,27 +34,29 @@ DeclarativeUserScriptMaster::~DeclarativeUserScriptMaster() {
void DeclarativeUserScriptMaster::AddScript(const UserScript& script) {
std::set<UserScript> set;
set.insert(script);
- loader_.AddScripts(set);
+ loader_->AddScripts(set);
}
void DeclarativeUserScriptMaster::AddScripts(
- const std::set<UserScript>& scripts) {
- loader_.AddScripts(scripts);
+ const std::set<UserScript>& scripts,
+ int render_process_id,
+ int render_view_id) {
+ loader_->AddScripts(scripts, render_process_id, render_view_id);
}
void DeclarativeUserScriptMaster::RemoveScript(const UserScript& script) {
std::set<UserScript> set;
set.insert(script);
- loader_.RemoveScripts(set);
+ loader_->RemoveScripts(set);
}
void DeclarativeUserScriptMaster::RemoveScripts(
const std::set<UserScript>& scripts) {
- loader_.RemoveScripts(scripts);
+ loader_->RemoveScripts(scripts);
}
void DeclarativeUserScriptMaster::ClearScripts() {
- loader_.ClearScripts();
+ loader_->ClearScripts();
}
} // namespace extensions