summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authorerikkay@chromium.org <erikkay@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-12 20:12:42 +0000
committererikkay@chromium.org <erikkay@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-12 20:12:42 +0000
commit6d7a6046d581348565fc0634d81efce653a1f550 (patch)
treed7f2b7ca49c1805d11dea9751adea02a0562a939 /chrome/browser
parent0ba9330a17a3fd294a28972f5a81b64f550e6a20 (diff)
downloadchromium_src-6d7a6046d581348565fc0634d81efce653a1f550.zip
chromium_src-6d7a6046d581348565fc0634d81efce653a1f550.tar.gz
chromium_src-6d7a6046d581348565fc0634d81efce653a1f550.tar.bz2
remove toolstrips
BUG=51703 BUG=30178 BUG=25106 TEST=none Review URL: http://codereview.chromium.org/3129003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@55921 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/browser.cc25
-rw-r--r--chrome/browser/browser.h15
-rw-r--r--chrome/browser/browser_resources.grd1
-rw-r--r--chrome/browser/browser_window.h14
-rw-r--r--chrome/browser/cocoa/browser_window_cocoa.h2
-rw-r--r--chrome/browser/cocoa/browser_window_cocoa.mm8
-rw-r--r--chrome/browser/cocoa/view_id_util_browsertest.mm4
-rw-r--r--chrome/browser/dom_ui/dom_ui.cc1
-rw-r--r--chrome/browser/dom_ui/dom_ui.h7
-rw-r--r--chrome/browser/dom_ui/new_tab_ui.cc1
-rw-r--r--chrome/browser/extensions/extension_browsertest.cc5
-rw-r--r--chrome/browser/extensions/extension_browsertests_misc.cc107
-rw-r--r--chrome/browser/extensions/extension_function_dispatcher.cc9
-rw-r--r--chrome/browser/extensions/extension_host.cc73
-rw-r--r--chrome/browser/extensions/extension_host.h8
-rw-r--r--chrome/browser/extensions/extension_popup_api.cc15
-rw-r--r--chrome/browser/extensions/extension_popup_apitest.cc5
-rw-r--r--chrome/browser/extensions/extension_prefs.cc28
-rw-r--r--chrome/browser/extensions/extension_process_manager.cc11
-rw-r--r--chrome/browser/extensions/extension_process_manager.h4
-rw-r--r--chrome/browser/extensions/extension_shelf_model.cc282
-rw-r--r--chrome/browser/extensions/extension_shelf_model.h168
-rw-r--r--chrome/browser/extensions/extension_shelf_model_browsertest.cc97
-rw-r--r--chrome/browser/extensions/extension_toolstrip_api.cc176
-rw-r--r--chrome/browser/extensions/extension_toolstrip_api.h61
-rw-r--r--chrome/browser/extensions/extension_toolstrip_apitest.cc11
-rw-r--r--chrome/browser/extensions/extensions_service_unittest.cc15
-rw-r--r--chrome/browser/gtk/browser_window_gtk.cc8
-rw-r--r--chrome/browser/gtk/browser_window_gtk.h2
-rw-r--r--chrome/browser/gtk/view_id_util.cc3
-rw-r--r--chrome/browser/gtk/view_id_util_browsertest.cc4
-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.css8
-rw-r--r--chrome/browser/tab_contents/navigation_controller.cc3
-rw-r--r--chrome/browser/tab_contents/tab_contents.cc24
-rw-r--r--chrome/browser/tab_contents/tab_contents.h8
-rw-r--r--chrome/browser/task_manager_browsertest.cc11
-rw-r--r--chrome/browser/view_ids.h3
-rw-r--r--chrome/browser/views/extensions/extension_shelf.cc1108
-rw-r--r--chrome/browser/views/extensions/extension_shelf.h155
-rw-r--r--chrome/browser/views/extensions/extension_view.cc6
-rw-r--r--chrome/browser/views/frame/browser_view.cc33
-rw-r--r--chrome/browser/views/frame/browser_view.h9
-rw-r--r--chrome/browser/views/frame/browser_view_layout.cc40
-rw-r--r--chrome/browser/views/frame/browser_view_layout.h6
46 files changed, 34 insertions, 2557 deletions
diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc
index a5f65d2..03568cb 100644
--- a/chrome/browser/browser.cc
+++ b/chrome/browser/browser.cc
@@ -44,7 +44,7 @@
#include "chrome/browser/extensions/crashed_extension_infobar.h"
#include "chrome/browser/extensions/extension_browser_event_router.h"
#include "chrome/browser/extensions/extension_disabled_infobar_delegate.h"
-#include "chrome/browser/extensions/extension_shelf_model.h"
+#include "chrome/browser/extensions/extension_host.h"
#include "chrome/browser/extensions/extension_tabs_module.h"
#include "chrome/browser/extensions/extensions_service.h"
#include "chrome/browser/find_bar.h"
@@ -355,9 +355,6 @@ Browser* Browser::CreateForDevTools(Profile* profile) {
void Browser::CreateBrowserWindow() {
DCHECK(!window_);
- if (SupportsWindowFeature(FEATURE_EXTENSIONSHELF))
- extension_shelf_model_.reset(new ExtensionShelfModel(this));
-
window_ = BrowserWindow::CreateBrowserWindow(this);
#if defined(OS_WIN)
@@ -1159,7 +1156,6 @@ bool Browser::SupportsWindowFeatureImpl(WindowFeature feature,
if (type() == TYPE_NORMAL) {
features |= FEATURE_BOOKMARKBAR;
- features |= FEATURE_EXTENSIONSHELF;
}
if (!hide_ui_for_fullscreen) {
@@ -1731,12 +1727,6 @@ void Browser::ToggleBookmarkBar() {
window_->ToggleBookmarkBar();
}
-void Browser::ToggleExtensionShelf() {
- UserMetrics::RecordAction(UserMetricsAction("ToggleExtensionShelf"),
- profile_);
- window_->ToggleExtensionShelf();
-}
-
void Browser::OpenBookmarkManager() {
UserMetrics::RecordAction(UserMetricsAction("ShowBookmarkManager"), profile_);
ShowBookmarkManagerTab();
@@ -1949,7 +1939,6 @@ void Browser::RegisterUserPrefs(PrefService* prefs) {
prefs->RegisterIntegerPref(prefs::kDeleteTimePeriod, 0);
prefs->RegisterBooleanPref(prefs::kCheckDefaultBrowser, true);
prefs->RegisterBooleanPref(prefs::kShowOmniboxSearchHint, true);
- prefs->RegisterBooleanPref(prefs::kShowExtensionShelf, true);
prefs->RegisterBooleanPref(prefs::kWebAppCreateOnDesktop, true);
prefs->RegisterBooleanPref(prefs::kWebAppCreateInAppsMenu, true);
prefs->RegisterBooleanPref(prefs::kWebAppCreateInQuickLaunchBar, true);
@@ -2128,7 +2117,6 @@ void Browser::ExecuteCommandWithDisposition(
case IDC_REPORT_BUG: OpenBugReportDialog(); break;
case IDC_SHOW_BOOKMARK_BAR: ToggleBookmarkBar(); break;
- case IDC_SHOW_EXTENSION_SHELF: ToggleExtensionShelf(); break;
case IDC_SHOW_BOOKMARK_MANAGER: OpenBookmarkManager(); break;
case IDC_SHOW_APP_MENU: ShowAppMenu(); break;
@@ -2692,10 +2680,6 @@ void Browser::ToolbarSizeChanged(TabContents* source, bool is_animating) {
}
}
-void Browser::ExtensionShelfSizeChanged() {
- window_->SelectedTabExtensionShelfSizeChanged();
-}
-
void Browser::URLStarredChanged(TabContents* source, bool starred) {
if (source == GetSelectedTabContents())
window_->SetStarredState(starred);
@@ -3240,7 +3224,6 @@ void Browser::InitCommandState() {
command_updater_.UpdateCommandEnabled(IDC_TASK_MANAGER, true);
command_updater_.UpdateCommandEnabled(IDC_SHOW_HISTORY, true);
command_updater_.UpdateCommandEnabled(IDC_SHOW_BOOKMARK_MANAGER, true);
- command_updater_.UpdateCommandEnabled(IDC_SHOW_EXTENSION_SHELF, true);
command_updater_.UpdateCommandEnabled(IDC_SHOW_DOWNLOADS, true);
command_updater_.UpdateCommandEnabled(IDC_HELP_PAGE, true);
command_updater_.UpdateCommandEnabled(IDC_IMPORT_SETTINGS, true);
@@ -3418,11 +3401,9 @@ void Browser::ScheduleUIUpdate(const TabContents* source,
TabStripModelObserver::TITLE_NOT_LOADING);
}
- if (changed_flags & TabContents::INVALIDATE_BOOKMARK_BAR ||
- changed_flags & TabContents::INVALIDATE_EXTENSION_SHELF) {
+ if (changed_flags & TabContents::INVALIDATE_BOOKMARK_BAR) {
window()->ShelfVisibilityChanged();
- changed_flags &= ~(TabContents::INVALIDATE_BOOKMARK_BAR |
- TabContents::INVALIDATE_EXTENSION_SHELF);
+ changed_flags &= ~TabContents::INVALIDATE_BOOKMARK_BAR;
}
// If the only updates were synchronously handled above, we're done.
diff --git a/chrome/browser/browser.h b/chrome/browser/browser.h
index ff3bb03..57da415 100644
--- a/chrome/browser/browser.h
+++ b/chrome/browser/browser.h
@@ -32,7 +32,6 @@
class BrowserWindow;
class Extension;
-class ExtensionShelfModel;
class FindBarController;
class PrefService;
class Profile;
@@ -87,8 +86,7 @@ class Browser : public TabStripModelDelegate,
FEATURE_LOCATIONBAR = 8,
FEATURE_BOOKMARKBAR = 16,
FEATURE_INFOBAR = 32,
- FEATURE_DOWNLOADSHELF = 64,
- FEATURE_EXTENSIONSHELF = 128
+ FEATURE_DOWNLOADSHELF = 64
};
// Maximized state on creation.
@@ -175,9 +173,6 @@ class Browser : public TabStripModelDelegate,
ToolbarModel* toolbar_model() { return &toolbar_model_; }
const SessionID& session_id() const { return session_id_; }
CommandUpdater* command_updater() { return &command_updater_; }
- ExtensionShelfModel* extension_shelf_model() {
- return extension_shelf_model_.get();
- }
// Get the FindBarController for this browser, creating it if it does not
// yet exist.
@@ -384,10 +379,6 @@ class Browser : public TabStripModelDelegate,
// part of an animation.
void ToolbarSizeChanged(bool is_animating);
- // Notification that the extension shelf has changed size (as a result of
- // becoming detached or attached).
- void ExtensionShelfSizeChanged();
-
// Replaces the state of the currently selected tab with the session
// history restored from the SessionRestore system.
void ReplaceRestoredTab(
@@ -508,7 +499,6 @@ class Browser : public TabStripModelDelegate,
void OpenBugReportDialog();
void ToggleBookmarkBar();
- void ToggleExtensionShelf();
void OpenBookmarkManager();
void ShowAppMenu();
@@ -985,9 +975,6 @@ class Browser : public TabStripModelDelegate,
// The model for the toolbar view.
ToolbarModel toolbar_model_;
- // The model for the extension shelf.
- scoped_ptr<ExtensionShelfModel> extension_shelf_model_;
-
// UI update coalescing and handling ////////////////////////////////////////
typedef std::map<const TabContents*, int> UpdateMap;
diff --git a/chrome/browser/browser_resources.grd b/chrome/browser/browser_resources.grd
index 40a11a1..63137c2 100644
--- a/chrome/browser/browser_resources.grd
+++ b/chrome/browser/browser_resources.grd
@@ -35,7 +35,6 @@ without changes to the corresponding grd file. eadee -->
<if expr="os != 'darwin'">
<include name="IDR_EXTENSIONS_INFOBAR_CSS" file="resources\extensions_infobar.css" flattenhtml="true" type="BINDATA" />
</if>
- <include name="IDR_EXTENSIONS_TOOLSTRIP_THEME_CSS" file="resources\extensions_toolstrip.css" flattenhtml="true" type="BINDATA" />
<include name="IDR_EXTENSIONS_UI_HTML" file="resources\extensions_ui.html" flattenhtml="true" type="BINDATA" />
<include name="IDR_GAIA_LOGIN_HTML" file="sync\resources\gaia_login.html" flattenhtml="true" type="BINDATA" />
<include name="IDR_GMAIL_APP_MANIFEST" file="resources\gmail_app\manifest.json" type="BINDATA" />
diff --git a/chrome/browser/browser_window.h b/chrome/browser/browser_window.h
index 0b679ab..6554713 100644
--- a/chrome/browser/browser_window.h
+++ b/chrome/browser/browser_window.h
@@ -87,17 +87,14 @@ class BrowserWindow {
// BrowserView.
virtual void SelectedTabToolbarSizeChanged(bool is_animating) = 0;
- // Notification for the Extension Shelf changing its size.
- virtual void SelectedTabExtensionShelfSizeChanged() = 0;
-
// Inform the frame that the selected tab favicon or title has changed. Some
// frames may need to refresh their title bar.
virtual void UpdateTitleBar() = 0;
- // Invoked when the visibility of the bookmark bar or extension shelf changes.
- // NOTE: this is NOT sent when the user toggles the visibility of one of
- // these shelves, but rather when the user transitions from a page that forces
- // the shelves to be visibile to one that doesn't have them visible (or
+ // Invoked when the visibility of the bookmark bar.
+ // NOTE: this is NOT sent when the user toggles the visibility of this,
+ // but rather when the user transitions from a page that forces
+ // it to be visibile to one that doesn't have it visible (or
// vice-versa).
// TODO(sky): see about routing visibility pref changing through here too.
virtual void ShelfVisibilityChanged() = 0;
@@ -190,9 +187,6 @@ class BrowserWindow {
// Shows or hides the bookmark bar depending on its current visibility.
virtual void ToggleBookmarkBar() = 0;
- // Shows or hides the extension shelf depending on its current visibility.
- virtual void ToggleExtensionShelf() = 0;
-
// Shows the About Chrome dialog box.
virtual views::Window* ShowAboutChromeDialog() = 0;
diff --git a/chrome/browser/cocoa/browser_window_cocoa.h b/chrome/browser/cocoa/browser_window_cocoa.h
index 68e7061..354b9d5 100644
--- a/chrome/browser/cocoa/browser_window_cocoa.h
+++ b/chrome/browser/cocoa/browser_window_cocoa.h
@@ -42,7 +42,6 @@ class BrowserWindowCocoa : public BrowserWindow,
virtual BrowserWindowTesting* GetBrowserWindowTesting();
virtual StatusBubble* GetStatusBubble();
virtual void SelectedTabToolbarSizeChanged(bool is_animating);
- virtual void SelectedTabExtensionShelfSizeChanged();
virtual void UpdateTitleBar();
virtual void ShelfVisibilityChanged();
virtual void UpdateDevTools();
@@ -70,7 +69,6 @@ class BrowserWindowCocoa : public BrowserWindow,
virtual void ConfirmAddSearchProvider(const TemplateURL* template_url,
Profile* profile);
virtual void ToggleBookmarkBar();
- virtual void ToggleExtensionShelf();
virtual views::Window* ShowAboutChromeDialog();
virtual void ShowUpdateChromeDialog();
virtual void ShowTaskManager();
diff --git a/chrome/browser/cocoa/browser_window_cocoa.mm b/chrome/browser/cocoa/browser_window_cocoa.mm
index 33bbc73..d7c1828 100644
--- a/chrome/browser/cocoa/browser_window_cocoa.mm
+++ b/chrome/browser/cocoa/browser_window_cocoa.mm
@@ -141,10 +141,6 @@ void BrowserWindowCocoa::SelectedTabToolbarSizeChanged(bool is_animating) {
// sort on Mac.
}
-void BrowserWindowCocoa::SelectedTabExtensionShelfSizeChanged() {
- NOTIMPLEMENTED();
-}
-
void BrowserWindowCocoa::UpdateTitleBar() {
NSString* newTitle =
base::SysUTF16ToNSString(browser_->GetWindowTitleForCurrentTab());
@@ -276,10 +272,6 @@ void BrowserWindowCocoa::ToggleBookmarkBar() {
bookmark_utils::ToggleWhenVisible(browser_->profile());
}
-void BrowserWindowCocoa::ToggleExtensionShelf() {
- NOTIMPLEMENTED();
-}
-
void BrowserWindowCocoa::AddFindBar(
FindBarCocoaController* find_bar_cocoa_controller) {
return [controller_ addFindBar:find_bar_cocoa_controller];
diff --git a/chrome/browser/cocoa/view_id_util_browsertest.mm b/chrome/browser/cocoa/view_id_util_browsertest.mm
index 2f887f9..ca7f765 100644
--- a/chrome/browser/cocoa/view_id_util_browsertest.mm
+++ b/chrome/browser/cocoa/view_id_util_browsertest.mm
@@ -53,10 +53,6 @@ class ViewIDTest : public InProcessBrowserTest {
}
for (int i = VIEW_ID_TOOLBAR; i < VIEW_ID_PREDEFINED_COUNT; ++i) {
- // Extension shelf is being removed, http://crbug.com/30178.
- if (i == VIEW_ID_DEV_EXTENSION_SHELF)
- continue;
-
// Mac implementation does not support following ids yet.
if (i == VIEW_ID_STAR_BUTTON ||
i == VIEW_ID_AUTOCOMPLETE ||
diff --git a/chrome/browser/dom_ui/dom_ui.cc b/chrome/browser/dom_ui/dom_ui.cc
index a4f3583..983539e 100644
--- a/chrome/browser/dom_ui/dom_ui.cc
+++ b/chrome/browser/dom_ui/dom_ui.cc
@@ -38,7 +38,6 @@ std::wstring GetJavascript(const std::wstring& function_name,
DOMUI::DOMUI(TabContents* contents)
: hide_favicon_(false),
force_bookmark_bar_visible_(false),
- force_extension_shelf_visible_(false),
focus_location_bar_by_default_(false),
should_hide_url_(false),
link_transition_type_(PageTransition::LINK),
diff --git a/chrome/browser/dom_ui/dom_ui.h b/chrome/browser/dom_ui/dom_ui.h
index 4d35723..3aadbd5 100644
--- a/chrome/browser/dom_ui/dom_ui.h
+++ b/chrome/browser/dom_ui/dom_ui.h
@@ -64,12 +64,6 @@ class DOMUI {
return force_bookmark_bar_visible_;
}
- // Returns true if the extension shelf should be forced to being visible
- // (if it contains any items), overriding the user's preference.
- bool force_extension_shelf_visible() const {
- return force_extension_shelf_visible_;
- }
-
// Returns true if the location bar should be focused by default rather than
// the page contents. Some pages will want to use this to encourage the user
// to type in the URL bar.
@@ -129,7 +123,6 @@ class DOMUI {
// bool options default to false. See the public getters for more information.
bool hide_favicon_;
bool force_bookmark_bar_visible_;
- bool force_extension_shelf_visible_;
bool focus_location_bar_by_default_;
bool should_hide_url_;
string16 overridden_title_; // Defaults to empty string.
diff --git a/chrome/browser/dom_ui/new_tab_ui.cc b/chrome/browser/dom_ui/new_tab_ui.cc
index ffde24a..7d83e821 100644
--- a/chrome/browser/dom_ui/new_tab_ui.cc
+++ b/chrome/browser/dom_ui/new_tab_ui.cc
@@ -445,7 +445,6 @@ NewTabUI::NewTabUI(TabContents* contents)
// Override some options on the DOM UI.
hide_favicon_ = true;
force_bookmark_bar_visible_ = true;
- force_extension_shelf_visible_ = true;
focus_location_bar_by_default_ = true;
should_hide_url_ = true;
overridden_title_ = l10n_util::GetStringUTF16(IDS_NEW_TAB_TITLE);
diff --git a/chrome/browser/extensions/extension_browsertest.cc b/chrome/browser/extensions/extension_browsertest.cc
index a30f352..8660cb1 100644
--- a/chrome/browser/extensions/extension_browsertest.cc
+++ b/chrome/browser/extensions/extension_browsertest.cc
@@ -44,11 +44,6 @@ void ExtensionBrowserTest::SetUpCommandLine(CommandLine* command_line) {
PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir_);
test_data_dir_ = test_data_dir_.AppendASCII("extensions");
- // There are a number of tests that still use toolstrips. Rather than
- // selectively enabling each of them, enable toolstrips for all extension
- // tests.
- command_line->AppendSwitch(switches::kEnableExtensionToolstrips);
-
#if defined(OS_CHROMEOS)
// This makes sure that we create the Default profile first, with no
// ExtensionsService and then the real profile with one, as we do when
diff --git a/chrome/browser/extensions/extension_browsertests_misc.cc b/chrome/browser/extensions/extension_browsertests_misc.cc
index 8b7c9a2..038d07f 100644
--- a/chrome/browser/extensions/extension_browsertests_misc.cc
+++ b/chrome/browser/extensions/extension_browsertests_misc.cc
@@ -20,7 +20,6 @@
#include "chrome/browser/renderer_host/site_instance.h"
#include "chrome/browser/tab_contents/tab_contents.h"
#if defined(TOOLKIT_VIEWS)
-#include "chrome/browser/views/extensions/extension_shelf.h"
#include "chrome/browser/views/frame/browser_view.h"
#endif
#include "chrome/common/chrome_paths.h"
@@ -73,110 +72,6 @@ static ExtensionHost* FindHostWithPath(ExtensionProcessManager* manager,
return host;
}
-#if defined(OS_LINUX) && defined(TOOLKIT_VIEWS)
-// See http://crbug.com/30151.
-#define Toolstrip DISABLED_Toolstrip
-#endif
-
-// Tests that toolstrips initializes properly and can run basic extension js.
-IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, Toolstrip) {
- FilePath extension_test_data_dir = test_data_dir_.AppendASCII("good").
- AppendASCII("Extensions").AppendASCII("behllobkkfkfnphdnhnkndlbkcpglgmj").
- AppendASCII("1.0.0.0");
- ASSERT_TRUE(LoadExtension(extension_test_data_dir));
-
- // At this point, there should be three ExtensionHosts loaded because this
- // extension has two toolstrips and one background page. Find the one that is
- // hosting toolstrip1.html.
- ExtensionProcessManager* manager =
- browser()->profile()->GetExtensionProcessManager();
- ExtensionHost* host = FindHostWithPath(manager, "/toolstrip1.html", 3);
-
- // Tell it to run some JavaScript that tests that basic extension code works.
- bool result = false;
- ui_test_utils::ExecuteJavaScriptAndExtractBool(
- host->render_view_host(), L"", L"testTabsAPI()", &result);
- EXPECT_TRUE(result);
-
- // Test for compact language detection API. First navigate to a (static) html
- // file with a French sentence. Then, run the test API in toolstrip1.html to
- // actually call the language detection API through the existing extension,
- // and verify that the language returned is indeed French.
- FilePath language_url = extension_test_data_dir.AppendASCII(
- "french_sentence.html");
- ui_test_utils::NavigateToURL(browser(), net::FilePathToFileURL(language_url));
-
- ui_test_utils::ExecuteJavaScriptAndExtractBool(
- host->render_view_host(), L"", L"testTabsLanguageAPI()", &result);
- EXPECT_TRUE(result);
-}
-
-IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, ExtensionViews) {
- FilePath extension_test_data_dir = test_data_dir_.AppendASCII("good").
- AppendASCII("Extensions").AppendASCII("behllobkkfkfnphdnhnkndlbkcpglgmj").
- AppendASCII("1.0.0.0");
- ASSERT_TRUE(LoadExtension(extension_test_data_dir));
-
- // At this point, there should be three ExtensionHosts loaded because this
- // extension has two toolstrips and one background page. Find the one that is
- // hosting toolstrip1.html.
- ExtensionProcessManager* manager =
- browser()->profile()->GetExtensionProcessManager();
- ExtensionHost* host = FindHostWithPath(manager, "/toolstrip1.html", 3);
-
- FilePath gettabs_url = extension_test_data_dir.AppendASCII(
- "test_gettabs.html");
- ui_test_utils::NavigateToURL(
- browser(),
- GURL(gettabs_url.value()));
-
- bool result = false;
- ui_test_utils::ExecuteJavaScriptAndExtractBool(
- host->render_view_host(), L"", L"testgetToolstripsAPI()", &result);
- EXPECT_TRUE(result);
-
- result = false;
- ui_test_utils::ExecuteJavaScriptAndExtractBool(
- host->render_view_host(), L"", L"testgetBackgroundPageAPI()", &result);
- EXPECT_TRUE(result);
-
- ui_test_utils::NavigateToURL(
- browser(),
- GURL("chrome-extension://behllobkkfkfnphdnhnkndlbkcpglgmj/"
- "test_gettabs.html"));
- result = false;
- ui_test_utils::ExecuteJavaScriptAndExtractBool(
- host->render_view_host(), L"", L"testgetExtensionTabsAPI()", &result);
- EXPECT_TRUE(result);
-}
-
-#if defined(TOOLKIT_VIEWS)
-// http://crbug.com/29897 - for other UI toolkits?
-
-// Tests that the ExtensionShelf initializes properly, notices that
-// an extension loaded and has a view available, and then sets that up
-// properly.
-IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, Shelf) {
- // When initialized, there are no extension views and the preferred height
- // should be zero.
- BrowserView* browser_view = static_cast<BrowserView*>(browser()->window());
- ExtensionShelf* shelf = browser_view->extension_shelf();
- ASSERT_TRUE(shelf);
- EXPECT_EQ(shelf->GetChildViewCount(), 0);
- EXPECT_EQ(shelf->GetPreferredSize().height(), 0);
-
- ASSERT_TRUE(LoadExtension(
- test_data_dir_.AppendASCII("good").AppendASCII("Extensions")
- .AppendASCII("behllobkkfkfnphdnhnkndlbkcpglgmj")
- .AppendASCII("1.0.0.0")));
-
- // There should now be two extension views and preferred height of the view
- // should be non-zero.
- EXPECT_EQ(shelf->GetChildViewCount(), 2);
- EXPECT_NE(shelf->GetPreferredSize().height(), 0);
-}
-#endif // defined(TOOLKIT_VIEWS)
-
// Tests that extension resources can be loaded from origins which the
// extension specifies in permissions but not from others.
IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, OriginPrivileges) {
@@ -700,7 +595,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, LastError) {
// Get the ExtensionHost that is hosting our toolstrip page.
ExtensionProcessManager* manager =
browser()->profile()->GetExtensionProcessManager();
- ExtensionHost* host = FindHostWithPath(manager, "/toolstrip.html", 1);
+ ExtensionHost* host = FindHostWithPath(manager, "/bg.html", 1);
bool result = false;
ui_test_utils::ExecuteJavaScriptAndExtractBool(
diff --git a/chrome/browser/extensions/extension_function_dispatcher.cc b/chrome/browser/extensions/extension_function_dispatcher.cc
index 8371346..a4c255a 100644
--- a/chrome/browser/extensions/extension_function_dispatcher.cc
+++ b/chrome/browser/extensions/extension_function_dispatcher.cc
@@ -44,7 +44,6 @@
#include "chrome/browser/extensions/extension_tabs_module.h"
#include "chrome/browser/extensions/extension_tabs_module_constants.h"
#include "chrome/browser/extensions/extension_test_api.h"
-#include "chrome/browser/extensions/extension_toolstrip_api.h"
#if defined(OS_CHROMEOS)
#include "chrome/browser/extensions/extension_tts_api.h"
#endif
@@ -183,10 +182,6 @@ void FactoryRegistry::ResetFunctions() {
// Idle
RegisterFunction<ExtensionIdleQueryStateFunction>();
- // Toolstrips.
- RegisterFunction<ToolstripExpandFunction>();
- RegisterFunction<ToolstripCollapseFunction>();
-
// I18N.
RegisterFunction<GetAcceptLanguagesFunction>();
@@ -400,8 +395,8 @@ Browser* ExtensionFunctionDispatcher::GetCurrentBrowser(
include_incognito);
// NOTE(rafaelw): This can return NULL in some circumstances. In particular,
- // a toolstrip or background_page onload chrome.tabs api call can make it
- // into here before the browser is sufficiently initialized to return here.
+ // a background_page onload chrome.tabs api call can make it into here
+ // before the browser is sufficiently initialized to return here.
// A similar situation may arise during shutdown.
// TODO(rafaelw): Delay creation of background_page until the browser
// is available. http://code.google.com/p/chromium/issues/detail?id=13284
diff --git a/chrome/browser/extensions/extension_host.cc b/chrome/browser/extensions/extension_host.cc
index 49e84ba..895fd2f 100644
--- a/chrome/browser/extensions/extension_host.cc
+++ b/chrome/browser/extensions/extension_host.cc
@@ -59,8 +59,6 @@ using WebKit::WebDragOperationsMask;
// static
bool ExtensionHost::enable_dom_automation_ = false;
-static const char* kToolstripTextColorSubstitution = "$TEXT_COLOR$";
-
// Helper class that rate-limits the creation of renderer processes for
// ExtensionHosts, to avoid blocking the UI.
class ExtensionHost::ProcessCreationQueue {
@@ -249,12 +247,6 @@ void ExtensionHost::Observe(NotificationType type,
DCHECK(extension_->GetBackgroundPageReady());
NavigateToURL(url_);
break;
- case NotificationType::BROWSER_THEME_CHANGED:
- if (extension_host_type_ == ViewType::EXTENSION_TOOLSTRIP ||
- extension_host_type_ == ViewType::EXTENSION_MOLE) {
- InsertThemedToolstripCSS();
- }
- break;
case NotificationType::RENDERER_PROCESS_CREATED:
LOG(INFO) << "Sending EXTENSION_PROCESS_CREATED";
NotificationService::current()->Notify(
@@ -325,8 +317,7 @@ void ExtensionHost::DidNavigate(RenderViewHost* render_view_host,
// In both cases, we preserve the old URL and reset the EFD to NULL. This
// will leave the host in kind of a bad state with poor UI and errors, but
// it's better than the alternative.
- // TODO(erikkay) Perhaps we should display log errors or display a big 404
- // in the toolstrip or something like that.
+ // TODO(erikkay) Perhaps we should display errors in developer mode.
if (params.url.host() != extension_->id()) {
extension_function_dispatcher_.reset(NULL);
return;
@@ -350,36 +341,6 @@ void ExtensionHost::InsertInfobarCSS() {
L"", css.as_string(), "InfobarThemeCSS");
}
-void ExtensionHost::InsertThemedToolstripCSS() {
- DCHECK(!is_background_page());
-
- static const base::StringPiece toolstrip_theme_css(
- ResourceBundle::GetSharedInstance().GetRawDataResource(
- IDR_EXTENSIONS_TOOLSTRIP_THEME_CSS));
-
- std::string css = toolstrip_theme_css.as_string();
- ThemeProvider* theme_provider =
- render_view_host()->process()->profile()->GetThemeProvider();
-
- SkColor text_color = theme_provider ?
- theme_provider->GetColor(BrowserThemeProvider::COLOR_BOOKMARK_TEXT) :
- SK_ColorBLACK;
-
- std::string hex_color_string = StringPrintf(
- "#%02x%02x%02x", SkColorGetR(text_color),
- SkColorGetG(text_color),
- SkColorGetB(text_color));
- size_t pos = css.find(kToolstripTextColorSubstitution);
- while (pos != std::string::npos) {
- css.replace(pos, 12, hex_color_string);
- pos = css.find(kToolstripTextColorSubstitution);
- }
-
- // 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");
-}
-
void ExtensionHost::DisableScrollbarsForSmallWindows(
const gfx::Size& size_limit) {
render_view_host()->Send(new ViewMsg_DisableScrollbarsForSmallWindows(
@@ -389,9 +350,7 @@ void ExtensionHost::DisableScrollbarsForSmallWindows(
void ExtensionHost::DidStopLoading() {
bool notify = !did_stop_loading_;
did_stop_loading_ = true;
- if (extension_host_type_ == ViewType::EXTENSION_TOOLSTRIP ||
- extension_host_type_ == ViewType::EXTENSION_MOLE ||
- extension_host_type_ == ViewType::EXTENSION_POPUP ||
+ if (extension_host_type_ == ViewType::EXTENSION_POPUP ||
extension_host_type_ == ViewType::EXTENSION_INFOBAR) {
#if defined(TOOLKIT_VIEWS)
if (view_.get())
@@ -410,9 +369,6 @@ void ExtensionHost::DidStopLoading() {
} else if (extension_host_type_ == ViewType::EXTENSION_POPUP) {
UMA_HISTOGRAM_TIMES("Extensions.PopupLoadTime",
since_created_.Elapsed());
- } else if (extension_host_type_ == ViewType::EXTENSION_TOOLSTRIP) {
- UMA_HISTOGRAM_TIMES("Extensions.ToolstripLoadTime",
- since_created_.Elapsed());
} else if (extension_host_type_ == ViewType::EXTENSION_INFOBAR) {
UMA_HISTOGRAM_TIMES("Extensions.InfobarLoadTime",
since_created_.Elapsed());
@@ -434,15 +390,6 @@ void ExtensionHost::DocumentAvailableInMainFrame(RenderViewHost* rvh) {
case ViewType::EXTENSION_INFOBAR:
InsertInfobarCSS();
break;
- case ViewType::EXTENSION_TOOLSTRIP:
- case ViewType::EXTENSION_MOLE:
- // See also BROWSER_THEME_CHANGED in the Observe function.
- InsertThemedToolstripCSS();
-
- // Listen for browser changes so we can resend the CSS.
- registrar_.Add(this, NotificationType::BROWSER_THEME_CHANGED,
- NotificationService::AllSources());
- break;
default:
break; // No style sheet for other types, at the moment.
}
@@ -702,14 +649,6 @@ void ExtensionHost::HandleMouseLeave() {
#endif
}
-void ExtensionHost::SetRenderViewType(ViewType::Type type) {
- DCHECK(type == ViewType::EXTENSION_MOLE ||
- type == ViewType::EXTENSION_TOOLSTRIP ||
- type == ViewType::EXTENSION_POPUP);
- extension_host_type_ = type;
- render_view_host()->ViewTypeChanged(extension_host_type_);
-}
-
ViewType::Type ExtensionHost::GetRenderViewType() const {
return extension_host_type_;
}
@@ -727,9 +666,7 @@ void ExtensionHost::RenderViewCreated(RenderViewHost* render_view_host) {
extension_function_dispatcher_.reset(
ExtensionFunctionDispatcher::Create(render_view_host, this, url_));
- if (extension_host_type_ == ViewType::EXTENSION_TOOLSTRIP ||
- extension_host_type_ == ViewType::EXTENSION_MOLE ||
- extension_host_type_ == ViewType::EXTENSION_POPUP ||
+ if (extension_host_type_ == ViewType::EXTENSION_POPUP ||
extension_host_type_ == ViewType::EXTENSION_INFOBAR) {
render_view_host->EnablePreferredSizeChangedMode(
kPreferredSizeWidth | kPreferredSizeHeightThisIsSlow);
@@ -740,9 +677,7 @@ int ExtensionHost::GetBrowserWindowID() const {
// Hosts not attached to any browser window have an id of -1. This includes
// those mentioned below, and background pages.
int window_id = extension_misc::kUnknownWindowId;
- if (extension_host_type_ == ViewType::EXTENSION_TOOLSTRIP ||
- extension_host_type_ == ViewType::EXTENSION_MOLE ||
- extension_host_type_ == ViewType::EXTENSION_POPUP ||
+ if (extension_host_type_ == ViewType::EXTENSION_POPUP ||
extension_host_type_ == ViewType::EXTENSION_INFOBAR) {
// If the host is bound to a browser, then extract its window id.
// Extensions hosted in ExternalTabContainer objects may not have
diff --git a/chrome/browser/extensions/extension_host.h b/chrome/browser/extensions/extension_host.h
index 253c4f4..7d293db 100644
--- a/chrome/browser/extensions/extension_host.h
+++ b/chrome/browser/extensions/extension_host.h
@@ -92,9 +92,6 @@ class ExtensionHost : public RenderViewHostDelegate,
associated_tab_contents_ = associated_tab_contents;
}
- // 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;
@@ -109,9 +106,6 @@ class ExtensionHost : public RenderViewHostDelegate,
// Insert a default style sheet for Extension Infobars.
void InsertInfobarCSS();
- // Insert the theme CSS for a toolstrip/mole.
- void InsertThemedToolstripCSS();
-
// Tell the renderer not to draw scrollbars on windows smaller than
// |size_limit| in both width and height.
void DisableScrollbarsForSmallWindows(const gfx::Size& size_limit);
@@ -267,7 +261,7 @@ class ExtensionHost : public RenderViewHostDelegate,
scoped_ptr<ExtensionFunctionDispatcher> extension_function_dispatcher_;
- // Only EXTENSION_TOOLSTRIP, EXTENSION_POPUP, and EXTENSION_BACKGROUND_PAGE
+ // Only EXTENSION_INFOBAR, EXTENSION_POPUP, and EXTENSION_BACKGROUND_PAGE
// are used here, others are not hosted by ExtensionHost.
ViewType::Type extension_host_type_;
diff --git a/chrome/browser/extensions/extension_popup_api.cc b/chrome/browser/extensions/extension_popup_api.cc
index 1d3c3c7..855dfa1 100644
--- a/chrome/browser/extensions/extension_popup_api.cc
+++ b/chrome/browser/extensions/extension_popup_api.cc
@@ -45,7 +45,7 @@ const char kBadAnchorArgument[] = "Invalid anchor argument.";
const char kInvalidURLError[] = "Invalid URL.";
const char kNotAnExtension[] = "Not an extension view.";
const char kPopupsDisallowed[] =
- "Popups are only supported from toolstrip or tab-contents views.";
+ "Popups are only supported from tab-contents views.";
// Keys.
const wchar_t kUrlKey[] = L"url";
@@ -356,12 +356,10 @@ void PopupShowFunction::Run() {
}
bool PopupShowFunction::RunImpl() {
- // Popups may only be displayed from TAB_CONTENTS and EXTENSION_TOOLSTRIP
- // views.
+ // Popups may only be displayed from TAB_CONTENTS.
ViewType::Type view_type =
dispatcher()->render_view_host()->delegate()->GetRenderViewType();
- if (ViewType::EXTENSION_TOOLSTRIP != view_type &&
- ViewType::TAB_CONTENTS != view_type) {
+ if (ViewType::TAB_CONTENTS != view_type) {
error_ = kPopupsDisallowed;
return false;
}
@@ -444,11 +442,7 @@ bool PopupShowFunction::RunImpl() {
window = GetCurrentBrowser()->window()->GetNativeHandle();
#if defined(TOOLKIT_VIEWS)
- // Pop-up from extension views (ExtensionShelf, etc.), and drop-down when
- // in a TabContents view.
- BubbleBorder::ArrowLocation arrow_location =
- view_type == ViewType::TAB_CONTENTS ?
- BubbleBorder::TOP_LEFT : BubbleBorder::BOTTOM_LEFT;
+ BubbleBorder::ArrowLocation arrow_location = BubbleBorder::TOP_LEFT;
// ExtensionPopupHost manages it's own lifetime.
ExtensionPopupHost* popup_host = new ExtensionPopupHost(dispatcher());
@@ -468,6 +462,7 @@ bool PopupShowFunction::RunImpl() {
popup_->set_close_on_lost_focus(false);
popup_host->set_popup(popup_);
#endif // defined(TOOLKIT_VIEWS)
+
return true;
}
diff --git a/chrome/browser/extensions/extension_popup_apitest.cc b/chrome/browser/extensions/extension_popup_apitest.cc
index ba6a082..0d71219 100644
--- a/chrome/browser/extensions/extension_popup_apitest.cc
+++ b/chrome/browser/extensions/extension_popup_apitest.cc
@@ -13,11 +13,10 @@
#define MAYBE_Popup Popup
#endif
-IN_PROC_BROWSER_TEST_F(ExtensionApiTest, MAYBE_Popup) {
+// Disabled for some rewriting. http://crbug.com/51821
+IN_PROC_BROWSER_TEST_F(ExtensionApiTest, DISABLED_Popup) {
CommandLine::ForCurrentProcess()->AppendSwitch(
switches::kEnableExperimentalExtensionApis);
- CommandLine::ForCurrentProcess()->AppendSwitch(
- switches::kEnableExtensionToolstrips);
ASSERT_TRUE(RunExtensionTest("popup")) << message_;
}
diff --git a/chrome/browser/extensions/extension_prefs.cc b/chrome/browser/extensions/extension_prefs.cc
index e987065..c33ea33 100644
--- a/chrome/browser/extensions/extension_prefs.cc
+++ b/chrome/browser/extensions/extension_prefs.cc
@@ -41,10 +41,6 @@ const char kPrefBlacklist[] = "blacklist";
// Indicates whether to show an install warning when the user enables.
const char kExtensionDidEscalatePermissions[] = "install_warning_on_enable";
-// A preference that tracks extension shelf configuration. This is a list
-// object read from the Preferences file, containing a list of toolstrip URLs.
-const char kExtensionShelf[] = "extensions.shelf";
-
// A preference that tracks admin policy regarding which extensions the user
// can and can not install. This preference is a list object, containing
// strings that list extension ids. Denylist can contain "*" meaning all
@@ -438,29 +434,6 @@ void ExtensionPrefs::GetKilledExtensionIds(std::set<std::string>* killed_ids) {
}
}
-ExtensionPrefs::URLList ExtensionPrefs::GetShelfToolstripOrder() {
- URLList urls;
- const ListValue* toolstrip_urls = prefs_->GetList(kExtensionShelf);
- if (toolstrip_urls) {
- for (size_t i = 0; i < toolstrip_urls->GetSize(); ++i) {
- std::string url;
- if (toolstrip_urls->GetString(i, &url))
- urls.push_back(GURL(url));
- }
- }
- return urls;
-}
-
-void ExtensionPrefs::SetShelfToolstripOrder(const URLList& urls) {
- ListValue* toolstrip_urls = prefs_->GetMutableList(kExtensionShelf);
- toolstrip_urls->Clear();
- for (size_t i = 0; i < urls.size(); ++i) {
- GURL url = urls[i];
- toolstrip_urls->Append(new StringValue(url.spec()));
- }
- prefs_->ScheduleSavePersistentPrefs();
-}
-
std::vector<std::string> ExtensionPrefs::GetToolbarOrder() {
std::vector<std::string> extension_ids;
const ListValue* toolbar_order = prefs_->GetList(kExtensionToolbar);
@@ -821,7 +794,6 @@ std::set<std::string> ExtensionPrefs::GetIdleInstallInfoIds() {
// static
void ExtensionPrefs::RegisterUserPrefs(PrefService* prefs) {
prefs->RegisterDictionaryPref(kExtensionsPref);
- prefs->RegisterListPref(kExtensionShelf);
prefs->RegisterListPref(kExtensionToolbar);
prefs->RegisterIntegerPref(prefs::kExtensionToolbarSize, -1);
prefs->RegisterDictionaryPref(kExtensionsBlacklistUpdate);
diff --git a/chrome/browser/extensions/extension_process_manager.cc b/chrome/browser/extensions/extension_process_manager.cc
index 3cde54e..49205cd 100644
--- a/chrome/browser/extensions/extension_process_manager.cc
+++ b/chrome/browser/extensions/extension_process_manager.cc
@@ -94,17 +94,6 @@ ExtensionHost* ExtensionProcessManager::CreateView(const GURL& url,
return NULL;
}
-ExtensionHost* ExtensionProcessManager::CreateToolstrip(Extension* extension,
- const GURL& url,
- Browser* browser) {
- return CreateView(extension, url, browser, ViewType::EXTENSION_TOOLSTRIP);
-}
-
-ExtensionHost* ExtensionProcessManager::CreateToolstrip(const GURL& url,
- Browser* browser) {
- return CreateView(url, browser, ViewType::EXTENSION_TOOLSTRIP);
-}
-
ExtensionHost* ExtensionProcessManager::CreatePopup(Extension* extension,
const GURL& url,
Browser* browser) {
diff --git a/chrome/browser/extensions/extension_process_manager.h b/chrome/browser/extensions/extension_process_manager.h
index 13b98142..f0c2927 100644
--- a/chrome/browser/extensions/extension_process_manager.h
+++ b/chrome/browser/extensions/extension_process_manager.h
@@ -40,10 +40,6 @@ class ExtensionProcessManager : public NotificationObserver {
ExtensionHost* CreateView(const GURL& url,
Browser* browser,
ViewType::Type view_type);
- ExtensionHost* CreateToolstrip(Extension* extension,
- const GURL& url,
- Browser* browser);
- ExtensionHost* CreateToolstrip(const GURL& url, Browser* browser);
ExtensionHost* CreatePopup(Extension* extension,
const GURL& url,
Browser* browser);
diff --git a/chrome/browser/extensions/extension_shelf_model.cc b/chrome/browser/extensions/extension_shelf_model.cc
deleted file mode 100644
index 51a8ce1..0000000
--- a/chrome/browser/extensions/extension_shelf_model.cc
+++ /dev/null
@@ -1,282 +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/extensions/extension_shelf_model.h"
-
-#include "base/stl_util-inl.h"
-#include "chrome/browser/browser.h"
-#include "chrome/browser/profile.h"
-#include "chrome/browser/extensions/extension_host.h"
-#include "chrome/browser/extensions/extension_process_manager.h"
-#include "chrome/browser/extensions/extension_toolstrip_api.h"
-#include "chrome/browser/extensions/extensions_service.h"
-#include "chrome/browser/renderer_host/render_view_host.h"
-#include "chrome/common/extensions/extension.h"
-#include "chrome/common/notification_service.h"
-
-ExtensionShelfModel::ExtensionShelfModel(Browser* browser)
- : browser_(browser), ready_(false) {
- // Watch extensions loaded and unloaded notifications.
- registrar_.Add(this, NotificationType::EXTENSION_UNLOADED,
- NotificationService::AllSources());
- registrar_.Add(this, NotificationType::EXTENSION_LOADED,
- NotificationService::AllSources());
- registrar_.Add(this, NotificationType::EXTENSIONS_READY,
- NotificationService::AllSources());
-
- // Add any already-loaded extensions now, since we missed the notification for
- // those.
- ExtensionsService* service = browser_->profile()->GetExtensionsService();
- if (service) { // This can be null in unit tests.
- prefs_ = browser_->profile()->GetExtensionsService()->extension_prefs();
- registrar_.Add(this, NotificationType::EXTENSION_SHELF_MODEL_CHANGED,
- Source<ExtensionPrefs>(prefs_));
- ready_ = service->is_ready();
- if (ready_) {
- AddExtensions(service->extensions());
- SortToolstrips();
- }
- }
-}
-
-ExtensionShelfModel::~ExtensionShelfModel() {
- FOR_EACH_OBSERVER(ExtensionShelfModelObserver, observers_,
- ShelfModelDeleting());
-
- observers_.Clear();
-
- for (iterator t = toolstrips_.begin(); t != toolstrips_.end(); ++t)
- delete t->host;
- toolstrips_.clear();
-}
-
-void ExtensionShelfModel::AddObserver(ExtensionShelfModelObserver* observer) {
- observers_.AddObserver(observer);
-}
-
-void ExtensionShelfModel::RemoveObserver(
- ExtensionShelfModelObserver* observer) {
- observers_.RemoveObserver(observer);
-}
-
-void ExtensionShelfModel::AppendToolstrip(const ToolstripItem& toolstrip) {
- InsertToolstripAt(count(), toolstrip);
-}
-
-void ExtensionShelfModel::InsertToolstripAt(int index,
- const ToolstripItem& toolstrip) {
- toolstrips_.insert(toolstrips_.begin() + index, toolstrip);
- if (ready_) {
- FOR_EACH_OBSERVER(ExtensionShelfModelObserver, observers_,
- ToolstripInsertedAt(toolstrip.host, index));
- }
-}
-
-void ExtensionShelfModel::RemoveToolstripAt(int index) {
- ExtensionHost* host = ToolstripAt(index).host;
- FOR_EACH_OBSERVER(ExtensionShelfModelObserver, observers_,
- ToolstripRemovingAt(host, index));
- toolstrips_.erase(toolstrips_.begin() + index);
- delete host;
-}
-
-void ExtensionShelfModel::MoveToolstripAt(int index, int to_index) {
- DCHECK(index >= 0);
- DCHECK(to_index >= 0);
- if (index == to_index)
- return;
-
- ToolstripItem toolstrip = toolstrips_[index];
- toolstrips_.erase(toolstrips_.begin() + index);
- toolstrips_.insert(toolstrips_.begin() + to_index, toolstrip);
-
- FOR_EACH_OBSERVER(ExtensionShelfModelObserver, observers_,
- ToolstripMoved(toolstrip.host, index, to_index));
-
- UpdatePrefs();
-}
-
-int ExtensionShelfModel::IndexOfHost(ExtensionHost* host) {
- for (iterator i = toolstrips_.begin(); i != toolstrips_.end(); ++i) {
- if (i->host == host)
- return i - toolstrips_.begin();
- }
- return -1;
-}
-
-ExtensionShelfModel::iterator ExtensionShelfModel::ToolstripForHost(
- ExtensionHost* host) {
- for (iterator i = toolstrips_.begin(); i != toolstrips_.end(); ++i) {
- if (i->host == host)
- return i;
- }
- return toolstrips_.end();
-}
-
-const ExtensionShelfModel::ToolstripItem& ExtensionShelfModel::ToolstripAt(
- int index) {
- DCHECK(index >= 0);
- return toolstrips_[index];
-}
-
-void ExtensionShelfModel::SetToolstripDataAt(int index, void* data) {
- DCHECK(index >= 0);
- toolstrips_[index].data = data;
-}
-
-void ExtensionShelfModel::ExpandToolstrip(iterator toolstrip,
- const GURL& url, int height) {
- if (toolstrip == end())
- return;
- toolstrip->height = height;
- toolstrip->url = url;
- FOR_EACH_OBSERVER(ExtensionShelfModelObserver, observers_,
- ToolstripChanged(toolstrip));
- int routing_id = toolstrip->host->render_view_host()->routing_id();
- ToolstripEventRouter::OnToolstripExpanded(browser_->profile(),
- routing_id,
- url, height);
- toolstrip->host->SetRenderViewType(ViewType::EXTENSION_MOLE);
-}
-
-void ExtensionShelfModel::CollapseToolstrip(iterator toolstrip,
- const GURL& url) {
- if (toolstrip == end())
- return;
- toolstrip->height = 0;
- toolstrip->url = url;
- FOR_EACH_OBSERVER(ExtensionShelfModelObserver, observers_,
- ToolstripChanged(toolstrip));
- int routing_id = toolstrip->host->render_view_host()->routing_id();
- ToolstripEventRouter::OnToolstripCollapsed(browser_->profile(),
- routing_id,
- url);
- toolstrip->host->SetRenderViewType(ViewType::EXTENSION_TOOLSTRIP);
-}
-
-void ExtensionShelfModel::Observe(NotificationType type,
- const NotificationSource& source,
- const NotificationDetails& details) {
- switch (type.value) {
- case NotificationType::EXTENSION_LOADED:
- if (ready_)
- AddExtension(Details<Extension>(details).ptr());
- break;
- case NotificationType::EXTENSION_UNLOADED:
- RemoveExtension(Details<Extension>(details).ptr());
- break;
- case NotificationType::EXTENSIONS_READY:
- if (browser_->profile()->GetExtensionsService()) {
- AddExtensions(
- browser_->profile()->GetExtensionsService()->extensions());
- SortToolstrips();
- }
- ready_ = true;
- break;
- case NotificationType::EXTENSION_SHELF_MODEL_CHANGED:
- // Ignore changes that this model originated.
- if (Details<ExtensionShelfModel>(details).ptr() != this)
- SortToolstrips();
- break;
- default:
- DCHECK(false) << "Unhandled notification of type: " << type.value;
- break;
- }
-}
-
-void ExtensionShelfModel::AddExtension(Extension* extension) {
- ExtensionProcessManager* manager =
- browser_->profile()->GetExtensionProcessManager();
- DCHECK(manager);
- if (!manager)
- return;
-
- for (std::vector<Extension::ToolstripInfo>::const_iterator toolstrip =
- extension->toolstrips().begin();
- toolstrip != extension->toolstrips().end(); ++toolstrip) {
- GURL url = toolstrip->toolstrip;
- ToolstripItem item;
- item.host = manager->CreateToolstrip(extension, url, browser_);
- item.info = *toolstrip;
- item.data = NULL;
- item.height = 0;
- AppendToolstrip(item);
- }
-}
-
-void ExtensionShelfModel::AddExtensions(const ExtensionList* extensions) {
- if (extensions->size()) {
- ExtensionList::const_iterator extension = extensions->begin();
- for (; extension != extensions->end(); ++extension)
- AddExtension(*extension);
- }
-}
-
-void ExtensionShelfModel::RemoveExtension(Extension* extension) {
- bool changed = false;
- for (int i = count() - 1; i >= 0; --i) {
- ExtensionHost* t = ToolstripAt(i).host;
- if (t->extension()->id() == extension->id()) {
- changed = true;
- RemoveToolstripAt(i);
-
- // There can be more than one toolstrip per extension, so we have to keep
- // looping even after finding a match.
- }
- }
- if (changed)
- UpdatePrefs();
-}
-
-void ExtensionShelfModel::UpdatePrefs() {
- if (!prefs_)
- return;
-
- // It's easiest to just rebuild the list each time.
- ExtensionPrefs::URLList urls;
- for (int i = 0; i < count(); ++i)
- urls.push_back(ToolstripAt(i).host->GetURL());
- prefs_->SetShelfToolstripOrder(urls);
-
- NotificationService::current()->Notify(
- NotificationType::EXTENSION_SHELF_MODEL_CHANGED,
- Source<ExtensionPrefs>(prefs_),
- Details<ExtensionShelfModel>(this));
-}
-
-void ExtensionShelfModel::SortToolstrips() {
- ExtensionPrefs::URLList urls = prefs_->GetShelfToolstripOrder();
- ToolstripList copy =
- ToolstripList(toolstrips_.begin(), toolstrips_.end());
- toolstrips_.clear();
-
- // Go through the urls and find the matching toolstrip, re-adding it to the
- // new list in the proper order.
- for (size_t i = 0; i < urls.size(); ++i) {
- GURL& url = urls[i];
- for (iterator toolstrip = copy.begin();
- toolstrip != copy.end(); ++toolstrip) {
- if (url == toolstrip->host->GetURL()) {
- // Note that it's technically possible for the same URL to appear in
- // multiple toolstrips, so we don't do any testing for uniqueness.
- toolstrips_.push_back(*toolstrip);
-
- // Remove the toolstrip from the list so we don't have to iterate over
- // it next time.
- copy.erase(toolstrip);
- break;
- }
- }
- }
-
- // Any toolstrips remaining in |copy| were somehow missing from the prefs,
- // so just append them to the end.
- for (iterator toolstrip = copy.begin();
- toolstrip != copy.end(); ++toolstrip) {
- toolstrips_.push_back(*toolstrip);
- }
-
- FOR_EACH_OBSERVER(ExtensionShelfModelObserver, observers_,
- ShelfModelReloaded());
-}
diff --git a/chrome/browser/extensions/extension_shelf_model.h b/chrome/browser/extensions/extension_shelf_model.h
deleted file mode 100644
index c2261c5..0000000
--- a/chrome/browser/extensions/extension_shelf_model.h
+++ /dev/null
@@ -1,168 +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_EXTENSIONS_EXTENSION_SHELF_MODEL_H_
-#define CHROME_BROWSER_EXTENSIONS_EXTENSION_SHELF_MODEL_H_
-#pragma once
-
-#include <vector>
-
-#include "base/basictypes.h"
-#include "base/observer_list.h"
-#include "chrome/browser/extensions/extension_host.h"
-#include "chrome/common/extensions/extension.h"
-#include "chrome/common/notification_observer.h"
-#include "chrome/common/notification_registrar.h"
-
-class Browser;
-class ExtensionPrefs;
-class ExtensionShelfModelObserver;
-
-// The model representing the toolstrips on an ExtensionShelf. The order of
-// the toolstrips is common across all of the models for a given Profile,
-// but there are multiple models. Each model contains the hosts/views which
-// are specific to a Browser.
-class ExtensionShelfModel : public NotificationObserver {
- public:
- explicit ExtensionShelfModel(Browser* browser);
- virtual ~ExtensionShelfModel();
-
- struct ToolstripItem {
- ExtensionHost* host;
- Extension::ToolstripInfo info;
- void* data;
- int height;
- GURL url;
- };
-
- typedef std::vector<ToolstripItem> ToolstripList;
- typedef ToolstripList::iterator iterator;
-
- // Add and remove observers to changes within this ExtensionShelfModel.
- void AddObserver(ExtensionShelfModelObserver* observer);
- void RemoveObserver(ExtensionShelfModelObserver* observer);
-
- // The number of toolstrips in the model.
- int count() const { return static_cast<int>(toolstrips_.size()); }
- bool empty() const { return toolstrips_.empty(); }
-
- // Iterators for the toolstrips in the model.
- iterator begin() { return toolstrips_.begin(); }
- ExtensionShelfModel::iterator end() { return toolstrips_.end(); }
-
- // Add |toolstrip| to the end of the shelf.
- void AppendToolstrip(const ToolstripItem& toolstrip);
-
- // Insert |toolstrip| and |data| at |index|.
- void InsertToolstripAt(int index, const ToolstripItem& toolstrip);
-
- // Remove the toolstrip at |index|.
- void RemoveToolstripAt(int index);
-
- // Move the toolstrip at |index| to |to_index|.
- void MoveToolstripAt(int index, int to_index);
-
- // Lookup the index of |host|. Returns -1 if not present.
- int IndexOfHost(ExtensionHost* host);
-
- // Return the toolstrip at |index|.
- const ToolstripItem& ToolstripAt(int index);
-
- // Return the ToolstripItem associated with |host| or NULL if it's not
- // present.
- ToolstripList::iterator ToolstripForHost(ExtensionHost* host);
-
- // Set some arbitrary data associated with a particular toolstrip.
- void SetToolstripDataAt(int index, void* data);
-
- // Update the ToolstripItem for |toolstrip| to set its |url| and |height|
- // and then call ToolstripChanged for all observers.
- // If |url| is empty, no navigation is requested.
- void ExpandToolstrip(iterator toolstrip, const GURL& url, int height);
-
- // Update the ToolstripItem for |toolstrip| to set its |url| and its height
- // to 0, and then call ToolstripChanged for all observers.
- // If |url| is empty, no navigation is requested.
- void CollapseToolstrip(iterator toolstrip, const GURL& url);
-
- // NotificationObserver
- virtual void Observe(NotificationType type,
- const NotificationSource& source,
- const NotificationDetails& details);
-
- private:
- // Add all of the toolstrips from |extension|.
- void AddExtension(Extension* extension);
-
- // Add all of the toolstrips from each extension in |extensions|.
- void AddExtensions(const ExtensionList* extensions);
-
- // Remove all of the toolstrips in |extension| from the shelf.
- void RemoveExtension(Extension* extension);
-
- // Update prefs with the most recent changes.
- void UpdatePrefs();
-
- // Reloads order from prefs.
- void SortToolstrips();
-
- // The browser that this model is attached to.
- Browser* browser_;
-
- // The preferences that this model uses.
- ExtensionPrefs* prefs_;
-
- // Manages our notification registrations.
- NotificationRegistrar registrar_;
-
- // The Toolstrips loaded in this model. The model owns these objects.
- ToolstripList toolstrips_;
-
- // Our observers.
- typedef ObserverList<ExtensionShelfModelObserver>
- ExtensionShelfModelObservers;
- ExtensionShelfModelObservers observers_;
-
- // Whether the model has received an EXTENSIONS_READY notification.
- bool ready_;
-
- DISALLOW_COPY_AND_ASSIGN(ExtensionShelfModel);
-};
-
-// Objects implement this interface when they wish to be notified of changes to
-// the ExtensionShelfModel.
-//
-// Register your ExtensionShelfModelObserver with the ExtensionShelfModel using
-// Add/RemoveObserver methods.
-class ExtensionShelfModelObserver {
- public:
- // A new toolstrip was inserted into ExtensionShelfModel at |index|.
- virtual void ToolstripInsertedAt(ExtensionHost* toolstrip, int index) {}
-
- // The specified toolstrip is being removed and destroyed.
- virtual void ToolstripRemovingAt(ExtensionHost* toolstrip, int index) {}
-
- // |toolstrip| moved from |from_index| to |to_index|.
- virtual void ToolstripMoved(ExtensionHost* toolstrip,
- int from_index,
- int to_index) {}
-
- // The specified toolstrip changed in some way (currently only size changes)
- virtual void ToolstripChanged(ExtensionShelfModel::iterator toolstrip) {}
-
- // There are no more toolstrips in the model.
- virtual void ExtensionShelfEmpty() {}
-
- // The entire model may have changed.
- virtual void ShelfModelReloaded() {}
-
- // The model is being destroyed.
- virtual void ShelfModelDeleting() {}
-
- protected:
- virtual ~ExtensionShelfModelObserver() {}
-};
-
-
-#endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SHELF_MODEL_H_
diff --git a/chrome/browser/extensions/extension_shelf_model_browsertest.cc b/chrome/browser/extensions/extension_shelf_model_browsertest.cc
deleted file mode 100644
index abb2a93..0000000
--- a/chrome/browser/extensions/extension_shelf_model_browsertest.cc
+++ /dev/null
@@ -1,97 +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/browser.h"
-#include "chrome/browser/extensions/extension_browsertest.h"
-#include "chrome/browser/extensions/extension_error_reporter.h"
-#include "chrome/browser/extensions/extension_host.h"
-#include "chrome/browser/extensions/extension_shelf_model.h"
-#include "chrome/browser/extensions/extensions_service.h"
-#include "chrome/browser/profile.h"
-#include "chrome/browser/views/extensions/extension_shelf.h"
-#include "chrome/browser/views/frame/browser_view.h"
-#include "chrome/common/chrome_paths.h"
-#include "chrome/common/chrome_switches.h"
-#include "chrome/test/in_process_browser_test.h"
-
-namespace {
-
-// The extension we're using as our test case.
-const char* kExtensionId = "behllobkkfkfnphdnhnkndlbkcpglgmj";
-
-}; // namespace
-
-
-// An InProcessBrowserTest for testing the ExtensionShelfModel.
-// TODO(erikkay) It's unfortunate that this needs to be an in-proc browser test.
-// It would be nice to refactor things so that ExtensionShelfModel,
-// ExtensionHost and ExtensionsService could run without so much of the browser
-// in place.
-class ExtensionShelfModelTest : public ExtensionBrowserTest,
- public ExtensionShelfModelObserver {
- public:
- virtual void SetUp() {
- inserted_count_ = 0;
- removed_count_ = 0;
- moved_count_ = 0;
- InProcessBrowserTest::SetUp();
- }
-
- virtual Browser* CreateBrowser(Profile* profile) {
- Browser* b = InProcessBrowserTest::CreateBrowser(profile);
- BrowserView* browser_view = static_cast<BrowserView*>(b->window());
- model_ = browser_view->extension_shelf()->model();
- model_->AddObserver(this);
- return b;
- }
-
- virtual void CleanUpOnMainThread() {
- model_->RemoveObserver(this);
- }
-
- virtual void ToolstripInsertedAt(ExtensionHost* toolstrip, int index) {
- inserted_count_++;
- }
-
- virtual void ToolstripRemovingAt(ExtensionHost* toolstrip, int index) {
- removed_count_++;
- }
-
- virtual void ToolstripMoved(ExtensionHost* toolstrip,
- int from_index,
- int to_index) {
- moved_count_++;
- }
-
- protected:
- ExtensionShelfModel* model_;
-
- int inserted_count_;
- int removed_count_;
- int moved_count_;
-};
-
-IN_PROC_BROWSER_TEST_F(ExtensionShelfModelTest, Basic) {
- ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("good")
- .AppendASCII("Extensions")
- .AppendASCII(kExtensionId)
- .AppendASCII("1.0.0.0")));
-
- // extension1 has two toolstrips
- EXPECT_EQ(inserted_count_, 2);
- ExtensionHost* one = model_->ToolstripAt(0).host;
- ExtensionHost* two = model_->ToolstripAt(1).host;
- EXPECT_EQ(one->GetURL().path(), "/toolstrip1.html");
- EXPECT_EQ(two->GetURL().path(), "/toolstrip2.html");
-
- model_->MoveToolstripAt(0, 1);
- EXPECT_EQ(two, model_->ToolstripAt(0).host);
- EXPECT_EQ(one, model_->ToolstripAt(1).host);
- EXPECT_EQ(moved_count_, 1);
-
- model_->RemoveToolstripAt(0);
- EXPECT_EQ(one, model_->ToolstripAt(0).host);
- EXPECT_EQ(1, model_->count());
- EXPECT_EQ(removed_count_, 1);
-}
diff --git a/chrome/browser/extensions/extension_toolstrip_api.cc b/chrome/browser/extensions/extension_toolstrip_api.cc
deleted file mode 100644
index 26618e0..0000000
--- a/chrome/browser/extensions/extension_toolstrip_api.cc
+++ /dev/null
@@ -1,176 +0,0 @@
-// Copyright (c) 2010 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/extensions/extension_toolstrip_api.h"
-
-#include "base/json/json_writer.h"
-#include "base/string_util.h"
-#include "chrome/browser/browser.h"
-#include "chrome/browser/extensions/extension_host.h"
-#include "chrome/browser/extensions/extension_message_service.h"
-#include "chrome/browser/extensions/extension_shelf_model.h"
-#include "chrome/browser/extensions/extension_tabs_module_constants.h"
-#include "chrome/browser/profile.h"
-#include "chrome/browser/renderer_host/render_view_host.h"
-
-namespace extension_toolstrip_api_events {
-const char kOnToolstripExpanded[] = "toolstrip.onExpanded.%d";
-const char kOnToolstripCollapsed[] = "toolstrip.onCollapsed.%d";
-}; // namespace extension_toolstrip_api_events
-
-namespace {
-// Errors.
-const char kNotAToolstripError[] = "This page is not a toolstrip.";
-const char kAlreadyExpandedError[] = "This toolstrip is already expanded.";
-const char kAlreadyCollapsedError[] = "This toolstrip is already collapsed.";
-const char kInvalidURLError[] = "Invalid URL";
-const char kBadHeightError[] = "Bad height.";
-
-// TODO(erikkay) what are good values here?
-const int kMinHeight = 50;
-const int kMaxHeight = 1000;
-}; // namespace
-
-namespace keys = extension_tabs_module_constants;
-namespace events = extension_toolstrip_api_events;
-
-bool ToolstripFunction::RunImpl() {
- ViewType::Type view_type =
- dispatcher()->render_view_host()->delegate()->GetRenderViewType();
- if (view_type != ViewType::EXTENSION_TOOLSTRIP &&
- view_type != ViewType::EXTENSION_MOLE) {
- error_ = kNotAToolstripError;
- return false;
- }
-
- Browser* browser = GetCurrentBrowser();
- if (!browser) {
- error_ = kNotAToolstripError;
- return false;
- }
-
- model_ = browser->extension_shelf_model();
- if (!model_) {
- error_ = kNotAToolstripError;
- return false;
- }
-
- // Since this is an EXTENSION_TOOLSTRIP or EXTESION_MOLE view type, we know
- // the delegate must be an ExtensionHost.
- ExtensionHost* host =
- static_cast<ExtensionHost*>(dispatcher()->delegate());
- toolstrip_ = model_->ToolstripForHost(host);
- if (toolstrip_ == model_->end()) {
- error_ = kNotAToolstripError;
- return false;
- }
-
- return true;
-}
-
-bool ToolstripExpandFunction::RunImpl() {
- if (!ToolstripFunction::RunImpl())
- return false;
- if (toolstrip_->height != 0) {
- error_ = kAlreadyExpandedError;
- return false;
- }
-
- DictionaryValue* args;
- EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(0, &args));
-
- int height;
- EXTENSION_FUNCTION_VALIDATE(args->GetInteger(keys::kHeightKey,
- &height));
- EXTENSION_FUNCTION_VALIDATE(height >= 0);
- if (height < kMinHeight || height > kMaxHeight) {
- error_ = kBadHeightError;
- return false;
- }
-
- GURL url;
- if (args->HasKey(keys::kUrlKey)) {
- std::string url_string;
- EXTENSION_FUNCTION_VALIDATE(args->GetString(keys::kUrlKey,
- &url_string));
- url = dispatcher()->url().Resolve(url_string);
- if (!url.is_valid()) {
- error_ = kInvalidURLError;
- return false;
- }
- }
-
- model_->ExpandToolstrip(toolstrip_, url, height);
- return true;
-}
-
-bool ToolstripCollapseFunction::RunImpl() {
- if (!ToolstripFunction::RunImpl())
- return false;
-
- if (toolstrip_->height == 0) {
- error_ = kAlreadyCollapsedError;
- return false;
- }
-
- GURL url;
- if (HasOptionalArgument(0)) {
- DictionaryValue* args;
- EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(0, &args));
-
- if (args->HasKey(keys::kUrlKey)) {
- std::string url_string;
- EXTENSION_FUNCTION_VALIDATE(args->GetString(keys::kUrlKey,
- &url_string));
- url = dispatcher()->url().Resolve(url_string);
- if (!url.is_valid()) {
- error_ = kInvalidURLError;
- return false;
- }
- }
- }
-
- model_->CollapseToolstrip(toolstrip_, url);
- return true;
-}
-
-// static
-void ToolstripEventRouter::DispatchEvent(Profile *profile,
- int routing_id,
- const char *event_name,
- const Value& json) {
- if (profile->GetExtensionMessageService()) {
- std::string json_args;
- base::JSONWriter::Write(&json, false, &json_args);
- std::string full_event_name = StringPrintf(event_name, routing_id);
- profile->GetExtensionMessageService()->DispatchEventToRenderers(
- full_event_name, json_args, profile->IsOffTheRecord(), GURL());
- }
-}
-
-// static
-void ToolstripEventRouter::OnToolstripExpanded(Profile* profile,
- int routing_id,
- const GURL &url,
- int height) {
- ListValue args;
- DictionaryValue* obj = new DictionaryValue();
- if (!url.is_empty())
- obj->SetString(keys::kUrlKey, url.spec());
- obj->SetInteger(keys::kHeightKey, height);
- args.Append(obj);
- DispatchEvent(profile, routing_id, events::kOnToolstripExpanded, args);
-}
-
-// static
-void ToolstripEventRouter::OnToolstripCollapsed(Profile* profile,
- int routing_id,
- const GURL &url) {
- ListValue args;
- DictionaryValue* obj = new DictionaryValue();
- if (!url.is_empty())
- obj->SetString(keys::kUrlKey, url.spec());
- args.Append(obj);
- DispatchEvent(profile, routing_id, events::kOnToolstripCollapsed, args);
-}
diff --git a/chrome/browser/extensions/extension_toolstrip_api.h b/chrome/browser/extensions/extension_toolstrip_api.h
deleted file mode 100644
index 07ba8f1..0000000
--- a/chrome/browser/extensions/extension_toolstrip_api.h
+++ /dev/null
@@ -1,61 +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_EXTENSIONS_EXTENSION_TOOLSTRIP_API_H_
-#define CHROME_BROWSER_EXTENSIONS_EXTENSION_TOOLSTRIP_API_H_
-#pragma once
-
-#include "chrome/browser/extensions/extension_function.h"
-#include "chrome/browser/extensions/extension_shelf_model.h"
-
-class Profile;
-
-namespace extension_toolstrip_api_events {
- extern const char kOnToolstripExpanded[];
- extern const char kOnToolstripCollapsed[];
-}; // namespace extension_toolstrip_api_events
-
-class ToolstripFunction : public SyncExtensionFunction {
- protected:
- virtual ~ToolstripFunction() {}
- virtual bool RunImpl();
-
- ExtensionShelfModel* model_;
- ExtensionShelfModel::iterator toolstrip_;
-};
-
-class ToolstripExpandFunction : public ToolstripFunction {
- ~ToolstripExpandFunction() {}
- virtual bool RunImpl();
- DECLARE_EXTENSION_FUNCTION_NAME("toolstrip.expand")
-};
-
-class ToolstripCollapseFunction : public ToolstripFunction {
- ~ToolstripCollapseFunction() {}
- virtual bool RunImpl();
- DECLARE_EXTENSION_FUNCTION_NAME("toolstrip.collapse")
-};
-
-class ToolstripEventRouter {
- public:
- // Toolstrip events.
- static void OnToolstripExpanded(Profile* profile,
- int routing_id,
- const GURL& url,
- int height);
- static void OnToolstripCollapsed(Profile* profile,
- int routing_id,
- const GURL& url);
-
- private:
- // Helper to actually dispatch an event to extension listeners.
- static void DispatchEvent(Profile* profile,
- int routing_id,
- const char* event_name,
- const Value& json);
-
- DISALLOW_COPY_AND_ASSIGN(ToolstripEventRouter);
-};
-
-#endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_TOOLSTRIP_API_H_
diff --git a/chrome/browser/extensions/extension_toolstrip_apitest.cc b/chrome/browser/extensions/extension_toolstrip_apitest.cc
deleted file mode 100644
index 05955a0..0000000
--- a/chrome/browser/extensions/extension_toolstrip_apitest.cc
+++ /dev/null
@@ -1,11 +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/extensions/extension_apitest.h"
-
-// Disabled, http://crbug.com/30151 (Linux and ChromeOS),
-// http://crbug.com/35034 (others).
-IN_PROC_BROWSER_TEST_F(ExtensionApiTest, DISABLED_Toolstrip) {
- ASSERT_TRUE(RunExtensionTest("toolstrip")) << message_;
-}
diff --git a/chrome/browser/extensions/extensions_service_unittest.cc b/chrome/browser/extensions/extensions_service_unittest.cc
index c23f451..b3e2b0f 100644
--- a/chrome/browser/extensions/extensions_service_unittest.cc
+++ b/chrome/browser/extensions/extensions_service_unittest.cc
@@ -246,11 +246,6 @@ ExtensionsServiceTestBase::~ExtensionsServiceTestBase() {
void ExtensionsServiceTestBase::InitializeExtensionsService(
const FilePath& pref_file, const FilePath& extensions_install_dir) {
- // Must setup the commandline here, since Extension caches the switch value
- // when the prefs are registered.
- CommandLine::ForCurrentProcess()->AppendSwitch(
- switches::kEnableExtensionToolstrips);
-
ExtensionTestingProfile* profile = new ExtensionTestingProfile();
// Create a preference service that only contains user defined
// preference values.
@@ -685,8 +680,6 @@ TEST_F(ExtensionsServiceTest, LoadAllExtensionsFromDirectorySuccess) {
Extension* extension = loaded_[0];
const UserScriptList& scripts = extension->content_scripts();
- const std::vector<Extension::ToolstripInfo>& toolstrips =
- extension->toolstrips();
ASSERT_EQ(2u, scripts.size());
EXPECT_EQ(3u, scripts[0].url_patterns().size());
EXPECT_EQ("file://*",
@@ -722,14 +715,6 @@ TEST_F(ExtensionsServiceTest, LoadAllExtensionsFromDirectorySuccess) {
ASSERT_EQ(2u, permissions.size());
EXPECT_EQ("http://*.google.com/*", permissions[0].GetAsString());
EXPECT_EQ("https://*.google.com/*", permissions[1].GetAsString());
- ASSERT_EQ(2u, toolstrips.size());
- EXPECT_EQ(extension->GetResourceURL("toolstrip1.html"),
- toolstrips[0].toolstrip);
- EXPECT_EQ(extension->GetResourceURL("lorem_ipsum.html"),
- toolstrips[0].mole);
- EXPECT_EQ(200, toolstrips[0].mole_height);
- EXPECT_EQ(extension->GetResourceURL("toolstrip2.html"),
- toolstrips[1].toolstrip);
EXPECT_EQ(std::string(good1), loaded_[1]->id());
EXPECT_EQ(std::string("My extension 2"), loaded_[1]->name());
diff --git a/chrome/browser/gtk/browser_window_gtk.cc b/chrome/browser/gtk/browser_window_gtk.cc
index b268484..3d8e865 100644
--- a/chrome/browser/gtk/browser_window_gtk.cc
+++ b/chrome/browser/gtk/browser_window_gtk.cc
@@ -742,10 +742,6 @@ void BrowserWindowGtk::SelectedTabToolbarSizeChanged(bool is_animating) {
// http://code.google.com/p/chromium/issues/detail?id=12291
}
-void BrowserWindowGtk::SelectedTabExtensionShelfSizeChanged() {
- NOTIMPLEMENTED();
-}
-
void BrowserWindowGtk::UpdateTitleBar() {
string16 title = browser_->GetWindowTitleForCurrentTab();
gtk_window_set_title(window_, UTF16ToUTF8(title).c_str());
@@ -913,10 +909,6 @@ void BrowserWindowGtk::ToggleBookmarkBar() {
bookmark_utils::ToggleWhenVisible(browser_->profile());
}
-void BrowserWindowGtk::ToggleExtensionShelf() {
- NOTIMPLEMENTED();
-}
-
views::Window* BrowserWindowGtk::ShowAboutChromeDialog() {
ShowAboutDialogForProfile(window_, browser_->profile());
return NULL;
diff --git a/chrome/browser/gtk/browser_window_gtk.h b/chrome/browser/gtk/browser_window_gtk.h
index f2bc145..e02f4ab 100644
--- a/chrome/browser/gtk/browser_window_gtk.h
+++ b/chrome/browser/gtk/browser_window_gtk.h
@@ -60,7 +60,6 @@ class BrowserWindowGtk : public BrowserWindow,
virtual BrowserWindowTesting* GetBrowserWindowTesting();
virtual StatusBubble* GetStatusBubble();
virtual void SelectedTabToolbarSizeChanged(bool is_animating);
- virtual void SelectedTabExtensionShelfSizeChanged();
virtual void UpdateTitleBar();
virtual void ShelfVisibilityChanged();
virtual void UpdateDevTools();
@@ -88,7 +87,6 @@ class BrowserWindowGtk : public BrowserWindow,
virtual void ConfirmAddSearchProvider(const TemplateURL* template_url,
Profile* profile);
virtual void ToggleBookmarkBar();
- virtual void ToggleExtensionShelf();
virtual views::Window* ShowAboutChromeDialog();
virtual void ShowUpdateChromeDialog();
virtual void ShowTaskManager();
diff --git a/chrome/browser/gtk/view_id_util.cc b/chrome/browser/gtk/view_id_util.cc
index 684c669..2b8e396 100644
--- a/chrome/browser/gtk/view_id_util.cc
+++ b/chrome/browser/gtk/view_id_util.cc
@@ -107,9 +107,6 @@ const char* GetNameFromID(ViewID id) {
case VIEW_ID_DEV_TOOLS_DOCKED:
return "chrome-dev-tools-docked";
- case VIEW_ID_DEV_EXTENSION_SHELF:
- return "chrome-extension-shelf";
-
// These are never hit because the tab container uses the delegate to
// set its ID.
case VIEW_ID_TAB_CONTAINER:
diff --git a/chrome/browser/gtk/view_id_util_browsertest.cc b/chrome/browser/gtk/view_id_util_browsertest.cc
index b647900..b80fb02 100644
--- a/chrome/browser/gtk/view_id_util_browsertest.cc
+++ b/chrome/browser/gtk/view_id_util_browsertest.cc
@@ -33,10 +33,6 @@ IN_PROC_BROWSER_TEST_F(ViewIDTest, Basic) {
browser()->ShowFindBar();
for (int i = VIEW_ID_TOOLBAR; i < VIEW_ID_PREDEFINED_COUNT; ++i) {
- // Extension shelf is being removed, http://crbug.com/25106.
- if (i == VIEW_ID_DEV_EXTENSION_SHELF)
- continue;
-
// The following ids are used only in views implementation.
if (i == VIEW_ID_CONTENTS_SPLIT ||
i == VIEW_ID_INFO_BAR_CONTAINER ||
diff --git a/chrome/browser/renderer_host/render_view_host.cc b/chrome/browser/renderer_host/render_view_host.cc
index 644d116..fcdc75f 100644
--- a/chrome/browser/renderer_host/render_view_host.cc
+++ b/chrome/browser/renderer_host/render_view_host.cc
@@ -1911,10 +1911,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::UpdateBrowserWindowId(int window_id) {
Send(new ViewMsg_UpdateBrowserWindowId(routing_id(), window_id));
}
diff --git a/chrome/browser/renderer_host/render_view_host.h b/chrome/browser/renderer_host/render_view_host.h
index 6d770cd..736c08f 100644
--- a/chrome/browser/renderer_host/render_view_host.h
+++ b/chrome/browser/renderer_host/render_view_host.h
@@ -442,9 +442,6 @@ class RenderViewHost : public RenderWidgetHost {
// permission.
void BlockExtensionRequest(int request_id);
- // Notifies the renderer that its view type has changed.
- void ViewTypeChanged(ViewType::Type type);
-
// Tells the renderer which browser window it is being attached to.
void UpdateBrowserWindowId(int window_id);
diff --git a/chrome/browser/resources/extensions_toolstrip.css b/chrome/browser/resources/extensions_toolstrip.css
deleted file mode 100644
index d4691fc..0000000
--- a/chrome/browser/resources/extensions_toolstrip.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/tab_contents/navigation_controller.cc b/chrome/browser/tab_contents/navigation_controller.cc
index fcc1e7a..1b2f117 100644
--- a/chrome/browser/tab_contents/navigation_controller.cc
+++ b/chrome/browser/tab_contents/navigation_controller.cc
@@ -36,8 +36,7 @@
namespace {
const int kInvalidateAllButShelves =
- 0xFFFFFFFF & ~(TabContents::INVALIDATE_BOOKMARK_BAR |
- TabContents::INVALIDATE_EXTENSION_SHELF);
+ 0xFFFFFFFF & ~TabContents::INVALIDATE_BOOKMARK_BAR;
// Invoked when entries have been pruned, or removed. For example, if the
// current entries are [google, digg, yahoo], with the current entry google,
diff --git a/chrome/browser/tab_contents/tab_contents.cc b/chrome/browser/tab_contents/tab_contents.cc
index 42f63db..1d2e028 100644
--- a/chrome/browser/tab_contents/tab_contents.cc
+++ b/chrome/browser/tab_contents/tab_contents.cc
@@ -1176,27 +1176,6 @@ bool TabContents::ShouldShowBookmarkBar() {
return false; // Default.
}
-bool TabContents::IsExtensionShelfAlwaysVisible() {
- // See GetDOMUIForCurrentState() comment for more info. This case is very
- // similar, but for non-first loads, we want to use the committed entry. This
- // is so the bookmarks bar disappears at the same time the page does.
- if (controller_.GetLastCommittedEntry()) {
- // Not the first load, always use the committed DOM UI.
- if (render_manager_.dom_ui())
- return render_manager_.dom_ui()->force_extension_shelf_visible();
- return false; // Default.
- }
-
- // When it's the first load, we know either the pending one or the committed
- // one will have the DOM UI in it (see GetDOMUIForCurrentState), and only one
- // of them will be valid, so we can just check both.
- if (render_manager_.pending_dom_ui())
- return render_manager_.pending_dom_ui()->force_extension_shelf_visible();
- if (render_manager_.dom_ui())
- return render_manager_.dom_ui()->force_extension_shelf_visible();
- return false; // Default.
-}
-
void TabContents::ToolbarSizeChanged(bool is_animating) {
TabContentsDelegate* d = delegate();
if (d)
@@ -2381,14 +2360,11 @@ void TabContents::DidNavigate(RenderViewHost* rvh,
if (PageTransition::IsMainFrame(params.transition)) {
bool was_bookmark_bar_visible = ShouldShowBookmarkBar();
- bool was_extension_shelf_visible = IsExtensionShelfAlwaysVisible();
render_manager_.DidNavigateMainFrame(rvh);
if (was_bookmark_bar_visible != ShouldShowBookmarkBar())
extra_invalidate_flags |= INVALIDATE_BOOKMARK_BAR;
- if (was_extension_shelf_visible != IsExtensionShelfAlwaysVisible())
- extra_invalidate_flags |= INVALIDATE_EXTENSION_SHELF;
}
// Update the site of the SiteInstance if it doesn't have one yet.
diff --git a/chrome/browser/tab_contents/tab_contents.h b/chrome/browser/tab_contents/tab_contents.h
index cba7367..49f89e2 100644
--- a/chrome/browser/tab_contents/tab_contents.h
+++ b/chrome/browser/tab_contents/tab_contents.h
@@ -111,10 +111,7 @@ class TabContents : public PageNavigator,
INVALIDATE_PAGE_ACTIONS = 1 << 3, // Page action icons have changed.
INVALIDATE_BOOKMARK_BAR = 1 << 4, // State of ShouldShowBookmarkBar
// changed.
- INVALIDATE_EXTENSION_SHELF = 1 << 5, // State of
- // IsExtensionShelfAlwaysVisible
- // changed.
- INVALIDATE_TITLE = 1 << 6, // The title changed.
+ INVALIDATE_TITLE = 1 << 5, // The title changed.
};
// |base_tab_contents| is used if we want to size the new tab contents view
@@ -466,9 +463,6 @@ class TabContents : public PageNavigator,
// Returns true if a Bookmark Bar should be shown for this tab.
virtual bool ShouldShowBookmarkBar();
- // Returns whether the extension shelf should be visible.
- virtual bool IsExtensionShelfAlwaysVisible();
-
// Notifies the delegate that a download is about to be started.
// This notification is fired before a local temporary file has been created.
bool CanDownload(int request_id);
diff --git a/chrome/browser/task_manager_browsertest.cc b/chrome/browser/task_manager_browsertest.cc
index d546fe5..a8eaa2e 100644
--- a/chrome/browser/task_manager_browsertest.cc
+++ b/chrome/browser/task_manager_browsertest.cc
@@ -128,16 +128,11 @@ IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, FLAKY_NoticeExtensionChanges) {
// Browser and the New Tab Page.
EXPECT_EQ(2, model()->ResourceCount());
- // Loading an extension should result in a new resource being
- // created for it.
- ASSERT_TRUE(LoadExtension(
- test_data_dir_.AppendASCII("common").AppendASCII("one_in_shelf")));
- WaitForResourceChange(3);
-
- // Make sure we also recognize extensions with just background pages.
+ // Loading an extension with a background page should result in a new
+ // resource being created for it.
ASSERT_TRUE(LoadExtension(
test_data_dir_.AppendASCII("common").AppendASCII("background_page")));
- WaitForResourceChange(4);
+ WaitForResourceChange(3);
}
// Times out on Vista; disabled to keep tests fast. http://crbug.com/44991
diff --git a/chrome/browser/view_ids.h b/chrome/browser/view_ids.h
index 5adf18a..f345b3f 100644
--- a/chrome/browser/view_ids.h
+++ b/chrome/browser/view_ids.h
@@ -62,9 +62,6 @@ enum ViewID {
// Docked dev tools.
VIEW_ID_DEV_TOOLS_DOCKED,
- // Bottom extension shelf.
- VIEW_ID_DEV_EXTENSION_SHELF,
-
// The contents split.
VIEW_ID_CONTENTS_SPLIT,
diff --git a/chrome/browser/views/extensions/extension_shelf.cc b/chrome/browser/views/extensions/extension_shelf.cc
deleted file mode 100644
index 000c988..0000000
--- a/chrome/browser/views/extensions/extension_shelf.cc
+++ /dev/null
@@ -1,1108 +0,0 @@
-// Copyright (c) 2010 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/views/extensions/extension_shelf.h"
-
-#include <algorithm>
-
-#include "app/resource_bundle.h"
-#include "base/logging.h"
-#include "base/message_loop.h"
-#include "base/stl_util-inl.h"
-#include "base/string_util.h"
-#include "base/utf_string_conversions.h"
-#include "chrome/browser/browser.h"
-#include "chrome/browser/browser_theme_provider.h"
-#include "chrome/browser/extensions/extension_host.h"
-#include "chrome/browser/extensions/extension_process_manager.h"
-#include "chrome/browser/extensions/extensions_service.h"
-#include "chrome/browser/profile.h"
-#include "chrome/browser/tab_contents/tab_contents.h"
-#include "chrome/browser/views/extensions/extension_view.h"
-#include "chrome/browser/view_ids.h"
-#include "chrome/common/chrome_switches.h"
-#include "chrome/common/extensions/extension.h"
-#include "chrome/common/notification_service.h"
-#include "chrome/common/pref_names.h"
-#include "gfx/canvas_skia.h"
-#include "views/controls/label.h"
-#include "views/screen.h"
-#include "views/widget/root_view.h"
-
-namespace {
-
-// This is the slight padding that is there around the edge of the browser. This
-// has been determined empirically.
-// TODO(sidchat): Compute this value from the root view of the extension shelf.
-static const int kExtensionShelfPaddingOnLeft = 4;
-
-// Margins around the content.
-static const int kTopMarginWhenExtensionsOnTop = 1;
-static const int kTopMarginWhenExtensionsOnBottom = 2;
-static const int kBottomMargin = 2;
-static const int kLeftMargin = 0;
-static const int kRightMargin = 0;
-
-// Padding on left and right side of an extension toolstrip.
-static const int kToolstripPadding = 2;
-
-// Width of the toolstrip divider.
-static const int kToolstripDividerWidth = 2;
-
-// Preferred height of the ExtensionShelf.
-static const int kShelfHeight = 29;
-
-// Preferred height of the Extension shelf when only shown on the new tab page.
-const int kNewtabShelfHeight = 58;
-
-// How inset the extension shelf is when displayed on the new tab page. This is
-// in addition to the margins above.
-static const int kNewtabHorizontalPadding = 8;
-static const int kNewtabVerticalPadding = 12;
-
-// We need an extra margin to the left of all the toolstrips in detached mode,
-// so that the first toolstrip doesn't look so squished against the rounded
-// corners of the extension shelf.
-static const int kNewtabExtraHorMargin = 2;
-static const int kNewtabExtraVerMargin = 2;
-
-// Padding for the title inside the handle.
-static const int kHandlePadding = 4;
-
-// Inset for the extension view when displayed either dragging or expanded.
-static const int kWindowInset = 1;
-
-// Delays for showing and hiding the shelf handle.
-static const int kShowDelayMs = 500;
-static const int kHideDelayMs = 300;
-
-} // namespace
-
-
-// A view that holds the place for a toolstrip in the shelf while the toolstrip
-// is being dragged or moved.
-// TODO(erikkay) this should draw a dimmed out version of the toolstrip.
-class ExtensionShelf::PlaceholderView : public views::View {
- public:
- PlaceholderView() {}
-
- void SetWidth(int width) {
- SetBounds(x(), y(), width, height());
- PreferredSizeChanged();
- }
-
- // ExtensionShelf resizes its views to their preferred size at layout,
- // so just always prefer the current size.
- gfx::Size GetPreferredSize() { return size(); }
-
- private:
- DISALLOW_COPY_AND_ASSIGN(PlaceholderView);
-};
-
-// A wrapper class for the ExtensionHost displayed as a toolstrip.
-// The class itself also acts as the View for the handle of the toolstrip
-// it represents.
-class ExtensionShelf::Toolstrip : public views::View,
- public BrowserBubble::Delegate,
- public AnimationDelegate {
- public:
- Toolstrip(ExtensionShelf* shelf, ExtensionHost* host,
- const Extension::ToolstripInfo& info);
- virtual ~Toolstrip();
-
- // Convenience to calculate just the size of the handle.
- gfx::Size GetHandlePreferredSize();
-
- // View methods:
- virtual void Paint(gfx::Canvas* canvas);
- virtual gfx::Size GetPreferredSize();
- virtual void Layout();
- virtual void OnMouseEntered(const views::MouseEvent& event);
- virtual void OnMouseExited(const views::MouseEvent& event);
- virtual bool OnMousePressed(const views::MouseEvent& event);
- virtual bool OnMouseDragged(const views::MouseEvent& event);
- virtual void OnMouseReleased(const views::MouseEvent& event, bool canceled);
- virtual bool IsFocusable() const { return true; }
- virtual void ChildPreferredSizeChanged(View* child);
-
- // Adjust the size and position of the window/handle.
- void LayoutWindow();
-
- // Is the toolstrip window visible (not necessarily the handle).
- bool window_visible() { return (window_.get() && window_->visible()); }
-
- // Is the handle for this toolstrip currently visible.
- bool handle_visible() { return (window_visible() && handle_visible_); }
-
- // Is the toolstrip opened in expanded mode.
- bool expanded() { return expanded_; }
-
- // Is the toolstrip being dragged.
- bool dragging() { return dragging_; }
-
- // Accessors for the host and its view.
- ExtensionHost* host() const { return host_; }
- ExtensionView* view() const { return host_->view(); }
-
- // The view that's currently displayed in the shelf. This could be
- // either the ExtensionView or |placeholder_view_| depending on the
- // current state.
- View* GetShelfView() const {
- if (placeholder_view_)
- return placeholder_view_;
- return view();
- }
-
- // Detaching the toolstrip from the shelf means that the ExtensionView is
- // displayed inside of the BrowserBubble rather than the shelf. This may
- // still visually appear to be part of the shelf (expanded) or completely
- // separate (dragging).
- // If |browser| is true, it also will detach/attach to the browser window.
- void DetachFromShelf(bool browser);
- void AttachToShelf(bool browser);
-
- // Show / Hide the shelf handle.
- void ShowShelfHandle();
- void DoShowShelfHandle();
- void HideShelfHandle(int delay_ms);
- void DoHideShelfHandle();
- void StopHandleTimer();
- void HideWindow();
- void ShowWindow();
-
- // Expand / Collapse
- void Expand(int height, const GURL& url);
- void Collapse(const GURL& url);
-
- // BrowserBubble::Delegate
- virtual void BubbleBrowserWindowMoved(BrowserBubble* bubble);
- virtual void BubbleBrowserWindowClosing(BrowserBubble* bubble);
-
- // AnimationDelegate
- virtual void AnimationProgressed(const Animation* animation);
- virtual void AnimationEnded(const Animation* animation);
-
- private:
- // The actual renderer that this toolstrip contains.
- ExtensionHost* host_;
-
- // Manifest definition of this toolstrip.
- Extension::ToolstripInfo info_;
-
- // A window that can be logically attached to the browser window. This is
- // used for two purposes: a handle that sits above the toolstrip when it's
- // collapsed and not dragging, and as a container for the toolstrip when it's
- // dragging or expanded.
- scoped_ptr<BrowserBubble> window_;
-
- // Used for drawing the name of the extension in the handle.
- scoped_ptr<views::Label> title_;
-
- // Pointer back to the containing shelf.
- ExtensionShelf* shelf_;
-
- // When dragging, a placeholder view is put into the shelf to hold space
- // for the ExtensionView. This view is parent owned when it's in the view
- // hierarchy, so there's no ownership issues here.
- PlaceholderView* placeholder_view_;
-
- // Current state of the toolstrip, currently can't both be expanded and
- // dragging.
- // TODO(erikkay) Support dragging while expanded.
- bool dragging_;
- bool expanded_;
- bool handle_visible_;
-
- // The target expanded height of the toolstrip (used for animation).
- int expanded_height_;
-
- // If dragging, where did the drag start from.
- gfx::Point initial_drag_location_;
-
- // We have to remember the initial drag point in screen coordinates, because
- // later, when the toolstrip is being dragged around, there is no good way of
- // computing the screen coordinates given the initial drag view coordinates.
- gfx::Point initial_drag_screen_point_;
-
- // Timers for tracking mouse hovering.
- ScopedRunnableMethodFactory<ExtensionShelf::Toolstrip> timer_factory_;
-
- // Animate opening and closing the mole.
- scoped_ptr<SlideAnimation> mole_animation_;
-
- DISALLOW_COPY_AND_ASSIGN(Toolstrip);
-};
-
-ExtensionShelf::Toolstrip::Toolstrip(ExtensionShelf* shelf,
- ExtensionHost* host,
- const Extension::ToolstripInfo& info)
- : host_(host),
- info_(info),
- shelf_(shelf),
- placeholder_view_(NULL),
- dragging_(false),
- expanded_(false),
- handle_visible_(false),
- expanded_height_(0),
- ALLOW_THIS_IN_INITIALIZER_LIST(timer_factory_(this)) {
- DCHECK(host->view());
- // We're owned by shelf_, not the bubble that we get inserted in and out of.
- set_parent_owned(false);
-
- mole_animation_.reset(new SlideAnimation(this));
-
- std::wstring name = UTF8ToWide(host_->extension()->name());
- // |title_| isn't actually put in the view hierarchy. We just use it
- // to draw in place. The reason for this is so that we can properly handle
- // the various mouse events necessary for hovering and dragging.
- ResourceBundle& rb = ResourceBundle::GetSharedInstance();
- title_.reset(new views::Label(name, rb.GetFont(ResourceBundle::BaseFont)));
- title_->SetBounds(kHandlePadding, kHandlePadding, 100, 100);
- title_->SizeToPreferredSize();
-
- SizeToPreferredSize();
-}
-
-ExtensionShelf::Toolstrip::~Toolstrip() {
- if (window_.get() && window_->attached())
- window_->DetachFromBrowser();
-}
-
-void ExtensionShelf::Toolstrip::Paint(gfx::Canvas* canvas) {
- // Paint the background.
- SkColor theme_toolbar_color =
- shelf_->GetThemeProvider()->GetColor(BrowserThemeProvider::COLOR_TOOLBAR);
- canvas->FillRectInt(theme_toolbar_color, 0, 0, width(), height());
-
- // Paints the handle for the toolstrip (only called on mouse-hover).
- SkColor border_color = ResourceBundle::toolbar_separator_color;
- canvas->FillRectInt(border_color, 0, 0, width(), 1);
- canvas->FillRectInt(border_color, 0, 0, 1, height() - 1);
- canvas->FillRectInt(border_color, width() - 1, 0, 1, height() - 1);
- int ext_width = view()->width() + kToolstripPadding +
- kToolstripDividerWidth;
- if (ext_width < width()) {
- canvas->FillRectInt(border_color, ext_width, height() - 1,
- width() - ext_width, 1);
- }
-
- if (handle_visible_) {
- // Draw the title using a Label as a stamp.
- // See constructor for comment about this.
- title_->ProcessPaint(canvas);
-
- if (dragging_) {
- // When we're dragging, draw the bottom border.
- canvas->FillRectInt(border_color, 0, height() - 1, width(), 1);
- }
- }
-}
-
-gfx::Size ExtensionShelf::Toolstrip::GetHandlePreferredSize() {
- gfx::Size sz;
- if (handle_visible_) {
- sz = title_->GetPreferredSize();
- sz.set_width(std::max(view()->width(), sz.width()));
- sz.Enlarge(2 + kHandlePadding * 2, kHandlePadding * 2);
- }
- return sz;
-}
-
-gfx::Size ExtensionShelf::Toolstrip::GetPreferredSize() {
- gfx::Size sz;
- if (handle_visible_)
- sz = GetHandlePreferredSize();
- if (view()->GetParent() == this) {
- gfx::Size extension_size = view()->GetPreferredSize();
- sz.Enlarge(0, extension_size.height());
- sz.set_width(extension_size.width());
- }
-
- // The view is inset slightly when displayed in the window.
- sz.Enlarge(kWindowInset * 2, kWindowInset * 2);
- return sz;
-}
-
-void ExtensionShelf::Toolstrip::Layout() {
- if (view()->GetParent() == this) {
- int view_y = kWindowInset;
- if (handle_visible_)
- view_y += GetHandlePreferredSize().height();
- view()->SetBounds(kWindowInset, view_y, view()->width(), view()->height());
- }
-}
-
-void ExtensionShelf::Toolstrip::OnMouseEntered(const views::MouseEvent& event) {
- if (dragging_)
- return;
- ShowShelfHandle();
-}
-
-void ExtensionShelf::Toolstrip::OnMouseExited(const views::MouseEvent& event) {
- if (dragging_)
- return;
- HideShelfHandle(kHideDelayMs);
-}
-
-bool ExtensionShelf::Toolstrip::OnMousePressed(const views::MouseEvent& event) {
- initial_drag_location_ = event.location();
- initial_drag_screen_point_ = views::Screen::GetCursorScreenPoint();
- return true;
-}
-
-bool ExtensionShelf::Toolstrip::OnMouseDragged(const views::MouseEvent& event) {
- if (expanded_) {
- // Do nothing for now.
- } else if (!dragging_) {
- int y_delta = abs(initial_drag_location_.y() - event.location().y());
- int x_delta = abs(initial_drag_location_.x() - event.location().x());
- if (y_delta > GetVerticalDragThreshold() ||
- x_delta > GetHorizontalDragThreshold()) {
- dragging_ = true;
- StopHandleTimer();
- DetachFromShelf(true);
- }
- } else {
- // When freely dragging a window, you can really only trust the
- // actual screen point. Local coordinate conversions don't work.
- gfx::Point screen = views::Screen::GetCursorScreenPoint();
-
- // However, the handle is actually a child of the browser window
- // so we need to convert it back to local coordinates.
- gfx::Point origin(0, 0);
- views::View::ConvertPointToScreen(shelf_->GetRootView(), &origin);
- int screen_x = screen.x() - initial_drag_location_.x() - origin.x();
-
- // Restrict the horizontal and vertical motions of the toolstrip so that it
- // cannot be dragged out of the extension shelf. If the extension shelf is
- // on the top along with the bookmark bar, the toolstrip cannot be dragged
- // into the space allocated for bookmarks. The toolstrip cannot be dragged
- // out of the browser window.
- if (screen_x < kExtensionShelfPaddingOnLeft) {
- screen_x = kExtensionShelfPaddingOnLeft;
- } else if (screen_x > shelf_->width() - width() +
- kExtensionShelfPaddingOnLeft) {
- screen_x = shelf_->width() - width() + kExtensionShelfPaddingOnLeft;
- }
- screen.set_x(screen_x);
- screen.set_y(initial_drag_screen_point_.y() - origin.y() -
- initial_drag_location_.y());
-
- // TODO(erikkay) as this gets dragged around, update the placeholder view
- // on the shelf to show where it will get dropped to.
- window_->MoveTo(screen.x(), screen.y());
- }
- return true;
-}
-
-void ExtensionShelf::Toolstrip::OnMouseReleased(const views::MouseEvent& event,
- bool canceled) {
- StopHandleTimer();
- if (dragging_) {
- // Drop the toolstrip roughly where it is now.
- views::View::OnMouseReleased(event, canceled);
- dragging_ = false;
- // |this| and |shelf_| are in different view hierarchies, so we need to
- // convert to screen coordinates and back again to map locations.
- gfx::Point loc = event.location();
- View::ConvertPointToScreen(this, &loc);
- View::ConvertPointToView(NULL, shelf_, &loc);
- shelf_->DropExtension(this, loc, canceled);
- AttachToShelf(true);
- } else if (!canceled) {
- // Toggle mole to either expanded or collapsed.
- // TODO(erikkay) If there's no valid URL in the manifest, should we
- // post an event to the toolstrip in this case?
- if (expanded_) {
- if (info_.toolstrip.is_valid())
- shelf_->CollapseToolstrip(host_, info_.toolstrip);
- } else {
- if (info_.mole.is_valid())
- shelf_->ExpandToolstrip(host_, info_.mole, info_.mole_height);
- }
- }
-}
-
-void ExtensionShelf::Toolstrip::LayoutWindow() {
- if (!window_visible() && !handle_visible_ && !expanded_)
- return;
-
- if (!window_.get()) {
- window_.reset(new BrowserBubble(this, shelf_->GetWidget(),
- gfx::Point(0, 0),
- false)); // Do not add a drop-shadow.
- window_->set_delegate(this);
- }
-
- gfx::Size window_size = GetPreferredSize();
- if (mole_animation_->is_animating()) {
- // We only want to animate the body of the mole window. When we're
- // expanding, this is everything except for the handle. When we're
- // collapsing, this is everything except for the handle and the toolstrip.
- // We subtract this amount from the target height, figure out the step in
- // the animation from the rest, and then add it back in.
- int window_offset = shelf_->height();
- if (!mole_animation_->IsShowing())
- window_offset += GetPreferredSize().height();
- else
- window_offset += GetHandlePreferredSize().height();
- int h = expanded_height_ - window_offset;
- window_size.set_height(window_offset +
- static_cast<int>(h * mole_animation_->GetCurrentValue()));
- } else if (!expanded_ && !dragging_) {
- window_size.set_height(GetHandlePreferredSize().height());
- }
-
- // Now figure out where to place the window on the screen. Since it's a top-
- // level widget, we need to do some coordinate conversion to get this right.
- gfx::Point origin(-kToolstripPadding, 0);
- if (expanded_ || mole_animation_->is_animating()) {
- origin.set_y(GetShelfView()->height() - window_size.height());
- views::View::ConvertPointToView(GetShelfView(), shelf_->GetRootView(),
- &origin);
- } else {
- origin.set_y(-(window_size.height() + kToolstripPadding - 1));
- views::View::ConvertPointToWidget(view(), &origin);
- }
- SetBounds(0, 0, window_size.width(), window_size.height());
- window_->SetBounds(origin.x(), origin.y(),
- window_size.width(), window_size.height());
-}
-
-void ExtensionShelf::Toolstrip::ChildPreferredSizeChanged(View* child) {
- if (child == view()) {
- child->SizeToPreferredSize();
- Layout();
- if (window_visible())
- LayoutWindow();
- if (expanded_) {
- placeholder_view_->SetWidth(child->width());
- shelf_->Layout();
- }
- }
-}
-
-void ExtensionShelf::Toolstrip::BubbleBrowserWindowMoved(
- BrowserBubble* bubble) {
- if (!expanded_)
- HideWindow();
-}
-
-void ExtensionShelf::Toolstrip::BubbleBrowserWindowClosing(
- BrowserBubble* bubble) {
- HideWindow();
-}
-
-void ExtensionShelf::Toolstrip::AnimationProgressed(
- const Animation* animation) {
- LayoutWindow();
-}
-
-void ExtensionShelf::Toolstrip::AnimationEnded(const Animation* animation) {
- if (window_visible())
- LayoutWindow();
- if (!expanded_) {
- AttachToShelf(false);
- HideShelfHandle(kHideDelayMs);
- }
-}
-
-void ExtensionShelf::Toolstrip::DetachFromShelf(bool browserDetach) {
- DCHECK(window_.get());
- DCHECK(!placeholder_view_);
- if (browserDetach && window_->attached())
- window_->DetachFromBrowser();
-
- // Construct a placeholder view to replace the view.
- placeholder_view_ = new PlaceholderView();
- placeholder_view_->SetBounds(view()->bounds());
- shelf_->AddChildView(placeholder_view_);
-
- AddChildView(view());
- SizeToPreferredSize();
- window_->ResizeToView();
- Layout();
-}
-
-void ExtensionShelf::Toolstrip::AttachToShelf(bool browserAttach) {
- DCHECK(window_.get());
- DCHECK(placeholder_view_);
- if (browserAttach && !window_->attached())
- window_->AttachToBrowser();
-
- // Move the view back into the shelf and remove the old placeholder.
- shelf_->AddChildView(view());
-
- // The size of the view may have changed, so just set the position.
- view()->SetX(placeholder_view_->x());
- view()->SetY(placeholder_view_->y());
-
- // Remove the old placeholder.
- shelf_->RemoveChildView(placeholder_view_);
- delete placeholder_view_;
- placeholder_view_ = NULL;
-
- SizeToPreferredSize();
- Layout();
- shelf_->Layout();
-}
-
-void ExtensionShelf::Toolstrip::DoShowShelfHandle() {
- if (!handle_visible()) {
- handle_visible_ = true;
-
- // Make sure the text color for the title matches the theme colors.
- title_->SetColor(
- shelf_->GetThemeProvider()->GetColor(
- BrowserThemeProvider::COLOR_BOOKMARK_TEXT));
-
- ShowWindow();
- }
-}
-
-void ExtensionShelf::Toolstrip::HideWindow() {
- if (!window_visible())
- return;
- handle_visible_ = false;
- window_->Hide();
- if (expanded_) {
- if (info_.toolstrip.is_valid())
- shelf_->CollapseToolstrip(host_, info_.toolstrip);
- else
- shelf_->CollapseToolstrip(host_, GURL());
- }
- if (window_->attached())
- window_->DetachFromBrowser();
- window_.reset(NULL);
- shelf_->Layout();
-}
-
-void ExtensionShelf::Toolstrip::ShowWindow() {
- DCHECK(handle_visible_ || expanded_);
-
- LayoutWindow();
- if (!window_visible())
- window_->Show(false); // |false| means show, but don't activate.
-}
-
-void ExtensionShelf::Toolstrip::DoHideShelfHandle() {
- if (!handle_visible())
- return;
- handle_visible_ = false;
- if (expanded_) {
- LayoutWindow();
- Layout();
- } else {
- HideWindow();
- }
-}
-
-void ExtensionShelf::Toolstrip::StopHandleTimer() {
- if (!timer_factory_.empty())
- timer_factory_.RevokeAll();
-}
-
-void ExtensionShelf::Toolstrip::Expand(int height, const GURL& url) {
- DCHECK(!expanded_);
-
- expanded_ = true;
- ShowWindow();
-
- bool navigate = (!url.is_empty() && url != host_->GetURL());
- if (navigate)
- host_->NavigateToURL(url);
-
- StopHandleTimer();
- DetachFromShelf(false);
-
- mole_animation_->Show();
-
- gfx::Size extension_size = view()->GetPreferredSize();
- extension_size.set_height(height);
- view()->SetPreferredSize(extension_size);
- expanded_height_ = GetPreferredSize().height();
-
- // This is to prevent flickering as the page loads and lays out.
- // Once the navigation is finished, ExtensionView will wind up setting
- // visibility to true.
- if (navigate)
- view()->SetVisible(false);
-}
-
-void ExtensionShelf::Toolstrip::Collapse(const GURL& url) {
- DCHECK(expanded_);
- expanded_ = false;
-
- if (window_visible())
- mole_animation_->Hide();
-
- gfx::Size extension_size = view()->GetPreferredSize();
- extension_size.set_height(
- kShelfHeight - (shelf_->top_margin() + kBottomMargin));
- view()->SetPreferredSize(extension_size);
-
- if (!url.is_empty() && url != host_->GetURL()) {
- host_->NavigateToURL(url);
-
- // This is to prevent flickering as the page loads and lays out.
- // Once the navigation is finished, ExtensionView will wind up setting
- // visibility to true.
- view()->SetVisible(false);
- }
-
- if (!window_visible())
- AnimationEnded(NULL);
-}
-
-void ExtensionShelf::Toolstrip::ShowShelfHandle() {
- StopHandleTimer();
- if (handle_visible())
- return;
- MessageLoop::current()->PostDelayedTask(FROM_HERE,
- timer_factory_.NewRunnableMethod(
- &ExtensionShelf::Toolstrip::DoShowShelfHandle),
- kShowDelayMs);
-}
-
-void ExtensionShelf::Toolstrip::HideShelfHandle(int delay_ms) {
- StopHandleTimer();
- if (!handle_visible() || dragging_ || mole_animation_->is_animating())
- return;
- if (delay_ms) {
- MessageLoop::current()->PostDelayedTask(FROM_HERE,
- timer_factory_.NewRunnableMethod(
- &ExtensionShelf::Toolstrip::DoHideShelfHandle),
- delay_ms);
- } else {
- DoHideShelfHandle();
- }
-}
-
-////////////////////////////////////////////////////////////////////////////////
-
-ExtensionShelf::ExtensionShelf(Browser* browser)
- : background_needs_repaint_(true),
- browser_(browser),
- model_(browser->extension_shelf_model()),
- fullscreen_(false) {
- SetID(VIEW_ID_DEV_EXTENSION_SHELF);
-
- top_margin_ = kTopMarginWhenExtensionsOnBottom;
-
- model_->AddObserver(this);
- LoadFromModel();
- EnableCanvasFlippingForRTLUI(true);
- registrar_.Add(this,
- NotificationType::EXTENSION_SHELF_VISIBILITY_PREF_CHANGED,
- NotificationService::AllSources());
-
- size_animation_.reset(new SlideAnimation(this));
- if (IsAlwaysShown())
- size_animation_->Reset(1);
- else
- size_animation_->Reset(0);
-}
-
-ExtensionShelf::~ExtensionShelf() {
- if (model_) {
- int count = model_->count();
- for (int i = 0; i < count; ++i) {
- delete ToolstripAtIndex(i);
- model_->SetToolstripDataAt(i, NULL);
- }
- model_->RemoveObserver(this);
- }
-}
-
-void ExtensionShelf::PaintChildren(gfx::Canvas* canvas) {
- InitBackground(canvas);
-
- int max_x = width();
- if (IsDetached())
- max_x -= 2 * kNewtabHorizontalPadding;
-
- // Draw vertical dividers between Toolstrip items in the Extension shelf.
- int count = GetChildViewCount();
- for (int i = 0; i < count; ++i) {
- int right = GetChildViewAt(i)->bounds().right() + kToolstripPadding;
- if (right >= max_x)
- break;
- int vertical_padding = IsDetached() ? (height() - kShelfHeight) / 2 : 1;
-
- DetachableToolbarView::PaintVerticalDivider(
- canvas, right, height(), vertical_padding,
- DetachableToolbarView::kEdgeDividerColor,
- DetachableToolbarView::kMiddleDividerColor,
- GetThemeProvider()->GetColor(BrowserThemeProvider::COLOR_TOOLBAR));
- }
-}
-
-// static
-void ExtensionShelf::ToggleWhenExtensionShelfVisible(Profile* profile) {
- PrefService* prefs = profile->GetPrefs();
- const bool always_show = !prefs->GetBoolean(prefs::kShowExtensionShelf);
-
- // The user changed when the Extension Shelf is shown, update the
- // preferences.
- prefs->SetBoolean(prefs::kShowExtensionShelf, always_show);
- prefs->ScheduleSavePersistentPrefs();
-
- // And notify the notification service.
- Source<Profile> source(profile);
- NotificationService::current()->Notify(
- NotificationType::EXTENSION_SHELF_VISIBILITY_PREF_CHANGED,
- source,
- NotificationService::NoDetails());
-}
-
-gfx::Size ExtensionShelf::GetPreferredSize() {
- return LayoutItems(true);
-}
-
-void ExtensionShelf::ChildPreferredSizeChanged(View* child) {
- PreferredSizeChanged();
-}
-
-void ExtensionShelf::Layout() {
- LayoutItems(false);
-}
-
-void ExtensionShelf::OnMouseEntered(const views::MouseEvent& event) {
-}
-
-void ExtensionShelf::OnMouseExited(const views::MouseEvent& event) {
-}
-
-bool ExtensionShelf::GetAccessibleRole(AccessibilityTypes::Role* role) {
- DCHECK(role);
-
- *role = AccessibilityTypes::ROLE_TOOLBAR;
- return true;
-}
-
-void ExtensionShelf::OnThemeChanged() {
- // 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()->InsertThemedToolstripCSS();
-
- Layout();
-}
-
-void ExtensionShelf::ToolstripInsertedAt(ExtensionHost* host,
- int index) {
- model_->SetToolstripDataAt(index,
- new Toolstrip(this, host, model_->ToolstripAt(index).info));
-
- bool had_views = GetChildViewCount() > 0;
- ExtensionView* view = host->view();
- AddChildView(view);
- view->SetContainer(this);
- if (!had_views)
- PreferredSizeChanged();
- Layout();
-}
-
-void ExtensionShelf::ToolstripRemovingAt(ExtensionHost* host, int index) {
- // Delete the Toolstrip view and remove it from the model.
- Toolstrip* toolstrip = ToolstripAtIndex(index);
- View* view = toolstrip->GetShelfView();
- RemoveChildView(view);
- delete toolstrip;
- model_->SetToolstripDataAt(index, NULL);
-
- // Technically, the toolstrip is still in the model at this point, but
- // the Layout code handles this case.
- Layout();
-}
-
-void ExtensionShelf::ToolstripDraggingFrom(ExtensionHost* host, int index) {
-}
-
-void ExtensionShelf::ToolstripMoved(ExtensionHost* host, int from_index,
- int to_index) {
- Layout();
-}
-
-void ExtensionShelf::ToolstripChanged(ExtensionShelfModel::iterator toolstrip) {
- Toolstrip* t = static_cast<Toolstrip*>(toolstrip->data);
- if (toolstrip->height > 0) {
- if (!t->expanded()) {
- t->Expand(toolstrip->height, toolstrip->url);
- }
- } else if (t->expanded()) {
- t->Collapse(toolstrip->url);
- }
-}
-
-void ExtensionShelf::ExtensionShelfEmpty() {
- PreferredSizeChanged();
-}
-
-void ExtensionShelf::ShelfModelReloaded() {
- // None of the child views are parent owned, so nothing is being leaked here.
- RemoveAllChildViews(false);
- LoadFromModel();
-}
-
-void ExtensionShelf::ShelfModelDeleting() {
- int count = model_->count();
- for (int i = 0; i < count; ++i) {
- delete ToolstripAtIndex(i);
- model_->SetToolstripDataAt(i, NULL);
- }
- model_->RemoveObserver(this);
- model_ = NULL;
-}
-
-void ExtensionShelf::AnimationProgressed(const Animation* animation) {
- if (browser_)
- browser_->ExtensionShelfSizeChanged();
-}
-
-void ExtensionShelf::AnimationEnded(const Animation* animation) {
- if (browser_)
- browser_->ExtensionShelfSizeChanged();
-
- Layout();
-}
-
-void ExtensionShelf::Observe(NotificationType type,
- const NotificationSource& source,
- const NotificationDetails& details) {
- switch (type.value) {
- case NotificationType::EXTENSION_SHELF_VISIBILITY_PREF_CHANGED: {
- if (fullscreen_)
- break;
- if (IsAlwaysShown())
- size_animation_->Show();
- else
- size_animation_->Hide();
- break;
- }
- default:
- NOTREACHED();
- break;
- }
-}
-
-void ExtensionShelf::OnExtensionMouseMove(ExtensionView* view) {
- Toolstrip *toolstrip = ToolstripForView(view);
- if (toolstrip)
- toolstrip->ShowShelfHandle();
-}
-
-void ExtensionShelf::OnExtensionMouseLeave(ExtensionView* view) {
- Toolstrip *toolstrip = ToolstripForView(view);
- if (toolstrip)
- toolstrip->HideShelfHandle(kHideDelayMs);
-}
-
-void ExtensionShelf::DropExtension(Toolstrip* toolstrip, const gfx::Point& pt,
- bool cancel) {
- Toolstrip* dest_toolstrip = ToolstripAtX(pt.x());
- if (!dest_toolstrip) {
- if (pt.x() > 0)
- dest_toolstrip = ToolstripAtIndex(model_->count() - 1);
- else
- dest_toolstrip = ToolstripAtIndex(0);
- }
- if (toolstrip == dest_toolstrip)
- return;
- int from = model_->IndexOfHost(toolstrip->host());
- int to = model_->IndexOfHost(dest_toolstrip->host());
- DCHECK(from != to);
- model_->MoveToolstripAt(from, to);
-}
-
-void ExtensionShelf::ExpandToolstrip(ExtensionHost* host, const GURL& url,
- int height) {
- ExtensionShelfModel::iterator toolstrip = model_->ToolstripForHost(host);
- model_->ExpandToolstrip(toolstrip, url, height);
-}
-
-void ExtensionShelf::CollapseToolstrip(ExtensionHost* host, const GURL& url) {
- ExtensionShelfModel::iterator toolstrip = model_->ToolstripForHost(host);
- model_->CollapseToolstrip(toolstrip, url);
-}
-
-void ExtensionShelf::InitBackground(gfx::Canvas* canvas) {
- if (!background_needs_repaint_)
- return;
-
- // Capture a background bitmap to give to the toolstrips.
- SkRect background_rect = {
- SkIntToScalar(0),
- SkIntToScalar(0),
- SkIntToScalar(width()),
- SkIntToScalar(height())
- };
-
- // Tell all extension views about the new background.
- int count = model_->count();
- for (int i = 0; i < count; ++i) {
- ExtensionView* view = ToolstripAtIndex(i)->view();
-
- const SkBitmap& background =
- canvas->AsCanvasSkia()->getDevice()->accessBitmap(false);
-
- SkRect mapped_subset = background_rect;
- gfx::Rect view_bounds = view->bounds();
- mapped_subset.offset(SkIntToScalar(view_bounds.x()),
- SkIntToScalar(view_bounds.y()));
- bool result =
- canvas->AsCanvasSkia()->getTotalMatrix().mapRect(&mapped_subset);
- DCHECK(result);
-
- SkIRect isubset;
- mapped_subset.round(&isubset);
- SkBitmap subset_bitmap;
- // This will create another bitmap that just references pixels in the
- // actual bitmap.
- result = background.extractSubset(&subset_bitmap, isubset);
- if (!result)
- return;
-
- // We do a deep copy because extractSubset() returns a bitmap that
- // references pixels in the original one and we want to actually make a
- // smaller copy that will have a long lifetime.
- SkBitmap smaller_copy;
- if (!subset_bitmap.copyTo(&smaller_copy, SkBitmap::kARGB_8888_Config))
- return;
- DCHECK(smaller_copy.readyToDraw());
-
- view->SetBackground(smaller_copy);
- }
-
- background_needs_repaint_ = false;
-}
-
-ExtensionShelf::Toolstrip* ExtensionShelf::ToolstripAtX(int x) {
- int count = model_->count();
- if (count == 0)
- return NULL;
-
- if (x < 0)
- return NULL;
-
- for (int i = 0; i < count; ++i) {
- Toolstrip* toolstrip = ToolstripAtIndex(i);
- View* view = toolstrip->GetShelfView();
- int x_mirrored = view->GetRootView()->MirroredXCoordinateInsideView(x);
- if (x_mirrored > view->x() + view->width() + kToolstripPadding)
- continue;
- return toolstrip;
- }
-
- return NULL;
-}
-
-ExtensionShelf::Toolstrip* ExtensionShelf::ToolstripAtIndex(int index) {
- return static_cast<Toolstrip*>(model_->ToolstripAt(index).data);
-}
-
-ExtensionShelf::Toolstrip* ExtensionShelf::ToolstripForView(
- ExtensionView* view) {
- int count = model_->count();
- for (int i = 0; i < count; ++i) {
- Toolstrip* toolstrip = ToolstripAtIndex(i);
- if (view == toolstrip->view())
- return toolstrip;
- }
- return NULL;
-}
-
-void ExtensionShelf::LoadFromModel() {
- int count = model_->count();
- for (int i = 0; i < count; ++i)
- ToolstripInsertedAt(model_->ToolstripAt(i).host, i);
-}
-
-gfx::Size ExtensionShelf::LayoutItems(bool compute_bounds_only) {
- if (!GetParent() || !model_ || !model_->count())
- return gfx::Size(0, 0);
-
- gfx::Size prefsize;
- int x = kLeftMargin;
- int y = top_margin_;
- int content_height = kShelfHeight - top_margin_ - kBottomMargin;
- int max_x = width() - kRightMargin;
-
- if (OnNewTabPage()) {
- double current_state = 1 - size_animation_->GetCurrentValue();
- x += static_cast<int>(static_cast<double>
- (kNewtabHorizontalPadding + kNewtabExtraHorMargin) * current_state);
- y += static_cast<int>(static_cast<double>
- (kNewtabVerticalPadding + kNewtabExtraVerMargin) * current_state);
- max_x -= static_cast<int>(static_cast<double>
- (2 * kNewtabHorizontalPadding) * current_state);
- }
-
- int count = model_->count();
- for (int i = 0; i < count; ++i) {
- x += kToolstripPadding; // Left padding.
- Toolstrip* toolstrip = ToolstripAtIndex(i);
- if (!toolstrip) // Can be NULL while in the process of removing.
- continue;
- View* view = toolstrip->GetShelfView();
- gfx::Size pref = view->GetPreferredSize();
-
- // |next_x| is the x value for where the next toolstrip in the list will be.
- int next_x = x + pref.width() + kToolstripPadding; // Right padding.
- if (!compute_bounds_only) {
- bool clipped = next_x >= max_x;
- if (clipped)
- pref.set_width(std::max(0, max_x - x));
- if (view == toolstrip->view())
- toolstrip->view()->SetIsClipped(clipped);
- view->SetBounds(x, y, pref.width(), content_height);
- view->Layout();
- if (toolstrip->window_visible())
- toolstrip->LayoutWindow();
- }
- x = next_x + kToolstripDividerWidth;
- }
-
- if (!compute_bounds_only) {
- background_needs_repaint_ = true;
- SchedulePaint();
- } else {
- if (OnNewTabPage()) {
- prefsize.set_height(kShelfHeight + static_cast<int>(static_cast<double>
- (kNewtabShelfHeight - kShelfHeight) *
- (1 - size_animation_->GetCurrentValue())));
- } else {
- prefsize.set_height(static_cast<int>(static_cast<double>(kShelfHeight) *
- size_animation_->GetCurrentValue()));
- }
-
- x += kRightMargin;
- prefsize.set_width(x);
- }
-
- return prefsize;
-}
-
-bool ExtensionShelf::IsDetached() const {
- return OnNewTabPage() && (size_animation_->GetCurrentValue() != 1);
-}
-
-bool ExtensionShelf::IsAlwaysShown() const {
- Profile* profile = browser_->profile();
- return profile->GetPrefs()->GetBoolean(prefs::kShowExtensionShelf);
-}
-
-bool ExtensionShelf::OnNewTabPage() const {
- return (browser_ && browser_->GetSelectedTabContents() &&
- browser_->GetSelectedTabContents()->IsExtensionShelfAlwaysVisible());
-}
-
-void ExtensionShelf::OnFullscreenToggled(bool fullscreen) {
- if (fullscreen == fullscreen_)
- return;
- fullscreen_ = fullscreen;
- if (!IsAlwaysShown())
- return;
- size_animation_->Reset(fullscreen ? 0 : 1);
-}
diff --git a/chrome/browser/views/extensions/extension_shelf.h b/chrome/browser/views/extensions/extension_shelf.h
deleted file mode 100644
index 256b5cc..0000000
--- a/chrome/browser/views/extensions/extension_shelf.h
+++ /dev/null
@@ -1,155 +0,0 @@
-// Copyright (c) 2010 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_VIEWS_EXTENSIONS_EXTENSION_SHELF_H_
-#define CHROME_BROWSER_VIEWS_EXTENSIONS_EXTENSION_SHELF_H_
-#pragma once
-
-#include "app/slide_animation.h"
-#include "base/task.h"
-#include "chrome/browser/extensions/extension_shelf_model.h"
-#include "chrome/browser/extensions/extensions_service.h"
-#include "chrome/browser/views/browser_bubble.h"
-#include "chrome/browser/views/detachable_toolbar_view.h"
-#include "gfx/canvas.h"
-#include "views/view.h"
-
-class Browser;
-namespace views {
- class Label;
- class MouseEvent;
-}
-
-// A shelf that contains Extension toolstrips.
-class ExtensionShelf : public DetachableToolbarView,
- public ExtensionView::Container,
- public ExtensionShelfModelObserver,
- public AnimationDelegate,
- public NotificationObserver {
- public:
- explicit ExtensionShelf(Browser* browser);
- virtual ~ExtensionShelf();
-
- // Get the current model.
- ExtensionShelfModel* model() { return model_; }
-
- // Toggles a preference for whether to always show the extension shelf.
- static void ToggleWhenExtensionShelfVisible(Profile* profile);
-
- int top_margin() { return top_margin_; }
-
- // DetachableToolbarView methods:
- virtual bool IsDetached() const;
- virtual double GetAnimationValue() const {
- return size_animation_->GetCurrentValue();
- }
-
- // View methods:
- virtual void PaintChildren(gfx::Canvas* canvas);
- virtual gfx::Size GetPreferredSize();
- virtual void Layout();
- virtual void OnMouseExited(const views::MouseEvent& event);
- virtual void OnMouseEntered(const views::MouseEvent& event);
- virtual bool GetAccessibleRole(AccessibilityTypes::Role* role);
- virtual void OnThemeChanged();
-
- // ExtensionContainer methods:
- virtual void OnExtensionMouseMove(ExtensionView* view);
- virtual void OnExtensionMouseLeave(ExtensionView* view);
-
- // ExtensionShelfModelObserver methods:
- virtual void ToolstripInsertedAt(ExtensionHost* toolstrip, int index);
- virtual void ToolstripRemovingAt(ExtensionHost* toolstrip, int index);
- virtual void ToolstripDraggingFrom(ExtensionHost* toolstrip, int index);
- virtual void ToolstripMoved(ExtensionHost* toolstrip,
- int from_index,
- int to_index);
- virtual void ToolstripChanged(ExtensionShelfModel::iterator toolstrip);
- virtual void ExtensionShelfEmpty();
- virtual void ShelfModelReloaded();
- virtual void ShelfModelDeleting();
-
- // AnimationDelegate methods:
- virtual void AnimationProgressed(const Animation* animation);
- virtual void AnimationEnded(const Animation* animation);
-
- // NotificationObserver methods:
- virtual void Observe(NotificationType type,
- const NotificationSource& source,
- const NotificationDetails& details);
-
- // Toggle fullscreen mode.
- void OnFullscreenToggled(bool fullscreen);
-
- protected:
- // View methods:
- virtual void ChildPreferredSizeChanged(View* child);
-
- private:
- class Toolstrip;
- friend class Toolstrip;
- class PlaceholderView;
-
- // Dragging toolstrips
- void DropExtension(Toolstrip* handle, const gfx::Point& pt, bool cancel);
-
- // Expand the specified toolstrip, navigating to |url| if non-empty,
- // and setting the |height|.
- void ExpandToolstrip(ExtensionHost* host, const GURL& url, int height);
-
- // Collapse the specified toolstrip, navigating to |url| if non-empty.
- void CollapseToolstrip(ExtensionHost* host, const GURL& url);
-
- // Initializes the background bitmaps for all views.
- void InitBackground(gfx::Canvas* canvas);
-
- // Returns the Toolstrip at |x| coordinate. If |x| is out of bounds, returns
- // NULL.
- Toolstrip* ToolstripAtX(int x);
-
- // Returns the Toolstrip at |index|.
- Toolstrip* ToolstripAtIndex(int index);
-
- // Returns the toolstrip associated with |view|.
- Toolstrip* ToolstripForView(ExtensionView* view);
-
- // Loads initial state from |model_|.
- void LoadFromModel();
-
- // This method computes the bounds for the extension shelf items. If
- // |compute_bounds_only| = TRUE, the bounds for the items are just computed,
- // but are not set. This mode is used by GetPreferredSize() to obtain the
- // desired bounds. If |compute_bounds_only| = FALSE, the bounds are set.
- gfx::Size LayoutItems(bool compute_bounds_only);
-
- // Returns whether the extension shelf always shown (checks pref value).
- bool IsAlwaysShown() const;
-
- // Returns whether the extension shelf is being displayed over the new tab
- // page.
- bool OnNewTabPage() const;
-
- int top_margin_;
-
- NotificationRegistrar registrar_;
-
- // Background bitmap to draw under extension views.
- bool background_needs_repaint_;
-
- // The browser this extension shelf belongs to.
- Browser* browser_;
-
- // The model representing the toolstrips on the shelf.
- ExtensionShelfModel* model_;
-
- // Animation controlling showing and hiding of the shelf.
- scoped_ptr<SlideAnimation> size_animation_;
-
- // Are we in fullscreen mode or not.
- bool fullscreen_;
-
- DISALLOW_COPY_AND_ASSIGN(ExtensionShelf);
-};
-
-#endif // CHROME_BROWSER_VIEWS_EXTENSIONS_EXTENSION_SHELF_H_
diff --git a/chrome/browser/views/extensions/extension_view.cc b/chrome/browser/views/extensions/extension_view.cc
index 355e455..4e7f1ae 100644
--- a/chrome/browser/views/extensions/extension_view.cc
+++ b/chrome/browser/views/extensions/extension_view.cc
@@ -120,13 +120,7 @@ void ExtensionView::ShowIfCompletelyLoaded() {
// We wait to show the ExtensionView until it has loaded, and the view has
// actually been created. These can happen in different orders.
if (host_->did_stop_loading()) {
- // For toolstrips, also wait until our parent has given us a background.
- if (host_->GetRenderViewType() == ViewType::EXTENSION_TOOLSTRIP &&
- render_view_host()->view()->background().empty()) {
- return;
- }
SetVisible(true);
-
UpdatePreferredSize(pending_preferred_size_);
}
}
diff --git a/chrome/browser/views/frame/browser_view.cc b/chrome/browser/views/frame/browser_view.cc
index 0174537..85c2d16 100644
--- a/chrome/browser/views/frame/browser_view.cc
+++ b/chrome/browser/views/frame/browser_view.cc
@@ -10,6 +10,7 @@
#include "app/l10n_util.h"
#include "app/resource_bundle.h"
+#include "base/command_line.h"
#include "base/i18n/rtl.h"
#include "base/string_number_conversions.h"
#include "base/utf_string_conversions.h"
@@ -37,7 +38,6 @@
#include "chrome/browser/views/bookmark_bar_view.h"
#include "chrome/browser/views/browser_dialogs.h"
#include "chrome/browser/views/download_shelf_view.h"
-#include "chrome/browser/views/extensions/extension_shelf.h"
#include "chrome/browser/views/frame/browser_view_layout.h"
#include "chrome/browser/views/fullscreen_exit_bubble.h"
#include "chrome/browser/views/status_bubble_views.h"
@@ -488,12 +488,12 @@ BrowserView::BrowserView(Browser* browser)
contents_(NULL),
contents_split_(NULL),
initialized_(false),
- ignore_layout_(true),
+ ignore_layout_(true)
#if defined(OS_WIN)
- hung_window_detector_(&hung_plugin_action_),
- ticker_(0),
+ ,hung_window_detector_(&hung_plugin_action_),
+ ticker_(0)
#endif
- extension_shelf_(NULL) {
+ {
browser_->tabstrip_model()->AddObserver(this);
}
@@ -807,10 +807,6 @@ void BrowserView::SelectedTabToolbarSizeChanged(bool is_animating) {
}
}
-void BrowserView::SelectedTabExtensionShelfSizeChanged() {
- Layout();
-}
-
void BrowserView::UpdateTitleBar() {
frame_->GetWindow()->UpdateWindowTitle();
if (ShouldShowWindowIcon() && !loading_animation_timer_.IsRunning())
@@ -1068,10 +1064,6 @@ void BrowserView::ToggleBookmarkBar() {
bookmark_utils::ToggleWhenVisible(browser_->profile());
}
-void BrowserView::ToggleExtensionShelf() {
- ExtensionShelf::ToggleWhenExtensionShelfVisible(browser_->profile());
-}
-
views::Window* BrowserView::ShowAboutChromeDialog() {
return browser::ShowAboutChromeView(GetWindow()->GetNativeWindow(),
browser_->profile());
@@ -1872,16 +1864,6 @@ void BrowserView::Init() {
status_bubble_.reset(new StatusBubbleViews(GetWidget()));
- if (browser_->SupportsWindowFeature(Browser::FEATURE_EXTENSIONSHELF)) {
- extension_shelf_ = new ExtensionShelf(browser_.get());
- extension_shelf_->set_background(
- new BookmarkExtensionBackground(this, extension_shelf_,
- browser_.get()));
- extension_shelf_->
- SetAccessibleName(l10n_util::GetString(IDS_ACCNAME_EXTENSIONS));
- AddChildView(extension_shelf_);
- }
-
#if defined(OS_WIN)
InitSystemMenu();
@@ -2113,11 +2095,6 @@ void BrowserView::ProcessFullscreen(bool fullscreen) {
if (bookmark_bar_view_.get())
bookmark_bar_view_->OnFullscreenToggled(fullscreen);
- // Notify extension shelf, so it can set itself to the appropriate drawing
- // state.
- if (extension_shelf_)
- extension_shelf_->OnFullscreenToggled(fullscreen);
-
// Toggle fullscreen mode.
#if defined(OS_WIN)
frame_->GetWindow()->SetFullscreen(fullscreen);
diff --git a/chrome/browser/views/frame/browser_view.h b/chrome/browser/views/frame/browser_view.h
index 62c628c..4cdd39e 100644
--- a/chrome/browser/views/frame/browser_view.h
+++ b/chrome/browser/views/frame/browser_view.h
@@ -46,7 +46,6 @@ class BrowserBubble;
class BrowserViewLayout;
class DownloadShelfView;
class EncodingMenuModel;
-class ExtensionShelf;
class FullscreenExitBubble;
class HtmlDialogUIDelegate;
class InfoBarContainer;
@@ -152,9 +151,6 @@ class BrowserView : public BrowserBubbleHost,
// Accessor for the Toolbar.
ToolbarView* toolbar() const { return toolbar_; }
- // Accessor for the ExtensionShelf.
- ExtensionShelf* extension_shelf() const { return extension_shelf_; }
-
// Returns true if various window components are visible.
bool IsTabStripVisible() const;
@@ -251,7 +247,6 @@ class BrowserView : public BrowserBubbleHost,
virtual BrowserWindowTesting* GetBrowserWindowTesting();
virtual StatusBubble* GetStatusBubble();
virtual void SelectedTabToolbarSizeChanged(bool is_animating);
- virtual void SelectedTabExtensionShelfSizeChanged();
virtual void UpdateTitleBar();
virtual void ShelfVisibilityChanged();
virtual void UpdateDevTools();
@@ -279,7 +274,6 @@ class BrowserView : public BrowserBubbleHost,
virtual void ConfirmAddSearchProvider(const TemplateURL* template_url,
Profile* profile);
virtual void ToggleBookmarkBar();
- virtual void ToggleExtensionShelf();
virtual views::Window* ShowAboutChromeDialog();
virtual void ShowUpdateChromeDialog();
virtual void ShowTaskManager();
@@ -592,9 +586,6 @@ class BrowserView : public BrowserBubbleHost,
// The timer used to update frames for the Loading Animation.
base::RepeatingTimer<BrowserView> loading_animation_timer_;
- // A bottom bar for showing extensions.
- ExtensionShelf* extension_shelf_;
-
UnhandledKeyboardEventHandler unhandled_keyboard_event_handler_;
scoped_ptr<AccessibleViewHelper> accessible_view_helper_;
diff --git a/chrome/browser/views/frame/browser_view_layout.cc b/chrome/browser/views/frame/browser_view_layout.cc
index e7d807b..8af0a07 100644
--- a/chrome/browser/views/frame/browser_view_layout.cc
+++ b/chrome/browser/views/frame/browser_view_layout.cc
@@ -9,7 +9,6 @@
#include "chrome/browser/view_ids.h"
#include "chrome/browser/views/bookmark_bar_view.h"
#include "chrome/browser/views/download_shelf_view.h"
-#include "chrome/browser/views/extensions/extension_shelf.h"
#include "chrome/browser/views/frame/browser_frame.h"
#include "chrome/browser/views/frame/browser_view.h"
#include "chrome/browser/views/tabs/side_tab_strip.h"
@@ -45,7 +44,6 @@ BrowserViewLayout::BrowserViewLayout()
contents_container_(NULL),
infobar_container_(NULL),
download_shelf_(NULL),
- extension_shelf_(NULL),
active_bookmark_bar_(NULL),
browser_view_(NULL),
find_bar_y_(0) {
@@ -199,7 +197,6 @@ void BrowserViewLayout::Installed(views::View* host) {
contents_container_ = NULL;
infobar_container_ = NULL;
download_shelf_ = NULL;
- extension_shelf_ = NULL;
active_bookmark_bar_ = NULL;
tabstrip_ = NULL;
browser_view_ = static_cast<BrowserView*>(host);
@@ -219,9 +216,6 @@ void BrowserViewLayout::ViewAdded(views::View* host, views::View* view) {
case VIEW_ID_DOWNLOAD_SHELF:
download_shelf_ = static_cast<DownloadShelfView*>(view);
break;
- case VIEW_ID_DEV_EXTENSION_SHELF:
- extension_shelf_ = static_cast<ExtensionShelf*>(view);
- break;
case VIEW_ID_BOOKMARK_BAR:
active_bookmark_bar_ = static_cast<BookmarkBarView*>(view);
break;
@@ -247,7 +241,7 @@ void BrowserViewLayout::Layout(views::View* host) {
int top = LayoutTabStrip();
top = LayoutToolbar(top);
top = LayoutBookmarkAndInfoBars(top);
- int bottom = LayoutExtensionAndDownloadShelves();
+ int bottom = LayoutDownloadShelf(browser_view_->height());
LayoutTabContents(top, bottom);
// This must be done _after_ we lay out the TabContents since this
// code calls back into us to find the bounding box the find bar
@@ -368,24 +362,6 @@ void BrowserViewLayout::LayoutTabContents(int top, int bottom) {
vertical_layout_rect_.width(), bottom - top);
}
-int BrowserViewLayout::LayoutExtensionAndDownloadShelves() {
- // If we're showing the Extension bar in detached style, then we
- // need to show Download shelf _above_ the Extension bar, since
- // the Extension bar is styled to look like it's part of the page.
- //
- // TODO(Oshima): confirm this comment.
- int bottom = browser_view_->height();
- if (extension_shelf_) {
- if (extension_shelf_->IsDetached()) {
- bottom = LayoutDownloadShelf(bottom);
- return LayoutExtensionShelf(bottom);
- }
- // Otherwise, Extension shelf first, Download shelf second.
- bottom = LayoutExtensionShelf(bottom);
- }
- return LayoutDownloadShelf(bottom);
-}
-
int BrowserViewLayout::LayoutDownloadShelf(int bottom) {
// Re-layout the shelf either if it is visible or if it's close animation
// is currently running.
@@ -404,17 +380,3 @@ int BrowserViewLayout::LayoutDownloadShelf(int bottom) {
return bottom;
}
-int BrowserViewLayout::LayoutExtensionShelf(int bottom) {
- if (extension_shelf_) {
- bool visible = browser()->SupportsWindowFeature(
- Browser::FEATURE_EXTENSIONSHELF);
- int height =
- visible ? extension_shelf_->GetPreferredSize().height() : 0;
- extension_shelf_->SetVisible(visible && height != 0);
- extension_shelf_->SetBounds(vertical_layout_rect_.x(), bottom - height,
- vertical_layout_rect_.width(), height);
- extension_shelf_->Layout();
- bottom -= height;
- }
- return bottom;
-}
diff --git a/chrome/browser/views/frame/browser_view_layout.h b/chrome/browser/views/frame/browser_view_layout.h
index 30f3756..e0e0975 100644
--- a/chrome/browser/views/frame/browser_view_layout.h
+++ b/chrome/browser/views/frame/browser_view_layout.h
@@ -58,16 +58,11 @@ class BrowserViewLayout : public views::LayoutManager {
// Layout the TabContents container, between the coordinates |top| and
// |bottom|.
void LayoutTabContents(int top, int bottom);
- int LayoutExtensionAndDownloadShelves();
// Layout the Download Shelf, returns the coordinate of the top of the
// control, for laying out the previous control.
int LayoutDownloadShelf(int bottom);
- // Layout the Extension Shelf, returns the coordinate of the top of the
- // control, for laying out the previous control.
- int LayoutExtensionShelf(int bottom);
-
// See description above vertical_layout_rect_ for details.
void set_vertical_layout_rect(const gfx::Rect& bounds) {
vertical_layout_rect_ = bounds;
@@ -83,7 +78,6 @@ class BrowserViewLayout : public views::LayoutManager {
views::View* contents_container_;
views::View* infobar_container_;
DownloadShelfView* download_shelf_;
- ExtensionShelf* extension_shelf_;
BookmarkBarView* active_bookmark_bar_;
BrowserView* browser_view_;