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); |
} |