summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/app/chrome_dll_resource.h1
-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
-rw-r--r--chrome/chrome_browser.gypi13
-rw-r--r--chrome/chrome_tests.gypi3
-rw-r--r--chrome/common/chrome_switches.cc3
-rw-r--r--chrome/common/chrome_switches.h1
-rw-r--r--chrome/common/extensions/api/extension_api.json40
-rw-r--r--chrome/common/extensions/extension.cc31
-rw-r--r--chrome/common/extensions/extension.h13
-rw-r--r--chrome/common/extensions/extension_constants.cc2
-rw-r--r--chrome/common/extensions/extension_constants.h2
-rw-r--r--chrome/common/notification_type.h8
-rw-r--r--chrome/common/pref_names.cc3
-rw-r--r--chrome/common/pref_names.h1
-rw-r--r--chrome/common/view_types.cc2
-rw-r--r--chrome/common/view_types.h4
-rw-r--r--chrome/renderer/extensions/extension_process_bindings.cc1432
-rw-r--r--chrome/renderer/extensions/extension_process_bindings.h5
-rw-r--r--chrome/renderer/render_view.cc25
-rw-r--r--chrome/renderer/render_view.h6
-rw-r--r--chrome/renderer/renderer_resources.grd1
-rw-r--r--chrome/renderer/resources/extension_toolstrip.css100
-rw-r--r--chrome/test/data/extensions/api_test/README.txt2
-rw-r--r--chrome/test/data/extensions/api_test/toolstrip/folder/relative.html8
-rw-r--r--chrome/test/data/extensions/api_test/toolstrip/manifest.json6
-rw-r--r--chrome/test/data/extensions/api_test/toolstrip/test.html42
-rw-r--r--chrome/test/data/extensions/api_test/toolstrip/test2.html9
-rw-r--r--chrome/test/data/extensions/browsertest/last_error/bg.html (renamed from chrome/test/data/extensions/browsertest/last_error/toolstrip.html)0
-rw-r--r--chrome/test/data/extensions/browsertest/last_error/manifest.json2
-rw-r--r--chrome/test/data/extensions/common/one_in_shelf/manifest.json8
-rw-r--r--chrome/test/data/extensions/common/one_in_shelf/shelf.html2
-rw-r--r--chrome/test/data/extensions/good/Extensions/behllobkkfkfnphdnhnkndlbkcpglgmj/1.0.0.0/manifest.json8
-rw-r--r--chrome/test/data/extensions/good/Extensions/behllobkkfkfnphdnhnkndlbkcpglgmj/1.0.0.0/toolstrip1.html59
-rw-r--r--chrome/test/data/extensions/good/Extensions/behllobkkfkfnphdnhnkndlbkcpglgmj/1.0.0.0/toolstrip2.html4
-rw-r--r--chrome/test/data/extensions/good/Preferences8
-rw-r--r--chrome/test/data/extensions/profiles/toolstrips1/Default/Extensions/behllobkkfkfnphdnhnkndlbkcpglgmj/1.0.0.0/manifest.json8
-rw-r--r--chrome/test/data/extensions/profiles/toolstrips1/Default/Extensions/behllobkkfkfnphdnhnkndlbkcpglgmj/1.0.0.0/toolstrip1.html5
-rw-r--r--chrome/test/data/extensions/profiles/toolstrips1/Default/Preferences36
-rw-r--r--chrome/test/data/extensions/profiles/toolstrips50/Default/Extensions/behllobkkfkfnphdnhnkndlbkcpglgmj/1.0.0.0/manifest.json73
-rw-r--r--chrome/test/data/extensions/profiles/toolstrips50/Default/Extensions/behllobkkfkfnphdnhnkndlbkcpglgmj/1.0.0.0/toolstrip1.html5
-rw-r--r--chrome/test/data/extensions/profiles/toolstrips50/Default/Preferences101
-rw-r--r--chrome/test/startup/startup_test.cc17
-rw-r--r--chrome/test/test_browser_window.h2
88 files changed, 746 insertions, 3946 deletions
diff --git a/chrome/app/chrome_dll_resource.h b/chrome/app/chrome_dll_resource.h
index 9022381..7835826 100644
--- a/chrome/app/chrome_dll_resource.h
+++ b/chrome/app/chrome_dll_resource.h
@@ -205,7 +205,6 @@
#define IDC_ABOUT 40018
#define IDC_HELP_PAGE 40019
#define IDC_SHOW_APP_MENU 40020
-#define IDC_SHOW_EXTENSION_SHELF 40021
#define IDC_MANAGE_EXTENSIONS 40022
#define IDC_AUTOFILL_DEFAULT 40023
#define IDC_DEV_TOOLS_INSPECT 40025
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_;
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index 35807fa..c43c430 100644
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -1374,8 +1374,6 @@
'browser/extensions/extension_proxy_api.h',
'browser/extensions/extension_rlz_module.cc',
'browser/extensions/extension_rlz_module.h',
- 'browser/extensions/extension_shelf_model.cc',
- 'browser/extensions/extension_shelf_model.h',
'browser/extensions/extension_tabs_module.cc',
'browser/extensions/extension_tabs_module.h',
'browser/extensions/extension_tabs_module_constants.cc',
@@ -1386,8 +1384,6 @@
'browser/extensions/extension_tts_api.h',
'browser/extensions/extension_toolbar_model.cc',
'browser/extensions/extension_toolbar_model.h',
- 'browser/extensions/extension_toolstrip_api.cc',
- 'browser/extensions/extension_toolstrip_api.h',
'browser/extensions/extension_updater.cc',
'browser/extensions/extension_updater.h',
'browser/extensions/extension_web_navigation_api_constants.cc',
@@ -2685,8 +2681,6 @@
'browser/views/extensions/extension_installed_bubble.h',
'browser/views/extensions/extension_popup.cc',
'browser/views/extensions/extension_popup.h',
- 'browser/views/extensions/extension_shelf.cc',
- 'browser/views/extensions/extension_shelf.h',
'browser/views/extensions/extension_view.cc',
'browser/views/extensions/extension_view.h',
'browser/views/external_protocol_dialog.cc',
@@ -3021,9 +3015,6 @@
],
},
'sources!': [
- # Exclude extension shelf for toolstrips.
- 'browser/views/extensions/extension_shelf.cc',
- 'browser/views/extensions/extension_shelf.h',
'browser/views/extensions/extension_view.cc',
'browser/views/extensions/extension_view.h',
],
@@ -3097,8 +3088,6 @@
'browser/renderer_host/gpu_view_host.h',
'browser/renderer_host/video_layer_proxy.cc',
'browser/renderer_host/video_layer_proxy.h',
- 'browser/views/extensions/extension_shelf.cc',
- 'browser/views/extensions/extension_shelf.h',
'browser/views/extensions/extension_view.cc',
'browser/views/extensions/extension_view.h',
],
@@ -3383,8 +3372,6 @@
['include', '^browser/views/extensions/extension_installed_bubble.h'],
['include', '^browser/views/extensions/extension_popup.cc'],
['include', '^browser/views/extensions/extension_popup.h'],
- ['include', '^browser/views/extensions/extension_shelf.cc'],
- ['include', '^browser/views/extensions/extension_shelf.h'],
['include', '^browser/views/extensions/extension_view.cc'],
['include', '^browser/views/extensions/extension_view.h'],
['include', '^browser/views/extension_view.cc'],
diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi
index 2f3d647..a6e49b0 100644
--- a/chrome/chrome_tests.gypi
+++ b/chrome/chrome_tests.gypi
@@ -1602,14 +1602,12 @@
'browser/extensions/extension_proxy_apitest.cc',
'browser/extensions/extension_processes_apitest.cc',
'browser/extensions/extension_rlz_apitest.cc',
- 'browser/extensions/extension_shelf_model_browsertest.cc',
'browser/extensions/extension_startup_browsertest.cc',
'browser/extensions/extension_storage_apitest.cc',
'browser/extensions/extension_tabs_apitest.cc',
'browser/extensions/extension_test_message_listener.cc',
'browser/extensions/extension_test_message_listener.h',
'browser/extensions/extension_toolbar_model_browsertest.cc',
- 'browser/extensions/extension_toolstrip_apitest.cc',
'browser/extensions/extension_tts_apitest.cc',
'browser/extensions/extension_webnavigation_apitest.cc',
'browser/extensions/extension_webrequest_apitest.cc',
@@ -1714,7 +1712,6 @@
'app/chrome_dll_version.rc.version',
'browser/extensions/extension_popup_apitest.cc',
'browser/extensions/extension_rlz_apitest.cc',
- 'browser/extensions/extension_shelf_model_browsertest.cc',
# TODO(jam): http://crbug.com/15101 These tests fail on Linux and
# Mac.
'browser/child_process_security_policy_browsertest.cc',
diff --git a/chrome/common/chrome_switches.cc b/chrome/common/chrome_switches.cc
index 3f8b0f5..16a6800 100644
--- a/chrome/common/chrome_switches.cc
+++ b/chrome/common/chrome_switches.cc
@@ -345,9 +345,6 @@ const char kEnableExperimentalWebGL[] = "enable-webgl";
// Enable experimental timeline API.
const char kEnableExtensionTimelineApi[] = "enable-extension-timeline-api";
-// Enable extension toolstrips (deprecated API - will be removed).
-const char kEnableExtensionToolstrips[] = "enable-extension-toolstrips";
-
// Enable the fastback page cache.
const char kEnableFastback[] = "enable-fastback";
diff --git a/chrome/common/chrome_switches.h b/chrome/common/chrome_switches.h
index dde93de..0078657 100644
--- a/chrome/common/chrome_switches.h
+++ b/chrome/common/chrome_switches.h
@@ -114,7 +114,6 @@ extern const char kEnableDNSSECCerts[];
extern const char kEnableExperimentalExtensionApis[];
extern const char kEnableExperimentalWebGL[];
extern const char kEnableExtensionTimelineApi[];
-extern const char kEnableExtensionToolstrips[];
extern const char kEnableFastback[];
extern const char kEnableFileCookies[];
extern const char kEnableGPUPlugin[];
diff --git a/chrome/common/extensions/api/extension_api.json b/chrome/common/extensions/api/extension_api.json
index e0530b9..670d72b 100644
--- a/chrome/common/extensions/api/extension_api.json
+++ b/chrome/common/extensions/api/extension_api.json
@@ -2148,46 +2148,6 @@
]
},
{
- "namespace": "toolstrip",
- "nodoc": true,
- "types": [],
- "functions": [
- {
- "name": "expand",
- "type": "function",
- "description": "",
- "parameters": [
- {
- "type": "object",
- "name": "expandInfo",
- "properties": {
- "height": { "type": "integer", "minimum": 0, "description": "The vertical pixel height required of the toolstrip area." },
- "url": { "type": "string", "optional": true, "description": "If present, the toolstrip mole will change it's content to the provided URL. Otherwise, the current page will just be expanded in size." }
- }
- },
- {"type": "function", "name": "callback", "optional": true, "parameters": []}
- ]
- },
- {
- "name": "collapse",
- "type": "function",
- "description": "",
- "parameters": [
- {
- "type": "object",
- "name": "collapseInfo",
- "optional": true,
- "properties": {
- "url": { "type": "string", "optional": true, "description": "If present, the toolstrip mole will change it's content to the provided URL. Otherwise, the current page will just be collapsed in size." }
- }
- },
- {"type": "function", "name": "callback", "optional": true, "parameters": []}
- ]
- }
- ],
- "events": []
- },
- {
"namespace": "i18n",
"unprivileged": true,
"types": [],
diff --git a/chrome/common/extensions/extension.cc b/chrome/common/extensions/extension.cc
index d69527e..3e5701d 100644
--- a/chrome/common/extensions/extension.cc
+++ b/chrome/common/extensions/extension.cc
@@ -1257,10 +1257,11 @@ bool Extension::InitFromValue(const DictionaryValue& source, bool require_key,
options_url_ = GetResourceURL(options_str);
}
- // Initialize toolstrips (deprecated and optional).
- // TODO(erikkay) remove this altogether.
+ // Initialize toolstrips. This is deprecated for public use.
+ // NOTE(erikkay) Although deprecated, we intend to preserve this parsing
+ // code indefinitely. Please contact me or Joi for details as to why.
if (CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kEnableExtensionToolstrips) &&
+ switches::kEnableExperimentalExtensionApis) &&
source.HasKey(keys::kToolstrips)) {
ListValue* list_value;
if (!source.GetList(keys::kToolstrips, &list_value)) {
@@ -1269,12 +1270,12 @@ bool Extension::InitFromValue(const DictionaryValue& source, bool require_key,
}
for (size_t i = 0; i < list_value->GetSize(); ++i) {
- ToolstripInfo toolstrip;
+ GURL toolstrip;
DictionaryValue* toolstrip_value;
std::string toolstrip_path;
if (list_value->GetString(i, &toolstrip_path)) {
// Support a simple URL value for backwards compatibility.
- toolstrip.toolstrip = GetResourceURL(toolstrip_path);
+ toolstrip = GetResourceURL(toolstrip_path);
} else if (list_value->GetDictionary(i, &toolstrip_value)) {
if (!toolstrip_value->GetString(keys::kToolstripPath,
&toolstrip_path)) {
@@ -1282,25 +1283,7 @@ bool Extension::InitFromValue(const DictionaryValue& source, bool require_key,
errors::kInvalidToolstrip, base::IntToString(i));
return false;
}
- toolstrip.toolstrip = GetResourceURL(toolstrip_path);
- if (toolstrip_value->HasKey(keys::kToolstripMolePath)) {
- std::string mole_path;
- if (!toolstrip_value->GetString(keys::kToolstripMolePath,
- &mole_path)) {
- *error = ExtensionErrorUtils::FormatErrorMessage(
- errors::kInvalidToolstrip, base::IntToString(i));
- return false;
- }
- int height;
- if (!toolstrip_value->GetInteger(keys::kToolstripMoleHeight,
- &height) || (height < 0)) {
- *error = ExtensionErrorUtils::FormatErrorMessage(
- errors::kInvalidToolstrip, base::IntToString(i));
- return false;
- }
- toolstrip.mole = GetResourceURL(mole_path);
- toolstrip.mole_height = height;
- }
+ toolstrip = GetResourceURL(toolstrip_path);
} else {
*error = ExtensionErrorUtils::FormatErrorMessage(
errors::kInvalidToolstrip, base::IntToString(i));
diff --git a/chrome/common/extensions/extension.h b/chrome/common/extensions/extension.h
index 9bcd7b1..3ab2482 100644
--- a/chrome/common/extensions/extension.h
+++ b/chrome/common/extensions/extension.h
@@ -125,15 +125,6 @@ class Extension {
bool is_public; // False if only this extension can load this plugin.
};
- // A toolstrip and its associated mole.
- struct ToolstripInfo {
- ToolstripInfo() : mole_height(0) {}
-
- GURL toolstrip;
- GURL mole;
- int mole_height;
- };
-
// The name of the manifest inside an extension.
static const FilePath::CharType kManifestFilename[];
@@ -265,7 +256,7 @@ class Extension {
const GURL& background_url() const { return background_url_; }
const GURL& options_url() const { return options_url_; }
const GURL& devtools_url() const { return devtools_url_; }
- const std::vector<ToolstripInfo>& toolstrips() const { return toolstrips_; }
+ const std::vector<GURL>& toolstrips() const { return toolstrips_; }
const std::vector<std::string>& api_permissions() const {
return api_permissions_;
}
@@ -495,7 +486,7 @@ class Extension {
GURL devtools_url_;
// Optional list of toolstrips_ and associated properties.
- std::vector<ToolstripInfo> toolstrips_;
+ std::vector<GURL> toolstrips_;
// The public key ('key' in the manifest) used to sign the contents of the
// crx package ('signature' in the manifest)
diff --git a/chrome/common/extensions/extension_constants.cc b/chrome/common/extensions/extension_constants.cc
index 0f4f5dd..a14b244 100644
--- a/chrome/common/extensions/extension_constants.cc
+++ b/chrome/common/extensions/extension_constants.cc
@@ -57,8 +57,6 @@ const char* kThemeColors = "colors";
const char* kThemeDisplayProperties = "properties";
const char* kThemeImages = "images";
const char* kThemeTints = "tints";
-const char* kToolstripMoleHeight = "mole_height";
-const char* kToolstripMolePath = "mole";
const char* kToolstripPath = "path";
const char* kToolstrips = "toolstrips";
const char* kType = "type";
diff --git a/chrome/common/extensions/extension_constants.h b/chrome/common/extensions/extension_constants.h
index 3258449..83817b8 100644
--- a/chrome/common/extensions/extension_constants.h
+++ b/chrome/common/extensions/extension_constants.h
@@ -59,8 +59,6 @@ namespace extension_manifest_keys {
extern const char* kThemeDisplayProperties;
extern const char* kThemeImages;
extern const char* kThemeTints;
- extern const char* kToolstripMoleHeight;
- extern const char* kToolstripMolePath;
extern const char* kToolstripPath;
extern const char* kToolstrips;
extern const char* kType;
diff --git a/chrome/common/notification_type.h b/chrome/common/notification_type.h
index 7c19c9e..f07cb59 100644
--- a/chrome/common/notification_type.h
+++ b/chrome/common/notification_type.h
@@ -476,11 +476,6 @@ class NotificationType {
// NoDetails.
BOOKMARK_BAR_VISIBILITY_PREF_CHANGED,
- // This is sent when the user's preference (for when the extension shelf
- // should be shown) changes. The source is the profile, and the details are
- // NoDetails.
- EXTENSION_SHELF_VISIBILITY_PREF_CHANGED,
-
// Sent just before the installation confirm dialog is shown. The source
// is the ExtensionInstallUI, the details are NoDetails.
EXTENSION_WILL_SHOW_CONFIRM_DIALOG,
@@ -845,9 +840,6 @@ class NotificationType {
// during browser shutdown.
EXTENSION_PROCESS_TERMINATED,
- // Sent when the contents or order of toolstrips in the shelf model change.
- EXTENSION_SHELF_MODEL_CHANGED,
-
// Sent when a background page is ready so other components can load.
EXTENSION_BACKGROUND_PAGE_READY,
diff --git a/chrome/common/pref_names.cc b/chrome/common/pref_names.cc
index 7eab2f9..01f3a6a2 100644
--- a/chrome/common/pref_names.cc
+++ b/chrome/common/pref_names.cc
@@ -808,9 +808,6 @@ const char kDisableVideoAndChat[] = "disable_video_chat";
// Whether Extensions are enabled.
const char kDisableExtensions[] = "extensions.disabled";
-// Boolean which specifies whether the Extension Shelf is visible on all tabs.
-const char kShowExtensionShelf[] = "extensions.shelf.show_on_all_tabs";
-
// Integer boolean representing the width (in pixels) of the container for
// browser actions.
const char kBrowserActionContainerWidth[] =
diff --git a/chrome/common/pref_names.h b/chrome/common/pref_names.h
index 2fa8b7b..21d44db 100644
--- a/chrome/common/pref_names.h
+++ b/chrome/common/pref_names.h
@@ -298,7 +298,6 @@ extern const char kNumKeywords[];
extern const char kDisableVideoAndChat[];
extern const char kDisableExtensions[];
-extern const char kShowExtensionShelf[];
extern const char kBrowserActionContainerWidth[];
extern const char kLastExtensionsUpdateCheck[];
diff --git a/chrome/common/view_types.cc b/chrome/common/view_types.cc
index c32174b..73c604f 100644
--- a/chrome/common/view_types.cc
+++ b/chrome/common/view_types.cc
@@ -5,8 +5,6 @@
#include "chrome/common/view_types.h"
const char* ViewType::kTabContents = "TAB";
-const char* ViewType::kToolstrip = "TOOLSTRIP";
-const char* ViewType::kMole = "MOLE";
const char* ViewType::kBackgroundPage = "BACKGROUND";
const char* ViewType::kPopup = "POPUP";
const char* ViewType::kInfobar = "INFOBAR";
diff --git a/chrome/common/view_types.h b/chrome/common/view_types.h
index 2947a29..2d9c539 100644
--- a/chrome/common/view_types.h
+++ b/chrome/common/view_types.h
@@ -15,8 +15,6 @@ class ViewType {
INVALID,
BACKGROUND_CONTENTS,
TAB_CONTENTS,
- EXTENSION_TOOLSTRIP,
- EXTENSION_MOLE,
EXTENSION_BACKGROUND_PAGE,
EXTENSION_POPUP,
EXTENSION_INFOBAR,
@@ -28,8 +26,6 @@ class ViewType {
// Constant strings corresponding to the Type enumeration values. Used
// when converting JS arguments.
static const char* kTabContents;
- static const char* kToolstrip;
- static const char* kMole;
static const char* kBackgroundPage;
static const char* kPopup;
static const char* kInfobar;
diff --git a/chrome/renderer/extensions/extension_process_bindings.cc b/chrome/renderer/extensions/extension_process_bindings.cc
index 8057e67..1a97872 100644
--- a/chrome/renderer/extensions/extension_process_bindings.cc
+++ b/chrome/renderer/extensions/extension_process_bindings.cc
@@ -1,732 +1,700 @@
-// 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/renderer/extensions/extension_process_bindings.h"
-
-#include <map>
-#include <set>
-#include <string>
-#include <vector>
-
-#include "base/command_line.h"
-#include "base/json/json_reader.h"
-#include "base/scoped_ptr.h"
-#include "base/singleton.h"
-#include "base/string_util.h"
-#include "chrome/common/chrome_switches.h"
-#include "chrome/common/extensions/extension.h"
-#include "chrome/common/extensions/extension_constants.h"
-#include "chrome/common/extensions/url_pattern.h"
-#include "chrome/common/render_messages.h"
-#include "chrome/common/url_constants.h"
-#include "chrome/renderer/extensions/bindings_utils.h"
-#include "chrome/renderer/extensions/event_bindings.h"
-#include "chrome/renderer/extensions/js_only_v8_extensions.h"
-#include "chrome/renderer/extensions/renderer_extension_bindings.h"
-#include "chrome/renderer/user_script_slave.h"
-#include "chrome/renderer/render_thread.h"
-#include "chrome/renderer/render_view.h"
-#include "chrome/renderer/render_view_visitor.h"
-#include "grit/common_resources.h"
-#include "grit/renderer_resources.h"
-#include "third_party/skia/include/core/SkBitmap.h"
-#include "third_party/skia/include/core/SkColor.h"
-#include "third_party/WebKit/WebKit/chromium/public/WebFrame.h"
-#include "third_party/WebKit/WebKit/chromium/public/WebURL.h"
-#include "third_party/WebKit/WebKit/chromium/public/WebKit.h"
-#include "third_party/WebKit/WebKit/chromium/public/WebSecurityPolicy.h"
-#include "third_party/WebKit/WebKit/chromium/public/WebView.h"
-
-using bindings_utils::GetStringResource;
-using bindings_utils::ContextInfo;
-using bindings_utils::ContextList;
-using bindings_utils::GetContexts;
-using bindings_utils::GetPendingRequestMap;
-using bindings_utils::PendingRequest;
-using bindings_utils::PendingRequestMap;
-using bindings_utils::ExtensionBase;
-using WebKit::WebFrame;
-using WebKit::WebSecurityPolicy;
-using WebKit::WebView;
-
-namespace {
-
-// A map of extension ID to vector of page action ids.
-typedef std::map< std::string, std::vector<std::string> > PageActionIdMap;
-
-// A map of permission name to whether its enabled for this extension.
-typedef std::map<std::string, bool> PermissionsMap;
-
-// A map of extension ID to permissions map.
-typedef std::map<std::string, PermissionsMap> ExtensionPermissionsMap;
-
-// A map of extension ID to whether this extension was enabled in incognito.
-typedef std::map<std::string, bool> IncognitoEnabledMap;
-
-const char kExtensionName[] = "chrome/ExtensionProcessBindings";
-const char* kExtensionDeps[] = {
- BaseJsV8Extension::kName,
- EventBindings::kName,
- JsonSchemaJsV8Extension::kName,
- RendererExtensionBindings::kName,
- ExtensionApiTestV8Extension::kName,
-};
-
-// A list of the API packages which have no associated permission.
-// TODO(erikkay) It might be nice if for consistency we could merge these with
-// the permissions list, or at least have them in one place.
-const char* kNonPermissionExtensionPackages[] = {
- "extension",
- // TODO(erikkay): We're inconsistent about the the package name in the events
- // for pageAction and browserAction.
- "pageAction",
- "pageActions",
- "browserAction",
- "browserActions",
- "i18n",
- "devtools",
- "test"
-};
-
-struct SingletonData {
- std::set<std::string> function_names_;
- PageActionIdMap page_action_ids_;
- ExtensionPermissionsMap permissions_;
- IncognitoEnabledMap incognito_enabled_map_;
-};
-
-static std::set<std::string>* GetFunctionNameSet() {
- return &Singleton<SingletonData>()->function_names_;
-}
-
-static PageActionIdMap* GetPageActionMap() {
- return &Singleton<SingletonData>()->page_action_ids_;
-}
-
-static PermissionsMap* GetPermissionsMap(const std::string& extension_id) {
- return &Singleton<SingletonData>()->permissions_[extension_id];
-}
-
-static IncognitoEnabledMap* GetIncognitoEnabledMap() {
- return &Singleton<SingletonData>()->incognito_enabled_map_;
-}
-
-static void GetActiveExtensionIDs(std::set<std::string>* extension_ids) {
- ExtensionPermissionsMap& permissions =
- Singleton<SingletonData>()->permissions_;
-
- for (ExtensionPermissionsMap::iterator iter = permissions.begin();
- iter != permissions.end(); ++iter) {
- extension_ids->insert(iter->first);
- }
-}
-
-// A RenderViewVisitor class that iterates through the set of available
-// views, looking for a view of the given type, in the given browser window
-// and within the given extension.
-// Used to accumulate the list of views associated with an extension.
-class ExtensionViewAccumulator : public RenderViewVisitor {
- public:
- ExtensionViewAccumulator(const std::string& extension_id,
- int browser_window_id,
- ViewType::Type view_type)
- : extension_id_(extension_id),
- browser_window_id_(browser_window_id),
- view_type_(view_type),
- views_(v8::Array::New()),
- index_(0) {
- }
-
- v8::Local<v8::Array> views() { return views_; }
-
- virtual bool Visit(RenderView* render_view) {
- if (!ViewTypeMatches(render_view->view_type(), view_type_))
- return true;
-
- GURL url = render_view->webview()->mainFrame()->url();
- if (!url.SchemeIs(chrome::kExtensionScheme))
- return true;
- const std::string& extension_id = url.host();
- if (extension_id != extension_id_)
- return true;
-
- // If we are searching for a pop-up, it may be the case that the pop-up
- // is not attached to a browser window instance. (It is hosted in a
- // ExternalTabContainer.) If so, then bypass validation of
- // same-browser-window origin.
- // TODO(twiz): The browser window id of the views visited should always
- // match that of the arguments to the accumulator.
- // See bug: http://crbug.com/29646
- if (!(view_type_ == ViewType::EXTENSION_POPUP &&
- render_view->browser_window_id() ==
- extension_misc::kUnknownWindowId)) {
- if (browser_window_id_ != extension_misc::kUnknownWindowId &&
- render_view->browser_window_id() != browser_window_id_) {
- return true;
- }
- }
-
- v8::Local<v8::Context> context =
- render_view->webview()->mainFrame()->mainWorldScriptContext();
- if (!context.IsEmpty()) {
- v8::Local<v8::Value> window = context->Global();
- DCHECK(!window.IsEmpty());
-
- if (!OnMatchedView(window))
- return false;
- }
- return true;
- }
-
- private:
- // Called on each view found matching the search criteria. Returns false
- // to terminate the iteration.
- bool OnMatchedView(const v8::Local<v8::Value>& view_window) {
- views_->Set(v8::Integer::New(index_), view_window);
- index_++;
-
- if (view_type_ == ViewType::EXTENSION_BACKGROUND_PAGE)
- return false; // There can be only one...
-
- return true;
- }
-
- // Returns true is |type| "isa" |match|.
- static bool ViewTypeMatches(ViewType::Type type, ViewType::Type match) {
- if (type == match)
- return true;
-
- // INVALID means match all.
- if (match == ViewType::INVALID)
- return true;
-
- // TODO(erikkay) for now, special case mole as a type of toolstrip.
- // Perhaps this isn't the right long-term thing to do.
- if (match == ViewType::EXTENSION_TOOLSTRIP &&
- type == ViewType::EXTENSION_MOLE) {
- return true;
- }
-
- return false;
- }
-
- std::string extension_id_;
- int browser_window_id_;
- ViewType::Type view_type_;
- v8::Local<v8::Array> views_;
- int index_;
-};
-
-class ExtensionImpl : public ExtensionBase {
- public:
- ExtensionImpl() : ExtensionBase(
- kExtensionName, GetStringResource<IDR_EXTENSION_PROCESS_BINDINGS_JS>(),
- arraysize(kExtensionDeps), kExtensionDeps) {}
-
- static void SetFunctionNames(const std::vector<std::string>& names) {
- std::set<std::string>* name_set = GetFunctionNameSet();
- for (size_t i = 0; i < names.size(); ++i) {
- name_set->insert(names[i]);
- }
- }
-
- // Note: do not call this function before or during the chromeHidden.onLoad
- // event dispatch. The URL might not have been committed yet and might not
- // be an extension URL.
- static std::string ExtensionIdForCurrentContext() {
- RenderView* renderview = bindings_utils::GetRenderViewForCurrentContext();
- if (!renderview)
- return std::string(); // this can happen as a tab is closing.
-
- GURL url = renderview->webview()->mainFrame()->url();
- if (!url.SchemeIs(chrome::kExtensionScheme))
- return std::string();
-
- return url.host();
- }
-
- virtual v8::Handle<v8::FunctionTemplate> GetNativeFunction(
- v8::Handle<v8::String> name) {
- if (name->Equals(v8::String::New("GetExtensionAPIDefinition"))) {
- return v8::FunctionTemplate::New(GetExtensionAPIDefinition);
- } else if (name->Equals(v8::String::New("GetExtensionViews"))) {
- return v8::FunctionTemplate::New(GetExtensionViews);
- } else if (name->Equals(v8::String::New("GetNextRequestId"))) {
- return v8::FunctionTemplate::New(GetNextRequestId);
- } else if (name->Equals(v8::String::New("OpenChannelToTab"))) {
- return v8::FunctionTemplate::New(OpenChannelToTab);
- } else if (name->Equals(v8::String::New("GetCurrentPageActions"))) {
- return v8::FunctionTemplate::New(GetCurrentPageActions);
- } else if (name->Equals(v8::String::New("StartRequest"))) {
- return v8::FunctionTemplate::New(StartRequest);
- } else if (name->Equals(v8::String::New("GetRenderViewId"))) {
- return v8::FunctionTemplate::New(GetRenderViewId);
- } else if (name->Equals(v8::String::New("GetPopupView"))) {
- return v8::FunctionTemplate::New(GetPopupView);
- } else if (name->Equals(v8::String::New("GetPopupParentWindow"))) {
- return v8::FunctionTemplate::New(GetPopupParentWindow);
- } else if (name->Equals(v8::String::New("SetExtensionActionIcon"))) {
- return v8::FunctionTemplate::New(SetExtensionActionIcon);
- } else if (name->Equals(v8::String::New("IsExtensionProcess"))) {
- return v8::FunctionTemplate::New(IsExtensionProcess);
- }
-
- return ExtensionBase::GetNativeFunction(name);
- }
-
- private:
- static v8::Handle<v8::Value> GetExtensionAPIDefinition(
- const v8::Arguments& args) {
- return v8::String::New(GetStringResource<IDR_EXTENSION_API_JSON>());
- }
-
- static v8::Handle<v8::Value> PopupViewFinder(
- const v8::Arguments& args,
- ViewType::Type viewtype_to_find) {
- // TODO(twiz) Correct the logic that ties the ownership of the pop-up view
- // to the hosting view. At the moment we assume that there may only be
- // a single pop-up view for a given extension. By doing so, we can find
- // the pop-up view by simply searching for the only pop-up view present.
- // We also assume that if the current view is a pop-up, we can find the
- // hosting view by searching for a TOOLSTRIP view.
- if (args.Length() != 0)
- return v8::Undefined();
-
- if (viewtype_to_find != ViewType::EXTENSION_POPUP &&
- viewtype_to_find != ViewType::EXTENSION_TOOLSTRIP) {
- NOTREACHED() << "Requesting invalid view type.";
- }
-
- // Disallow searching for a host view if we are a popup view, and likewise
- // if we are a toolstrip view.
- RenderView* render_view = bindings_utils::GetRenderViewForCurrentContext();
- if (!render_view ||
- render_view->view_type() == viewtype_to_find) {
- return v8::Undefined();
- }
-
- int browser_window_id = render_view->browser_window_id();
- std::string extension_id = ExtensionIdForCurrentContext();
- if (extension_id.empty())
- return v8::Undefined();
-
- ExtensionViewAccumulator popup_matcher(extension_id,
- browser_window_id,
- viewtype_to_find);
- RenderView::ForEach(&popup_matcher);
-
- if (0 == popup_matcher.views()->Length())
- return v8::Undefined();
- DCHECK(1 == popup_matcher.views()->Length());
-
- // Return the first view found.
- return popup_matcher.views()->Get(v8::Integer::New(0));
- }
-
- static v8::Handle<v8::Value> GetPopupView(const v8::Arguments& args) {
- return PopupViewFinder(args, ViewType::EXTENSION_POPUP);
- }
-
- static v8::Handle<v8::Value> GetPopupParentWindow(const v8::Arguments& args) {
- return PopupViewFinder(args, ViewType::EXTENSION_TOOLSTRIP);
- }
-
- static v8::Handle<v8::Value> GetExtensionViews(const v8::Arguments& args) {
- if (args.Length() != 2)
- return v8::Undefined();
-
- if (!args[0]->IsInt32() || !args[1]->IsString())
- return v8::Undefined();
-
- // |browser_window_id| == extension_misc::kUnknownWindowId means getting
- // views attached to any browser window.
- int browser_window_id = args[0]->Int32Value();
-
- std::string view_type_string = *v8::String::Utf8Value(args[1]->ToString());
- StringToUpperASCII(&view_type_string);
- // |view_type| == ViewType::INVALID means getting any type of views.
- ViewType::Type view_type = ViewType::INVALID;
- if (view_type_string == ViewType::kToolstrip) {
- view_type = ViewType::EXTENSION_TOOLSTRIP;
- } else if (view_type_string == ViewType::kMole) {
- view_type = ViewType::EXTENSION_MOLE;
- } else if (view_type_string == ViewType::kBackgroundPage) {
- view_type = ViewType::EXTENSION_BACKGROUND_PAGE;
- } else if (view_type_string == ViewType::kInfobar) {
- view_type = ViewType::EXTENSION_INFOBAR;
- } else if (view_type_string == ViewType::kNotification) {
- view_type = ViewType::NOTIFICATION;
- } else if (view_type_string == ViewType::kTabContents) {
- view_type = ViewType::TAB_CONTENTS;
- } else if (view_type_string == ViewType::kPopup) {
- view_type = ViewType::EXTENSION_POPUP;
- } else if (view_type_string != ViewType::kAll) {
- return v8::Undefined();
- }
-
- std::string extension_id = ExtensionIdForCurrentContext();
- if (extension_id.empty())
- return v8::Undefined();
-
- ExtensionViewAccumulator accumulator(extension_id, browser_window_id,
- view_type);
- RenderView::ForEach(&accumulator);
- return accumulator.views();
- }
-
- static v8::Handle<v8::Value> GetNextRequestId(const v8::Arguments& args) {
- static int next_request_id = 0;
- return v8::Integer::New(next_request_id++);
- }
-
- // Creates a new messaging channel to the tab with the given ID.
- static v8::Handle<v8::Value> OpenChannelToTab(const v8::Arguments& args) {
- // Get the current RenderView so that we can send a routed IPC message from
- // the correct source.
- RenderView* renderview = bindings_utils::GetRenderViewForCurrentContext();
- if (!renderview)
- return v8::Undefined();
-
- if (args.Length() >= 3 && args[0]->IsInt32() && args[1]->IsString() &&
- args[2]->IsString()) {
- int tab_id = args[0]->Int32Value();
- std::string extension_id = *v8::String::Utf8Value(args[1]->ToString());
- std::string channel_name = *v8::String::Utf8Value(args[2]->ToString());
- int port_id = -1;
- renderview->Send(new ViewHostMsg_OpenChannelToTab(
- renderview->routing_id(), tab_id, extension_id, channel_name,
- &port_id));
- return v8::Integer::New(port_id);
- }
- return v8::Undefined();
- }
-
- static v8::Handle<v8::Value> GetCurrentPageActions(
- const v8::Arguments& args) {
- std::string extension_id = *v8::String::Utf8Value(args[0]->ToString());
- PageActionIdMap* page_action_map = GetPageActionMap();
- PageActionIdMap::const_iterator it = page_action_map->find(extension_id);
-
- std::vector<std::string> page_actions;
- size_t size = 0;
- if (it != page_action_map->end()) {
- page_actions = it->second;
- size = page_actions.size();
- }
-
- v8::Local<v8::Array> page_action_vector = v8::Array::New(size);
- for (size_t i = 0; i < size; ++i) {
- std::string page_action_id = page_actions[i];
- page_action_vector->Set(v8::Integer::New(i),
- v8::String::New(page_action_id.c_str()));
- }
-
- return page_action_vector;
- }
-
- // Common code for starting an API request to the browser. |value_args|
- // contains the request's arguments.
- static v8::Handle<v8::Value> StartRequestCommon(
- const v8::Arguments& args, const ListValue& value_args) {
- // Get the current RenderView so that we can send a routed IPC message from
- // the correct source.
- RenderView* renderview = bindings_utils::GetRenderViewForCurrentContext();
- if (!renderview)
- return v8::Undefined();
-
- std::string name = *v8::String::AsciiValue(args[0]);
- if (GetFunctionNameSet()->find(name) == GetFunctionNameSet()->end()) {
- NOTREACHED() << "Unexpected function " << name;
- return v8::Undefined();
- }
-
- if (!ExtensionProcessBindings::CurrentContextHasPermission(name)) {
- return ExtensionProcessBindings::ThrowPermissionDeniedException(name);
- }
-
- GURL source_url;
- WebFrame* webframe = WebFrame::frameForCurrentContext();
- if (webframe)
- source_url = webframe->url();
-
- int request_id = args[2]->Int32Value();
- bool has_callback = args[3]->BooleanValue();
-
- v8::Persistent<v8::Context> current_context =
- v8::Persistent<v8::Context>::New(v8::Context::GetCurrent());
- DCHECK(!current_context.IsEmpty());
- GetPendingRequestMap()[request_id].reset(new PendingRequest(
- current_context, name));
-
- renderview->SendExtensionRequest(name, value_args, source_url,
- request_id, has_callback);
-
- return v8::Undefined();
- }
-
- // Starts an API request to the browser, with an optional callback. The
- // callback will be dispatched to EventBindings::HandleResponse.
- static v8::Handle<v8::Value> StartRequest(const v8::Arguments& args) {
- std::string str_args = *v8::String::Utf8Value(args[1]);
- base::JSONReader reader;
- scoped_ptr<Value> value_args;
- value_args.reset(reader.JsonToValue(str_args, false, false));
-
- // Since we do the serialization in the v8 extension, we should always get
- // valid JSON.
- if (!value_args.get() || !value_args->IsType(Value::TYPE_LIST)) {
- NOTREACHED() << "Invalid JSON passed to StartRequest.";
- return v8::Undefined();
- }
-
- return StartRequestCommon(args, static_cast<const ListValue&>(
- *value_args.get()));
- }
-
- // A special request for setting the extension action icon. This function
- // accepts a canvas ImageData object, so it needs to do extra processing
- // before sending the request to the browser.
- static v8::Handle<v8::Value> SetExtensionActionIcon(
- const v8::Arguments& args) {
- v8::Local<v8::Object> extension_args = args[1]->ToObject();
- v8::Local<v8::Object> details =
- extension_args->Get(v8::String::New("0"))->ToObject();
- v8::Local<v8::Object> image_data =
- details->Get(v8::String::New("imageData"))->ToObject();
- v8::Local<v8::Object> data =
- image_data->Get(v8::String::New("data"))->ToObject();
- int width = image_data->Get(v8::String::New("width"))->Int32Value();
- int height = image_data->Get(v8::String::New("height"))->Int32Value();
-
- int data_length = data->Get(v8::String::New("length"))->Int32Value();
- if (data_length != 4 * width * height) {
- NOTREACHED() << "Invalid argument to setIcon. Expecting ImageData.";
- return v8::Undefined();
- }
-
- SkBitmap bitmap;
- bitmap.setConfig(SkBitmap::kARGB_8888_Config, width, height);
- bitmap.allocPixels();
- bitmap.eraseARGB(0, 0, 0, 0);
-
- uint32_t* pixels = bitmap.getAddr32(0, 0);
- for (int t = 0; t < width*height; t++) {
- // |data| is RGBA, pixels is ARGB.
- pixels[t] = SkPreMultiplyColor(
- ((data->Get(v8::Integer::New(4*t + 3))->Int32Value() & 0xFF) << 24) |
- ((data->Get(v8::Integer::New(4*t + 0))->Int32Value() & 0xFF) << 16) |
- ((data->Get(v8::Integer::New(4*t + 1))->Int32Value() & 0xFF) << 8) |
- ((data->Get(v8::Integer::New(4*t + 2))->Int32Value() & 0xFF) << 0));
- }
-
- // Construct the Value object.
- IPC::Message bitmap_pickle;
- IPC::WriteParam(&bitmap_pickle, bitmap);
- Value* bitmap_value = BinaryValue::CreateWithCopiedBuffer(
- static_cast<const char*>(bitmap_pickle.data()), bitmap_pickle.size());
-
- DictionaryValue* dict = new DictionaryValue();
- dict->Set("imageData", bitmap_value);
-
- if (details->Has(v8::String::New("tabId"))) {
- dict->SetInteger("tabId",
- details->Get(v8::String::New("tabId"))->Int32Value());
- }
-
- ListValue list_value;
- list_value.Append(dict);
-
- return StartRequestCommon(args, list_value);
- }
-
- static v8::Handle<v8::Value> GetRenderViewId(const v8::Arguments& args) {
- RenderView* renderview = bindings_utils::GetRenderViewForCurrentContext();
- if (!renderview)
- return v8::Undefined();
- return v8::Integer::New(renderview->routing_id());
- }
-
- static v8::Handle<v8::Value> IsExtensionProcess(const v8::Arguments& args) {
- bool retval = false;
- if (EventBindings::GetRenderThread())
- retval = EventBindings::GetRenderThread()->IsExtensionProcess();
- return v8::Boolean::New(retval);
- }
-};
-
-} // namespace
-
-v8::Extension* ExtensionProcessBindings::Get() {
- static v8::Extension* extension = new ExtensionImpl();
- return extension;
-}
-
-void ExtensionProcessBindings::GetActiveExtensions(
- std::set<std::string>* extension_ids) {
- GetActiveExtensionIDs(extension_ids);
-}
-
-void ExtensionProcessBindings::SetFunctionNames(
- const std::vector<std::string>& names) {
- ExtensionImpl::SetFunctionNames(names);
-}
-
-void ExtensionProcessBindings::SetIncognitoEnabled(
- const std::string& extension_id, bool enabled) {
- (*GetIncognitoEnabledMap())[extension_id] = enabled;
-}
-
-// static
-bool ExtensionProcessBindings::HasIncognitoEnabled(
- const std::string& extension_id) {
- return (!extension_id.empty() && (*GetIncognitoEnabledMap())[extension_id]);
-}
-
-// static
-void ExtensionProcessBindings::HandleResponse(int request_id, bool success,
- const std::string& response,
- const std::string& error) {
- PendingRequestMap& pending_requests = GetPendingRequestMap();
- PendingRequestMap::iterator request = pending_requests.find(request_id);
- if (request == pending_requests.end())
- return; // The frame went away.
-
- v8::HandleScope handle_scope;
- v8::Handle<v8::Value> argv[5];
- argv[0] = v8::Integer::New(request_id);
- argv[1] = v8::String::New(request->second->name.c_str());
- argv[2] = v8::Boolean::New(success);
- argv[3] = v8::String::New(response.c_str());
- argv[4] = v8::String::New(error.c_str());
- v8::Handle<v8::Value> retval = bindings_utils::CallFunctionInContext(
- request->second->context, "handleResponse", arraysize(argv), argv);
- // In debug, the js will validate the callback parameters and return a
- // string if a validation error has occured.
-#ifdef _DEBUG
- if (!retval.IsEmpty() && !retval->IsUndefined()) {
- std::string error = *v8::String::AsciiValue(retval);
- DCHECK(false) << error;
- }
-#endif
-
- request->second->context.Dispose();
- request->second->context.Clear();
- pending_requests.erase(request);
-}
-
-// static
-void ExtensionProcessBindings::SetPageActions(
- const std::string& extension_id,
- const std::vector<std::string>& page_actions) {
- PageActionIdMap& page_action_map = *GetPageActionMap();
- if (!page_actions.empty()) {
- page_action_map[extension_id] = page_actions;
- } else {
- if (page_action_map.find(extension_id) != page_action_map.end())
- page_action_map.erase(extension_id);
- }
-}
-
-// static
-void ExtensionProcessBindings::SetAPIPermissions(
- const std::string& extension_id,
- const std::vector<std::string>& permissions) {
- PermissionsMap& permissions_map = *GetPermissionsMap(extension_id);
-
- // Default all the API permissions to off. We will reset them below.
- for (size_t i = 0; i < Extension::kNumPermissions; ++i)
- permissions_map[Extension::kPermissionNames[i]] = false;
- for (size_t i = 0; i < permissions.size(); ++i)
- permissions_map[permissions[i]] = true;
-}
-
-// static
-void ExtensionProcessBindings::SetHostPermissions(
- const GURL& extension_url,
- const std::vector<URLPattern>& permissions) {
- for (size_t i = 0; i < permissions.size(); ++i) {
- const char* schemes[] = {
- chrome::kHttpScheme,
- chrome::kHttpsScheme,
- chrome::kFileScheme,
- chrome::kChromeUIScheme,
- };
- for (size_t j = 0; j < arraysize(schemes); ++j) {
- if (permissions[i].MatchesScheme(schemes[j])) {
- WebSecurityPolicy::addOriginAccessWhitelistEntry(
- extension_url,
- WebKit::WebString::fromUTF8(schemes[j]),
- WebKit::WebString::fromUTF8(permissions[i].host()),
- permissions[i].match_subdomains());
- }
- }
- }
-}
-
-// static
-bool ExtensionProcessBindings::CurrentContextHasPermission(
- const std::string& function_name) {
- std::string extension_id = ExtensionImpl::ExtensionIdForCurrentContext();
- return HasPermission(extension_id, function_name);
-}
-
-// static
-bool ExtensionProcessBindings::HasPermission(const std::string& extension_id,
- const std::string& permission) {
- std::string permission_name = permission;
-
- // See if this is a function or event name first and strip out the package.
- // Functions will be of the form package.function
- // Events will be of the form package/id or package.optional.stuff
- size_t separator = permission.find_first_of("./");
- if (separator != std::string::npos)
- permission_name = permission.substr(0, separator);
-
- // windows and tabs are the same permission.
- if (permission_name == "windows")
- permission_name = Extension::kTabPermission;
-
- for (size_t i = 0; i < arraysize(kNonPermissionExtensionPackages); ++i)
- if (permission_name == kNonPermissionExtensionPackages[i])
- return true;
-
- PermissionsMap& permissions_map = *GetPermissionsMap(extension_id);
- PermissionsMap::iterator it = permissions_map.find(permission_name);
- return (it != permissions_map.end() && it->second);
-}
-
-// static
-v8::Handle<v8::Value>
- ExtensionProcessBindings::ThrowPermissionDeniedException(
- const std::string& function_name) {
- static const char kMessage[] =
- "You do not have permission to use '%s'. Be sure to declare"
- " in your manifest what permissions you need.";
- std::string error_msg = StringPrintf(kMessage, function_name.c_str());
-
- return v8::ThrowException(v8::Exception::Error(
- v8::String::New(error_msg.c_str())));
-}
-
-// static
-void ExtensionProcessBindings::SetViewType(WebView* view,
- ViewType::Type type) {
- DCHECK(type == ViewType::EXTENSION_MOLE ||
- type == ViewType::EXTENSION_TOOLSTRIP);
- const char* type_str;
- if (type == ViewType::EXTENSION_MOLE)
- type_str = "mole";
- else if (type == ViewType::EXTENSION_TOOLSTRIP)
- type_str = "toolstrip";
- else
- return;
-
- v8::HandleScope handle_scope;
- WebFrame* frame = view->mainFrame();
- v8::Local<v8::Context> context = frame->mainWorldScriptContext();
- v8::Handle<v8::Value> argv[1];
- argv[0] = v8::String::New(type_str);
- bindings_utils::CallFunctionInContext(context, "setViewType",
- arraysize(argv), argv);
-}
+// 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/renderer/extensions/extension_process_bindings.h"
+
+#include <map>
+#include <set>
+#include <string>
+#include <vector>
+
+#include "base/command_line.h"
+#include "base/json/json_reader.h"
+#include "base/scoped_ptr.h"
+#include "base/singleton.h"
+#include "base/string_util.h"
+#include "chrome/common/chrome_switches.h"
+#include "chrome/common/extensions/extension.h"
+#include "chrome/common/extensions/extension_constants.h"
+#include "chrome/common/extensions/url_pattern.h"
+#include "chrome/common/render_messages.h"
+#include "chrome/common/url_constants.h"
+#include "chrome/renderer/extensions/bindings_utils.h"
+#include "chrome/renderer/extensions/event_bindings.h"
+#include "chrome/renderer/extensions/js_only_v8_extensions.h"
+#include "chrome/renderer/extensions/renderer_extension_bindings.h"
+#include "chrome/renderer/user_script_slave.h"
+#include "chrome/renderer/render_thread.h"
+#include "chrome/renderer/render_view.h"
+#include "chrome/renderer/render_view_visitor.h"
+#include "grit/common_resources.h"
+#include "grit/renderer_resources.h"
+#include "third_party/skia/include/core/SkBitmap.h"
+#include "third_party/skia/include/core/SkColor.h"
+#include "third_party/WebKit/WebKit/chromium/public/WebFrame.h"
+#include "third_party/WebKit/WebKit/chromium/public/WebURL.h"
+#include "third_party/WebKit/WebKit/chromium/public/WebKit.h"
+#include "third_party/WebKit/WebKit/chromium/public/WebSecurityPolicy.h"
+#include "third_party/WebKit/WebKit/chromium/public/WebView.h"
+
+using bindings_utils::GetStringResource;
+using bindings_utils::ContextInfo;
+using bindings_utils::ContextList;
+using bindings_utils::GetContexts;
+using bindings_utils::GetPendingRequestMap;
+using bindings_utils::PendingRequest;
+using bindings_utils::PendingRequestMap;
+using bindings_utils::ExtensionBase;
+using WebKit::WebFrame;
+using WebKit::WebSecurityPolicy;
+using WebKit::WebView;
+
+namespace {
+
+// A map of extension ID to vector of page action ids.
+typedef std::map< std::string, std::vector<std::string> > PageActionIdMap;
+
+// A map of permission name to whether its enabled for this extension.
+typedef std::map<std::string, bool> PermissionsMap;
+
+// A map of extension ID to permissions map.
+typedef std::map<std::string, PermissionsMap> ExtensionPermissionsMap;
+
+// A map of extension ID to whether this extension was enabled in incognito.
+typedef std::map<std::string, bool> IncognitoEnabledMap;
+
+const char kExtensionName[] = "chrome/ExtensionProcessBindings";
+const char* kExtensionDeps[] = {
+ BaseJsV8Extension::kName,
+ EventBindings::kName,
+ JsonSchemaJsV8Extension::kName,
+ RendererExtensionBindings::kName,
+ ExtensionApiTestV8Extension::kName,
+};
+
+// A list of the API packages which have no associated permission.
+// TODO(erikkay) It might be nice if for consistency we could merge these with
+// the permissions list, or at least have them in one place.
+const char* kNonPermissionExtensionPackages[] = {
+ "extension",
+ // TODO(erikkay): We're inconsistent about the the package name in the events
+ // for pageAction and browserAction.
+ "pageAction",
+ "pageActions",
+ "browserAction",
+ "browserActions",
+ "i18n",
+ "devtools",
+ "test"
+};
+
+struct SingletonData {
+ std::set<std::string> function_names_;
+ PageActionIdMap page_action_ids_;
+ ExtensionPermissionsMap permissions_;
+ IncognitoEnabledMap incognito_enabled_map_;
+};
+
+static std::set<std::string>* GetFunctionNameSet() {
+ return &Singleton<SingletonData>()->function_names_;
+}
+
+static PageActionIdMap* GetPageActionMap() {
+ return &Singleton<SingletonData>()->page_action_ids_;
+}
+
+static PermissionsMap* GetPermissionsMap(const std::string& extension_id) {
+ return &Singleton<SingletonData>()->permissions_[extension_id];
+}
+
+static IncognitoEnabledMap* GetIncognitoEnabledMap() {
+ return &Singleton<SingletonData>()->incognito_enabled_map_;
+}
+
+static void GetActiveExtensionIDs(std::set<std::string>* extension_ids) {
+ ExtensionPermissionsMap& permissions =
+ Singleton<SingletonData>()->permissions_;
+
+ for (ExtensionPermissionsMap::iterator iter = permissions.begin();
+ iter != permissions.end(); ++iter) {
+ extension_ids->insert(iter->first);
+ }
+}
+
+// A RenderViewVisitor class that iterates through the set of available
+// views, looking for a view of the given type, in the given browser window
+// and within the given extension.
+// Used to accumulate the list of views associated with an extension.
+class ExtensionViewAccumulator : public RenderViewVisitor {
+ public:
+ ExtensionViewAccumulator(const std::string& extension_id,
+ int browser_window_id,
+ ViewType::Type view_type)
+ : extension_id_(extension_id),
+ browser_window_id_(browser_window_id),
+ view_type_(view_type),
+ views_(v8::Array::New()),
+ index_(0) {
+ }
+
+ v8::Local<v8::Array> views() { return views_; }
+
+ virtual bool Visit(RenderView* render_view) {
+ if (!ViewTypeMatches(render_view->view_type(), view_type_))
+ return true;
+
+ GURL url = render_view->webview()->mainFrame()->url();
+ if (!url.SchemeIs(chrome::kExtensionScheme))
+ return true;
+ const std::string& extension_id = url.host();
+ if (extension_id != extension_id_)
+ return true;
+
+ // If we are searching for a pop-up, it may be the case that the pop-up
+ // is not attached to a browser window instance. (It is hosted in a
+ // ExternalTabContainer.) If so, then bypass validation of
+ // same-browser-window origin.
+ // TODO(twiz): The browser window id of the views visited should always
+ // match that of the arguments to the accumulator.
+ // See bug: http://crbug.com/29646
+ if (!(view_type_ == ViewType::EXTENSION_POPUP &&
+ render_view->browser_window_id() ==
+ extension_misc::kUnknownWindowId)) {
+ if (browser_window_id_ != extension_misc::kUnknownWindowId &&
+ render_view->browser_window_id() != browser_window_id_) {
+ return true;
+ }
+ }
+
+ v8::Local<v8::Context> context =
+ render_view->webview()->mainFrame()->mainWorldScriptContext();
+ if (!context.IsEmpty()) {
+ v8::Local<v8::Value> window = context->Global();
+ DCHECK(!window.IsEmpty());
+
+ if (!OnMatchedView(window))
+ return false;
+ }
+ return true;
+ }
+
+ private:
+ // Called on each view found matching the search criteria. Returns false
+ // to terminate the iteration.
+ bool OnMatchedView(const v8::Local<v8::Value>& view_window) {
+ views_->Set(v8::Integer::New(index_), view_window);
+ index_++;
+
+ if (view_type_ == ViewType::EXTENSION_BACKGROUND_PAGE)
+ return false; // There can be only one...
+
+ return true;
+ }
+
+ // Returns true is |type| "isa" |match|.
+ static bool ViewTypeMatches(ViewType::Type type, ViewType::Type match) {
+ if (type == match)
+ return true;
+
+ // INVALID means match all.
+ if (match == ViewType::INVALID)
+ return true;
+
+ return false;
+ }
+
+ std::string extension_id_;
+ int browser_window_id_;
+ ViewType::Type view_type_;
+ v8::Local<v8::Array> views_;
+ int index_;
+};
+
+class ExtensionImpl : public ExtensionBase {
+ public:
+ ExtensionImpl() : ExtensionBase(
+ kExtensionName, GetStringResource<IDR_EXTENSION_PROCESS_BINDINGS_JS>(),
+ arraysize(kExtensionDeps), kExtensionDeps) {}
+
+ static void SetFunctionNames(const std::vector<std::string>& names) {
+ std::set<std::string>* name_set = GetFunctionNameSet();
+ for (size_t i = 0; i < names.size(); ++i) {
+ name_set->insert(names[i]);
+ }
+ }
+
+ // Note: do not call this function before or during the chromeHidden.onLoad
+ // event dispatch. The URL might not have been committed yet and might not
+ // be an extension URL.
+ static std::string ExtensionIdForCurrentContext() {
+ RenderView* renderview = bindings_utils::GetRenderViewForCurrentContext();
+ if (!renderview)
+ return std::string(); // this can happen as a tab is closing.
+
+ GURL url = renderview->webview()->mainFrame()->url();
+ if (!url.SchemeIs(chrome::kExtensionScheme))
+ return std::string();
+
+ return url.host();
+ }
+
+ virtual v8::Handle<v8::FunctionTemplate> GetNativeFunction(
+ v8::Handle<v8::String> name) {
+ if (name->Equals(v8::String::New("GetExtensionAPIDefinition"))) {
+ return v8::FunctionTemplate::New(GetExtensionAPIDefinition);
+ } else if (name->Equals(v8::String::New("GetExtensionViews"))) {
+ return v8::FunctionTemplate::New(GetExtensionViews);
+ } else if (name->Equals(v8::String::New("GetNextRequestId"))) {
+ return v8::FunctionTemplate::New(GetNextRequestId);
+ } else if (name->Equals(v8::String::New("OpenChannelToTab"))) {
+ return v8::FunctionTemplate::New(OpenChannelToTab);
+ } else if (name->Equals(v8::String::New("GetCurrentPageActions"))) {
+ return v8::FunctionTemplate::New(GetCurrentPageActions);
+ } else if (name->Equals(v8::String::New("StartRequest"))) {
+ return v8::FunctionTemplate::New(StartRequest);
+ } else if (name->Equals(v8::String::New("GetRenderViewId"))) {
+ return v8::FunctionTemplate::New(GetRenderViewId);
+ } else if (name->Equals(v8::String::New("GetPopupView"))) {
+ return v8::FunctionTemplate::New(GetPopupView);
+ } else if (name->Equals(v8::String::New("GetPopupParentWindow"))) {
+ return v8::FunctionTemplate::New(GetPopupParentWindow);
+ } else if (name->Equals(v8::String::New("SetExtensionActionIcon"))) {
+ return v8::FunctionTemplate::New(SetExtensionActionIcon);
+ } else if (name->Equals(v8::String::New("IsExtensionProcess"))) {
+ return v8::FunctionTemplate::New(IsExtensionProcess);
+ }
+
+ return ExtensionBase::GetNativeFunction(name);
+ }
+
+ private:
+ static v8::Handle<v8::Value> GetExtensionAPIDefinition(
+ const v8::Arguments& args) {
+ return v8::String::New(GetStringResource<IDR_EXTENSION_API_JSON>());
+ }
+
+ static v8::Handle<v8::Value> PopupViewFinder(
+ const v8::Arguments& args,
+ ViewType::Type viewtype_to_find) {
+ // TODO(twiz) Correct the logic that ties the ownership of the pop-up view
+ // to the hosting view. At the moment we assume that there may only be
+ // a single pop-up view for a given extension. By doing so, we can find
+ // the pop-up view by simply searching for the only pop-up view present.
+ // We also assume that if the current view is a pop-up, we can find the
+ // hosting view by searching for a tab contents view.
+ if (args.Length() != 0)
+ return v8::Undefined();
+
+ if (viewtype_to_find != ViewType::EXTENSION_POPUP &&
+ viewtype_to_find != ViewType::TAB_CONTENTS) {
+ NOTREACHED() << "Requesting invalid view type.";
+ }
+
+ // Disallow searching for the same view type as the current view:
+ // Popups can only look for hosts, and hosts can only look for popups.
+ RenderView* render_view = bindings_utils::GetRenderViewForCurrentContext();
+ if (!render_view ||
+ render_view->view_type() == viewtype_to_find) {
+ return v8::Undefined();
+ }
+
+ int browser_window_id = render_view->browser_window_id();
+ std::string extension_id = ExtensionIdForCurrentContext();
+ if (extension_id.empty())
+ return v8::Undefined();
+
+ ExtensionViewAccumulator popup_matcher(extension_id,
+ browser_window_id,
+ viewtype_to_find);
+ RenderView::ForEach(&popup_matcher);
+
+ if (0 == popup_matcher.views()->Length())
+ return v8::Undefined();
+ DCHECK(1 == popup_matcher.views()->Length());
+
+ // Return the first view found.
+ return popup_matcher.views()->Get(v8::Integer::New(0));
+ }
+
+ static v8::Handle<v8::Value> GetPopupView(const v8::Arguments& args) {
+ return PopupViewFinder(args, ViewType::EXTENSION_POPUP);
+ }
+
+ static v8::Handle<v8::Value> GetPopupParentWindow(const v8::Arguments& args) {
+ return PopupViewFinder(args, ViewType::TAB_CONTENTS);
+ }
+
+ static v8::Handle<v8::Value> GetExtensionViews(const v8::Arguments& args) {
+ if (args.Length() != 2)
+ return v8::Undefined();
+
+ if (!args[0]->IsInt32() || !args[1]->IsString())
+ return v8::Undefined();
+
+ // |browser_window_id| == extension_misc::kUnknownWindowId means getting
+ // views attached to any browser window.
+ int browser_window_id = args[0]->Int32Value();
+
+ std::string view_type_string = *v8::String::Utf8Value(args[1]->ToString());
+ StringToUpperASCII(&view_type_string);
+ // |view_type| == ViewType::INVALID means getting any type of views.
+ ViewType::Type view_type = ViewType::INVALID;
+ if (view_type_string == ViewType::kBackgroundPage) {
+ view_type = ViewType::EXTENSION_BACKGROUND_PAGE;
+ } else if (view_type_string == ViewType::kInfobar) {
+ view_type = ViewType::EXTENSION_INFOBAR;
+ } else if (view_type_string == ViewType::kNotification) {
+ view_type = ViewType::NOTIFICATION;
+ } else if (view_type_string == ViewType::kTabContents) {
+ view_type = ViewType::TAB_CONTENTS;
+ } else if (view_type_string == ViewType::kPopup) {
+ view_type = ViewType::EXTENSION_POPUP;
+ } else if (view_type_string != ViewType::kAll) {
+ return v8::Undefined();
+ }
+
+ std::string extension_id = ExtensionIdForCurrentContext();
+ if (extension_id.empty())
+ return v8::Undefined();
+
+ ExtensionViewAccumulator accumulator(extension_id, browser_window_id,
+ view_type);
+ RenderView::ForEach(&accumulator);
+ return accumulator.views();
+ }
+
+ static v8::Handle<v8::Value> GetNextRequestId(const v8::Arguments& args) {
+ static int next_request_id = 0;
+ return v8::Integer::New(next_request_id++);
+ }
+
+ // Creates a new messaging channel to the tab with the given ID.
+ static v8::Handle<v8::Value> OpenChannelToTab(const v8::Arguments& args) {
+ // Get the current RenderView so that we can send a routed IPC message from
+ // the correct source.
+ RenderView* renderview = bindings_utils::GetRenderViewForCurrentContext();
+ if (!renderview)
+ return v8::Undefined();
+
+ if (args.Length() >= 3 && args[0]->IsInt32() && args[1]->IsString() &&
+ args[2]->IsString()) {
+ int tab_id = args[0]->Int32Value();
+ std::string extension_id = *v8::String::Utf8Value(args[1]->ToString());
+ std::string channel_name = *v8::String::Utf8Value(args[2]->ToString());
+ int port_id = -1;
+ renderview->Send(new ViewHostMsg_OpenChannelToTab(
+ renderview->routing_id(), tab_id, extension_id, channel_name,
+ &port_id));
+ return v8::Integer::New(port_id);
+ }
+ return v8::Undefined();
+ }
+
+ static v8::Handle<v8::Value> GetCurrentPageActions(
+ const v8::Arguments& args) {
+ std::string extension_id = *v8::String::Utf8Value(args[0]->ToString());
+ PageActionIdMap* page_action_map = GetPageActionMap();
+ PageActionIdMap::const_iterator it = page_action_map->find(extension_id);
+
+ std::vector<std::string> page_actions;
+ size_t size = 0;
+ if (it != page_action_map->end()) {
+ page_actions = it->second;
+ size = page_actions.size();
+ }
+
+ v8::Local<v8::Array> page_action_vector = v8::Array::New(size);
+ for (size_t i = 0; i < size; ++i) {
+ std::string page_action_id = page_actions[i];
+ page_action_vector->Set(v8::Integer::New(i),
+ v8::String::New(page_action_id.c_str()));
+ }
+
+ return page_action_vector;
+ }
+
+ // Common code for starting an API request to the browser. |value_args|
+ // contains the request's arguments.
+ static v8::Handle<v8::Value> StartRequestCommon(
+ const v8::Arguments& args, const ListValue& value_args) {
+ // Get the current RenderView so that we can send a routed IPC message from
+ // the correct source.
+ RenderView* renderview = bindings_utils::GetRenderViewForCurrentContext();
+ if (!renderview)
+ return v8::Undefined();
+
+ std::string name = *v8::String::AsciiValue(args[0]);
+ if (GetFunctionNameSet()->find(name) == GetFunctionNameSet()->end()) {
+ NOTREACHED() << "Unexpected function " << name;
+ return v8::Undefined();
+ }
+
+ if (!ExtensionProcessBindings::CurrentContextHasPermission(name)) {
+ return ExtensionProcessBindings::ThrowPermissionDeniedException(name);
+ }
+
+ GURL source_url;
+ WebFrame* webframe = WebFrame::frameForCurrentContext();
+ if (webframe)
+ source_url = webframe->url();
+
+ int request_id = args[2]->Int32Value();
+ bool has_callback = args[3]->BooleanValue();
+
+ v8::Persistent<v8::Context> current_context =
+ v8::Persistent<v8::Context>::New(v8::Context::GetCurrent());
+ DCHECK(!current_context.IsEmpty());
+ GetPendingRequestMap()[request_id].reset(new PendingRequest(
+ current_context, name));
+
+ renderview->SendExtensionRequest(name, value_args, source_url,
+ request_id, has_callback);
+
+ return v8::Undefined();
+ }
+
+ // Starts an API request to the browser, with an optional callback. The
+ // callback will be dispatched to EventBindings::HandleResponse.
+ static v8::Handle<v8::Value> StartRequest(const v8::Arguments& args) {
+ std::string str_args = *v8::String::Utf8Value(args[1]);
+ base::JSONReader reader;
+ scoped_ptr<Value> value_args;
+ value_args.reset(reader.JsonToValue(str_args, false, false));
+
+ // Since we do the serialization in the v8 extension, we should always get
+ // valid JSON.
+ if (!value_args.get() || !value_args->IsType(Value::TYPE_LIST)) {
+ NOTREACHED() << "Invalid JSON passed to StartRequest.";
+ return v8::Undefined();
+ }
+
+ return StartRequestCommon(args, static_cast<const ListValue&>(
+ *value_args.get()));
+ }
+
+ // A special request for setting the extension action icon. This function
+ // accepts a canvas ImageData object, so it needs to do extra processing
+ // before sending the request to the browser.
+ static v8::Handle<v8::Value> SetExtensionActionIcon(
+ const v8::Arguments& args) {
+ v8::Local<v8::Object> extension_args = args[1]->ToObject();
+ v8::Local<v8::Object> details =
+ extension_args->Get(v8::String::New("0"))->ToObject();
+ v8::Local<v8::Object> image_data =
+ details->Get(v8::String::New("imageData"))->ToObject();
+ v8::Local<v8::Object> data =
+ image_data->Get(v8::String::New("data"))->ToObject();
+ int width = image_data->Get(v8::String::New("width"))->Int32Value();
+ int height = image_data->Get(v8::String::New("height"))->Int32Value();
+
+ int data_length = data->Get(v8::String::New("length"))->Int32Value();
+ if (data_length != 4 * width * height) {
+ NOTREACHED() << "Invalid argument to setIcon. Expecting ImageData.";
+ return v8::Undefined();
+ }
+
+ SkBitmap bitmap;
+ bitmap.setConfig(SkBitmap::kARGB_8888_Config, width, height);
+ bitmap.allocPixels();
+ bitmap.eraseARGB(0, 0, 0, 0);
+
+ uint32_t* pixels = bitmap.getAddr32(0, 0);
+ for (int t = 0; t < width*height; t++) {
+ // |data| is RGBA, pixels is ARGB.
+ pixels[t] = SkPreMultiplyColor(
+ ((data->Get(v8::Integer::New(4*t + 3))->Int32Value() & 0xFF) << 24) |
+ ((data->Get(v8::Integer::New(4*t + 0))->Int32Value() & 0xFF) << 16) |
+ ((data->Get(v8::Integer::New(4*t + 1))->Int32Value() & 0xFF) << 8) |
+ ((data->Get(v8::Integer::New(4*t + 2))->Int32Value() & 0xFF) << 0));
+ }
+
+ // Construct the Value object.
+ IPC::Message bitmap_pickle;
+ IPC::WriteParam(&bitmap_pickle, bitmap);
+ Value* bitmap_value = BinaryValue::CreateWithCopiedBuffer(
+ static_cast<const char*>(bitmap_pickle.data()), bitmap_pickle.size());
+
+ DictionaryValue* dict = new DictionaryValue();
+ dict->Set("imageData", bitmap_value);
+
+ if (details->Has(v8::String::New("tabId"))) {
+ dict->SetInteger("tabId",
+ details->Get(v8::String::New("tabId"))->Int32Value());
+ }
+
+ ListValue list_value;
+ list_value.Append(dict);
+
+ return StartRequestCommon(args, list_value);
+ }
+
+ static v8::Handle<v8::Value> GetRenderViewId(const v8::Arguments& args) {
+ RenderView* renderview = bindings_utils::GetRenderViewForCurrentContext();
+ if (!renderview)
+ return v8::Undefined();
+ return v8::Integer::New(renderview->routing_id());
+ }
+
+ static v8::Handle<v8::Value> IsExtensionProcess(const v8::Arguments& args) {
+ bool retval = false;
+ if (EventBindings::GetRenderThread())
+ retval = EventBindings::GetRenderThread()->IsExtensionProcess();
+ return v8::Boolean::New(retval);
+ }
+};
+
+} // namespace
+
+v8::Extension* ExtensionProcessBindings::Get() {
+ static v8::Extension* extension = new ExtensionImpl();
+ return extension;
+}
+
+void ExtensionProcessBindings::GetActiveExtensions(
+ std::set<std::string>* extension_ids) {
+ GetActiveExtensionIDs(extension_ids);
+}
+
+void ExtensionProcessBindings::SetFunctionNames(
+ const std::vector<std::string>& names) {
+ ExtensionImpl::SetFunctionNames(names);
+}
+
+void ExtensionProcessBindings::SetIncognitoEnabled(
+ const std::string& extension_id, bool enabled) {
+ (*GetIncognitoEnabledMap())[extension_id] = enabled;
+}
+
+// static
+bool ExtensionProcessBindings::HasIncognitoEnabled(
+ const std::string& extension_id) {
+ return (!extension_id.empty() && (*GetIncognitoEnabledMap())[extension_id]);
+}
+
+// static
+void ExtensionProcessBindings::HandleResponse(int request_id, bool success,
+ const std::string& response,
+ const std::string& error) {
+ PendingRequestMap& pending_requests = GetPendingRequestMap();
+ PendingRequestMap::iterator request = pending_requests.find(request_id);
+ if (request == pending_requests.end())
+ return; // The frame went away.
+
+ v8::HandleScope handle_scope;
+ v8::Handle<v8::Value> argv[5];
+ argv[0] = v8::Integer::New(request_id);
+ argv[1] = v8::String::New(request->second->name.c_str());
+ argv[2] = v8::Boolean::New(success);
+ argv[3] = v8::String::New(response.c_str());
+ argv[4] = v8::String::New(error.c_str());
+ v8::Handle<v8::Value> retval = bindings_utils::CallFunctionInContext(
+ request->second->context, "handleResponse", arraysize(argv), argv);
+ // In debug, the js will validate the callback parameters and return a
+ // string if a validation error has occured.
+#ifdef _DEBUG
+ if (!retval.IsEmpty() && !retval->IsUndefined()) {
+ std::string error = *v8::String::AsciiValue(retval);
+ DCHECK(false) << error;
+ }
+#endif
+
+ request->second->context.Dispose();
+ request->second->context.Clear();
+ pending_requests.erase(request);
+}
+
+// static
+void ExtensionProcessBindings::SetPageActions(
+ const std::string& extension_id,
+ const std::vector<std::string>& page_actions) {
+ PageActionIdMap& page_action_map = *GetPageActionMap();
+ if (!page_actions.empty()) {
+ page_action_map[extension_id] = page_actions;
+ } else {
+ if (page_action_map.find(extension_id) != page_action_map.end())
+ page_action_map.erase(extension_id);
+ }
+}
+
+// static
+void ExtensionProcessBindings::SetAPIPermissions(
+ const std::string& extension_id,
+ const std::vector<std::string>& permissions) {
+ PermissionsMap& permissions_map = *GetPermissionsMap(extension_id);
+
+ // Default all the API permissions to off. We will reset them below.
+ for (size_t i = 0; i < Extension::kNumPermissions; ++i)
+ permissions_map[Extension::kPermissionNames[i]] = false;
+ for (size_t i = 0; i < permissions.size(); ++i)
+ permissions_map[permissions[i]] = true;
+}
+
+// static
+void ExtensionProcessBindings::SetHostPermissions(
+ const GURL& extension_url,
+ const std::vector<URLPattern>& permissions) {
+ for (size_t i = 0; i < permissions.size(); ++i) {
+ const char* schemes[] = {
+ chrome::kHttpScheme,
+ chrome::kHttpsScheme,
+ chrome::kFileScheme,
+ chrome::kChromeUIScheme,
+ };
+ for (size_t j = 0; j < arraysize(schemes); ++j) {
+ if (permissions[i].MatchesScheme(schemes[j])) {
+ WebSecurityPolicy::addOriginAccessWhitelistEntry(
+ extension_url,
+ WebKit::WebString::fromUTF8(schemes[j]),
+ WebKit::WebString::fromUTF8(permissions[i].host()),
+ permissions[i].match_subdomains());
+ }
+ }
+ }
+}
+
+// static
+bool ExtensionProcessBindings::CurrentContextHasPermission(
+ const std::string& function_name) {
+ std::string extension_id = ExtensionImpl::ExtensionIdForCurrentContext();
+ return HasPermission(extension_id, function_name);
+}
+
+// static
+bool ExtensionProcessBindings::HasPermission(const std::string& extension_id,
+ const std::string& permission) {
+ std::string permission_name = permission;
+
+ // See if this is a function or event name first and strip out the package.
+ // Functions will be of the form package.function
+ // Events will be of the form package/id or package.optional.stuff
+ size_t separator = permission.find_first_of("./");
+ if (separator != std::string::npos)
+ permission_name = permission.substr(0, separator);
+
+ // windows and tabs are the same permission.
+ if (permission_name == "windows")
+ permission_name = Extension::kTabPermission;
+
+ for (size_t i = 0; i < arraysize(kNonPermissionExtensionPackages); ++i)
+ if (permission_name == kNonPermissionExtensionPackages[i])
+ return true;
+
+ PermissionsMap& permissions_map = *GetPermissionsMap(extension_id);
+ PermissionsMap::iterator it = permissions_map.find(permission_name);
+ return (it != permissions_map.end() && it->second);
+}
+
+// static
+v8::Handle<v8::Value>
+ ExtensionProcessBindings::ThrowPermissionDeniedException(
+ const std::string& function_name) {
+ static const char kMessage[] =
+ "You do not have permission to use '%s'. Be sure to declare"
+ " in your manifest what permissions you need.";
+ std::string error_msg = StringPrintf(kMessage, function_name.c_str());
+
+ return v8::ThrowException(v8::Exception::Error(
+ v8::String::New(error_msg.c_str())));
+}
+
diff --git a/chrome/renderer/extensions/extension_process_bindings.h b/chrome/renderer/extensions/extension_process_bindings.h
index 2710901..d64b4255 100644
--- a/chrome/renderer/extensions/extension_process_bindings.h
+++ b/chrome/renderer/extensions/extension_process_bindings.h
@@ -71,11 +71,6 @@ class ExtensionProcessBindings {
// denied. Must be called with a valid V8 context in scope.
static v8::Handle<v8::Value> ThrowPermissionDeniedException(
const std::string& function_name);
-
- // For EXTENSION_* |type| values, adds/replaces a special class name on to
- // the document element (e.g. "extension_toolstrip", "extension_mole") so
- // that the page can use CSS rules to control its display appropriately.
- static void SetViewType(WebKit::WebView* view, ViewType::Type type);
};
#endif // CHROME_RENDERER_EXTENSIONS_EXTENSION_PROCESS_BINDINGS_H_
diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc
index 919ee4c..768bdcb 100644
--- a/chrome/renderer/render_view.cc
+++ b/chrome/renderer/render_view.cc
@@ -2954,11 +2954,6 @@ void RenderView::didCreateDocumentElement(WebFrame* frame) {
RenderThread::current()->user_script_slave()->InjectScripts(
frame, UserScript::DOCUMENT_START);
}
- if (view_type_ == ViewType::EXTENSION_TOOLSTRIP ||
- view_type_ == ViewType::EXTENSION_MOLE) {
- InjectToolstripCSS();
- ExtensionProcessBindings::SetViewType(webview(), view_type_);
- }
// Notify the browser about non-blank documents loading in the top frame.
GURL url = frame->url();
@@ -4191,15 +4186,6 @@ void RenderView::OnMediaPlayerActionAt(const gfx::Point& location,
}
void RenderView::OnNotifyRendererViewType(ViewType::Type type) {
- // When this is first set, the bindings aren't fully loaded. We only need
- // to call through this API after the page has already been loaded. It's
- // also called in didCreateDocumentElement to bootstrap.
- if (view_type_ != ViewType::INVALID) {
- if (type == ViewType::EXTENSION_MOLE ||
- type == ViewType::EXTENSION_TOOLSTRIP) {
- ExtensionProcessBindings::SetViewType(webview(), type);
- }
- }
view_type_ = type;
}
@@ -4584,17 +4570,6 @@ void RenderView::OnExtensionResponse(int request_id,
request_id, success, response, error);
}
-void RenderView::InjectToolstripCSS() {
- if (view_type_ != ViewType::EXTENSION_TOOLSTRIP)
- return;
-
- static const base::StringPiece toolstrip_css(
- ResourceBundle::GetSharedInstance().GetRawDataResource(
- IDR_EXTENSION_TOOLSTRIP_CSS));
- std::string css = toolstrip_css.as_string();
- InsertCSS(L"", css, "ToolstripDefaultCSS");
-}
-
void RenderView::OnExtensionMessageInvoke(const std::string& function_name,
const ListValue& args,
bool requires_incognito_access,
diff --git a/chrome/renderer/render_view.h b/chrome/renderer/render_view.h
index 53e3d6d..2837f946 100644
--- a/chrome/renderer/render_view.h
+++ b/chrome/renderer/render_view.h
@@ -925,9 +925,6 @@ class RenderView : public RenderWidget,
// Decodes a data: URL image or returns an empty image in case of failure.
SkBitmap ImageFromDataUrl(const GURL&) const;
- // Inject toolstrip CSS for extension moles and toolstrips.
- void InjectToolstripCSS();
-
// Inserts a string of CSS in a particular frame. |id| can be specified to
// give the CSS style element an id, and (if specified) will replace the
// element with the same id.
@@ -1156,8 +1153,7 @@ class RenderView : public RenderWidget,
// View ----------------------------------------------------------------------
- // Type of view attached with RenderView, it could be INVALID, TAB_CONTENTS,
- // EXTENSION_TOOLSTRIP, EXTENSION_BACKGROUND_PAGE, DEV_TOOLS_UI.
+ // Type of view attached with RenderView. See view_types.h
ViewType::Type view_type_;
// Id number of browser window which RenderView is attached to. This is used
diff --git a/chrome/renderer/renderer_resources.grd b/chrome/renderer/renderer_resources.grd
index 295ccac..a084b31 100644
--- a/chrome/renderer/renderer_resources.grd
+++ b/chrome/renderer/renderer_resources.grd
@@ -18,7 +18,6 @@ without changes to the corresponding grd file. fb9 -->
<include name="IDR_EVENT_BINDINGS_JS" file="resources\event_bindings.js" type="BINDATA" />
<include name="IDR_EXTENSION_APITEST_JS" file="resources\extension_apitest.js" type="BINDATA" />
<include name="IDR_EXTENSION_PROCESS_BINDINGS_JS" file="resources\extension_process_bindings.js" type="BINDATA" />
- <include name="IDR_EXTENSION_TOOLSTRIP_CSS" file="resources\extension_toolstrip.css" flattenhtml="true" type="BINDATA" />
<include name="IDR_GREASEMONKEY_API_JS" file="resources\greasemonkey_api.js" type="BINDATA" />
<include name="IDR_JSON_SCHEMA_JS" file="resources\json_schema.js" type="BINDATA" />
<include name="IDR_NET_ERROR_HTML" file="resources\neterror.html" flattenhtml="true" type="BINDATA" />
diff --git a/chrome/renderer/resources/extension_toolstrip.css b/chrome/renderer/resources/extension_toolstrip.css
deleted file mode 100644
index f4843c6..0000000
--- a/chrome/renderer/resources/extension_toolstrip.css
+++ /dev/null
@@ -1,100 +0,0 @@
-/**
- * Body styles. This makes the toolstrip layout fit in with the Windows
- * bookmarkbar. Note that the background is provided separately, by
- * RenderWidget.
- */
-body {
- display:-webkit-box;
- -webkit-box-orient:horizontal;
- -webkit-box-align:center;
- white-space:nowrap;
- overflow: hidden;
- margin: 0;
- padding:0;
- font: menu;
- -webkit-user-select:none;
- cursor:default;
-}
-
-/**
- * This, combined with -webkit-box-align:center on body, makes content inside
- * the body tag center itself vertically by default.
- */
-body>* {
- display:-webkit-box;
-}
-
-/**
- * Set display property of <script> and <style> as none explicitly to avoid
- * inheriting from <body>.
- */
-body>script,
-body>style {
- display:none;
-}
-
-/**
- * Toolstrip Buttons. The following styles make
- * <div class="toolstrip-button"><img><span>Woot</span></div> look like the
- * bookmarkbar buttons on Windows.
- *
- * TODO(aa): We may have to come up with a way to modify these slightly on
- * different platforms.
- *
- * TODO(aa): It would be nice if we could use actual <button> tags work here,
- * which should work once https://bugs.webkit.org/show_bug.cgi?id=25406 is
- * fixed.
- */
-div.toolstrip-button {
- -webkit-box-orient:horizontal;
- -webkit-box-align:center;
- -webkit-box-sizing:border-box;
- border:7px solid transparent;
- font:menu;
- background:transparent;
- line-height:100%;
- height:100%;
- padding:0;
-}
-
-div.toolstrip-button>img {
- display:-webkit-box;
- width:16px;
- height:16px;
- /**
- * We inset the image slightly, so that the button can be shorter
- * than would otherwise be possibe with our fat borders. The 5px right border
- * just creates the spacing between the icon and the text.
- */
- margin:-2px 5px -2px -1px;
-}
-
-div.toolstrip-button>span {
- display:-webkit-box;
- margin-right:1px;
- /**
- * Hack: WebKit appears to measure text height slightly differently than we do
- * in native code, making us not line up when centering, so we shift ourselves
- * up one pixel to match.
- */
- margin-top:-1px;
-}
-
-/**
- * NOTE: These images were created by pasting src/app/resources/textbutton_*
- * into a 15px square 9 grid. If they look funky, check to see if they match
- * the bookmark buttons. If they don't, they probably need to be regenerated.
- *
- * TODO(aa): It would be neat-o if these were generated magically from the
- * underlying images. Since the dimensions of the images are arbitrary, though,
- * it would be tricky.
- */
-div.toolstrip-button:hover {
- border-width:7px;
- -webkit-border-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA8AAAAPCAYAAAA71pVKAAAACXBIWXMAAAsTAAALEwEAmpwYAAAKT2lDQ1BQaG90b3Nob3AgSUNDIHByb2ZpbGUAAHjanVNnVFPpFj333vRCS4iAlEtvUhUIIFJCi4AUkSYqIQkQSoghodkVUcERRUUEG8igiAOOjoCMFVEsDIoK2AfkIaKOg6OIisr74Xuja9a89+bN/rXXPues852zzwfACAyWSDNRNYAMqUIeEeCDx8TG4eQuQIEKJHAAEAizZCFz/SMBAPh+PDwrIsAHvgABeNMLCADATZvAMByH/w/qQplcAYCEAcB0kThLCIAUAEB6jkKmAEBGAYCdmCZTAKAEAGDLY2LjAFAtAGAnf+bTAICd+Jl7AQBblCEVAaCRACATZYhEAGg7AKzPVopFAFgwABRmS8Q5ANgtADBJV2ZIALC3AMDOEAuyAAgMADBRiIUpAAR7AGDIIyN4AISZABRG8lc88SuuEOcqAAB4mbI8uSQ5RYFbCC1xB1dXLh4ozkkXKxQ2YQJhmkAuwnmZGTKBNA/g88wAAKCRFRHgg/P9eM4Ors7ONo62Dl8t6r8G/yJiYuP+5c+rcEAAAOF0ftH+LC+zGoA7BoBt/qIl7gRoXgugdfeLZrIPQLUAoOnaV/Nw+H48PEWhkLnZ2eXk5NhKxEJbYcpXff5nwl/AV/1s+X48/Pf14L7iJIEyXYFHBPjgwsz0TKUcz5IJhGLc5o9H/LcL//wd0yLESWK5WCoU41EScY5EmozzMqUiiUKSKcUl0v9k4t8s+wM+3zUAsGo+AXuRLahdYwP2SycQWHTA4vcAAPK7b8HUKAgDgGiD4c93/+8//UegJQCAZkmScQAAXkQkLlTKsz/HCAAARKCBKrBBG/TBGCzABhzBBdzBC/xgNoRCJMTCQhBCCmSAHHJgKayCQiiGzbAdKmAv1EAdNMBRaIaTcA4uwlW4Dj1wD/phCJ7BKLyBCQRByAgTYSHaiAFiilgjjggXmYX4IcFIBBKLJCDJiBRRIkuRNUgxUopUIFVIHfI9cgI5h1xGupE7yAAygvyGvEcxlIGyUT3UDLVDuag3GoRGogvQZHQxmo8WoJvQcrQaPYw2oefQq2gP2o8+Q8cwwOgYBzPEbDAuxsNCsTgsCZNjy7EirAyrxhqwVqwDu4n1Y8+xdwQSgUXACTYEd0IgYR5BSFhMWE7YSKggHCQ0EdoJNwkDhFHCJyKTqEu0JroR+cQYYjIxh1hILCPWEo8TLxB7iEPENyQSiUMyJ7mQAkmxpFTSEtJG0m5SI+ksqZs0SBojk8naZGuyBzmULCAryIXkneTD5DPkG+Qh8lsKnWJAcaT4U+IoUspqShnlEOU05QZlmDJBVaOaUt2ooVQRNY9aQq2htlKvUYeoEzR1mjnNgxZJS6WtopXTGmgXaPdpr+h0uhHdlR5Ol9BX0svpR+iX6AP0dwwNhhWDx4hnKBmbGAcYZxl3GK+YTKYZ04sZx1QwNzHrmOeZD5lvVVgqtip8FZHKCpVKlSaVGyovVKmqpqreqgtV81XLVI+pXlN9rkZVM1PjqQnUlqtVqp1Q61MbU2epO6iHqmeob1Q/pH5Z/YkGWcNMw09DpFGgsV/jvMYgC2MZs3gsIWsNq4Z1gTXEJrHN2Xx2KruY/R27iz2qqaE5QzNKM1ezUvOUZj8H45hx+Jx0TgnnKKeX836K3hTvKeIpG6Y0TLkxZVxrqpaXllirSKtRq0frvTau7aedpr1Fu1n7gQ5Bx0onXCdHZ4/OBZ3nU9lT3acKpxZNPTr1ri6qa6UbobtEd79up+6Ynr5egJ5Mb6feeb3n+hx9L/1U/W36p/VHDFgGswwkBtsMzhg8xTVxbzwdL8fb8VFDXcNAQ6VhlWGX4YSRudE8o9VGjUYPjGnGXOMk423GbcajJgYmISZLTepN7ppSTbmmKaY7TDtMx83MzaLN1pk1mz0x1zLnm+eb15vft2BaeFostqi2uGVJsuRaplnutrxuhVo5WaVYVVpds0atna0l1rutu6cRp7lOk06rntZnw7Dxtsm2qbcZsOXYBtuutm22fWFnYhdnt8Wuw+6TvZN9un2N/T0HDYfZDqsdWh1+c7RyFDpWOt6azpzuP33F9JbpL2dYzxDP2DPjthPLKcRpnVOb00dnF2e5c4PziIuJS4LLLpc+Lpsbxt3IveRKdPVxXeF60vWdm7Obwu2o26/uNu5p7ofcn8w0nymeWTNz0MPIQ+BR5dE/C5+VMGvfrH5PQ0+BZ7XnIy9jL5FXrdewt6V3qvdh7xc+9j5yn+M+4zw33jLeWV/MN8C3yLfLT8Nvnl+F30N/I/9k/3r/0QCngCUBZwOJgUGBWwL7+Hp8Ib+OPzrbZfay2e1BjKC5QRVBj4KtguXBrSFoyOyQrSH355jOkc5pDoVQfujW0Adh5mGLw34MJ4WHhVeGP45wiFga0TGXNXfR3ENz30T6RJZE3ptnMU85ry1KNSo+qi5qPNo3ujS6P8YuZlnM1VidWElsSxw5LiquNm5svt/87fOH4p3iC+N7F5gvyF1weaHOwvSFpxapLhIsOpZATIhOOJTwQRAqqBaMJfITdyWOCnnCHcJnIi/RNtGI2ENcKh5O8kgqTXqS7JG8NXkkxTOlLOW5hCepkLxMDUzdmzqeFpp2IG0yPTq9MYOSkZBxQqohTZO2Z+pn5mZ2y6xlhbL+xW6Lty8elQfJa7OQrAVZLQq2QqboVFoo1yoHsmdlV2a/zYnKOZarnivN7cyzytuQN5zvn//tEsIS4ZK2pYZLVy0dWOa9rGo5sjxxedsK4xUFK4ZWBqw8uIq2Km3VT6vtV5eufr0mek1rgV7ByoLBtQFr6wtVCuWFfevc1+1dT1gvWd+1YfqGnRs+FYmKrhTbF5cVf9go3HjlG4dvyr+Z3JS0qavEuWTPZtJm6ebeLZ5bDpaql+aXDm4N2dq0Dd9WtO319kXbL5fNKNu7g7ZDuaO/PLi8ZafJzs07P1SkVPRU+lQ27tLdtWHX+G7R7ht7vPY07NXbW7z3/T7JvttVAVVN1WbVZftJ+7P3P66Jqun4lvttXa1ObXHtxwPSA/0HIw6217nU1R3SPVRSj9Yr60cOxx++/p3vdy0NNg1VjZzG4iNwRHnk6fcJ3/ceDTradox7rOEH0x92HWcdL2pCmvKaRptTmvtbYlu6T8w+0dbq3nr8R9sfD5w0PFl5SvNUyWna6YLTk2fyz4ydlZ19fi753GDborZ752PO32oPb++6EHTh0kX/i+c7vDvOXPK4dPKy2+UTV7hXmq86X23qdOo8/pPTT8e7nLuarrlca7nuer21e2b36RueN87d9L158Rb/1tWeOT3dvfN6b/fF9/XfFt1+cif9zsu72Xcn7q28T7xf9EDtQdlD3YfVP1v+3Njv3H9qwHeg89HcR/cGhYPP/pH1jw9DBY+Zj8uGDYbrnjg+OTniP3L96fynQ89kzyaeF/6i/suuFxYvfvjV69fO0ZjRoZfyl5O/bXyl/erA6xmv28bCxh6+yXgzMV70VvvtwXfcdx3vo98PT+R8IH8o/2j5sfVT0Kf7kxmTk/8EA5jz/GMzLdsAAAAgY0hSTQAAeiUAAICDAAD5/wAAgOkAAHUwAADqYAAAOpgAABdvkl/FRgAAAWJJREFUeNqkk7FOAkEURe/sspBVNm6xRkJCATFGgzbwG36BsbCVkh8wgx8iFovWljZuqOUDCKBRCVkKVg2wBGVmbGYIGgQSbvKayT3vZt68IfgtMqfEnJqaZ6EogA0AMQCRmaYTAGMAIYCvv000AJuUlnKNZqvYHwxdxsWjqv5g6DaarSKlpRyATemHLhNjlJYOzguF02QyeazrhsO4wIQJMC6g6RHHtu2jbPZwy7LiHc/zAgCMyC52o9k6S6fTJ4wDjAv8p9eX58r+3m4ZwIemkhOJRJ4vAQHA2d7Jy5kQBeumaWa4WAwCgGmaGXVdTU2bEGLw5SwIIYZ6JQULIcQ3VpD0CQULAGw0Gj2tAksfAyAUPPZ9v6aR5XC369fkwkzhsOK63nsQVBeBQa9Xvb2peHLThC7Puec9fFpWvJNKpfpGNBY1DMNRUBiG9Xb77f66fHV3SS/qKnmt3Sbr/KqfAQBYbqROksZsBwAAAABJRU5ErkJggg==) 7 round round;
-}
-
-div.toolstrip-button:active {
- border-width:7px;
- -webkit-border-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA8AAAAPCAYAAAA71pVKAAAACXBIWXMAAAsTAAALEwEAmpwYAAAKT2lDQ1BQaG90b3Nob3AgSUNDIHByb2ZpbGUAAHjanVNnVFPpFj333vRCS4iAlEtvUhUIIFJCi4AUkSYqIQkQSoghodkVUcERRUUEG8igiAOOjoCMFVEsDIoK2AfkIaKOg6OIisr74Xuja9a89+bN/rXXPues852zzwfACAyWSDNRNYAMqUIeEeCDx8TG4eQuQIEKJHAAEAizZCFz/SMBAPh+PDwrIsAHvgABeNMLCADATZvAMByH/w/qQplcAYCEAcB0kThLCIAUAEB6jkKmAEBGAYCdmCZTAKAEAGDLY2LjAFAtAGAnf+bTAICd+Jl7AQBblCEVAaCRACATZYhEAGg7AKzPVopFAFgwABRmS8Q5ANgtADBJV2ZIALC3AMDOEAuyAAgMADBRiIUpAAR7AGDIIyN4AISZABRG8lc88SuuEOcqAAB4mbI8uSQ5RYFbCC1xB1dXLh4ozkkXKxQ2YQJhmkAuwnmZGTKBNA/g88wAAKCRFRHgg/P9eM4Ors7ONo62Dl8t6r8G/yJiYuP+5c+rcEAAAOF0ftH+LC+zGoA7BoBt/qIl7gRoXgugdfeLZrIPQLUAoOnaV/Nw+H48PEWhkLnZ2eXk5NhKxEJbYcpXff5nwl/AV/1s+X48/Pf14L7iJIEyXYFHBPjgwsz0TKUcz5IJhGLc5o9H/LcL//wd0yLESWK5WCoU41EScY5EmozzMqUiiUKSKcUl0v9k4t8s+wM+3zUAsGo+AXuRLahdYwP2SycQWHTA4vcAAPK7b8HUKAgDgGiD4c93/+8//UegJQCAZkmScQAAXkQkLlTKsz/HCAAARKCBKrBBG/TBGCzABhzBBdzBC/xgNoRCJMTCQhBCCmSAHHJgKayCQiiGzbAdKmAv1EAdNMBRaIaTcA4uwlW4Dj1wD/phCJ7BKLyBCQRByAgTYSHaiAFiilgjjggXmYX4IcFIBBKLJCDJiBRRIkuRNUgxUopUIFVIHfI9cgI5h1xGupE7yAAygvyGvEcxlIGyUT3UDLVDuag3GoRGogvQZHQxmo8WoJvQcrQaPYw2oefQq2gP2o8+Q8cwwOgYBzPEbDAuxsNCsTgsCZNjy7EirAyrxhqwVqwDu4n1Y8+xdwQSgUXACTYEd0IgYR5BSFhMWE7YSKggHCQ0EdoJNwkDhFHCJyKTqEu0JroR+cQYYjIxh1hILCPWEo8TLxB7iEPENyQSiUMyJ7mQAkmxpFTSEtJG0m5SI+ksqZs0SBojk8naZGuyBzmULCAryIXkneTD5DPkG+Qh8lsKnWJAcaT4U+IoUspqShnlEOU05QZlmDJBVaOaUt2ooVQRNY9aQq2htlKvUYeoEzR1mjnNgxZJS6WtopXTGmgXaPdpr+h0uhHdlR5Ol9BX0svpR+iX6AP0dwwNhhWDx4hnKBmbGAcYZxl3GK+YTKYZ04sZx1QwNzHrmOeZD5lvVVgqtip8FZHKCpVKlSaVGyovVKmqpqreqgtV81XLVI+pXlN9rkZVM1PjqQnUlqtVqp1Q61MbU2epO6iHqmeob1Q/pH5Z/YkGWcNMw09DpFGgsV/jvMYgC2MZs3gsIWsNq4Z1gTXEJrHN2Xx2KruY/R27iz2qqaE5QzNKM1ezUvOUZj8H45hx+Jx0TgnnKKeX836K3hTvKeIpG6Y0TLkxZVxrqpaXllirSKtRq0frvTau7aedpr1Fu1n7gQ5Bx0onXCdHZ4/OBZ3nU9lT3acKpxZNPTr1ri6qa6UbobtEd79up+6Ynr5egJ5Mb6feeb3n+hx9L/1U/W36p/VHDFgGswwkBtsMzhg8xTVxbzwdL8fb8VFDXcNAQ6VhlWGX4YSRudE8o9VGjUYPjGnGXOMk423GbcajJgYmISZLTepN7ppSTbmmKaY7TDtMx83MzaLN1pk1mz0x1zLnm+eb15vft2BaeFostqi2uGVJsuRaplnutrxuhVo5WaVYVVpds0atna0l1rutu6cRp7lOk06rntZnw7Dxtsm2qbcZsOXYBtuutm22fWFnYhdnt8Wuw+6TvZN9un2N/T0HDYfZDqsdWh1+c7RyFDpWOt6azpzuP33F9JbpL2dYzxDP2DPjthPLKcRpnVOb00dnF2e5c4PziIuJS4LLLpc+Lpsbxt3IveRKdPVxXeF60vWdm7Obwu2o26/uNu5p7ofcn8w0nymeWTNz0MPIQ+BR5dE/C5+VMGvfrH5PQ0+BZ7XnIy9jL5FXrdewt6V3qvdh7xc+9j5yn+M+4zw33jLeWV/MN8C3yLfLT8Nvnl+F30N/I/9k/3r/0QCngCUBZwOJgUGBWwL7+Hp8Ib+OPzrbZfay2e1BjKC5QRVBj4KtguXBrSFoyOyQrSH355jOkc5pDoVQfujW0Adh5mGLw34MJ4WHhVeGP45wiFga0TGXNXfR3ENz30T6RJZE3ptnMU85ry1KNSo+qi5qPNo3ujS6P8YuZlnM1VidWElsSxw5LiquNm5svt/87fOH4p3iC+N7F5gvyF1weaHOwvSFpxapLhIsOpZATIhOOJTwQRAqqBaMJfITdyWOCnnCHcJnIi/RNtGI2ENcKh5O8kgqTXqS7JG8NXkkxTOlLOW5hCepkLxMDUzdmzqeFpp2IG0yPTq9MYOSkZBxQqohTZO2Z+pn5mZ2y6xlhbL+xW6Lty8elQfJa7OQrAVZLQq2QqboVFoo1yoHsmdlV2a/zYnKOZarnivN7cyzytuQN5zvn//tEsIS4ZK2pYZLVy0dWOa9rGo5sjxxedsK4xUFK4ZWBqw8uIq2Km3VT6vtV5eufr0mek1rgV7ByoLBtQFr6wtVCuWFfevc1+1dT1gvWd+1YfqGnRs+FYmKrhTbF5cVf9go3HjlG4dvyr+Z3JS0qavEuWTPZtJm6ebeLZ5bDpaql+aXDm4N2dq0Dd9WtO319kXbL5fNKNu7g7ZDuaO/PLi8ZafJzs07P1SkVPRU+lQ27tLdtWHX+G7R7ht7vPY07NXbW7z3/T7JvttVAVVN1WbVZftJ+7P3P66Jqun4lvttXa1ObXHtxwPSA/0HIw6217nU1R3SPVRSj9Yr60cOxx++/p3vdy0NNg1VjZzG4iNwRHnk6fcJ3/ceDTradox7rOEH0x92HWcdL2pCmvKaRptTmvtbYlu6T8w+0dbq3nr8R9sfD5w0PFl5SvNUyWna6YLTk2fyz4ydlZ19fi753GDborZ752PO32oPb++6EHTh0kX/i+c7vDvOXPK4dPKy2+UTV7hXmq86X23qdOo8/pPTT8e7nLuarrlca7nuer21e2b36RueN87d9L158Rb/1tWeOT3dvfN6b/fF9/XfFt1+cif9zsu72Xcn7q28T7xf9EDtQdlD3YfVP1v+3Njv3H9qwHeg89HcR/cGhYPP/pH1jw9DBY+Zj8uGDYbrnjg+OTniP3L96fynQ89kzyaeF/6i/suuFxYvfvjV69fO0ZjRoZfyl5O/bXyl/erA6xmv28bCxh6+yXgzMV70VvvtwXfcdx3vo98PT+R8IH8o/2j5sfVT0Kf7kxmTk/8EA5jz/GMzLdsAAAAgY0hSTQAAeiUAAICDAAD5/wAAgOkAAHUwAADqYAAAOpgAABdvkl/FRgAAActJREFUeNqkU7uO2lAQPeMHxiHkXhNBY2ktIaTVJhtcbE23HQVfwB9E/qeIHwgFhatE2ipFpDysQJGVMJGlOKy0xvaykIBvirWJN1UeV5o7V3d0NGdmzpAQAv96lNJbAqADMHKr5f83AK5zuwWQlQGFZ0EQdF3XPXMcp0FEayJaO47TcF33LAiCLgBWwoBy2rUgCLrj8Zi1O8d9y7J6jDFblmUkafJ+4fsXs0/eZDAYrEzT/JCzOdA2PM9rtTvH56fPTp9XqzpURYUkSdD1B3bDeGwrioLZbPbaNM0vBbigYEwmk+joyOpVNR0VtQJJugsREVRVRbvd6c3nc5H3417NtdFotGLs0YmiqiAiCOBgAFCv10/CMNyXGnkAy1EUZZIsV4gIfzq9ouY951za/si+KztR+ZWP8tx3vtVq1fDbbAHgZjgcsjRNp1mWlcICAgQBge3m9rNlWQ+LZpXB1/1+ny/8xcV+t4cQeb35JYEQx6upZVmVXCz3wbZtf0uj8JXvX76Ik+RjlgmAgM1mPb1afn2J3eZNs9n0yuBCJBIAFobh0+Vy+SSOYz1JEtI0TTMMQ+Gcbxljbznn7wCsColSaTH+Wtv0P1v1cwALNr3K+GzqTAAAAABJRU5ErkJggg==) 7 round round;
-}
diff --git a/chrome/test/data/extensions/api_test/README.txt b/chrome/test/data/extensions/api_test/README.txt
index a356855..06088f1 100644
--- a/chrome/test/data/extensions/api_test/README.txt
+++ b/chrome/test/data/extensions/api_test/README.txt
@@ -15,7 +15,7 @@ extension_bookmarks_apitest.cc for an example.
(2) Create an extension of in this directory of the same name as the extension
that your test referred to ("extension_name" above). This test should load
-either a background page or a toolstrip which immediately starts its test.
+either a background page which immediately starts its test.
(3) In your extension page, call chrome.test.runTests with an array of
functions which represent your subtests. Each of these functions will most
diff --git a/chrome/test/data/extensions/api_test/toolstrip/folder/relative.html b/chrome/test/data/extensions/api_test/toolstrip/folder/relative.html
deleted file mode 100644
index 9be5b62..0000000
--- a/chrome/test/data/extensions/api_test/toolstrip/folder/relative.html
+++ /dev/null
@@ -1,8 +0,0 @@
-<script>
-/*
-chrome.toolstrip.onExpanded.addListener(function() {
- chrome.test.log("relative expanded");
-});*/
-</script>
-relative
-
diff --git a/chrome/test/data/extensions/api_test/toolstrip/manifest.json b/chrome/test/data/extensions/api_test/toolstrip/manifest.json
deleted file mode 100644
index 63b5798..0000000
--- a/chrome/test/data/extensions/api_test/toolstrip/manifest.json
+++ /dev/null
@@ -1,6 +0,0 @@
-{
- "name": "chrome.toolstrip",
- "version": "0.1",
- "description": "end-to-end browser test for chrome.toolstrip API",
- "toolstrips": ["test.html", "test2.html"]
-}
diff --git a/chrome/test/data/extensions/api_test/toolstrip/test.html b/chrome/test/data/extensions/api_test/toolstrip/test.html
deleted file mode 100644
index 985e751..0000000
--- a/chrome/test/data/extensions/api_test/toolstrip/test.html
+++ /dev/null
@@ -1,42 +0,0 @@
-<script>
-chrome.test.runTests([
- function expand() {
- chrome.test.listenOnce(chrome.toolstrip.onExpanded, function(){});
- chrome.toolstrip.expand({height:200},
- chrome.test.callbackPass(function(){}));
- },
-
- function collapse() {
- chrome.test.listenOnce(chrome.toolstrip.onCollapsed, function(){});
- chrome.toolstrip.collapse({}, chrome.test.callbackPass(function(){}));
- },
-
- /* TODO(mpcomplete): this is failing in part due to bug 21905
- function expandOther() {
- var orig = window.location;
- var relative = "folder/relative.html";
-
- // Get the other toolstrip.
- var toolstrips = chrome.extension.getToolstrips();
- var other = (toolstrips[0].location == location) ?
- toolstrips[1] : toolstrips[0];
-
- other.chrome.toolstrip.expand({height:200, url:relative},
- chrome.test.callbackPass(function() {
- // TODO(mpcomplete) this never gets called
- chrome.test.log(other.location.toString());
- chrome.test.listenOnce(other.onLoad, function() {
- chrome.test.log(other.location.toString());
- chrome.test.assertEq(other.location.toString(),
- chrome.extension.getURL(relative));
- other.chrome.toolstrip.collapse({url:"../test2.html"},
- chrome.test.callbackPass(function() {
- chrome.test.assertEq(other.location.toString(), orig);
- }));
- });
- }));
- },
- */
-]);
-</script>
-test \ No newline at end of file
diff --git a/chrome/test/data/extensions/api_test/toolstrip/test2.html b/chrome/test/data/extensions/api_test/toolstrip/test2.html
deleted file mode 100644
index 957f4e4..0000000
--- a/chrome/test/data/extensions/api_test/toolstrip/test2.html
+++ /dev/null
@@ -1,9 +0,0 @@
-<script>
-chrome.toolstrip.onExpanded.addListener(function() {
- chrome.test.log("test2 expanded");
-});
-chrome.toolstrip.onCollapsed.addListener(function() {
- chrome.test.log("test2 collapsed");
-});
-</script>
-test2
diff --git a/chrome/test/data/extensions/browsertest/last_error/toolstrip.html b/chrome/test/data/extensions/browsertest/last_error/bg.html
index 6df972e..6df972e 100644
--- a/chrome/test/data/extensions/browsertest/last_error/toolstrip.html
+++ b/chrome/test/data/extensions/browsertest/last_error/bg.html
diff --git a/chrome/test/data/extensions/browsertest/last_error/manifest.json b/chrome/test/data/extensions/browsertest/last_error/manifest.json
index e0c6ad7..71bf252 100644
--- a/chrome/test/data/extensions/browsertest/last_error/manifest.json
+++ b/chrome/test/data/extensions/browsertest/last_error/manifest.json
@@ -2,6 +2,6 @@
"name": "lastError",
"description": "Used by browsertest to test the setting of lastError for callbacks.",
"version": "0.1",
- "toolstrips": ["toolstrip.html"],
+ "background_page": "bg.html",
"permissions": ["tabs"]
}
diff --git a/chrome/test/data/extensions/common/one_in_shelf/manifest.json b/chrome/test/data/extensions/common/one_in_shelf/manifest.json
deleted file mode 100644
index f714a17..0000000
--- a/chrome/test/data/extensions/common/one_in_shelf/manifest.json
+++ /dev/null
@@ -1,8 +0,0 @@
-{
- "description": "Extension which has exactly one item in the shelf",
- "name": "one_in_shelf",
- "toolstrips": [
- "shelf.html"
- ],
- "version": "0.1"
-} \ No newline at end of file
diff --git a/chrome/test/data/extensions/common/one_in_shelf/shelf.html b/chrome/test/data/extensions/common/one_in_shelf/shelf.html
deleted file mode 100644
index e2a5d5a..0000000
--- a/chrome/test/data/extensions/common/one_in_shelf/shelf.html
+++ /dev/null
@@ -1,2 +0,0 @@
-<div class="toolstrip-button">Hello World!</div>
-
diff --git a/chrome/test/data/extensions/good/Extensions/behllobkkfkfnphdnhnkndlbkcpglgmj/1.0.0.0/manifest.json b/chrome/test/data/extensions/good/Extensions/behllobkkfkfnphdnhnkndlbkcpglgmj/1.0.0.0/manifest.json
index 7362c99..7f119e6 100644
--- a/chrome/test/data/extensions/good/Extensions/behllobkkfkfnphdnhnkndlbkcpglgmj/1.0.0.0/manifest.json
+++ b/chrome/test/data/extensions/good/Extensions/behllobkkfkfnphdnhnkndlbkcpglgmj/1.0.0.0/manifest.json
@@ -7,14 +7,6 @@
"128": "icon_128.png"
},
"default_locale": "en_US",
- "toolstrips": [
- {
- "path": "toolstrip1.html",
- "mole": "lorem_ipsum.html",
- "mole_height": 200
- },
- "toolstrip2.html"
- ],
"background_page": "backgroundpage.html",
"permissions": ["tabs", "http://*.google.com/*", "https://*.google.com/*"],
"content_scripts": [
diff --git a/chrome/test/data/extensions/good/Extensions/behllobkkfkfnphdnhnkndlbkcpglgmj/1.0.0.0/toolstrip1.html b/chrome/test/data/extensions/good/Extensions/behllobkkfkfnphdnhnkndlbkcpglgmj/1.0.0.0/toolstrip1.html
deleted file mode 100644
index da7cdae..0000000
--- a/chrome/test/data/extensions/good/Extensions/behllobkkfkfnphdnhnkndlbkcpglgmj/1.0.0.0/toolstrip1.html
+++ /dev/null
@@ -1,59 +0,0 @@
-<script>
-var isToolstrip = 1;
-// This function is called from the C++ browser test. It does a basic sanity
-// test that we can call extension APIs.
-function testTabsAPI() {
- console.log(chrome.tabs);
-
- chrome.tabs.getAllInWindow(null, function(tabs) {
- window.domAutomationController.send(tabs.length == 1);
- });
-}
-
-// This function is called from the C++ browser test. It tests the getLanguage
-// function to make sure it can be used as an extension API. This will pass if
-// the browser navigates to a page in French language before this is called.
-function testTabsLanguageAPI() {
- chrome.tabs.detectLanguage(null, function(language) {
- window.domAutomationController.send(language == 'fr');
- });
-}
-
-// This function is called from the C++ browser test. It tests the getToolstrips
-// function to make sure it can be used as an extension API. This will pass if
-// getToolstrips returns all toolstrip views.
-function testgetToolstripsAPI() {
- var views = chrome.extension.getToolstrips();
- window.domAutomationController.send(views.length == 2 &&
- views[0].isToolstrip == 1 &&
- views[1].isToolstrip == 1);
-}
-
-// This function is called from the C++ browser test. It tests the
-// getBackgroundPage function to make sure it can be used as an extension API.
-// This will pass if getBackgroundPage returns background page view.
-function testgetBackgroundPageAPI() {
- var view = chrome.extension.getBackgroundPage();
- window.domAutomationController.send(view != null &&
- view.isBackgroundPage == 1);
-}
-
-// This function is called from the C++ browser test. It tests the
-// getExtensionTabs function to make sure it can be used as an extension API.
-// This will pass if getExtensionTabs returns tabcontent view.
-function testgetExtensionTabsAPI() {
- var views = chrome.extension.getExtensionTabs();
- // getTabContentses is here for backwards compatibility
- var views2 = chrome.extension.getTabContentses();
- window.domAutomationController.send(views.length == 1 &&
- views[0].isTabContents == 1 &&
- views2.length == 1 &&
- views2[0].isTabContents == 1);
-}
-
-</script>
-<select>
- <option>one</option>
- <option>two</option>
- <option>three</option>
-</select>
diff --git a/chrome/test/data/extensions/good/Extensions/behllobkkfkfnphdnhnkndlbkcpglgmj/1.0.0.0/toolstrip2.html b/chrome/test/data/extensions/good/Extensions/behllobkkfkfnphdnhnkndlbkcpglgmj/1.0.0.0/toolstrip2.html
deleted file mode 100644
index 2f0bc54..0000000
--- a/chrome/test/data/extensions/good/Extensions/behllobkkfkfnphdnhnkndlbkcpglgmj/1.0.0.0/toolstrip2.html
+++ /dev/null
@@ -1,4 +0,0 @@
-<script>
- var isToolstrip = 1;
-</script>
-<button onclick="window.open('http://www.google.com', 'mywindow', 'width=640, height=480');">HTML button</button>
diff --git a/chrome/test/data/extensions/good/Preferences b/chrome/test/data/extensions/good/Preferences
index 6d5c369..fc5524c 100644
--- a/chrome/test/data/extensions/good/Preferences
+++ b/chrome/test/data/extensions/good/Preferences
@@ -15,14 +15,6 @@
"128": "icon_128.png"
},
"default_locale": "en_US",
- "toolstrips": [
- {
- "path": "toolstrip1.html",
- "mole": "lorem_ipsum.html",
- "mole_height": 200
- },
- "toolstrip2.html"
- ],
"background_page": "backgroundpage.html",
"permissions": ["tabs", "http://*.google.com/*", "https://*.google.com/*"],
"content_scripts": [
diff --git a/chrome/test/data/extensions/profiles/toolstrips1/Default/Extensions/behllobkkfkfnphdnhnkndlbkcpglgmj/1.0.0.0/manifest.json b/chrome/test/data/extensions/profiles/toolstrips1/Default/Extensions/behllobkkfkfnphdnhnkndlbkcpglgmj/1.0.0.0/manifest.json
deleted file mode 100644
index 94c0e712..0000000
--- a/chrome/test/data/extensions/profiles/toolstrips1/Default/Extensions/behllobkkfkfnphdnhnkndlbkcpglgmj/1.0.0.0/manifest.json
+++ /dev/null
@@ -1,8 +0,0 @@
-{
- "key": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDuUZGKCDbff6IRaxa4Pue7PPkxwPaNhGT3JEqppEsNWFjM80imEdqMbf3lrWqEfaHgaNku7nlpwPO1mu3/4Hr+XdNa5MhfnOnuPee4hyTLwOs3Vzz81wpbdzUxZSi2OmqMyI5oTaBYICfNHLwcuc65N5dbt6WKGeKgTpp4v7j7zwIDAQAB",
- "version": "1.0.0.0",
- "name": "1 toolstrip",
- "toolstrips": [
- "toolstrip1.html"
- ]
-}
diff --git a/chrome/test/data/extensions/profiles/toolstrips1/Default/Extensions/behllobkkfkfnphdnhnkndlbkcpglgmj/1.0.0.0/toolstrip1.html b/chrome/test/data/extensions/profiles/toolstrips1/Default/Extensions/behllobkkfkfnphdnhnkndlbkcpglgmj/1.0.0.0/toolstrip1.html
deleted file mode 100644
index d45660f..0000000
--- a/chrome/test/data/extensions/profiles/toolstrips1/Default/Extensions/behllobkkfkfnphdnhnkndlbkcpglgmj/1.0.0.0/toolstrip1.html
+++ /dev/null
@@ -1,5 +0,0 @@
-<select>
- <option>one</option>
- <option>two</option>
- <option>three</option>
-</select>
diff --git a/chrome/test/data/extensions/profiles/toolstrips1/Default/Preferences b/chrome/test/data/extensions/profiles/toolstrips1/Default/Preferences
deleted file mode 100644
index a9b9760..0000000
--- a/chrome/test/data/extensions/profiles/toolstrips1/Default/Preferences
+++ /dev/null
@@ -1,36 +0,0 @@
-{
- "download": {
- "directory_upgrade": true,
- "extensions_to_open": ""
- },
- "extensions": {
- "autoupdate": {
- "next_check": "12897640036342487"
- },
- "settings": {
- "behllobkkfkfnphdnhnkndlbkcpglgmj": {
- "location": 1,
- "manifest":
- {
- "key": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDuUZGKCDbff6IRaxa4Pue7PPkxwPaNhGT3JEqppEsNWFjM80imEdqMbf3lrWqEfaHgaNku7nlpwPO1mu3/4Hr+XdNa5MhfnOnuPee4hyTLwOs3Vzz81wpbdzUxZSi2OmqMyI5oTaBYICfNHLwcuc65N5dbt6WKGeKgTpp4v7j7zwIDAQAB",
- "version": "1.0.0.0",
- "name": "1 toolstrip",
- "toolstrips": [
- "toolstrip1.html"
- ]
- },
- "path": "behllobkkfkfnphdnhnkndlbkcpglgmj/1.0.0.0",
- "state": 1
- }
- }
- },
- "profile": {
- "exited_cleanly": true,
- "id": "not-signed-in",
- "name": "",
- "nickname": ""
- },
- "session": {
- "urls_to_restore_on_startup": [ ]
- }
-}
diff --git a/chrome/test/data/extensions/profiles/toolstrips50/Default/Extensions/behllobkkfkfnphdnhnkndlbkcpglgmj/1.0.0.0/manifest.json b/chrome/test/data/extensions/profiles/toolstrips50/Default/Extensions/behllobkkfkfnphdnhnkndlbkcpglgmj/1.0.0.0/manifest.json
deleted file mode 100644
index 2053464..0000000
--- a/chrome/test/data/extensions/profiles/toolstrips50/Default/Extensions/behllobkkfkfnphdnhnkndlbkcpglgmj/1.0.0.0/manifest.json
+++ /dev/null
@@ -1,73 +0,0 @@
-{
- "key": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDuUZGKCDbff6IRaxa4Pue7PPkxwPaNhGT3JEqppEsNWFjM80imEdqMbf3lrWqEfaHgaNku7nlpwPO1mu3/4Hr+XdNa5MhfnOnuPee4hyTLwOs3Vzz81wpbdzUxZSi2OmqMyI5oTaBYICfNHLwcuc65N5dbt6WKGeKgTpp4v7j7zwIDAQAB",
- "version": "1.0.0.0",
- "name": "50 toolstrips",
- "toolstrips": [
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html"
- ]
-}
diff --git a/chrome/test/data/extensions/profiles/toolstrips50/Default/Extensions/behllobkkfkfnphdnhnkndlbkcpglgmj/1.0.0.0/toolstrip1.html b/chrome/test/data/extensions/profiles/toolstrips50/Default/Extensions/behllobkkfkfnphdnhnkndlbkcpglgmj/1.0.0.0/toolstrip1.html
deleted file mode 100644
index d45660f..0000000
--- a/chrome/test/data/extensions/profiles/toolstrips50/Default/Extensions/behllobkkfkfnphdnhnkndlbkcpglgmj/1.0.0.0/toolstrip1.html
+++ /dev/null
@@ -1,5 +0,0 @@
-<select>
- <option>one</option>
- <option>two</option>
- <option>three</option>
-</select>
diff --git a/chrome/test/data/extensions/profiles/toolstrips50/Default/Preferences b/chrome/test/data/extensions/profiles/toolstrips50/Default/Preferences
deleted file mode 100644
index d4b478c..0000000
--- a/chrome/test/data/extensions/profiles/toolstrips50/Default/Preferences
+++ /dev/null
@@ -1,101 +0,0 @@
-{
- "download": {
- "directory_upgrade": true,
- "extensions_to_open": ""
- },
- "extensions": {
- "autoupdate": {
- "next_check": "12897640036342487"
- },
- "settings": {
- "behllobkkfkfnphdnhnkndlbkcpglgmj": {
- "location": 1,
- "manifest":
- {
- "key": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDuUZGKCDbff6IRaxa4Pue7PPkxwPaNhGT3JEqppEsNWFjM80imEdqMbf3lrWqEfaHgaNku7nlpwPO1mu3/4Hr+XdNa5MhfnOnuPee4hyTLwOs3Vzz81wpbdzUxZSi2OmqMyI5oTaBYICfNHLwcuc65N5dbt6WKGeKgTpp4v7j7zwIDAQAB",
- "version": "1.0.0.0",
- "name": "50 toolstrips",
- "toolstrips": [
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html",
- "toolstrip1.html"
- ]
- },
- "path": "behllobkkfkfnphdnhnkndlbkcpglgmj/1.0.0.0",
- "state": 1
- }
- }
- },
- "profile": {
- "exited_cleanly": true,
- "id": "not-signed-in",
- "name": "",
- "nickname": ""
- },
- "session": {
- "urls_to_restore_on_startup": [ ]
- }
-}
diff --git a/chrome/test/startup/startup_test.cc b/chrome/test/startup/startup_test.cc
index e33e113..1422e49 100644
--- a/chrome/test/startup/startup_test.cc
+++ b/chrome/test/startup/startup_test.cc
@@ -79,9 +79,6 @@ class StartupTest : public UITest {
data_dir = data_dir.AppendASCII("extensions").AppendASCII("profiles").
AppendASCII(profile);
set_template_user_data(data_dir);
-
- // For now, these tests still depend on toolstrips.
- launch_arguments_.AppendSwitch(switches::kEnableExtensionToolstrips);
}
// Runs a test which loads |tab_count| tabs on startup, either as command line
@@ -343,20 +340,6 @@ TEST_F(StartupTest, PerfExtensionEmpty) {
UITest::DEFAULT_THEME, 1, 0);
}
-TEST_F(StartupTest, PerfExtensionToolstrips1) {
- SetUpWithFileURL();
- SetUpWithExtensionsProfile("toolstrips1");
- RunStartupTest("warm", "extension_toolstrip1", WARM, NOT_IMPORTANT,
- UITest::DEFAULT_THEME, 1, 0);
-}
-
-TEST_F(StartupTest, PerfExtensionToolstrips50) {
- SetUpWithFileURL();
- SetUpWithExtensionsProfile("toolstrips50");
- RunStartupTest("warm", "extension_toolstrip50", WARM, NOT_IMPORTANT,
- UITest::DEFAULT_THEME, 1, 0);
-}
-
TEST_F(StartupTest, PerfExtensionContentScript1) {
SetUpWithFileURL();
SetUpWithExtensionsProfile("content_scripts1");
diff --git a/chrome/test/test_browser_window.h b/chrome/test/test_browser_window.h
index 878bf72..d35e04c 100644
--- a/chrome/test/test_browser_window.h
+++ b/chrome/test/test_browser_window.h
@@ -30,7 +30,6 @@ class TestBrowserWindow : public BrowserWindow {
virtual BrowserWindowTesting* GetBrowserWindowTesting() { return NULL; }
virtual StatusBubble* GetStatusBubble() { return NULL; }
virtual void SelectedTabToolbarSizeChanged(bool is_animating) {}
- virtual void SelectedTabExtensionShelfSizeChanged() {}
virtual void UpdateTitleBar() {}
virtual void ShelfVisibilityChanged() {}
virtual void UpdateDevTools() {}
@@ -71,7 +70,6 @@ class TestBrowserWindow : public BrowserWindow {
virtual void ConfirmAddSearchProvider(const TemplateURL* template_url,
Profile* profile) {}
virtual void ToggleBookmarkBar() {}
- virtual void ToggleExtensionShelf() {}
virtual views::Window* ShowAboutChromeDialog() { return NULL; }
virtual void ShowUpdateChromeDialog() {}
virtual void ShowTaskManager() {}