diff options
author | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-21 17:36:49 +0000 |
---|---|---|
committer | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-21 17:36:49 +0000 |
commit | 86c10a17c5b7fbaa21d39b1f8d69b858a9fce417 (patch) | |
tree | e79f4da7a12456ed5e342c222d1592633242fdf1 /chrome/browser/gtk | |
parent | 3374f3ca35055b0bc4abaab15a962a53576fe8fd (diff) | |
download | chromium_src-86c10a17c5b7fbaa21d39b1f8d69b858a9fce417.zip chromium_src-86c10a17c5b7fbaa21d39b1f8d69b858a9fce417.tar.gz chromium_src-86c10a17c5b7fbaa21d39b1f8d69b858a9fce417.tar.bz2 |
Remove the extension shelf on Linux.
The extension team's plan is to get rid of extension shelf entirely.
This is also going to fix a crash.
TEST=none
BUG=25106
Review URL: http://codereview.chromium.org/313006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@29665 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/gtk')
-rw-r--r-- | chrome/browser/gtk/browser_window_gtk.cc | 18 | ||||
-rw-r--r-- | chrome/browser/gtk/browser_window_gtk.h | 8 | ||||
-rw-r--r-- | chrome/browser/gtk/extension_shelf_gtk.cc | 232 | ||||
-rw-r--r-- | chrome/browser/gtk/extension_shelf_gtk.h | 103 | ||||
-rw-r--r-- | chrome/browser/gtk/view_id_util_browsertest.cc | 4 |
5 files changed, 8 insertions, 357 deletions
diff --git a/chrome/browser/gtk/browser_window_gtk.cc b/chrome/browser/gtk/browser_window_gtk.cc index 269be50..9981031 100644 --- a/chrome/browser/gtk/browser_window_gtk.cc +++ b/chrome/browser/gtk/browser_window_gtk.cc @@ -45,7 +45,6 @@ #include "chrome/browser/gtk/download_in_progress_dialog_gtk.h" #include "chrome/browser/gtk/download_shelf_gtk.h" #include "chrome/browser/gtk/edit_search_engine_dialog.h" -#include "chrome/browser/gtk/extension_shelf_gtk.h" #include "chrome/browser/gtk/find_bar_gtk.h" #include "chrome/browser/gtk/go_button_gtk.h" #include "chrome/browser/gtk/gtk_theme_provider.h" @@ -1673,12 +1672,6 @@ void BrowserWindowGtk::InitWidgets() { G_CALLBACK(&OnCompactNavSpacerExpose), this); } #endif - if (IsExtensionShelfSupported()) { - extension_shelf_.reset(new ExtensionShelfGtk(browser()->profile(), - browser_.get())); - gtk_box_pack_end(GTK_BOX(window_vbox_), extension_shelf_->widget(), - FALSE, FALSE, 0); - } // This vbox surrounds the render area: find bar, info bars and render view. // The reason is that this area as a whole needs to be grouped in its own @@ -2158,8 +2151,7 @@ void BrowserWindowGtk::HideUnsupportedWindowFeatures() { if (!IsToolbarSupported()) toolbar_->Hide(); - // If the bookmark bar or extension shelf is unsupported, then we never - // create them. + // If the bookmark bar shelf is unsupported, then we never create it. } bool BrowserWindowGtk::IsTabStripSupported() const { @@ -2175,10 +2167,6 @@ bool BrowserWindowGtk::IsBookmarkBarSupported() const { return browser_->SupportsWindowFeature(Browser::FEATURE_BOOKMARKBAR); } -bool BrowserWindowGtk::IsExtensionShelfSupported() const { - return browser_->SupportsWindowFeature(Browser::FEATURE_EXTENSIONSHELF); -} - bool BrowserWindowGtk::GetWindowEdge(int x, int y, GdkWindowEdge* edge) { if (!UseCustomFrame()) return false; @@ -2247,8 +2235,8 @@ void BrowserWindowGtk::PlaceBookmarkBar(bool is_floating) { if (!is_floating) { // Place the bookmark bar at the end of |window_vbox_|; this happens after - // we have placed the extension shelf and render area at the end of - // |window_vbox_| so we will be above the render area. + // we have placed the render area at the end of |window_vbox_| so we will + // be above the render area. gtk_box_pack_end(GTK_BOX(window_vbox_), bookmark_bar_->widget(), FALSE, FALSE, 0); } else { diff --git a/chrome/browser/gtk/browser_window_gtk.h b/chrome/browser/gtk/browser_window_gtk.h index 00ed567..762af0a 100644 --- a/chrome/browser/gtk/browser_window_gtk.h +++ b/chrome/browser/gtk/browser_window_gtk.h @@ -31,7 +31,6 @@ class BrowserTitlebar; class BrowserToolbarGtk; class CustomDrawButton; class DownloadShelfGtk; -class ExtensionShelfGtk; class FindBarGtk; class InfoBarContainerGtk; class LocationBar; @@ -214,8 +213,7 @@ class BrowserWindowGtk : public BrowserWindow, // GtkAlignment that holds the interior components of the chromium window. // This is used to draw the custom frame border and content shadow. GtkWidget* window_container_; - // VBox that holds everything (tabs, toolbar, bookmarks bar, tab contents, - // and extension shelf). + // VBox that holds everything (tabs, toolbar, bookmarks bar, tab contents). GtkWidget* window_vbox_; // VBox that holds everything below the toolbar. GtkWidget* render_area_vbox_; @@ -319,7 +317,6 @@ class BrowserWindowGtk : public BrowserWindow, bool IsTabStripSupported() const; bool IsToolbarSupported() const; bool IsBookmarkBarSupported() const; - bool IsExtensionShelfSupported() const; // Checks to see if the mouse pointer at |x|, |y| is over the border of the // custom frame (a spot that should trigger a window resize). Returns true if @@ -356,9 +353,6 @@ class BrowserWindowGtk : public BrowserWindow, // bookmark bar is not supported. scoped_ptr<BookmarkBarGtk> bookmark_bar_; - // The object that manages the extension shelf. - scoped_ptr<ExtensionShelfGtk> extension_shelf_; - // The status bubble manager. Always non-NULL. scoped_ptr<StatusBubbleGtk> status_bubble_; diff --git a/chrome/browser/gtk/extension_shelf_gtk.cc b/chrome/browser/gtk/extension_shelf_gtk.cc deleted file mode 100644 index 112a214..0000000 --- a/chrome/browser/gtk/extension_shelf_gtk.cc +++ /dev/null @@ -1,232 +0,0 @@ -// Copyright (c) 2009 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. - -#include "chrome/browser/gtk/extension_shelf_gtk.h" - -#include "app/gfx/gtk_util.h" -#include "chrome/browser/browser.h" -#include "chrome/browser/gtk/browser_window_gtk.h" -#include "chrome/browser/gtk/gtk_theme_provider.h" -#include "chrome/browser/gtk/view_id_util.h" -#include "chrome/browser/profile.h" -#include "chrome/common/notification_service.h" -#include "grit/app_resources.h" -#include "grit/generated_resources.h" -#include "grit/theme_resources.h" - -// Preferred height of the ExtensionShelfGtk. -static const int kShelfHeight = 29; - -static const int kToolstripPadding = 2; - -class ExtensionShelfGtk::Toolstrip { - public: - explicit Toolstrip(ExtensionHost* host) - : host_(host), - extension_name_(host_->extension()->name()) { - DCHECK(host_->view()); - Init(); - } - - void AddToolstripToBox(GtkWidget* box); - void RemoveToolstripFromBox(GtkWidget* box); - - void SetBackground(const SkBitmap& background) { - host_->view()->SetBackground(background); - } - - private: - void Init(); - - gfx::NativeView native_view() { - return host_->view()->native_view(); - } - - ExtensionHost* host_; - - const std::string extension_name_; - - private: - DISALLOW_COPY_AND_ASSIGN(Toolstrip); -}; - -void ExtensionShelfGtk::Toolstrip::AddToolstripToBox(GtkWidget* box) { - gtk_box_pack_start(GTK_BOX(box), native_view(), FALSE, FALSE, - kToolstripPadding); -} - -void ExtensionShelfGtk::Toolstrip::RemoveToolstripFromBox(GtkWidget* box) { - gtk_container_remove(GTK_CONTAINER(box), native_view()); -} - -void ExtensionShelfGtk::Toolstrip::Init() { - host_->view()->set_is_toolstrip(true); - gtk_widget_show_all(native_view()); -} - -ExtensionShelfGtk::ExtensionShelfGtk(Profile* profile, Browser* browser) - : browser_(browser), - theme_provider_(GtkThemeProvider::GetFrom(profile)), - model_(browser->extension_shelf_model()) { - Init(profile); -} - -ExtensionShelfGtk::~ExtensionShelfGtk() { - if (model_) - model_->RemoveObserver(this); - event_box_.Destroy(); -} - -void ExtensionShelfGtk::Show() { - gtk_widget_show_all(event_box_.get()); -} - -void ExtensionShelfGtk::Hide() { - gtk_widget_hide(event_box_.get()); -} - -void ExtensionShelfGtk::ToolstripInsertedAt(ExtensionHost* host, - int index) { - InitBackground(); - Toolstrip* toolstrip = new Toolstrip(host); - toolstrip->SetBackground(*background_.get()); - toolstrip->AddToolstripToBox(shelf_hbox_); - toolstrips_.insert(toolstrip); - model_->SetToolstripDataAt(index, toolstrip); - - AdjustHeight(); -} - -void ExtensionShelfGtk::ToolstripRemovingAt(ExtensionHost* host, - int index) { - Toolstrip* toolstrip = ToolstripAtIndex(index); - toolstrip->RemoveToolstripFromBox(shelf_hbox_); - toolstrips_.erase(toolstrip); - model_->SetToolstripDataAt(index, NULL); - delete toolstrip; - - AdjustHeight(); -} - -void ExtensionShelfGtk::ToolstripMoved(ExtensionHost* host, - int from_index, - int to_index) { - // TODO(phajdan.jr): Implement reordering toolstrips. - AdjustHeight(); -} - -void ExtensionShelfGtk::ToolstripChanged( - ExtensionShelfModel::iterator toolstrip) { - // TODO(phajdan.jr): Implement changing toolstrips. - AdjustHeight(); -} - -void ExtensionShelfGtk::ExtensionShelfEmpty() { - AdjustHeight(); -} - -void ExtensionShelfGtk::ShelfModelReloaded() { - for (std::set<Toolstrip*>::iterator iter = toolstrips_.begin(); - iter != toolstrips_.end(); ++iter) { - (*iter)->RemoveToolstripFromBox(shelf_hbox_); - delete *iter; - } - toolstrips_.clear(); - LoadFromModel(); -} - -void ExtensionShelfGtk::ShelfModelDeleting() { - for (std::set<Toolstrip*>::iterator iter = toolstrips_.begin(); - iter != toolstrips_.end(); ++iter) { - (*iter)->RemoveToolstripFromBox(shelf_hbox_); - delete *iter; - } - toolstrips_.clear(); - - model_->RemoveObserver(this); - model_ = NULL; -} - -void ExtensionShelfGtk::Observe(NotificationType type, - const NotificationSource& source, - const NotificationDetails& details) { - DCHECK(type == NotificationType::BROWSER_THEME_CHANGED); - GdkColor color = theme_provider_->GetBorderColor(); - gtk_widget_modify_bg(top_border_, GTK_STATE_NORMAL, &color); - - color = theme_provider_->GetGdkColor(BrowserThemeProvider::COLOR_TOOLBAR); - gtk_widget_modify_bg(event_box_.get(), GTK_STATE_NORMAL, &color); - - // Reset the background images on all the individual toolstrips - background_.reset(); - InitBackground(); - for (std::set<Toolstrip*>::iterator it = toolstrips_.begin(); - it != toolstrips_.end(); ++it) { - (*it)->SetBackground(*background_.get()); - } -} - -void ExtensionShelfGtk::Init(Profile* profile) { - top_border_ = gtk_event_box_new(); - gtk_widget_set_size_request(GTK_WIDGET(top_border_), 0, 1); - - // The event box provides a background for the shelf and is its top-level - // widget. - event_box_.Own(gtk_event_box_new()); - ViewIDUtil::SetID(event_box_.get(), VIEW_ID_DEV_EXTENSION_SHELF); - - shelf_hbox_ = gtk_hbox_new(FALSE, 0); - - GtkWidget* vbox = gtk_vbox_new(FALSE, 0); - gtk_box_pack_start(GTK_BOX(vbox), top_border_, FALSE, FALSE, 0); - gtk_box_pack_start(GTK_BOX(vbox), shelf_hbox_, FALSE, FALSE, 0); - - gtk_container_add(GTK_CONTAINER(event_box_.get()), vbox); - - theme_provider_->InitThemesFor(this); - registrar_.Add(this, NotificationType::BROWSER_THEME_CHANGED, - NotificationService::AllSources()); - - LoadFromModel(); - model_->AddObserver(this); -} - -void ExtensionShelfGtk::InitBackground() { - if (background_.get()) - return; - - GdkColor color = - theme_provider_->GetGdkColor(BrowserThemeProvider::COLOR_TOOLBAR); - - background_.reset(new SkBitmap); - background_->setConfig(SkBitmap::kARGB_8888_Config, 3, 3); - background_->allocPixels(); - background_->eraseRGB(color.red >> 8, - color.green >> 8, - color.blue >> 8); -} - -void ExtensionShelfGtk::AdjustHeight() { - if (model_->empty() || toolstrips_.empty()) { - // It's possible that |model_| is not empty, but |toolstrips_| are empty - // when removing the last toolstrip. - DCHECK(toolstrips_.empty()); - Hide(); - } else { - gtk_widget_set_size_request(shelf_hbox_, -1, kShelfHeight); - Show(); - } -} - -void ExtensionShelfGtk::LoadFromModel() { - DCHECK(toolstrips_.empty()); - int count = model_->count(); - for (int i = 0; i < count; ++i) - ToolstripInsertedAt(model_->ToolstripAt(i).host, i); - AdjustHeight(); -} - -ExtensionShelfGtk::Toolstrip* ExtensionShelfGtk::ToolstripAtIndex(int index) { - return static_cast<Toolstrip*>(model_->ToolstripAt(index).data); -} diff --git a/chrome/browser/gtk/extension_shelf_gtk.h b/chrome/browser/gtk/extension_shelf_gtk.h deleted file mode 100644 index d8af344..0000000 --- a/chrome/browser/gtk/extension_shelf_gtk.h +++ /dev/null @@ -1,103 +0,0 @@ -// Copyright (c) 2009 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. - -#ifndef CHROME_BROWSER_GTK_EXTENSION_SHELF_GTK_H_ -#define CHROME_BROWSER_GTK_EXTENSION_SHELF_GTK_H_ - -#include <gtk/gtk.h> - -#include <set> - -#include "base/scoped_ptr.h" -#include "chrome/browser/extensions/extension_shelf_model.h" -#include "chrome/common/notification_registrar.h" -#include "chrome/common/owned_widget_gtk.h" - -class Browser; -class BrowserWindowGtk; -class CustomContainerButton; -class NineBox; -class Profile; -struct GtkThemeProvider; - -class ExtensionShelfGtk : public ExtensionShelfModelObserver, - public NotificationObserver { - public: - ExtensionShelfGtk(Profile* profile, Browser* browser); - virtual ~ExtensionShelfGtk(); - - // Change the visibility of the bookmarks bar. (Starts out hidden, per GTK's - // default behaviour). - void Show(); - void Hide(); - - // ExtensionShelfModelObserver - virtual void ToolstripInsertedAt(ExtensionHost* host, int index); - virtual void ToolstripRemovingAt(ExtensionHost* host, int index); - virtual void ToolstripMoved(ExtensionHost* host, - int from_index, - int to_index); - virtual void ToolstripChanged(ExtensionShelfModel::iterator toolstrip); - virtual void ExtensionShelfEmpty(); - virtual void ShelfModelReloaded(); - virtual void ShelfModelDeleting(); - - // NotificationObserver - virtual void Observe(NotificationType type, - const NotificationSource& source, - const NotificationDetails& details); - - GtkWidget* widget() { - return event_box_.get(); - } - - private: - class Toolstrip; - - // Create the contents of the extension shelf. - void Init(Profile* profile); - - // Lazily initialize background bitmap. Can be called many times. - void InitBackground(); - - // Determines what is our target height and sets it. - void AdjustHeight(); - - void LoadFromModel(); - - Toolstrip* ToolstripAtIndex(int index); - - // GtkHBox callbacks. - static gboolean OnHBoxExpose(GtkWidget* widget, GdkEventExpose* event, - ExtensionShelfGtk* window); - - Browser* browser_; - - // Top level event box which draws the one pixel border. - GtkWidget* top_border_; - - // Contains |shelf_hbox_|. Event box exists to prevent leakage of - // background color from the toplevel application window's GDK window. - OwnedWidgetGtk event_box_; - - // Used to position all children. - GtkWidget* shelf_hbox_; - - // Lazily-initialized background for toolstrips. - scoped_ptr<SkBitmap> background_; - - GtkThemeProvider* theme_provider_; - - // The model representing the toolstrips on the shelf. - ExtensionShelfModel* model_; - - // Set of toolstrip views which are really on the shelf. - std::set<Toolstrip*> toolstrips_; - - NotificationRegistrar registrar_; - - DISALLOW_COPY_AND_ASSIGN(ExtensionShelfGtk); -}; - -#endif // CHROME_BROWSER_GTK_EXTENSION_SHELF_GTK_H_ diff --git a/chrome/browser/gtk/view_id_util_browsertest.cc b/chrome/browser/gtk/view_id_util_browsertest.cc index f35eb2a..0ca9d9a 100644 --- a/chrome/browser/gtk/view_id_util_browsertest.cc +++ b/chrome/browser/gtk/view_id_util_browsertest.cc @@ -30,6 +30,10 @@ IN_PROC_BROWSER_TEST_F(ViewIDTest, Basic) { if (i == VIEW_ID_BOOKMARK_MENU) continue; + // Extension shelf is being removed, http://crbug.com/25106. + if (i == VIEW_ID_DEV_EXTENSION_SHELF) + continue; + CheckViewID(static_cast<ViewID>(i), true); } |