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

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: Revert silly changes 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..e7b8d183bc94ddb5465f9a6d0cd3c01e0e00c142 100644
--- a/extensions/renderer/dispatcher.cc
+++ b/extensions/renderer/dispatcher.cc
@@ -325,21 +325,35 @@ 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();
- ReplaceFirstSubstringAfterOffset(
- &stylesheet, 0, "$FONTFAMILY", system_font_family_);
- ReplaceFirstSubstringAfterOffset(
- &stylesheet, 0, "$FONTSIZE", system_font_size_);
- frame->document().insertStyleSheet(WebString::fromUTF8(stylesheet));
+ // 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) {
not at google - send to devlin 2014/07/21 16:44:23 given the whole rest of this method is inside this
ericzeng 2014/07/21 18:12:33 Done.
+ if (extension->is_extension() || extension->is_platform_app()) {
+ std::string stylesheet;
+ if (extension->is_platform_app())
+ // 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.
not at google - send to devlin 2014/07/21 16:44:23 this comment belongs before the "insertStyleSheet"
ericzeng 2014/07/21 18:12:33 Done.
+ stylesheet = ResourceBundle::GetSharedInstance()
+ .GetRawDataResource(IDR_PLATFORM_APP_CSS)
not at google - send to devlin 2014/07/21 16:44:23 it would be simpler to switch on the resource ID r
ericzeng 2014/07/21 18:12:33 What do you mean by switching on the resource ID?
not at google - send to devlin 2014/07/21 18:31:29 Ternary operator is fine here because the block is
ericzeng 2014/07/21 18:43:11 Got it, but I'll use extension->is_platform_app()
+ .as_string();
+ else if (extension->is_extension())
+ stylesheet = ResourceBundle::GetSharedInstance()
+ .GetRawDataResource(IDR_EXTENSION_CSS)
+ .as_string();
+ ReplaceFirstSubstringAfterOffset(
+ &stylesheet, 0, "$FONTFAMILY", system_font_family_);
+ ReplaceFirstSubstringAfterOffset(
+ &stylesheet, 0, "$FONTSIZE", system_font_size_);
+ frame->document().insertStyleSheet(WebString::fromUTF8(stylesheet));
+ }
+ content_watcher_->DidCreateDocumentElement(frame);
not at google - send to devlin 2014/07/21 16:44:23 (note: moving this inside the if-block is a change
}
-
- content_watcher_->DidCreateDocumentElement(frame);
}
void Dispatcher::DidMatchCSS(
« 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