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

Unified Diff: chrome/renderer/extensions/dispatcher.cc

Issue 22709003: Enable webview and browser-plugin as custom elements in Chrome Apps (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updated Created 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/renderer/extensions/dispatcher.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/extensions/dispatcher.cc
diff --git a/chrome/renderer/extensions/dispatcher.cc b/chrome/renderer/extensions/dispatcher.cc
index 3b2c3efdd37651f99f33890651c8850ee755da35..975a97f7edc25ca4bc9f37f0b5389cf260b94129 100644
--- a/chrome/renderer/extensions/dispatcher.cc
+++ b/chrome/renderer/extensions/dispatcher.cc
@@ -83,9 +83,11 @@
#include "grit/renderer_resources.h"
#include "third_party/WebKit/public/platform/WebString.h"
#include "third_party/WebKit/public/platform/WebURLRequest.h"
+#include "third_party/WebKit/public/web/WebCustomElement.h"
#include "third_party/WebKit/public/web/WebDataSource.h"
#include "third_party/WebKit/public/web/WebDocument.h"
#include "third_party/WebKit/public/web/WebFrame.h"
+#include "third_party/WebKit/public/web/WebRuntimeFeatures.h"
#include "third_party/WebKit/public/web/WebScopedUserGesture.h"
#include "third_party/WebKit/public/web/WebSecurityPolicy.h"
#include "third_party/WebKit/public/web/WebView.h"
@@ -472,6 +474,9 @@ void Dispatcher::WebKitInitialized() {
InitOriginPermissions(extension);
}
+ if (IsWithinPlatformApp())
+ EnableCustomElementWhiteList();
+
is_webkit_initialized_ = true;
}
@@ -1076,7 +1081,7 @@ void Dispatcher::DidCreateScriptContext(
AddOrRemoveBindingsForContext(context);
- bool is_within_platform_app = IsWithinPlatformApp(frame);
+ bool is_within_platform_app = IsWithinPlatformApp();
// Inject custom JS into the platform app context.
if (is_within_platform_app) {
module_system->Require("platformApp");
@@ -1149,11 +1154,14 @@ std::string Dispatcher::GetExtensionID(const WebFrame* frame, int world_id) {
return extensions_.GetExtensionOrAppIDByURL(frame_url);
}
-bool Dispatcher::IsWithinPlatformApp(const WebFrame* frame) {
- GURL url(UserScriptSlave::GetDataSourceURLForFrame(frame->top()));
- const Extension* extension = extensions_.GetExtensionOrAppByURL(url);
-
- return extension && extension->is_platform_app();
+bool Dispatcher::IsWithinPlatformApp() {
+ for (std::set<std::string>::iterator iter = active_extension_ids_.begin();
+ iter != active_extension_ids_.end(); ++iter) {
+ const Extension* extension = extensions_.GetByID(*iter);
+ if (extension && extension->is_platform_app())
+ return true;
+ }
+ return false;
}
void Dispatcher::WillReleaseScriptContext(
@@ -1171,7 +1179,7 @@ void Dispatcher::WillReleaseScriptContext(
}
void Dispatcher::DidCreateDocumentElement(WebKit::WebFrame* frame) {
- if (IsWithinPlatformApp(frame)) {
+ if (IsWithinPlatformApp()) {
// WebKit doesn't let us define an additional user agent stylesheet, so we
// insert the default platform app stylesheet into all documents that are
// loaded in each app.
@@ -1222,6 +1230,9 @@ void Dispatcher::OnActivateExtension(const std::string& extension_id) {
extension_id,
extension->url(),
string16());
+
+ if (IsWithinPlatformApp())
+ EnableCustomElementWhiteList();
}
}
@@ -1269,6 +1280,14 @@ void Dispatcher::AddOrRemoveOriginPermissions(
}
}
+void Dispatcher::EnableCustomElementWhiteList() {
+ WebKit::WebRuntimeFeatures::enableCustomElements(true);
+ WebKit::WebCustomElement::allowTagName("webview");
+ // TODO(fsamuel): Add <adview> to the whitelist once it has been converted
+ // into a custom element.
+ WebKit::WebCustomElement::allowTagName("browser-plugin");
+}
+
void Dispatcher::AddOrRemoveBindings(const std::string& extension_id) {
v8_context_set().ForEach(
extension_id,
« no previous file with comments | « chrome/renderer/extensions/dispatcher.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698