summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/extensions')
-rw-r--r--chrome/browser/extensions/extension_host.cc55
-rw-r--r--chrome/browser/extensions/extension_host.h8
-rw-r--r--chrome/browser/extensions/extension_shelf_model.cc2
3 files changed, 38 insertions, 27 deletions
diff --git a/chrome/browser/extensions/extension_host.cc b/chrome/browser/extensions/extension_host.cc
index a23c886..f8503f3 100644
--- a/chrome/browser/extensions/extension_host.cc
+++ b/chrome/browser/extensions/extension_host.cc
@@ -180,12 +180,32 @@ void ExtensionHost::DidNavigate(RenderViewHost* render_view_host,
new ExtensionFunctionDispatcher(render_view_host_, this, url_));
}
-void ExtensionHost::InsertThemeCSS() {
- DCHECK(!is_background_page());
+void ExtensionHost::InsertCssIfToolstrip() {
+
+ // 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(
ResourceBundle::GetSharedInstance().GetRawDataResource(
- IDR_EXTENSIONS_TOOLSTRIP_THEME_CSS));
+ IDR_EXTENSIONS_TOOLSTRIP_CSS));
std::string css = toolstrip_css.as_string();
ThemeProvider* theme_provider =
@@ -205,12 +225,16 @@ void ExtensionHost::InsertThemeCSS() {
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, "ToolstripThemeCSS");
+ render_view_host()->InsertCSSInWebFrame(L"", css, "ToolstripDefaultCss");
}
void ExtensionHost::DidStopLoading(RenderViewHost* render_view_host) {
+ InsertCssIfToolstrip();
if (!did_stop_loading_) {
NotificationService::current()->Notify(
NotificationType::EXTENSION_HOST_DID_STOP_LOADING,
@@ -218,21 +242,12 @@ 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,
@@ -263,6 +278,13 @@ 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;
}
@@ -369,13 +391,6 @@ 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_;
}
diff --git a/chrome/browser/extensions/extension_host.h b/chrome/browser/extensions/extension_host.h
index 3b3d64e..49a75f1 100644
--- a/chrome/browser/extensions/extension_host.h
+++ b/chrome/browser/extensions/extension_host.h
@@ -69,9 +69,6 @@ class ExtensionHost : public RenderViewHostDelegate,
return document_element_available_;
}
- // Sets the the ViewType of this host (e.g. mole, toolstrip).
- void SetRenderViewType(ViewType::Type type);
-
// Returns true if the render view is initialized and didn't crash.
bool IsRenderViewLive() const;
@@ -83,8 +80,8 @@ class ExtensionHost : public RenderViewHostDelegate,
// Sets |url_| and navigates |render_view_host_|.
void NavigateToURL(const GURL& url);
- // Insert the theme CSS for a toolstrip/mole.
- void InsertThemeCSS();
+ // Insert the CSS for a toolstrip.
+ void InsertCssIfToolstrip();
// RenderViewHostDelegate implementation.
virtual RenderViewHostDelegate::View* GetViewDelegate();
@@ -109,6 +106,7 @@ class ExtensionHost : public RenderViewHostDelegate,
const int flags,
IPC::Message* reply_msg,
bool* did_suppress_message);
+ virtual void DidInsertCSS();
// RenderViewHostDelegate::View
virtual void CreateNewWindow(int route_id,
diff --git a/chrome/browser/extensions/extension_shelf_model.cc b/chrome/browser/extensions/extension_shelf_model.cc
index 10b56b2..5a6db01 100644
--- a/chrome/browser/extensions/extension_shelf_model.cc
+++ b/chrome/browser/extensions/extension_shelf_model.cc
@@ -138,7 +138,6 @@ void ExtensionShelfModel::ExpandToolstrip(iterator toolstrip,
ToolstripEventRouter::OnToolstripExpanded(browser_->profile(),
routing_id,
url, height);
- toolstrip->host->SetRenderViewType(ViewType::EXTENSION_MOLE);
}
void ExtensionShelfModel::CollapseToolstrip(iterator toolstrip,
@@ -153,7 +152,6 @@ void ExtensionShelfModel::CollapseToolstrip(iterator toolstrip,
ToolstripEventRouter::OnToolstripCollapsed(browser_->profile(),
routing_id,
url);
- toolstrip->host->SetRenderViewType(ViewType::EXTENSION_TOOLSTRIP);
}
void ExtensionShelfModel::Observe(NotificationType type,