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

Unified Diff: extensions/renderer/dispatcher.cc

Issue 537773003: Add a user agent stylesheet for extension options pages (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use grit to handle background-image data URIs Created 6 years, 3 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 db2f0e8cf6345feb1dda1d7be8757c4b980b4ccf..04ee21d00d570aa94ea13c09aa8cfe510a031bdc 100644
--- a/extensions/renderer/dispatcher.cc
+++ b/extensions/renderer/dispatcher.cc
@@ -32,6 +32,7 @@
#include "extensions/common/manifest_constants.h"
#include "extensions/common/manifest_handlers/background_info.h"
#include "extensions/common/manifest_handlers/externally_connectable.h"
+#include "extensions/common/manifest_handlers/options_page_info.h"
#include "extensions/common/manifest_handlers/sandboxed_page_info.h"
#include "extensions/common/message_bundle.h"
#include "extensions/common/permissions/permission_set.h"
@@ -349,13 +350,14 @@ void Dispatcher::DidCreateDocumentElement(blink::WebFrame* frame) {
// 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;
+ int resource_id = extension->is_platform_app() ? IDR_PLATFORM_APP_CSS
+ : IDR_EXTENSION_FONTS_CSS;
std::string stylesheet = ResourceBundle::GetSharedInstance()
.GetRawDataResource(resource_id)
.as_string();
@@ -369,6 +371,17 @@ void Dispatcher::DidCreateDocumentElement(blink::WebFrame* frame) {
// documents that are loaded in each app or extension.
frame->document().insertStyleSheet(WebString::fromUTF8(stylesheet));
}
+
+ // If this is an extension options page, and the extension has opted into
+ // using Chrome styles, then insert the Chrome extension stylesheet.
+ if (extension && extension->is_extension() &&
+ OptionsPageInfo::ShouldUseChromeStyle(extension) &&
+ effective_document_url == OptionsPageInfo::GetOptionsPage(extension)) {
+ frame->document().insertStyleSheet(
+ WebString::fromUTF8(ResourceBundle::GetSharedInstance()
+ .GetRawDataResource(IDR_EXTENSION_CSS)
+ .as_string()));
+ }
content_watcher_->DidCreateDocumentElement(frame);
}

Powered by Google App Engine
This is Rietveld 408576698