summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/browser_resources.grd2
-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
-rw-r--r--chrome/browser/renderer_host/render_view_host.cc4
-rw-r--r--chrome/browser/renderer_host/render_view_host.h3
-rw-r--r--chrome/browser/resources/extensions_toolstrip.css95
-rw-r--r--chrome/browser/resources/extensions_toolstrip_theme.css8
-rw-r--r--chrome/browser/views/extensions/extension_shelf.cc2
-rw-r--r--chrome/browser/views/extensions/extension_view.cc8
-rw-r--r--chrome/browser/views/extensions/extension_view.h6
11 files changed, 142 insertions, 51 deletions
diff --git a/chrome/browser/browser_resources.grd b/chrome/browser/browser_resources.grd
index 7e07058..788d62d 100644
--- a/chrome/browser/browser_resources.grd
+++ b/chrome/browser/browser_resources.grd
@@ -41,7 +41,7 @@ without changes to the corresponding grd file. fb03 -->
<include name="IDR_LOCAL_STRINGS_JS" file="resources\local_strings.js" type="BINDATA" />
<include name="IDR_DOM_UI_CSS" file="resources\dom_ui.css" flattenhtml="true" type="BINDATA" />
<include name="IDR_EXTENSIONS_UI_HTML" file="resources\extensions_ui.html" flattenhtml="true" type="BINDATA" />
- <include name="IDR_EXTENSIONS_TOOLSTRIP_THEME_CSS" file="resources\extensions_toolstrip_theme.css" flattenhtml="true" type="BINDATA" />
+ <include name="IDR_EXTENSIONS_TOOLSTRIP_CSS" file="resources\extensions_toolstrip.css" flattenhtml="true" type="BINDATA" />
<include name="IDR_PRINT_TAB_HTML" file="resources\print_tab.html" flattenhtml="true" type="BINDATA" />
<include name="IDR_PRINT_TAB_CSS" file="resources\print_tab.css" type="BINDATA" />
<include name="IDR_PRINT_TAB_JS" file="resources\print_tab.js" type="BINDATA" />
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,
diff --git a/chrome/browser/renderer_host/render_view_host.cc b/chrome/browser/renderer_host/render_view_host.cc
index 41a30f2..63cc15e 100644
--- a/chrome/browser/renderer_host/render_view_host.cc
+++ b/chrome/browser/renderer_host/render_view_host.cc
@@ -1660,10 +1660,6 @@ void RenderViewHost::BlockExtensionRequest(int request_id) {
"Access to extension API denied.");
}
-void RenderViewHost::ViewTypeChanged(ViewType::Type type) {
- Send(new ViewMsg_NotifyRenderViewType(routing_id(), type));
-}
-
void RenderViewHost::OnExtensionPostMessage(
int port_id, const std::string& message) {
if (process()->profile()->GetExtensionMessageService()) {
diff --git a/chrome/browser/renderer_host/render_view_host.h b/chrome/browser/renderer_host/render_view_host.h
index cbf0f73..b7f2d86 100644
--- a/chrome/browser/renderer_host/render_view_host.h
+++ b/chrome/browser/renderer_host/render_view_host.h
@@ -436,9 +436,6 @@ class RenderViewHost : public RenderWidgetHost,
// permission.
void BlockExtensionRequest(int request_id);
- // Notify the renderer that its view type has changed.
- void ViewTypeChanged(ViewType::Type type);
-
void SignalModalDialogEvent();
void ResetModalDialogEvent();
diff --git a/chrome/browser/resources/extensions_toolstrip.css b/chrome/browser/resources/extensions_toolstrip.css
new file mode 100644
index 0000000..cb23825
--- /dev/null
+++ b/chrome/browser/resources/extensions_toolstrip.css
@@ -0,0 +1,95 @@
+/**
+ * Body styles. This makes the toolstrip layout fit in with the Windows
+ * bookmarkbar. Note that the background is provided separately, by
+ * RenderWidget.
+ */
+body {
+ display:-webkit-box;
+ -webkit-box-orient:horizontal;
+ -webkit-box-align:center;
+ white-space:nowrap;
+ overflow: hidden;
+ margin: 0;
+ padding:0;
+ font: menu;
+ color: $TEXT_COLOR$;
+ -webkit-user-select:none;
+ cursor:default;
+}
+
+/**
+ * This, combined with -webkit-box-align:center on body, makes content inside
+ * the body tag center itself vertically by default.
+ */
+body>* {
+ display:-webkit-box;
+}
+
+/**
+ * Set display property of <script> and <style> as none explicitly to avoid
+ * inheriting from <body>.
+ */
+body>script,
+body>style {
+ display:none;
+}
+
+/**
+ * Toolstrip Buttons. The following styles make
+ * <div class="toolstrip-button"><img><span>Woot</span></div> look like the
+ * bookmarkbar buttons on Windows.
+ *
+ * TODO(aa): We may have to come up with a way to modify these slightly on
+ * different platforms.
+ *
+ * TODO(aa): It would be nice if we could use actual <button> tags work here,
+ * which should work once https://bugs.webkit.org/show_bug.cgi?id=25406 is
+ * fixed.
+ */
+div.toolstrip-button {
+ -webkit-box-orient:horizontal;
+ -webkit-box-align:center;
+ border:6px solid transparent;
+ font:menu;
+ background:transparent;
+ color: $TEXT_COLOR$;
+ line-height:100%;
+ padding:0;
+}
+
+div.toolstrip-button>img {
+ display:-webkit-box;
+ width:16px;
+ height:16px;
+ /**
+ * We inset the image slightly vertically, so that the button can be shorter
+ * than would otherwise be possibe with our fat borders.
+ */
+ margin:-1px 5px -1px 0;
+}
+
+div.toolstrip-button>span {
+ display:-webkit-box;
+ margin-right:1px;
+ /**
+ * Hack: WebKit appears to measure text height slightly differently than we do
+ * in native code, making us not line up when centering, so we shift ourselves
+ * up one pixel to match.
+ */
+ margin-top:-1px;
+}
+
+/**
+ * TODO(aa): It would be nice if these border images could be stored in Chrome
+ * as, normal images even if those images are just translated into data URLs at
+ * runtime.
+ */
+div.toolstrip-button:hover {
+ border-width:6px;
+ -webkit-border-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAaCAYAAACHD21cAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAVRJREFUeNpi/P//PwMjIyMfAwODEhsbmworKxvD79+/GED0jx/fGf7+/csABT+A+B4Q3wLq+cME0sTMzOzW1dOncuX6bYZnL98wvH73CUy/+/iV4eOXH2B86+5DjoLCYi2gxgCwHiBDs7O7Vyg9I4uBh4eHARcAyTk6OTMICQkx7N61U5kJKCZqY2PLQCyAqv3ICCSCgE5jAvqPKI2/fv1iEBXiYwDZSLQmEACpBYYJWCNZgCyNoChi4uTkpJ+N9NdIdqhycHCSpxGUCcj3IygJkQpAWY6k5AbPmMB8yvT9+3f6BQ7YRrKTHMijZCVyUJyQGrLglAPSffvWTaI13bhxHWIj0LbLq1auIFoj1JKnoFLu44kTxzVAhY+goCCDmJg4TpuWL1vKkJOV8RTIvcsILZA5QAUy0O1aoDgC+RuWQkDg69cvIOoTEL8AFcpAPV8AAgwAn6qHYvNUlBEAAAAASUVORK5CYII=) 6 round round;
+}
+
+div.toolstrip-button:active {
+ border-width:6px;
+ -webkit-border-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAaCAYAAACHD21cAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAbhJREFUeNqcVDtPwmAU/R6tCUZsIw5AKODoYNREBNREiAb9t+qoRmDxBYOYOGGiVAexaGzDUJK2X70fFURjUtuztfeennMfvdh1XTTCer5AKKUEY8zgkULMvrw4/06YAObE3Hoep1KppWx2YVqSZQTkcbLjOJgxhnX9Az0+PLx3uy/tZqOBBB5MJpNLO7sVobK3/yZJEotEIj9UTNPEmvZK67Va9PTkeHllZfWW8EBKUaa2S6V+PB53fpM4+LtMJmuXyuW+klbEVusGDYmxuZggSTJDPuA5PDdfKHpE6AiSZX8iz+G5hBBMUEB8NQ4LEw//BoyIkY3NLRqExMdT3Nj0xhEUoIgIColQzQGrOJQi7DINa5WFrxH+DhaGR8I0aGgVZuKEVQwMKM8JvHJjST4TSgU3qCiBe+IMBibRdd3XNj8hlmXxSRBi27bb62msp2m+lg3DIIau2yDGSLNxzZ5UVa/Xq7P37bbIv/qXkqp2hOrZafT5+Qk1rq+887iWy6FEIrmYzmRmYrF5QRRF5i20VzuUQuE82mqnYx4dHtyN7+oI/L4KAGiYM1pmHgdn1tXlxQ8XnwIMABNlyWs2CMVlAAAAAElFTkSuQmCC) 6 round round;
+}
diff --git a/chrome/browser/resources/extensions_toolstrip_theme.css b/chrome/browser/resources/extensions_toolstrip_theme.css
deleted file mode 100644
index d4691fc..0000000
--- a/chrome/browser/resources/extensions_toolstrip_theme.css
+++ /dev/null
@@ -1,8 +0,0 @@
-/**
- * The following style rules affect toolstrips and moles and are affected by
- * theme changes.
- */
-
-body {
- color: $TEXT_COLOR$;
-}
diff --git a/chrome/browser/views/extensions/extension_shelf.cc b/chrome/browser/views/extensions/extension_shelf.cc
index 229d697..a3ac3bf 100644
--- a/chrome/browser/views/extensions/extension_shelf.cc
+++ b/chrome/browser/views/extensions/extension_shelf.cc
@@ -740,7 +740,7 @@ void ExtensionShelf::ThemeChanged() {
// Refresh the CSS to update toolstrip text colors from theme.
int count = model_->count();
for (int i = 0; i < count; ++i)
- ToolstripAtIndex(i)->view()->host()->InsertThemeCSS();
+ ToolstripAtIndex(i)->view()->host()->InsertCssIfToolstrip();
Layout();
}
diff --git a/chrome/browser/views/extensions/extension_view.cc b/chrome/browser/views/extensions/extension_view.cc
index 4302c93..7b39336 100644
--- a/chrome/browser/views/extensions/extension_view.cc
+++ b/chrome/browser/views/extensions/extension_view.cc
@@ -15,7 +15,7 @@
ExtensionView::ExtensionView(ExtensionHost* host, Browser* browser)
: host_(host), browser_(browser),
initialized_(false), pending_preferred_width_(0), container_(NULL),
- did_stop_loading_(false), is_clipped_(false), is_toolstrip_(true) {
+ did_insert_css_(false), is_clipped_(false), is_toolstrip_(true) {
host_->set_view(this);
}
@@ -34,8 +34,8 @@ RenderViewHost* ExtensionView::render_view_host() const {
return host_->render_view_host();
}
-void ExtensionView::DidStopLoading() {
- did_stop_loading_ = true;
+void ExtensionView::SetDidInsertCSS(bool did_insert) {
+ did_insert_css_ = did_insert;
ShowIfCompletelyLoaded();
}
@@ -100,7 +100,7 @@ void ExtensionView::ShowIfCompletelyLoaded() {
// given us a background and css has been inserted into page. These can happen
// in different orders.
if (!IsVisible() && host_->did_stop_loading() && render_view_host()->view() &&
- !is_clipped_ && did_stop_loading_ &&
+ !is_clipped_ && did_insert_css_ &&
!render_view_host()->view()->background().empty()) {
SetVisible(true);
UpdatePreferredWidth(pending_preferred_width_);
diff --git a/chrome/browser/views/extensions/extension_view.h b/chrome/browser/views/extensions/extension_view.h
index fc1ef90..1e08f79 100644
--- a/chrome/browser/views/extensions/extension_view.h
+++ b/chrome/browser/views/extensions/extension_view.h
@@ -36,7 +36,7 @@ class ExtensionView : public views::NativeViewHost {
Browser* browser() const { return browser_; }
Extension* extension() const;
RenderViewHost* render_view_host() const;
- void DidStopLoading();
+ void SetDidInsertCSS(bool did_insert);
void set_is_clipped(bool is_clipped) { is_clipped_ = is_clipped; }
bool is_toolstrip() const { return is_toolstrip_; }
void set_is_toolstrip(bool is) { is_toolstrip_ = is; }
@@ -94,8 +94,8 @@ class ExtensionView : public views::NativeViewHost {
// Note: the view does not own its container.
ExtensionContainer* container_;
- // Whether the RenderView has finished loading.
- bool did_stop_loading_;
+ // Whether the RenderView has inserted extension css into toolstrip page.
+ bool did_insert_css_;
// Whether this extension view is clipped.
bool is_clipped_;