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

Unified Diff: chrome/browser/extensions/extension_host.cc

Issue 208020: Change the view mode when switching between moles and toolstrips, and (Closed)
Patch Set: build system workarounds Created 11 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
« no previous file with comments | « chrome/browser/extensions/extension_host.h ('k') | chrome/browser/extensions/extension_shelf_model.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/extension_host.cc
diff --git a/chrome/browser/extensions/extension_host.cc b/chrome/browser/extensions/extension_host.cc
index f8503f33ce1aa453ae151406d963b04a78e884d9..b1a304fbf8e33a5cba965850d55a10a67347a4d1 100644
--- a/chrome/browser/extensions/extension_host.cc
+++ b/chrome/browser/extensions/extension_host.cc
@@ -180,34 +180,14 @@ void ExtensionHost::DidNavigate(RenderViewHost* render_view_host,
new ExtensionFunctionDispatcher(render_view_host_, this, url_));
}
-void ExtensionHost::InsertCssIfToolstrip() {
+void ExtensionHost::InsertThemeCSS() {
+ DCHECK(!is_background_page());
- // TODO(erikkay): Make these ifdefs go away -- http://crbug.com/21939
-#if defined(TOOLKIT_VIEWS)
- ExtensionView* view = view_.get();
- if (!view)
- return;
- if (!view->is_toolstrip()) {
- // No CSS injecting currently, but call SetDidInsertCSS to tell the view
- // that it's OK to display.
- view->SetDidInsertCSS(true);
- return;
- }
-#elif defined(OS_LINUX) || defined(OS_MACOSX)
-#if defined(OS_LINUX)
- ExtensionViewGtk* view = view_.get();
-#else
- ExtensionViewMac* view = view_.get();
-#endif
- if (!view || !view->is_toolstrip())
- return;
-#endif
-
- static const base::StringPiece toolstrip_css(
+ static const base::StringPiece toolstrip_theme_css(
ResourceBundle::GetSharedInstance().GetRawDataResource(
- IDR_EXTENSIONS_TOOLSTRIP_CSS));
+ IDR_EXTENSIONS_TOOLSTRIP_THEME_CSS));
- std::string css = toolstrip_css.as_string();
+ std::string css = toolstrip_theme_css.as_string();
ThemeProvider* theme_provider =
render_view_host()->process()->profile()->GetThemeProvider();
@@ -225,16 +205,12 @@ void ExtensionHost::InsertCssIfToolstrip() {
pos = css.find(kToolstripTextColorSubstitution);
}
- // TODO(erikkay) this injection should really happen in the renderer.
- // When the Jerry's view type change lands, investigate moving this there.
-
// As a toolstrip, inject our toolstrip CSS to make it easier for toolstrips
// to blend in with the chrome UI.
- render_view_host()->InsertCSSInWebFrame(L"", css, "ToolstripDefaultCss");
+ render_view_host()->InsertCSSInWebFrame(L"", css, "ToolstripThemeCSS");
}
void ExtensionHost::DidStopLoading(RenderViewHost* render_view_host) {
- InsertCssIfToolstrip();
if (!did_stop_loading_) {
NotificationService::current()->Notify(
NotificationType::EXTENSION_HOST_DID_STOP_LOADING,
@@ -242,12 +218,21 @@ void ExtensionHost::DidStopLoading(RenderViewHost* render_view_host) {
Details<ExtensionHost>(this));
did_stop_loading_ = true;
}
+ if (extension_host_type_ == ViewType::EXTENSION_TOOLSTRIP ||
+ extension_host_type_ == ViewType::EXTENSION_MOLE) {
+#if defined(TOOLKIT_VIEWS)
+ if (view_.get())
+ view_->DidStopLoading();
+#endif
+ }
}
void ExtensionHost::DocumentAvailableInMainFrame(RenderViewHost* rvh) {
document_element_available_ = true;
if (is_background_page())
extension_->SetBackgroundPageReady();
+ else
+ InsertThemeCSS();
}
void ExtensionHost::RunJavaScriptMessage(const std::wstring& message,
@@ -278,13 +263,6 @@ void ExtensionHost::ProcessDOMUIMessage(const std::string& message,
}
}
-void ExtensionHost::DidInsertCSS() {
-#if defined(TOOLKIT_VIEWS)
- if (view_.get())
- view_->SetDidInsertCSS(true);
-#endif
-}
-
RenderViewHostDelegate::View* ExtensionHost::GetViewDelegate() {
return this;
}
@@ -391,6 +369,13 @@ Browser* ExtensionHost::GetBrowser() {
return browser;
}
+void ExtensionHost::SetRenderViewType(ViewType::Type type) {
+ DCHECK(type == ViewType::EXTENSION_MOLE ||
+ type == ViewType::EXTENSION_TOOLSTRIP);
+ extension_host_type_ = type;
+ render_view_host()->ViewTypeChanged(extension_host_type_);
+}
+
ViewType::Type ExtensionHost::GetRenderViewType() const {
return extension_host_type_;
}
« no previous file with comments | « chrome/browser/extensions/extension_host.h ('k') | chrome/browser/extensions/extension_shelf_model.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698