Commit 1e89d82e authored by ericzeng@chromium.org's avatar ericzeng@chromium.org

Add default fonts for extensions.

This CL applies the default system font style to extension pages.
Extensions that specify their own fonts will still override these styles. 

BUG=141703, 395319

Review URL: https://codereview.chromium.org/400343002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@284597 0039d316-1c4b-4281-b951-d872f2087c98
parent e7349628
......@@ -325,20 +325,31 @@ 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 &&
(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_);
// Blink doesn't let us define an additional user agent stylesheet, so
// 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);
}
......
/*
* Copyright 2014 The Chromium Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*
* A style sheet for Chrome extensions.
*/
body {
font-family: $FONTFAMILY;
font-size: $FONTSIZE;
}
......@@ -40,6 +40,9 @@
<!-- Platform app support. -->
<include name="IDR_PLATFORM_APP_CSS" file="platform_app.css" type="BINDATA" />
<include name="IDR_PLATFORM_APP_JS" file="platform_app.js" type="BINDATA" />
<!-- Extension styles -->
<include name="IDR_EXTENSION_CSS" file="extension.css" type="BINDATA"/>
</includes>
</release>
</grit>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment