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

Unified Diff: extensions/renderer/dispatcher.cc

Issue 400343002: Add default fonts for extensions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 5 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
Index: extensions/renderer/dispatcher.cc
diff --git a/extensions/renderer/dispatcher.cc b/extensions/renderer/dispatcher.cc
index c9aaec457060e951d8c0bae5a1e0731fd5505fc5..b48efd53dbb3ddc6af108a5d7f9188348c7d4f9c 100644
--- a/extensions/renderer/dispatcher.cc
+++ b/extensions/renderer/dispatcher.cc
@@ -325,20 +325,25 @@ void Dispatcher::WillReleaseScriptContext(
}
void Dispatcher::DidCreateDocumentElement(blink::WebFrame* 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.
- std::string stylesheet = ResourceBundle::GetSharedInstance()
- .GetRawDataResource(IDR_PLATFORM_APP_CSS)
- .as_string();
+ if (IsWithinPlatformApp() || IsWithinExtension()) {
not at google - send to devlin 2014/07/19 00:08:10 I don't think (looking at IsWithinExtension) this
not at google - send to devlin 2014/07/19 00:19:24 The URL shouldn't come from frame->document()->url
ericzeng 2014/07/19 01:48:59 Done.
+ std::string stylesheet;
+ 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.
+ stylesheet = ResourceBundle::GetSharedInstance()
+ .GetRawDataResource(IDR_PLATFORM_APP_CSS)
+ .as_string();
+ else if (IsWithinExtension())
+ stylesheet = ResourceBundle::GetSharedInstance()
+ .GetRawDataResource(IDR_EXTENSION_CSS)
+ .as_string();
not at google - send to devlin 2014/07/19 00:08:10 each of these has multi-line bodies; use {}. thou
ericzeng 2014/07/19 01:48:59 Is there a case where the renderer could host some
not at google - send to devlin 2014/07/19 01:54:16 oh, right. yes :) good point.
ReplaceFirstSubstringAfterOffset(
&stylesheet, 0, "$FONTFAMILY", system_font_family_);
ReplaceFirstSubstringAfterOffset(
&stylesheet, 0, "$FONTSIZE", system_font_size_);
frame->document().insertStyleSheet(WebString::fromUTF8(stylesheet));
}
-
content_watcher_->DidCreateDocumentElement(frame);
}
@@ -1068,6 +1073,17 @@ bool Dispatcher::IsWithinPlatformApp() {
return false;
}
+bool Dispatcher::IsWithinExtension() {
+ 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_extension())
+ return true;
+ }
+ return false;
+}
+
// TODO(kalman): This is checking for the wrong thing, it should be checking if
// the frame's security origin is unique. The extension sandbox directive is
// checked for in extensions/common/manifest_handlers/csp_info.cc.

Powered by Google App Engine
This is Rietveld 408576698