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

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
« no previous file with comments | « no previous file | extensions/renderer/resources/extension.css » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/renderer/dispatcher.cc
diff --git a/extensions/renderer/dispatcher.cc b/extensions/renderer/dispatcher.cc
index c9aaec457060e951d8c0bae5a1e0731fd5505fc5..8c2985d8ce9af861de1c3bea7a9a33795cf17708 100644
--- a/extensions/renderer/dispatcher.cc
+++ b/extensions/renderer/dispatcher.cc
@@ -325,20 +325,32 @@ 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.
+ // Note: use GetEffectiveDocumentURL not just frame->document()->url()
+ // so that this also injects the stylesheet on about:blank frames that
+ // are hosted in the extension process.
+ GURL effective_document_url = ScriptContext::GetEffectiveDocumentURL(
+ frame, frame->document().url(), true /* match_about_blank */);
+ const Extension* extension =
+ extensions_.GetExtensionOrAppByURL(effective_document_url);
+ if (!extension)
+ return;
+
+ if (extension->is_extension() || extension->is_platform_app()) {
+ int resource_id =
+ extension->is_platform_app() ? IDR_PLATFORM_APP_CSS : IDR_EXTENSION_CSS;
std::string stylesheet = ResourceBundle::GetSharedInstance()
- .GetRawDataResource(IDR_PLATFORM_APP_CSS)
+ .GetRawDataResource(resource_id)
.as_string();
ReplaceFirstSubstringAfterOffset(
&stylesheet, 0, "$FONTFAMILY", system_font_family_);
ReplaceFirstSubstringAfterOffset(
&stylesheet, 0, "$FONTSIZE", system_font_size_);
+
+ // WebKit doesn't let us define an additional user agent stylesheet, so
not at google - send to devlin 2014/07/21 18:48:19 s/WebKit/Blink/
ericzeng 2014/07/21 19:29:34 Done.
+ // we insert the default platform app or extension stylesheet into all
+ // documents that are loaded in each app or extension.
frame->document().insertStyleSheet(WebString::fromUTF8(stylesheet));
}
-
content_watcher_->DidCreateDocumentElement(frame);
}
« no previous file with comments | « no previous file | extensions/renderer/resources/extension.css » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698