summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authorben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-25 21:56:10 +0000
committerben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-25 21:56:10 +0000
commita37d4b081fa9c311c30e233fb1160d6d0af1353e (patch)
treef87ca96ad3c4793a7f4d2a08170a1b5db06189db /chrome/browser
parent51b9a6b2fef24656af23c20a167ea81bedbeaa2a (diff)
downloadchromium_src-a37d4b081fa9c311c30e233fb1160d6d0af1353e.zip
chromium_src-a37d4b081fa9c311c30e233fb1160d6d0af1353e.tar.gz
chromium_src-a37d4b081fa9c311c30e233fb1160d6d0af1353e.tar.bz2
Move browser commands into a separate file.
http://crbug.com/133576 TEST=none Review URL: https://chromiumcodereview.appspot.com/10657016 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@144028 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/app_controller_mac.mm7
-rw-r--r--chrome/browser/autocomplete/autocomplete_browsertest.cc5
-rw-r--r--chrome/browser/automation/testing_automation_provider.cc11
-rw-r--r--chrome/browser/background/background_mode_manager.cc9
-rw-r--r--chrome/browser/browser_commands_unittest.cc9
-rw-r--r--chrome/browser/browser_encoding_browsertest.cc5
-rw-r--r--chrome/browser/browser_focus_uitest.cc31
-rw-r--r--chrome/browser/captive_portal/captive_portal_browsertest.cc9
-rw-r--r--chrome/browser/chrome_main_browsertest.cc5
-rw-r--r--chrome/browser/chromeos/oom_priority_manager_browsertest.cc21
-rw-r--r--chrome/browser/crash_recovery_browsertest.cc5
-rw-r--r--chrome/browser/debugger/devtools_sanity_browsertest.cc3
-rw-r--r--chrome/browser/download/download_browsertest.cc11
-rw-r--r--chrome/browser/download/download_danger_prompt_browsertest.cc3
-rw-r--r--chrome/browser/download/save_page_browsertest.cc5
-rw-r--r--chrome/browser/errorpage_browsertest.cc5
-rw-r--r--chrome/browser/extensions/api/extension_action/browser_action_apitest.cc5
-rw-r--r--chrome/browser/extensions/api/tabs/tabs.cc5
-rw-r--r--chrome/browser/extensions/api/tabs/tabs_test.cc3
-rw-r--r--chrome/browser/extensions/app_process_apitest.cc17
-rw-r--r--chrome/browser/extensions/extension_crash_recovery_browsertest.cc7
-rw-r--r--chrome/browser/extensions/extension_management_apitest.cc3
-rw-r--r--chrome/browser/extensions/extension_test_api.cc4
-rw-r--r--chrome/browser/extensions/isolated_app_browsertest.cc5
-rw-r--r--chrome/browser/extensions/plugin_apitest.cc3
-rw-r--r--chrome/browser/fast_shutdown_browsertest.cc5
-rw-r--r--chrome/browser/geolocation/geolocation_browsertest.cc3
-rw-r--r--chrome/browser/net/gaia/gaia_oauth_fetcher.cc3
-rw-r--r--chrome/browser/prerender/prerender_browsertest.cc5
-rw-r--r--chrome/browser/printing/print_preview_tab_controller_browsertest.cc3
-rw-r--r--chrome/browser/printing/print_preview_tab_controller_unittest.cc9
-rw-r--r--chrome/browser/printing/printing_layout_browsertest.cc5
-rw-r--r--chrome/browser/referrer_policy_browsertest.cc7
-rw-r--r--chrome/browser/renderer_host/chrome_render_widget_host_view_mac_delegate.mm9
-rw-r--r--chrome/browser/renderer_host/render_process_host_chrome_browsertest.cc5
-rw-r--r--chrome/browser/renderer_host/web_cache_manager_browsertest.cc13
-rw-r--r--chrome/browser/sessions/session_restore_browsertest.cc17
-rw-r--r--chrome/browser/ssl/ssl_browser_tests.cc9
-rw-r--r--chrome/browser/sync/test/integration/performance/sessions_sync_perf_test.cc3
-rw-r--r--chrome/browser/tab_contents/render_view_context_menu.cc9
-rw-r--r--chrome/browser/tab_restore_browsertest.cc9
-rw-r--r--chrome/browser/ui/browser.cc873
-rw-r--r--chrome/browser/ui/browser.h103
-rw-r--r--chrome/browser/ui/browser_browsertest.cc31
-rw-r--r--chrome/browser/ui/browser_commands.cc682
-rw-r--r--chrome/browser/ui/browser_commands.h107
-rw-r--r--chrome/browser/ui/browser_navigator_browsertest.cc9
-rw-r--r--chrome/browser/ui/browser_tab_restore_service_delegate.cc3
-rw-r--r--chrome/browser/ui/browser_win.cc33
-rw-r--r--chrome/browser/ui/cocoa/applescript/window_applescript.mm3
-rw-r--r--chrome/browser/ui/cocoa/cocoa_profile_test.mm3
-rw-r--r--chrome/browser/ui/cocoa/location_bar/location_icon_decoration.mm4
-rw-r--r--chrome/browser/ui/cocoa/view_id_util_browsertest.mm5
-rw-r--r--chrome/browser/ui/find_bar/find_bar_host_browsertest.cc33
-rw-r--r--chrome/browser/ui/fullscreen_controller_browsertest.cc3
-rw-r--r--chrome/browser/ui/fullscreen_controller_test.cc5
-rw-r--r--chrome/browser/ui/gtk/bookmarks/bookmark_bar_gtk_interactive_uitest.cc9
-rw-r--r--chrome/browser/ui/gtk/browser_titlebar.cc5
-rw-r--r--chrome/browser/ui/gtk/browser_toolbar_gtk.cc3
-rw-r--r--chrome/browser/ui/gtk/browser_window_gtk.cc5
-rw-r--r--chrome/browser/ui/gtk/location_bar_view_gtk.cc4
-rw-r--r--chrome/browser/ui/gtk/reload_button_gtk.cc3
-rw-r--r--chrome/browser/ui/gtk/view_id_util_browsertest.cc3
-rw-r--r--chrome/browser/ui/login/login_prompt_browsertest.cc11
-rw-r--r--chrome/browser/ui/omnibox/omnibox_view_browsertest.cc25
-rw-r--r--chrome/browser/ui/panels/old_panel_browsertest.cc19
-rw-r--r--chrome/browser/ui/panels/panel_browser_window.cc3
-rw-r--r--chrome/browser/ui/panels/panel_browsertest.cc19
-rw-r--r--chrome/browser/ui/tab_contents/tab_contents_iterator_unittest.cc23
-rw-r--r--chrome/browser/ui/tabs/tab_menu_model_unittest.cc3
-rw-r--r--chrome/browser/ui/toolbar/back_forward_menu_model.cc6
-rw-r--r--chrome/browser/ui/toolbar/wrench_menu_model.cc3
-rw-r--r--chrome/browser/ui/views/ash/chrome_shell_delegate.cc11
-rw-r--r--chrome/browser/ui/views/ash/launcher/chrome_launcher_controller.cc7
-rw-r--r--chrome/browser/ui/views/ash/launcher/chrome_launcher_controller_browsertest.cc3
-rw-r--r--chrome/browser/ui/views/constrained_window_views_browsertest.cc3
-rw-r--r--chrome/browser/ui/views/find_bar_host_interactive_uitest.cc21
-rw-r--r--chrome/browser/ui/views/frame/browser_frame_win.cc5
-rw-r--r--chrome/browser/ui/views/toolbar_view.cc3
-rw-r--r--chrome/browser/ui/webui/help/help_handler.cc3
-rw-r--r--chrome/browser/ui/webui/ntp/new_tab_ui_browsertest.cc5
-rw-r--r--chrome/browser/ui/webui/print_preview/print_preview_handler_unittest.cc4
-rw-r--r--chrome/browser/ui/webui/print_preview/print_preview_ui_browsertest.cc3
-rw-r--r--chrome/browser/ui/webui/print_preview/print_preview_ui_unittest.cc4
-rw-r--r--chrome/browser/ui/webui/web_dialog_controller_browsertest.cc3
-rw-r--r--chrome/browser/ui/webui/web_ui_browsertest.cc3
-rw-r--r--chrome/browser/unload_browsertest.cc13
87 files changed, 1317 insertions, 1125 deletions
diff --git a/chrome/browser/app_controller_mac.mm b/chrome/browser/app_controller_mac.mm
index b59a1879..be7af30 100644
--- a/chrome/browser/app_controller_mac.mm
+++ b/chrome/browser/app_controller_mac.mm
@@ -38,6 +38,7 @@
#include "chrome/browser/sync/sync_ui_util.h"
#include "chrome/browser/sync/sync_ui_util_mac.h"
#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/browser_mac.h"
@@ -100,7 +101,7 @@ NSString* NSPopoverDidShowNotification = @"NSPopoverDidShowNotification";
NSString* NSPopoverDidCloseNotification = @"NSPopoverDidCloseNotification";
#endif
-// True while AppController is calling Browser::NewEmptyWindow(). We need a
+// True while AppController is calling chrome::NewEmptyWindow(). We need a
// global flag here, analogue to StartupBrowserCreator::InProcessStartup()
// because otherwise the SessionService will try to restore sessions when we
// make a new window while there are no other active windows.
@@ -122,7 +123,7 @@ Browser* ActivateBrowser(Profile* profile) {
Browser* CreateBrowser(Profile* profile) {
{
AutoReset<bool> auto_reset_in_run(&g_is_opening_new_window, true);
- Browser::NewEmptyWindow(profile);
+ chrome::NewEmptyWindow(profile);
}
Browser* browser = browser::GetLastActiveBrowser();
@@ -843,7 +844,7 @@ const AEEventClass kAECloudPrintUninstallClass = 'GCPu';
CreateBrowser(lastProfile->GetOffTheRecordProfile());
break;
case IDC_RESTORE_TAB:
- Browser::OpenWindowWithRestoredTabs(lastProfile);
+ chrome::OpenWindowWithRestoredTabs(lastProfile);
break;
case IDC_OPEN_FILE:
CreateBrowser(lastProfile)->ExecuteCommand(IDC_OPEN_FILE);
diff --git a/chrome/browser/autocomplete/autocomplete_browsertest.cc b/chrome/browser/autocomplete/autocomplete_browsertest.cc
index 785e56b..59a946c 100644
--- a/chrome/browser/autocomplete/autocomplete_browsertest.cc
+++ b/chrome/browser/autocomplete/autocomplete_browsertest.cc
@@ -15,6 +15,7 @@
#include "chrome/browser/history/history_service_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/omnibox/location_bar.h"
#include "chrome/browser/ui/omnibox/omnibox_popup_model.h"
@@ -157,7 +158,7 @@ IN_PROC_BROWSER_TEST_F(AutocompleteBrowserTest, TabAwayRevertSelect) {
content::PAGE_TRANSITION_START_PAGE);
observer.Wait();
EXPECT_EQ(UTF8ToUTF16(chrome::kAboutBlankURL), location_entry->GetText());
- browser()->CloseTab();
+ chrome::CloseTab(browser());
EXPECT_EQ(UTF8ToUTF16(chrome::kAboutBlankURL), location_entry->GetText());
EXPECT_TRUE(location_entry->IsSelectAll());
}
@@ -287,7 +288,7 @@ IN_PROC_BROWSER_TEST_F(AutocompleteBrowserTest, ExtensionAppProvider) {
EXPECT_FALSE(match.deletable);
}
- browser()->NewTab();
+ chrome::NewTab(browser());
// Try out the hosted app.
{
diff --git a/chrome/browser/automation/testing_automation_provider.cc b/chrome/browser/automation/testing_automation_provider.cc
index 7cce4b3..6c613fb 100644
--- a/chrome/browser/automation/testing_automation_provider.cc
+++ b/chrome/browser/automation/testing_automation_provider.cc
@@ -101,6 +101,7 @@
#include "chrome/browser/ui/app_modal_dialogs/native_app_modal_dialog.h"
#include "chrome/browser/ui/blocked_content/blocked_content_tab_helper.h"
#include "chrome/browser/ui/bookmarks/bookmark_bar.h"
+#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/browser_window.h"
@@ -636,7 +637,7 @@ void TestingAutomationProvider::Reload(int handle,
if (browser && browser->command_updater()->IsCommandEnabled(IDC_RELOAD)) {
new NavigationNotificationObserver(
tab, this, reply_message, 1, false, false);
- browser->Reload(CURRENT_TAB);
+ chrome::Reload(browser, CURRENT_TAB);
return;
}
}
@@ -1377,7 +1378,7 @@ void TestingAutomationProvider::HandleOpenFindInPageRequest(
const IPC::Message& message, int handle) {
if (browser_tracker_->ContainsHandle(handle)) {
Browser* browser = browser_tracker_->GetResource(handle);
- browser->FindInPage(false, false);
+ chrome::FindInPage(browser, false, false);
}
}
@@ -1624,7 +1625,7 @@ void TestingAutomationProvider::GoBackBlockUntilNavigationsComplete(
if (browser && browser->command_updater()->IsCommandEnabled(IDC_BACK)) {
new NavigationNotificationObserver(tab, this, reply_message,
number_of_navigations, false, false);
- browser->GoBack(CURRENT_TAB);
+ chrome::GoBack(browser, CURRENT_TAB);
return;
}
}
@@ -1642,7 +1643,7 @@ void TestingAutomationProvider::GoForwardBlockUntilNavigationsComplete(
if (browser && browser->command_updater()->IsCommandEnabled(IDC_FORWARD)) {
new NavigationNotificationObserver(tab, this, reply_message,
number_of_navigations, false, false);
- browser->GoForward(CURRENT_TAB);
+ chrome::GoForward(browser, CURRENT_TAB);
return;
}
}
@@ -3146,7 +3147,7 @@ void TestingAutomationProvider::SetOmniboxText(Browser* browser,
reply.SendError("text missing");
return;
}
- browser->FocusLocationBar();
+ chrome::FocusLocationBar(browser);
LocationBar* loc_bar = browser->window()->GetLocationBar();
if (!loc_bar) {
reply.SendError("The specified browser does not have a location bar.");
diff --git a/chrome/browser/background/background_mode_manager.cc b/chrome/browser/background/background_mode_manager.cc
index 7b5297b..3cd9d07 100644
--- a/chrome/browser/background/background_mode_manager.cc
+++ b/chrome/browser/background/background_mode_manager.cc
@@ -25,6 +25,7 @@
#include "chrome/browser/status_icons/status_icon.h"
#include "chrome/browser/status_icons/status_tray.h"
#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/chrome_pages.h"
#include "chrome/browser/ui/extensions/application_launch.h"
@@ -93,11 +94,7 @@ void BackgroundModeManager::BackgroundModeData::ExecuteCommand(int item) {
Browser* BackgroundModeManager::BackgroundModeData::GetBrowserWindow() {
Browser* browser = browser::FindLastActiveWithProfile(profile_);
- if (!browser) {
- Browser::OpenEmptyWindow(profile_);
- browser = browser::FindLastActiveWithProfile(profile_);
- }
- return browser;
+ return browser ? browser : chrome::OpenEmptyWindow(profile_);
}
int BackgroundModeManager::BackgroundModeData::GetBackgroundAppCount() const {
@@ -496,7 +493,7 @@ void BackgroundModeManager::ExecuteCommand(int command_id) {
chrome::ShowAboutChrome(bmd->GetBrowserWindow());
break;
case IDC_TASK_MANAGER:
- bmd->GetBrowserWindow()->OpenTaskManager(true);
+ chrome::OpenTaskManager(bmd->GetBrowserWindow(), true);
break;
case IDC_EXIT:
content::RecordAction(UserMetricsAction("Exit"));
diff --git a/chrome/browser/browser_commands_unittest.cc b/chrome/browser/browser_commands_unittest.cc
index 54c53e8..ca12761 100644
--- a/chrome/browser/browser_commands_unittest.cc
+++ b/chrome/browser/browser_commands_unittest.cc
@@ -4,6 +4,7 @@
#include "chrome/app/chrome_command_ids.h"
#include "chrome/browser/bookmarks/bookmark_model.h"
+#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/common/url_constants.h"
#include "chrome/test/base/browser_with_test_window_test.h"
@@ -120,7 +121,7 @@ TEST_F(BrowserCommandsTest, BackForwardInNewTab) {
NavigateAndCommitActiveTab(url2);
// Go back in a new background tab.
- browser()->GoBack(NEW_BACKGROUND_TAB);
+ chrome::GoBack(browser(), NEW_BACKGROUND_TAB);
EXPECT_EQ(0, browser()->active_index());
ASSERT_EQ(2, browser()->tab_count());
@@ -144,7 +145,7 @@ TEST_F(BrowserCommandsTest, BackForwardInNewTab) {
// (to test both codepaths).
CommitPendingLoad(&first->GetController());
EXPECT_EQ(1, browser()->active_index());
- browser()->GoForward(NEW_BACKGROUND_TAB);
+ chrome::GoForward(browser(), NEW_BACKGROUND_TAB);
// The previous tab should be unchanged and still in the foreground.
EXPECT_EQ(url1, first->GetURL());
@@ -164,14 +165,14 @@ TEST_F(BrowserCommandsTest, BackForwardInNewTab) {
browser()->ActivateTabAt(2, true);
// TODO(brettw) bug 11055: see the comment above about why we need this.
CommitPendingLoad(&second->GetController());
- browser()->GoBack(NEW_FOREGROUND_TAB);
+ chrome::GoBack(browser(), NEW_FOREGROUND_TAB);
ASSERT_EQ(3, browser()->active_index());
ASSERT_EQ(url1, browser()->GetActiveWebContents()->GetURL());
// Same thing again for forward.
// TODO(brettw) bug 11055: see the comment above about why we need this.
CommitPendingLoad(&browser()->GetActiveWebContents()->GetController());
- browser()->GoForward(NEW_FOREGROUND_TAB);
+ chrome::GoForward(browser(), NEW_FOREGROUND_TAB);
ASSERT_EQ(4, browser()->active_index());
ASSERT_EQ(url2, browser()->GetActiveWebContents()->GetURL());
}
diff --git a/chrome/browser/browser_encoding_browsertest.cc b/chrome/browser/browser_encoding_browsertest.cc
index f868a82..a730af4 100644
--- a/chrome/browser/browser_encoding_browsertest.cc
+++ b/chrome/browser/browser_encoding_browsertest.cc
@@ -10,6 +10,7 @@
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_commands.h"
#include "chrome/common/pref_names.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h"
@@ -139,7 +140,7 @@ IN_PROC_BROWSER_TEST_F(BrowserEncodingTest, MAYBE_TestEncodingAliasMapping) {
EXPECT_EQ(kEncodingTestDatas[i].encoding_name,
browser()->GetActiveWebContents()->GetEncoding());
- browser()->CloseTab();
+ chrome::CloseTab(browser());
}
}
@@ -280,7 +281,7 @@ IN_PROC_BROWSER_TEST_F(BrowserEncodingTest, MAYBE_TestEncodingAutoDetect) {
content::TestNavigationObserver observer(
content::Source<content::NavigationController>(
&web_contents->GetController()));
- browser()->Reload(CURRENT_TAB);
+ chrome::Reload(browser(), CURRENT_TAB);
observer.Wait();
// Re-get the encoding of page. It should return the real encoding now.
diff --git a/chrome/browser/browser_focus_uitest.cc b/chrome/browser/browser_focus_uitest.cc
index 3ccb9db..78c2da3 100644
--- a/chrome/browser/browser_focus_uitest.cc
+++ b/chrome/browser/browser_focus_uitest.cc
@@ -13,6 +13,7 @@
#include "base/stringprintf.h"
#include "base/utf_string_conversions.h"
#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/chrome_pages.h"
#include "chrome/browser/ui/tab_contents/tab_contents.h"
@@ -265,7 +266,7 @@ IN_PROC_BROWSER_TEST_F(BrowserFocusTest, DISABLED_BrowsersRememberFocus) {
ASSERT_TRUE(ui_test_utils::ShowAndFocusNativeWindow(window));
ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER));
- browser()->FocusLocationBar();
+ chrome::FocusLocationBar(browser());
ASSERT_TRUE(IsViewFocused(location_bar_focus_view_id_));
// Hide the window, show it again, the focus should not have changed.
ui_test_utils::HideNativeWindow(window);
@@ -343,7 +344,7 @@ IN_PROC_BROWSER_TEST_F(BrowserFocusTest, DISABLED_TabsRememberFocus) {
if (kFocusPage[i][j]) {
browser()->GetWebContentsAt(j)->GetView()->Focus();
} else {
- browser()->FocusLocationBar();
+ chrome::FocusLocationBar(browser());
}
}
@@ -391,13 +392,13 @@ IN_PROC_BROWSER_TEST_F(BrowserFocusTest, MAYBE_TabsRememberFocusFindInPage) {
GURL url = test_server()->GetURL(kSimplePage);
ui_test_utils::NavigateToURL(browser(), url);
- browser()->Find();
+ chrome::Find(browser());
ui_test_utils::FindInPage(browser()->GetActiveTabContents(),
ASCIIToUTF16("a"), true, false, NULL);
ASSERT_TRUE(IsViewFocused(VIEW_ID_FIND_IN_PAGE_TEXT_FIELD));
// Focus the location bar.
- browser()->FocusLocationBar();
+ chrome::FocusLocationBar(browser());
// Create a 2nd tab.
browser()->AddSelectedTabWithURL(url, content::PAGE_TRANSITION_TYPED);
@@ -412,7 +413,7 @@ IN_PROC_BROWSER_TEST_F(BrowserFocusTest, MAYBE_TabsRememberFocusFindInPage) {
// Now open the find box again, switch to another tab and come back, the focus
// should return to the find box.
- browser()->Find();
+ chrome::Find(browser());
ASSERT_TRUE(IsViewFocused(VIEW_ID_FIND_IN_PAGE_TEXT_FIELD));
browser()->ActivateTabAt(1, true);
ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER));
@@ -479,7 +480,7 @@ IN_PROC_BROWSER_TEST_F(BrowserFocusTest, LocationBarLockFocus) {
GURL url = test_server()->GetURL(kStealFocusPage);
ui_test_utils::NavigateToURL(browser(), url);
- browser()->FocusLocationBar();
+ chrome::FocusLocationBar(browser());
ASSERT_TRUE(ui_test_utils::ExecuteJavaScript(
browser()->GetActiveWebContents()->GetRenderViewHost(), L"",
@@ -502,7 +503,7 @@ IN_PROC_BROWSER_TEST_F(BrowserFocusTest, MAYBE_FocusTraversal) {
GURL url = test_server()->GetURL(kTypicalPage);
ui_test_utils::NavigateToURL(browser(), url);
- browser()->FocusLocationBar();
+ chrome::FocusLocationBar(browser());
const char* kTextElementID = "textEdit";
const char* kExpElementIDs[] = {
@@ -637,7 +638,7 @@ IN_PROC_BROWSER_TEST_F(BrowserFocusTest, MAYBE_FocusTraversalOnInterstitial) {
base::TimeDelta::FromSeconds(1));
ui_test_utils::RunMessageLoop();
- browser()->FocusLocationBar();
+ chrome::FocusLocationBar(browser());
const char* kExpElementIDs[] = {
"", // Initially no element in the page should be focused
@@ -802,7 +803,7 @@ IN_PROC_BROWSER_TEST_F(BrowserFocusTest, MAYBE_FindFocusTest) {
ASSERT_TRUE(WaitForFocusChange(VIEW_ID_FIND_IN_PAGE_TEXT_FIELD));
- browser()->FocusLocationBar();
+ chrome::FocusLocationBar(browser());
ASSERT_TRUE(IsViewFocused(location_bar_focus_view_id_));
// Now press Ctrl+F again and focus should move to the Find box.
@@ -844,7 +845,7 @@ IN_PROC_BROWSER_TEST_F(BrowserFocusTest, DISABLED_TabInitialFocus) {
EXPECT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER));
// Open the new tab, focus should be on the location bar.
- browser()->NewTab();
+ chrome::NewTab(browser());
ASSERT_NO_FATAL_FAILURE(ui_test_utils::WaitForLoadStop(
browser()->GetActiveWebContents()));
EXPECT_TRUE(IsViewFocused(location_bar_focus_view_id_));
@@ -873,7 +874,7 @@ IN_PROC_BROWSER_TEST_F(BrowserFocusTest, FocusOnReload) {
ui_test_utils::WindowedNotificationObserver observer(
content::NOTIFICATION_LOAD_STOP,
content::NotificationService::AllSources());
- browser()->NewTab();
+ chrome::NewTab(browser());
observer.Wait();
}
ui_test_utils::RunAllPendingInMessageLoop();
@@ -883,7 +884,7 @@ IN_PROC_BROWSER_TEST_F(BrowserFocusTest, FocusOnReload) {
content::NOTIFICATION_LOAD_STOP,
content::Source<NavigationController>(
&browser()->GetActiveWebContents()->GetController()));
- browser()->Reload(CURRENT_TAB);
+ chrome::Reload(browser(), CURRENT_TAB);
observer.Wait();
}
// Focus should stay on the location bar.
@@ -891,14 +892,14 @@ IN_PROC_BROWSER_TEST_F(BrowserFocusTest, FocusOnReload) {
// Open a regular page, focus the location bar, reload.
ui_test_utils::NavigateToURL(browser(), test_server()->GetURL(kSimplePage));
- browser()->FocusLocationBar();
+ chrome::FocusLocationBar(browser());
ASSERT_TRUE(IsViewFocused(location_bar_focus_view_id_));
{
ui_test_utils::WindowedNotificationObserver observer(
content::NOTIFICATION_LOAD_STOP,
content::Source<NavigationController>(
&browser()->GetActiveWebContents()->GetController()));
- browser()->Reload(CURRENT_TAB);
+ chrome::Reload(browser(), CURRENT_TAB);
observer.Wait();
}
@@ -920,7 +921,7 @@ IN_PROC_BROWSER_TEST_F(BrowserFocusTest, DISABLED_FocusOnReloadCrashedTab) {
content::NOTIFICATION_LOAD_STOP,
content::Source<NavigationController>(
&browser()->GetActiveWebContents()->GetController()));
- browser()->Reload(CURRENT_TAB);
+ chrome::Reload(browser(), CURRENT_TAB);
observer.Wait();
}
diff --git a/chrome/browser/captive_portal/captive_portal_browsertest.cc b/chrome/browser/captive_portal/captive_portal_browsertest.cc
index bad23d3..de6c359 100644
--- a/chrome/browser/captive_portal/captive_portal_browsertest.cc
+++ b/chrome/browser/captive_portal/captive_portal_browsertest.cc
@@ -21,6 +21,7 @@
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/browser_navigator.h"
#include "chrome/browser/ui/tab_contents/tab_contents_iterator.h"
@@ -1467,7 +1468,7 @@ IN_PROC_BROWSER_TEST_F(CaptivePortalBrowserTest, CloseLoginTab) {
FailLoadsWithoutLogin(browser(), 1);
// Close login tab.
- browser()->CloseTab();
+ chrome::CloseTab(browser());
// Go through the standard slow load login, and make sure it still works.
SlowLoadBehindCaptivePortal(browser(), true);
@@ -1524,7 +1525,7 @@ IN_PROC_BROWSER_TEST_F(CaptivePortalBrowserTest, AbortLoad) {
// Switch back to the hung tab from the login tab, and abort the navigation.
browser()->ActivateTabAt(0, true);
- browser()->Stop();
+ chrome::Stop(browser());
navigation_observer.WaitForNavigations(1);
EXPECT_EQ(0, NumBrokenTabs());
@@ -1617,7 +1618,7 @@ IN_PROC_BROWSER_TEST_F(CaptivePortalBrowserTest, GoBack) {
// Activate the error page tab again and go back.
browser()->ActivateTabAt(0, true);
- browser()->GoBack(CURRENT_TAB);
+ chrome::GoBack(browser(), CURRENT_TAB);
navigation_observer.WaitForNavigations(1);
EXPECT_EQ(1, navigation_observer.NumNavigationsForTab(
@@ -1652,7 +1653,7 @@ IN_PROC_BROWSER_TEST_F(CaptivePortalBrowserTest, GoBackToTimeout) {
// Go to the error page.
MultiNavigationObserver navigation_observer;
CaptivePortalObserver portal_observer(browser()->profile());
- browser()->GoBack(CURRENT_TAB);
+ chrome::GoBack(browser(), CURRENT_TAB);
// Wait for both the check triggered by the broken tab and the first load
// of the login tab, and for the login tab to stop loading.
diff --git a/chrome/browser/chrome_main_browsertest.cc b/chrome/browser/chrome_main_browsertest.cc
index 5d5244e..e20dc43 100644
--- a/chrome/browser/chrome_main_browsertest.cc
+++ b/chrome/browser/chrome_main_browsertest.cc
@@ -9,6 +9,7 @@
#include "base/path_service.h"
#include "base/process_util.h"
#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/common/chrome_notification_types.h"
@@ -94,7 +95,7 @@ IN_PROC_BROWSER_TEST_F(ChromeMainTest, SecondLaunchFromIncognitoWithNormalUrl) {
ASSERT_EQ(1u, browser::GetTabbedBrowserCount(browser()->profile()));
// Create an incognito window.
- browser()->NewIncognitoWindow();
+ chrome::NewIncognitoWindow(browser());
ASSERT_EQ(2u, BrowserList::size());
ASSERT_EQ(1u, browser::GetTabbedBrowserCount(browser()->profile()));
@@ -104,7 +105,7 @@ IN_PROC_BROWSER_TEST_F(ChromeMainTest, SecondLaunchFromIncognitoWithNormalUrl) {
ui_test_utils::WindowedNotificationObserver observer(
chrome::NOTIFICATION_BROWSER_CLOSED,
content::NotificationService::AllSources());
- browser()->CloseWindow();
+ chrome::CloseWindow(browser());
observer.Wait();
// There should only be the incognito window open now.
diff --git a/chrome/browser/chromeos/oom_priority_manager_browsertest.cc b/chrome/browser/chromeos/oom_priority_manager_browsertest.cc
index 3a63223..a0abb6f 100644
--- a/chrome/browser/chromeos/oom_priority_manager_browsertest.cc
+++ b/chrome/browser/chromeos/oom_priority_manager_browsertest.cc
@@ -5,6 +5,7 @@
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chromeos/oom_priority_manager.h"
#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/find_bar/find_bar_controller.h"
#include "chrome/common/url_constants.h"
#include "chrome/test/base/in_process_browser_test.h"
@@ -105,7 +106,7 @@ IN_PROC_BROWSER_TEST_F(OomPriorityManagerTest, OomPriorityManagerBasics) {
WindowedNotificationObserver reload1(
content::NOTIFICATION_NAV_ENTRY_COMMITTED,
content::NotificationService::AllSources());
- browser()->SelectNumberedTab(0);
+ chrome::SelectNumberedTab(browser(), 0);
reload1.Wait();
// Make sure the FindBarController gets the right TabContents.
EXPECT_EQ(browser()->GetFindBarController()->tab_contents(),
@@ -119,7 +120,7 @@ IN_PROC_BROWSER_TEST_F(OomPriorityManagerTest, OomPriorityManagerBasics) {
WindowedNotificationObserver reload2(
content::NOTIFICATION_NAV_ENTRY_COMMITTED,
content::NotificationService::AllSources());
- browser()->SelectNumberedTab(2);
+ chrome::SelectNumberedTab(browser(), 2);
reload2.Wait();
EXPECT_EQ(2, browser()->active_index());
EXPECT_FALSE(browser()->IsTabDiscarded(0));
@@ -128,22 +129,22 @@ IN_PROC_BROWSER_TEST_F(OomPriorityManagerTest, OomPriorityManagerBasics) {
// Navigate the third tab back twice. We used to crash here due to
// crbug.com/121373.
- EXPECT_TRUE(browser()->CanGoBack());
- EXPECT_FALSE(browser()->CanGoForward());
+ EXPECT_TRUE(chrome::CanGoBack(browser()));
+ EXPECT_FALSE(chrome::CanGoForward(browser()));
WindowedNotificationObserver back1(
content::NOTIFICATION_NAV_ENTRY_COMMITTED,
content::NotificationService::AllSources());
- browser()->GoBack(CURRENT_TAB);
+ chrome::GoBack(browser(), CURRENT_TAB);
back1.Wait();
- EXPECT_TRUE(browser()->CanGoBack());
- EXPECT_TRUE(browser()->CanGoForward());
+ EXPECT_TRUE(chrome::CanGoBack(browser()));
+ EXPECT_TRUE(chrome::CanGoForward(browser()));
WindowedNotificationObserver back2(
content::NOTIFICATION_NAV_ENTRY_COMMITTED,
content::NotificationService::AllSources());
- browser()->GoBack(CURRENT_TAB);
+ chrome::GoBack(browser(), CURRENT_TAB);
back2.Wait();
- EXPECT_FALSE(browser()->CanGoBack());
- EXPECT_TRUE(browser()->CanGoForward());
+ EXPECT_FALSE(chrome::CanGoBack(browser()));
+ EXPECT_TRUE(chrome::CanGoForward(browser()));
}
} // namespace
diff --git a/chrome/browser/crash_recovery_browsertest.cc b/chrome/browser/crash_recovery_browsertest.cc
index c484353..877c586 100644
--- a/chrome/browser/crash_recovery_browsertest.cc
+++ b/chrome/browser/crash_recovery_browsertest.cc
@@ -4,6 +4,7 @@
#include "base/file_path.h"
#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/tab_contents/tab_contents.h"
#include "chrome/common/url_constants.h"
#include "chrome/test/base/in_process_browser_test.h"
@@ -53,7 +54,7 @@ IN_PROC_BROWSER_TEST_F(CrashRecoveryBrowserTest, Reload) {
content::NOTIFICATION_LOAD_STOP,
content::Source<NavigationController>(
&browser()->GetActiveWebContents()->GetController()));
- browser()->Reload(CURRENT_TAB);
+ chrome::Reload(browser(), CURRENT_TAB);
observer.Wait();
ASSERT_TRUE(ui_test_utils::GetCurrentTabTitle(browser(),
&title_after_crash));
@@ -82,7 +83,7 @@ IN_PROC_BROWSER_TEST_F(CrashRecoveryBrowserTest, LoadInNewTab) {
content::NOTIFICATION_LOAD_STOP,
content::Source<NavigationController>(
&browser()->GetActiveWebContents()->GetController()));
- browser()->Reload(CURRENT_TAB);
+ chrome::Reload(browser(), CURRENT_TAB);
observer.Wait();
ASSERT_TRUE(ui_test_utils::GetCurrentTabTitle(browser(),
&title_after_crash));
diff --git a/chrome/browser/debugger/devtools_sanity_browsertest.cc b/chrome/browser/debugger/devtools_sanity_browsertest.cc
index 5d414b6..68551d1 100644
--- a/chrome/browser/debugger/devtools_sanity_browsertest.cc
+++ b/chrome/browser/debugger/devtools_sanity_browsertest.cc
@@ -16,6 +16,7 @@
#include "chrome/browser/extensions/unpacked_installer.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/tab_contents/tab_contents.h"
#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/chrome_paths.h"
@@ -534,7 +535,7 @@ IN_PROC_BROWSER_TEST_F(DevToolsSanityTest, TestReattachAfterCrash) {
content::NOTIFICATION_LOAD_STOP,
content::Source<NavigationController>(
&browser()->GetActiveWebContents()->GetController()));
- browser()->Reload(CURRENT_TAB);
+ chrome::Reload(browser(), CURRENT_TAB);
observer.Wait();
RunTestFunction(window_, "testReattachAfterCrash");
diff --git a/chrome/browser/download/download_browsertest.cc b/chrome/browser/download/download_browsertest.cc
index a7ce09f..d37dc0f 100644
--- a/chrome/browser/download/download_browsertest.cc
+++ b/chrome/browser/download/download_browsertest.cc
@@ -37,6 +37,7 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/tab_contents/render_view_context_menu.h"
#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/chrome_pages.h"
@@ -1127,7 +1128,7 @@ IN_PROC_BROWSER_TEST_F(DownloadTest, IncognitoDownload) {
#endif
// Close the Incognito window and don't crash.
- incognito->CloseWindow();
+ chrome::CloseWindow(incognito);
#if !defined(OS_MACOSX)
signal.Wait();
@@ -1370,7 +1371,7 @@ IN_PROC_BROWSER_TEST_F(DownloadTest, NewWindow) {
#endif
// Close the new window.
- download_browser->CloseWindow();
+ chrome::CloseWindow(download_browser);
#if !defined(OS_MACOSX)
signal.Wait();
@@ -1589,7 +1590,7 @@ IN_PROC_BROWSER_TEST_F(DownloadTest, BrowserCloseAfterDownload) {
ui_test_utils::WindowedNotificationObserver signal(
chrome::NOTIFICATION_BROWSER_CLOSED,
content::Source<Browser>(browser()));
- browser()->CloseWindow();
+ chrome::CloseWindow(browser());
signal.Wait();
}
@@ -2016,7 +2017,7 @@ IN_PROC_BROWSER_TEST_F(DownloadTest, SavePageNonHTMLViaGet) {
new DownloadTestObserverTerminal(
DownloadManagerForBrowser(browser()), 1,
false, DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_FAIL));
- browser()->SavePage();
+ chrome::SavePage(browser());
waiter->WaitForFinished();
EXPECT_EQ(1u, waiter->NumDownloadsSeenInState(DownloadItem::COMPLETE));
CheckDownloadStates(1, DownloadItem::COMPLETE);
@@ -2095,7 +2096,7 @@ IN_PROC_BROWSER_TEST_F(DownloadTest, SavePageNonHTMLViaPost) {
new DownloadTestObserverTerminal(
DownloadManagerForBrowser(browser()), 1,
false, DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_FAIL));
- browser()->SavePage();
+ chrome::SavePage(browser());
waiter->WaitForFinished();
EXPECT_EQ(1u, waiter->NumDownloadsSeenInState(DownloadItem::COMPLETE));
CheckDownloadStates(1, DownloadItem::COMPLETE);
diff --git a/chrome/browser/download/download_danger_prompt_browsertest.cc b/chrome/browser/download/download_danger_prompt_browsertest.cc
index e15c116..0f77fb9 100644
--- a/chrome/browser/download/download_danger_prompt_browsertest.cc
+++ b/chrome/browser/download/download_danger_prompt_browsertest.cc
@@ -6,6 +6,7 @@
#include "base/file_path.h"
#include "chrome/browser/download/download_danger_prompt.h"
#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/tab_contents/tab_contents.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h"
@@ -136,6 +137,6 @@ IN_PROC_BROWSER_TEST_F(DownloadDangerPromptTest, TestAll) {
// If the containing tab is closed, the dialog should be canceled.
OpenNewTab();
SetUpExpectations(DownloadDangerPrompt::CANCEL);
- browser()->CloseTab();
+ chrome::CloseTab(browser());
VerifyExpectations();
}
diff --git a/chrome/browser/download/save_page_browsertest.cc b/chrome/browser/download/save_page_browsertest.cc
index 55c9cc9..bdd1b37 100644
--- a/chrome/browser/download/save_page_browsertest.cc
+++ b/chrome/browser/download/save_page_browsertest.cc
@@ -21,6 +21,7 @@
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
@@ -365,7 +366,7 @@ IN_PROC_BROWSER_TEST_F(SavePageBrowserTest, CleanFilenameFromPageTitle) {
ui_test_utils::WindowedNotificationObserver observer(
content::NOTIFICATION_SAVE_PACKAGE_SUCCESSFULLY_FINISHED,
content::NotificationService::AllSources());
- browser()->SavePage();
+ chrome::SavePage(browser());
observer.Wait();
EXPECT_TRUE(file_util::PathExists(full_file_name));
@@ -405,7 +406,7 @@ IN_PROC_BROWSER_TEST_F(SavePageAsMHTMLBrowserTest, SavePageAsMHTML) {
ui_test_utils::WindowedNotificationObserver observer(
content::NOTIFICATION_SAVE_PACKAGE_SUCCESSFULLY_FINISHED,
content::NotificationService::AllSources());
- browser()->SavePage();
+ chrome::SavePage(browser());
observer.Wait();
CheckDownloadHistory(url, full_file_name, -1);
diff --git a/chrome/browser/errorpage_browsertest.cc b/chrome/browser/errorpage_browsertest.cc
index ff634eec..54c4622 100644
--- a/chrome/browser/errorpage_browsertest.cc
+++ b/chrome/browser/errorpage_browsertest.cc
@@ -6,6 +6,7 @@
#include "base/utf_string_conversions.h"
#include "chrome/browser/net/url_request_mock_util.h"
#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/tab_contents/tab_contents.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h"
@@ -93,9 +94,9 @@ class ErrorPageTest : public InProcessBrowserTest {
NULL,
num_navigations);
if (direction == HISTORY_NAVIGATE_BACK) {
- browser()->GoBack(CURRENT_TAB);
+ chrome::GoBack(browser(), CURRENT_TAB);
} else if (direction == HISTORY_NAVIGATE_FORWARD) {
- browser()->GoForward(CURRENT_TAB);
+ chrome::GoForward(browser(), CURRENT_TAB);
} else {
FAIL();
}
diff --git a/chrome/browser/extensions/api/extension_action/browser_action_apitest.cc b/chrome/browser/extensions/api/extension_action/browser_action_apitest.cc
index 032b41f..d110b04 100644
--- a/chrome/browser/extensions/api/extension_action/browser_action_apitest.cc
+++ b/chrome/browser/extensions/api/extension_action/browser_action_apitest.cc
@@ -15,6 +15,7 @@
#include "chrome/browser/extensions/extension_tab_util.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/extensions/extension_action.h"
@@ -142,7 +143,7 @@ IN_PROC_BROWSER_TEST_F(BrowserActionApiTest,
EXPECT_EQ("Showing icon 2", GetBrowserActionsBar().GetTooltip(0));
// Open a new tab, the title should go back.
- browser()->NewTab();
+ chrome::NewTab(browser());
EXPECT_EQ("hi!", GetBrowserActionsBar().GetTooltip(0));
// Go back to first tab, changed title should reappear.
@@ -302,7 +303,7 @@ IN_PROC_BROWSER_TEST_F(BrowserActionApiTest, IncognitoBasic) {
browser()->profile()->GetExtensionService()->extension_prefs()->
SetIsIncognitoEnabled(extension->id(), true);
- incognito_browser->CloseWindow();
+ chrome::CloseWindow(incognito_browser);
incognito_browser = Browser::Create(incognito_profile);
ASSERT_EQ(1,
BrowserActionTestUtil(incognito_browser).NumberOfBrowserActions());
diff --git a/chrome/browser/extensions/api/tabs/tabs.cc b/chrome/browser/extensions/api/tabs/tabs.cc
index 38c2652..8b2ed1b 100644
--- a/chrome/browser/extensions/api/tabs/tabs.cc
+++ b/chrome/browser/extensions/api/tabs/tabs.cc
@@ -34,6 +34,7 @@
#include "chrome/browser/sessions/restore_tab_helper.h"
#include "chrome/browser/translate/translate_tab_helper.h"
#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/browser_navigator.h"
@@ -634,9 +635,9 @@ bool CreateWindowFunction::RunImpl() {
target_tab_strip->InsertTabContentsAt(urls.size(), contents,
TabStripModel::ADD_NONE);
} else if (urls.empty()) {
- new_window->NewTab();
+ chrome::NewTab(new_window);
}
- new_window->SelectNumberedTab(0);
+ chrome::SelectNumberedTab(new_window, 0);
// Unlike other window types, Panels do not take focus by default.
if (!saw_focus_key && window_type == Browser::TYPE_PANEL)
diff --git a/chrome/browser/extensions/api/tabs/tabs_test.cc b/chrome/browser/extensions/api/tabs/tabs_test.cc
index 02644f0..72cab59 100644
--- a/chrome/browser/extensions/api/tabs/tabs_test.cc
+++ b/chrome/browser/extensions/api/tabs/tabs_test.cc
@@ -17,6 +17,7 @@
#include "chrome/browser/prefs/incognito_mode_prefs.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h"
@@ -490,7 +491,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, DontCreateTabInClosingPopupWindow) {
Browser* popup_browser = Browser::CreateWithParams(
Browser::CreateParams(Browser::TYPE_POPUP, browser()->profile()));
int window_id = ExtensionTabUtil::GetWindowId(popup_browser);
- popup_browser->CloseWindow();
+ chrome::CloseWindow(popup_browser);
scoped_refptr<CreateTabFunction> create_tab_function(new CreateTabFunction());
// Without a callback the function will not generate a result.
diff --git a/chrome/browser/extensions/app_process_apitest.cc b/chrome/browser/extensions/app_process_apitest.cc
index 1c23037..5436de3 100644
--- a/chrome/browser/extensions/app_process_apitest.cc
+++ b/chrome/browser/extensions/app_process_apitest.cc
@@ -8,6 +8,7 @@
#include "chrome/browser/extensions/process_map.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/browser_window.h"
@@ -86,7 +87,7 @@ class AppApiTest : public ExtensionApiTest {
ui_test_utils::WindowedNotificationObserver tab_added_observer(
chrome::NOTIFICATION_TAB_ADDED,
content::NotificationService::AllSources());
- browser()->NewTab();
+ chrome::NewTab(browser());
tab_added_observer.Wait();
LOG(INFO) << "New tab.";
ui_test_utils::NavigateToURL(browser(),
@@ -155,7 +156,7 @@ IN_PROC_BROWSER_TEST_F(AppApiTest, AppProcess) {
ui_test_utils::WindowedNotificationObserver tab_added_observer(
chrome::NOTIFICATION_TAB_ADDED,
content::NotificationService::AllSources());
- browser()->NewTab();
+ chrome::NewTab(browser());
tab_added_observer.Wait();
LOG(INFO) << "New tab.";
ui_test_utils::NavigateToURL(browser(), base_url.Resolve("path3/empty.html"));
@@ -267,7 +268,7 @@ IN_PROC_BROWSER_TEST_F(AppApiTest, BookmarkAppGetsNormalProcess) {
ui_test_utils::WindowedNotificationObserver tab_added_observer(
chrome::NOTIFICATION_TAB_ADDED,
content::NotificationService::AllSources());
- browser()->NewTab();
+ chrome::NewTab(browser());
tab_added_observer.Wait();
ui_test_utils::NavigateToURL(browser(), base_url.Resolve("path2/empty.html"));
EXPECT_FALSE(process_map->Contains(
@@ -315,9 +316,9 @@ IN_PROC_BROWSER_TEST_F(AppApiTest, AppProcessRedirectBack) {
// Open two tabs in the app.
GURL base_url = GetTestBaseURL("app_process");
- browser()->NewTab();
+ chrome::NewTab(browser());
ui_test_utils::NavigateToURL(browser(), base_url.Resolve("path1/empty.html"));
- browser()->NewTab();
+ chrome::NewTab(browser());
// Wait until the second tab finishes its redirect train (2 hops).
// 1. We navigate to redirect.html
// 2. Renderer navigates and finishes, counting as a load stop.
@@ -387,7 +388,7 @@ IN_PROC_BROWSER_TEST_F(AppApiTest, MAYBE_ReloadIntoAppProcess) {
content::NOTIFICATION_LOAD_STOP,
content::Source<NavigationController>(
&browser()->GetActiveWebContents()->GetController()));
- browser()->Reload(CURRENT_TAB);
+ chrome::Reload(browser(), CURRENT_TAB);
reload_observer.Wait();
EXPECT_TRUE(process_map->Contains(
contents->GetRenderProcessHost()->GetID()));
@@ -398,7 +399,7 @@ IN_PROC_BROWSER_TEST_F(AppApiTest, MAYBE_ReloadIntoAppProcess) {
content::NOTIFICATION_LOAD_STOP,
content::Source<NavigationController>(
&browser()->GetActiveWebContents()->GetController()));
- browser()->Reload(CURRENT_TAB);
+ chrome::Reload(browser(), CURRENT_TAB);
reload_observer2.Wait();
EXPECT_FALSE(process_map->Contains(
contents->GetRenderProcessHost()->GetID()));
@@ -578,7 +579,7 @@ IN_PROC_BROWSER_TEST_F(AppApiTest, MAYBE_ReloadAppAfterCrash) {
content::NOTIFICATION_LOAD_STOP,
content::Source<NavigationController>(
&browser()->GetActiveWebContents()->GetController()));
- browser()->Reload(CURRENT_TAB);
+ chrome::Reload(browser(), CURRENT_TAB);
observer.Wait();
ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool(
contents->GetRenderViewHost(), L"",
diff --git a/chrome/browser/extensions/extension_crash_recovery_browsertest.cc b/chrome/browser/extensions/extension_crash_recovery_browsertest.cc
index e1f2bc2..4bc39f2 100644
--- a/chrome/browser/extensions/extension_crash_recovery_browsertest.cc
+++ b/chrome/browser/extensions/extension_crash_recovery_browsertest.cc
@@ -16,6 +16,7 @@
#include "chrome/browser/notifications/notification_ui_manager.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/tab_contents/tab_contents.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/test/base/ui_test_utils.h"
@@ -195,7 +196,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionCrashRecoveryTest,
ASSERT_EQ(1U, CountBalloons());
// Open a new tab, but the balloon will still be there.
- browser()->NewTab();
+ chrome::NewTab(browser());
WebContents* new_current_tab = browser()->GetActiveWebContents();
ASSERT_TRUE(new_current_tab);
ASSERT_NE(new_current_tab, original_tab);
@@ -466,7 +467,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionCrashRecoveryTest,
LoadTestExtension();
// Open a tab extension.
- browser()->NewTab();
+ chrome::NewTab(browser());
ui_test_utils::NavigateToURL(
browser(),
GURL("chrome-extension://" + first_extension_id_ + "/background.html"));
@@ -485,7 +486,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionCrashRecoveryTest,
content::NOTIFICATION_LOAD_STOP,
content::Source<NavigationController>(
&browser()->GetActiveWebContents()->GetController()));
- browser()->Reload(CURRENT_TAB);
+ chrome::Reload(browser(), CURRENT_TAB);
observer.Wait();
}
// Extension should now be loaded.
diff --git a/chrome/browser/extensions/extension_management_apitest.cc b/chrome/browser/extensions/extension_management_apitest.cc
index e00c58c..ade8685 100644
--- a/chrome/browser/extensions/extension_management_apitest.cc
+++ b/chrome/browser/extensions/extension_management_apitest.cc
@@ -11,6 +11,7 @@
#include "chrome/browser/extensions/test_management_policy.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/common/chrome_notification_types.h"
@@ -155,7 +156,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionManagementApiTest, LaunchPanelApp) {
chrome::NOTIFICATION_BROWSER_CLOSED,
content::Source<Browser>(app_browser));
- app_browser->CloseWindow();
+ chrome::CloseWindow(app_browser);
signal.Wait();
// Unload the extension.
diff --git a/chrome/browser/extensions/extension_test_api.cc b/chrome/browser/extensions/extension_test_api.cc
index 2991708..a496678 100644
--- a/chrome/browser/extensions/extension_test_api.cc
+++ b/chrome/browser/extensions/extension_test_api.cc
@@ -12,7 +12,7 @@
#include "chrome/browser/extensions/extension_function_dispatcher.h"
#include "chrome/browser/extensions/extensions_quota_service.h"
#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_commands.h"
#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/chrome_switches.h"
#include "content/public/browser/notification_service.h"
@@ -88,7 +88,7 @@ ExtensionTestCreateIncognitoTabFunction::
bool ExtensionTestCreateIncognitoTabFunction::RunImpl() {
std::string url;
EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &url));
- Browser::OpenURLOffTheRecord(profile(), GURL(url));
+ chrome::OpenURLOffTheRecord(profile(), GURL(url));
return true;
}
diff --git a/chrome/browser/extensions/isolated_app_browsertest.cc b/chrome/browser/extensions/isolated_app_browsertest.cc
index 6e0373f..46d0637 100644
--- a/chrome/browser/extensions/isolated_app_browsertest.cc
+++ b/chrome/browser/extensions/isolated_app_browsertest.cc
@@ -9,6 +9,7 @@
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/tab_contents/tab_contents.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/url_constants.h"
@@ -118,13 +119,13 @@ IN_PROC_BROWSER_TEST_F(IsolatedAppTest, CookieIsolation) {
EXPECT_FALSE(HasCookie(tab3, "nonAppFrame"));
// Check that isolation persists even if the tab crashes and is reloaded.
- browser()->SelectNumberedTab(1);
+ chrome::SelectNumberedTab(browser(), 1);
ui_test_utils::CrashTab(tab1);
ui_test_utils::WindowedNotificationObserver observer(
content::NOTIFICATION_LOAD_STOP,
content::Source<NavigationController>(
&browser()->GetActiveWebContents()->GetController()));
- browser()->Reload(CURRENT_TAB);
+ chrome::Reload(browser(), CURRENT_TAB);
observer.Wait();
EXPECT_TRUE(HasCookie(tab1, "app1=3"));
EXPECT_FALSE(HasCookie(tab1, "app2"));
diff --git a/chrome/browser/extensions/plugin_apitest.cc b/chrome/browser/extensions/plugin_apitest.cc
index 983529a..1172938 100644
--- a/chrome/browser/extensions/plugin_apitest.cc
+++ b/chrome/browser/extensions/plugin_apitest.cc
@@ -7,6 +7,7 @@
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/tab_contents/tab_contents.h"
#include "chrome/common/extensions/extension.h"
#include "chrome/common/pref_names.h"
@@ -73,7 +74,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, PluginLoadUnload) {
content::NOTIFICATION_LOAD_STOP,
content::Source<NavigationController>(
&browser()->GetActiveWebContents()->GetController()));
- browser()->Reload(CURRENT_TAB);
+ chrome::Reload(browser(), CURRENT_TAB);
observer.Wait();
}
ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool(
diff --git a/chrome/browser/fast_shutdown_browsertest.cc b/chrome/browser/fast_shutdown_browsertest.cc
index 6c84733..1e45db5 100644
--- a/chrome/browser/fast_shutdown_browsertest.cc
+++ b/chrome/browser/fast_shutdown_browsertest.cc
@@ -8,6 +8,7 @@
#include "base/synchronization/waitable_event.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/common/chrome_notification_types.h"
#include "chrome/test/automation/automation_proxy.h"
@@ -97,7 +98,7 @@ IN_PROC_BROWSER_TEST_F(FastShutdown, SlowTermination) {
ASSERT_EQ(2u, BrowserList::size());
BrowserList::const_iterator i = BrowserList::begin();
++i;
- (*i)->CloseWindow();
+ chrome::CloseWindow(*i);
// Need to wait for the renderer process to shutdown to ensure that we got the
// set cookies IPC.
@@ -106,7 +107,7 @@ IN_PROC_BROWSER_TEST_F(FastShutdown, SlowTermination) {
content::NotificationService::AllSources());
// Close the tab. This should launch the unload handler, which sets a cookie
// that's stored to disk.
- browser()->CloseTab();
+ chrome::CloseTab(browser());
renderer_shutdown_observer.Wait();
diff --git a/chrome/browser/geolocation/geolocation_browsertest.cc b/chrome/browser/geolocation/geolocation_browsertest.cc
index b911029..498d581 100644
--- a/chrome/browser/geolocation/geolocation_browsertest.cc
+++ b/chrome/browser/geolocation/geolocation_browsertest.cc
@@ -16,6 +16,7 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/tab_contents/confirm_infobar_delegate.h"
#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/tab_contents/tab_contents.h"
#include "chrome/common/chrome_notification_types.h"
@@ -242,7 +243,7 @@ class GeolocationBrowserTest : public InProcessBrowserTest {
browser()->profile()->GetOffTheRecordProfile(), false);
} else if (options == INITIALIZATION_NEWTAB) {
current_browser_ = browser();
- current_browser_->NewTab();
+ chrome::NewTab(current_browser_);
ui_test_utils::NavigateToURL(current_browser_, current_url_);
} else if (options == INITIALIZATION_IFRAMES) {
current_browser_ = browser();
diff --git a/chrome/browser/net/gaia/gaia_oauth_fetcher.cc b/chrome/browser/net/gaia/gaia_oauth_fetcher.cc
index bae1236..7aca93e 100644
--- a/chrome/browser/net/gaia/gaia_oauth_fetcher.cc
+++ b/chrome/browser/net/gaia/gaia_oauth_fetcher.cc
@@ -14,6 +14,7 @@
#include "chrome/browser/net/gaia/gaia_oauth_consumer.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/common/chrome_notification_types.h"
@@ -555,7 +556,7 @@ void GaiaOAuthFetcher::OnGetOAuthTokenFetched(const std::string& token) {
if (popup_) {
Browser* popped_up = popup_;
popup_ = NULL;
- popped_up->CloseWindow();
+ chrome::CloseWindow(popped_up);
}
consumer_->OnGetOAuthTokenSuccess(token);
if (ShouldAutoFetch(OAUTH1_ALL_ACCESS_TOKEN))
diff --git a/chrome/browser/prerender/prerender_browsertest.cc b/chrome/browser/prerender/prerender_browsertest.cc
index 445b01c..fffe4ed 100644
--- a/chrome/browser/prerender/prerender_browsertest.cc
+++ b/chrome/browser/prerender/prerender_browsertest.cc
@@ -26,6 +26,7 @@
#include "chrome/browser/task_manager/task_manager.h"
#include "chrome/browser/task_manager/task_manager_browsertest_util.h"
#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/tab_contents/tab_contents.h"
@@ -665,7 +666,7 @@ class PrerenderBrowserTest : public InProcessBrowserTest {
ui_test_utils::WindowedNotificationObserver back_nav_observer(
content::NOTIFICATION_NAV_ENTRY_COMMITTED,
content::NotificationService::AllSources());
- current_browser()->GoBack(CURRENT_TAB);
+ chrome::GoBack(current_browser(), CURRENT_TAB);
back_nav_observer.Wait();
bool original_prerender_page = false;
ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool(
@@ -685,7 +686,7 @@ class PrerenderBrowserTest : public InProcessBrowserTest {
ui_test_utils::WindowedNotificationObserver back_nav_observer(
content::NOTIFICATION_LOAD_STOP,
content::Source<NavigationController>(&tab->GetController()));
- current_browser()->GoBack(CURRENT_TAB);
+ chrome::GoBack(current_browser(), CURRENT_TAB);
back_nav_observer.Wait();
bool js_result;
ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool(
diff --git a/chrome/browser/printing/print_preview_tab_controller_browsertest.cc b/chrome/browser/printing/print_preview_tab_controller_browsertest.cc
index 9bcd651..3f36760 100644
--- a/chrome/browser/printing/print_preview_tab_controller_browsertest.cc
+++ b/chrome/browser/printing/print_preview_tab_controller_browsertest.cc
@@ -6,6 +6,7 @@
#include "chrome/browser/printing/print_preview_tab_controller.h"
#include "chrome/browser/printing/print_view_manager.h"
#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/tab_contents/tab_contents.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/url_constants.h"
@@ -120,7 +121,7 @@ IN_PROC_BROWSER_TEST_F(PrintPreviewTabControllerBrowserTest,
ui_test_utils::WindowedNotificationObserver notification_observer(
content::NOTIFICATION_LOAD_STOP,
content::NotificationService::AllSources());
- browser()->Reload(CURRENT_TAB);
+ chrome::Reload(browser(), CURRENT_TAB);
notification_observer.Wait();
ASSERT_TRUE(tab_destroyed_observer.tab_destroyed());
diff --git a/chrome/browser/printing/print_preview_tab_controller_unittest.cc b/chrome/browser/printing/print_preview_tab_controller_unittest.cc
index c6b312c..a86253b1 100644
--- a/chrome/browser/printing/print_preview_tab_controller_unittest.cc
+++ b/chrome/browser/printing/print_preview_tab_controller_unittest.cc
@@ -5,6 +5,7 @@
#include "chrome/browser/printing/print_preview_tab_controller.h"
#include "chrome/browser/printing/print_preview_unit_test_base.h"
#include "chrome/browser/printing/print_view_manager.h"
+#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/tab_contents/tab_contents.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
@@ -37,7 +38,7 @@ TEST_F(PrintPreviewTabControllerUnitTest, MAYBE_GetOrCreatePreviewTab) {
// Lets start with one window with one tab.
EXPECT_EQ(1u, BrowserList::size());
EXPECT_EQ(0, browser()->tab_count());
- browser()->NewTab();
+ chrome::NewTab(browser());
EXPECT_EQ(1, browser()->tab_count());
// Create a reference to initiator tab contents.
@@ -75,11 +76,11 @@ TEST_F(PrintPreviewTabControllerUnitTest, MAYBE_MultiplePreviewTabs) {
EXPECT_EQ(1u, BrowserList::size());
EXPECT_EQ(0, browser()->tab_count());
- browser()->NewTab();
+ chrome::NewTab(browser());
TabContents* tab_contents_1 = browser()->GetActiveTabContents();
ASSERT_TRUE(tab_contents_1);
- browser()->NewTab();
+ chrome::NewTab(browser());
TabContents* tab_contents_2 = browser()->GetActiveTabContents();
ASSERT_TRUE(tab_contents_2);
EXPECT_EQ(2, browser()->tab_count());
@@ -129,7 +130,7 @@ TEST_F(PrintPreviewTabControllerUnitTest, MAYBE_ClearInitiatorTabDetails) {
// Lets start with one window with one tab.
EXPECT_EQ(1u, BrowserList::size());
EXPECT_EQ(0, browser()->tab_count());
- browser()->NewTab();
+ chrome::NewTab(browser());
EXPECT_EQ(1, browser()->tab_count());
// Create a reference to initiator tab contents.
diff --git a/chrome/browser/printing/printing_layout_browsertest.cc b/chrome/browser/printing/printing_layout_browsertest.cc
index 53149d0..52f60b8 100644
--- a/chrome/browser/printing/printing_layout_browsertest.cc
+++ b/chrome/browser/printing/printing_layout_browsertest.cc
@@ -15,6 +15,7 @@
#include "chrome/browser/printing/print_job.h"
#include "chrome/browser/printing/print_view_manager.h"
#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/tab_contents/tab_contents.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
@@ -427,7 +428,7 @@ IN_PROC_BROWSER_TEST_F(PrintingLayoutTest, DISABLED_Delayed) {
url = test_server()->GetURL("files/printing/test1.html");
ui_test_utils::NavigateToURL(browser(), url);
}
- browser()->CloseWindow();
+ chrome::CloseWindow(browser());
ui_test_utils::RunAllPendingInMessageLoop();
EXPECT_EQ(0., CompareWithResult(L"popup_delayed_print"))
@@ -455,7 +456,7 @@ IN_PROC_BROWSER_TEST_F(PrintingLayoutTest, DISABLED_IFrame) {
url = test_server()->GetURL("files/printing/test1.html");
ui_test_utils::NavigateToURL(browser(), url);
}
- browser()->CloseWindow();
+ chrome::CloseWindow(browser());
ui_test_utils::RunAllPendingInMessageLoop();
EXPECT_EQ(0., CompareWithResult(L"iframe")) << L"iframe";
diff --git a/chrome/browser/referrer_policy_browsertest.cc b/chrome/browser/referrer_policy_browsertest.cc
index df69f97..3e6fc20 100644
--- a/chrome/browser/referrer_policy_browsertest.cc
+++ b/chrome/browser/referrer_policy_browsertest.cc
@@ -9,6 +9,7 @@
#include "chrome/browser/tab_contents/render_view_context_menu.h"
#include "chrome/browser/tab_contents/render_view_context_menu_browsertest_util.h"
#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/tab_contents/tab_contents.h"
#include "chrome/common/chrome_notification_types.h"
#include "chrome/test/base/in_process_browser_test.h"
@@ -389,20 +390,20 @@ IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, History) {
AddAllPossibleTitles(start_url, title_watcher.get());
// Go back to B.
- browser()->GoBack(CURRENT_TAB);
+ chrome::GoBack(browser(), CURRENT_TAB);
EXPECT_EQ(expected_title, title_watcher->WaitAndGetTitle());
title_watcher.reset(new ui_test_utils::TitleWatcher(tab, expected_title));
AddAllPossibleTitles(start_url, title_watcher.get());
// Reload to B.
- browser()->Reload(CURRENT_TAB);
+ chrome::Reload(browser(), CURRENT_TAB);
EXPECT_EQ(expected_title, title_watcher->WaitAndGetTitle());
title_watcher.reset(new ui_test_utils::TitleWatcher(tab, expected_title));
AddAllPossibleTitles(start_url, title_watcher.get());
// Shift-reload to B.
- browser()->ReloadIgnoringCache(CURRENT_TAB);
+ chrome::ReloadIgnoringCache(browser(), CURRENT_TAB);
EXPECT_EQ(expected_title, title_watcher->WaitAndGetTitle());
}
diff --git a/chrome/browser/renderer_host/chrome_render_widget_host_view_mac_delegate.mm b/chrome/browser/renderer_host/chrome_render_widget_host_view_mac_delegate.mm
index 3db2a64..d143305 100644
--- a/chrome/browser/renderer_host/chrome_render_widget_host_view_mac_delegate.mm
+++ b/chrome/browser/renderer_host/chrome_render_widget_host_view_mac_delegate.mm
@@ -11,6 +11,7 @@
#include "chrome/browser/debugger/devtools_window.h"
#include "chrome/browser/spellchecker/spellcheck_platform_mac.h"
#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_finder.h"
#import "chrome/browser/ui/cocoa/history_overlay_controller.h"
#import "chrome/browser/ui/cocoa/view_id_util.h"
@@ -188,8 +189,8 @@ class SpellCheckRenderViewObserver : public content::RenderViewHostObserver {
bool goForward = isRightScroll;
bool canGoBack = false, canGoForward = false;
if (browser) {
- canGoBack = browser->CanGoBack();
- canGoForward = browser->CanGoForward();
+ canGoBack = chrome::CanGoBack(browser);
+ canGoForward = chrome::CanGoForward(browser);
}
// If "forward" is inactive and the user rubber-bands to the right,
@@ -262,9 +263,9 @@ class SpellCheckRenderViewObserver : public content::RenderViewHostObserver {
historyOverlay.view.window);
if (ended && browser) {
if (goForward)
- browser->GoForward(CURRENT_TAB);
+ chrome::GoForward(browser, CURRENT_TAB);
else
- browser->GoBack(CURRENT_TAB);
+ chrome::GoBack(browser, CURRENT_TAB);
}
if (isComplete)
diff --git a/chrome/browser/renderer_host/render_process_host_chrome_browsertest.cc b/chrome/browser/renderer_host/render_process_host_chrome_browsertest.cc
index 8d6dc5d..44cea9d 100644
--- a/chrome/browser/renderer_host/render_process_host_chrome_browsertest.cc
+++ b/chrome/browser/renderer_host/render_process_host_chrome_browsertest.cc
@@ -5,6 +5,7 @@
#include "base/command_line.h"
#include "chrome/browser/debugger/devtools_window.h"
#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/singleton_tabs.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/url_constants.h"
@@ -82,7 +83,7 @@ IN_PROC_BROWSER_TEST_F(ChromeRenderProcessHostTest,
EXPECT_EQ(host_count, RenderProcessHostCount());
// DevTools start in docked mode (no new tab), in a separate process.
- browser()->ToggleDevToolsWindow(DEVTOOLS_TOGGLE_ACTION_INSPECT);
+ chrome::ToggleDevToolsWindow(browser(), DEVTOOLS_TOGGLE_ACTION_INSPECT);
host_count++;
EXPECT_EQ(tab_count, browser()->tab_count());
EXPECT_EQ(host_count, RenderProcessHostCount());
@@ -115,7 +116,7 @@ IN_PROC_BROWSER_TEST_F(ChromeRenderProcessHostTest,
EXPECT_EQ(host_count, RenderProcessHostCount());
// DevTools start in docked mode (no new tab), in a separate process.
- browser()->ToggleDevToolsWindow(DEVTOOLS_TOGGLE_ACTION_INSPECT);
+ chrome::ToggleDevToolsWindow(browser(), DEVTOOLS_TOGGLE_ACTION_INSPECT);
host_count++;
EXPECT_EQ(tab_count, browser()->tab_count());
EXPECT_EQ(host_count, RenderProcessHostCount());
diff --git a/chrome/browser/renderer_host/web_cache_manager_browsertest.cc b/chrome/browser/renderer_host/web_cache_manager_browsertest.cc
index 246012a..db85337 100644
--- a/chrome/browser/renderer_host/web_cache_manager_browsertest.cc
+++ b/chrome/browser/renderer_host/web_cache_manager_browsertest.cc
@@ -8,6 +8,7 @@
#include "base/process_util.h"
#include "chrome/browser/renderer_host/web_cache_manager.h"
#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_commands.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h"
#include "content/public/browser/render_process_host.h"
@@ -29,7 +30,7 @@ IN_PROC_BROWSER_TEST_F(WebCacheManagerBrowserTest, CrashOnceOnly) {
ui_test_utils::NavigateToURL(browser(), url);
- browser()->NewTab();
+ chrome::NewTab(browser());
ui_test_utils::NavigateToURL(browser(), url);
WebContents* tab = browser()->GetWebContentsAt(0);
@@ -38,21 +39,21 @@ IN_PROC_BROWSER_TEST_F(WebCacheManagerBrowserTest, CrashOnceOnly) {
content::RESULT_CODE_KILLED, true);
browser()->ActivateTabAt(0, true);
- browser()->NewTab();
+ chrome::NewTab(browser());
ui_test_utils::NavigateToURL(browser(), url);
browser()->ActivateTabAt(0, true);
- browser()->NewTab();
+ chrome::NewTab(browser());
ui_test_utils::NavigateToURL(browser(), url);
// We would have crashed at the above line with the bug.
browser()->ActivateTabAt(0, true);
- browser()->CloseTab();
+ chrome::CloseTab(browser());
browser()->ActivateTabAt(0, true);
- browser()->CloseTab();
+ chrome::CloseTab(browser());
browser()->ActivateTabAt(0, true);
- browser()->CloseTab();
+ chrome::CloseTab(browser());
ui_test_utils::NavigateToURL(browser(), url);
diff --git a/chrome/browser/sessions/session_restore_browsertest.cc b/chrome/browser/sessions/session_restore_browsertest.cc
index c8909d2..0494615 100644
--- a/chrome/browser/sessions/session_restore_browsertest.cc
+++ b/chrome/browser/sessions/session_restore_browsertest.cc
@@ -16,6 +16,7 @@
#include "chrome/browser/sessions/tab_restore_service.h"
#include "chrome/browser/sessions/tab_restore_service_factory.h"
#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
@@ -110,7 +111,7 @@ class SessionRestoreTest : public InProcessBrowserTest {
ui_test_utils::BrowserAddedObserver window_observer;
content::TestNavigationObserver navigation_observer(
content::NotificationService::AllSources(), NULL, expected_tab_count);
- Browser::NewEmptyWindow(profile);
+ chrome::NewEmptyWindow(profile);
Browser* new_browser = window_observer.WaitForSingleNewBrowser();
navigation_observer.Wait();
g_browser_process->ReleaseModule();
@@ -122,7 +123,7 @@ class SessionRestoreTest : public InProcessBrowserTest {
ui_test_utils::WindowedNotificationObserver observer(
content::NOTIFICATION_LOAD_STOP,
content::NotificationService::AllSources());
- browser->GoBack(CURRENT_TAB);
+ chrome::GoBack(browser, CURRENT_TAB);
observer.Wait();
}
@@ -130,7 +131,7 @@ class SessionRestoreTest : public InProcessBrowserTest {
ui_test_utils::WindowedNotificationObserver observer(
content::NOTIFICATION_LOAD_STOP,
content::NotificationService::AllSources());
- browser->GoForward(CURRENT_TAB);
+ chrome::GoForward(browser, CURRENT_TAB);
observer.Wait();
}
@@ -183,7 +184,7 @@ IN_PROC_BROWSER_TEST_F(SessionRestoreTest, NoSessionRestoreNewWindowChromeOS) {
// Create a new window, which should open NTP.
ui_test_utils::BrowserAddedObserver browser_added_observer;
- incognito_browser->NewWindow();
+ chrome::NewWindow(incognito_browser);
Browser* new_browser = browser_added_observer.WaitForSingleNewBrowser();
ASSERT_TRUE(new_browser);
@@ -234,7 +235,7 @@ IN_PROC_BROWSER_TEST_F(SessionRestoreTest,
// Create a new window, which should trigger session restore.
ui_test_utils::BrowserAddedObserver observer;
- popup->NewWindow();
+ chrome::NewWindow(popup);
Browser* new_browser = observer.WaitForSingleNewBrowser();
ASSERT_TRUE(new_browser != NULL);
@@ -361,7 +362,7 @@ IN_PROC_BROWSER_TEST_F(SessionRestoreTest, IncognitotoNonIncognito) {
// Create a new window, which should trigger session restore.
ui_test_utils::BrowserAddedObserver browser_added_observer;
- incognito_browser->NewWindow();
+ chrome::NewWindow(incognito_browser);
Browser* new_browser = browser_added_observer.WaitForSingleNewBrowser();
// The first tab should have 'url' as its url.
@@ -558,7 +559,7 @@ IN_PROC_BROWSER_TEST_F(SessionRestoreTest, ClosedTabStaysClosed) {
ui_test_utils::NavigateToURLWithDisposition(
browser(), url2_, NEW_FOREGROUND_TAB,
ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
- browser()->CloseTab();
+ chrome::CloseTab(browser());
Browser* new_browser = QuitBrowserAndRestore(browser(), 1);
@@ -742,7 +743,7 @@ IN_PROC_BROWSER_TEST_F(SessionRestoreTest, RestorePinnedSelectedTab) {
ASSERT_EQ(2, new_browser->tab_count());
ASSERT_EQ(0, new_browser->active_index());
// Close the pinned tab.
- new_browser->CloseTab();
+ chrome::CloseTab(new_browser);
ASSERT_EQ(1, new_browser->tab_count());
ASSERT_EQ(0, new_browser->active_index());
// Use the existing tab to navigate away, so that we can verify it was really
diff --git a/chrome/browser/ssl/ssl_browser_tests.cc b/chrome/browser/ssl/ssl_browser_tests.cc
index d0c3592..f70863d 100644
--- a/chrome/browser/ssl/ssl_browser_tests.cc
+++ b/chrome/browser/ssl/ssl_browser_tests.cc
@@ -10,6 +10,7 @@
#include "base/utf_string_conversions.h"
#include "chrome/app/chrome_command_ids.h"
#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_navigator.h"
#include "chrome/browser/ui/constrained_window_tab_helper.h"
#include "chrome/browser/ui/tab_contents/tab_contents.h"
@@ -427,7 +428,7 @@ IN_PROC_BROWSER_TEST_F(SSLUITest,
ProvisionalLoadWaiter load_failed_observer(tab);
// Simulate user clicking on back button (crbug.com/39248).
- browser()->GoBack(CURRENT_TAB);
+ chrome::GoBack(browser(), CURRENT_TAB);
// Wait until we hear the load failure, and make sure we haven't swapped out
// the previous page. Prevents regression of http://crbug.com/82667.
@@ -547,7 +548,7 @@ IN_PROC_BROWSER_TEST_F(SSLUITest, TestWSSInvalidCertAndClose) {
tabs[i] = browser()->AddSelectedTabWithURL(
slaveUrl, content::PAGE_TRANSITION_LINK);
}
- browser()->SelectNextTab();
+ chrome::SelectNextTab(browser());
// Visit a page which waits for one TLS handshake failure.
// The title will be changed to 'PASS'.
@@ -665,8 +666,8 @@ IN_PROC_BROWSER_TEST_F(SSLUITest, DISABLED_TestBadHTTPSDownload) {
// NAV_ENTRY_COMMITTED notification because going back with an
// active interstitial simply hides the interstitial.
ASSERT_TRUE(tab->GetInterstitialPage() != NULL);
- EXPECT_TRUE(browser()->CanGoBack());
- browser()->GoBack(CURRENT_TAB);
+ EXPECT_TRUE(chrome::CanGoBack(browser()));
+ chrome::GoBack(browser(), CURRENT_TAB);
}
//
diff --git a/chrome/browser/sync/test/integration/performance/sessions_sync_perf_test.cc b/chrome/browser/sync/test/integration/performance/sessions_sync_perf_test.cc
index c53ffc6..043dc77 100644
--- a/chrome/browser/sync/test/integration/performance/sessions_sync_perf_test.cc
+++ b/chrome/browser/sync/test/integration/performance/sessions_sync_perf_test.cc
@@ -4,6 +4,7 @@
#include "base/stringprintf.h"
#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/sync/profile_sync_service_harness.h"
#include "chrome/browser/sync/test/integration/performance/sync_timing_helper.h"
#include "chrome/browser/sync/test/integration/sessions_helper.h"
@@ -60,7 +61,7 @@ void SessionsSyncPerfTest::UpdateTabs(int profile) {
GURL url;
std::vector<GURL> urls;
for (int i = 0; i < browser->tab_count(); ++i) {
- browser->SelectNumberedTab(i);
+ chrome::SelectNumberedTab(browser, i);
url = NextURL();
browser->OpenURL(
OpenURLParams(url,
diff --git a/chrome/browser/tab_contents/render_view_context_menu.cc b/chrome/browser/tab_contents/render_view_context_menu.cc
index 51f35cc..ba9e11e 100644
--- a/chrome/browser/tab_contents/render_view_context_menu.cc
+++ b/chrome/browser/tab_contents/render_view_context_menu.cc
@@ -48,6 +48,7 @@
#include "chrome/browser/translate/translate_prefs.h"
#include "chrome/browser/translate/translate_tab_helper.h"
#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/search_engines/search_engine_tab_helper.h"
#include "chrome/browser/ui/tab_contents/core_tab_helper.h"
@@ -1716,8 +1717,8 @@ void RenderViewContextMenu::ExecuteCommand(int id, int event_flags) {
NavigationEntry* nav_entry = controller->GetActiveEntry();
Browser* browser =
browser::FindBrowserWithWebContents(source_web_contents_);
- browser->ShowPageInfo(source_web_contents_, nav_entry->GetURL(),
- nav_entry->GetSSL(), true);
+ chrome::ShowPageInfo(browser, source_web_contents_, nav_entry->GetURL(),
+ nav_entry->GetSSL(), true);
break;
}
@@ -1758,8 +1759,8 @@ void RenderViewContextMenu::ExecuteCommand(int id, int event_flags) {
case IDC_CONTENT_CONTEXT_VIEWFRAMEINFO: {
Browser* browser = browser::FindBrowserWithWebContents(
source_web_contents_);
- browser->ShowPageInfo(source_web_contents_, params_.frame_url,
- params_.security_info, false);
+ chrome::ShowPageInfo(browser, source_web_contents_, params_.frame_url,
+ params_.security_info, false);
break;
}
diff --git a/chrome/browser/tab_restore_browsertest.cc b/chrome/browser/tab_restore_browsertest.cc
index 83d422c..3f73d54 100644
--- a/chrome/browser/tab_restore_browsertest.cc
+++ b/chrome/browser/tab_restore_browsertest.cc
@@ -9,6 +9,7 @@
#include "base/utf_string_conversions.h"
#include "chrome/app/chrome_command_ids.h"
#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/find_bar/find_notification_details.h"
#include "chrome/browser/ui/tab_contents/tab_contents.h"
@@ -122,7 +123,7 @@ class TabRestoreTest : public InProcessBrowserTest {
ui_test_utils::WindowedNotificationObserver observer(
content::NOTIFICATION_LOAD_STOP,
content::NotificationService::AllSources());
- browser->GoBack(CURRENT_TAB);
+ chrome::GoBack(browser, CURRENT_TAB);
observer.Wait();
}
@@ -280,7 +281,7 @@ IN_PROC_BROWSER_TEST_F(TabRestoreTest, RestoreWindowAndTab) {
ui_test_utils::WindowedNotificationObserver observer(
chrome::NOTIFICATION_BROWSER_CLOSED,
content::NotificationService::AllSources());
- browser()->CloseWindow();
+ chrome::CloseWindow(browser());
observer.Wait();
EXPECT_EQ(1u, BrowserList::size());
@@ -434,7 +435,7 @@ IN_PROC_BROWSER_TEST_F(TabRestoreTest,
ui_test_utils::NavigateToURLWithDisposition(
browser(), http_url2, CURRENT_TAB,
ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
- EXPECT_FALSE(browser()->CanGoForward());
+ EXPECT_FALSE(chrome::CanGoForward(browser()));
EXPECT_EQ(http_url2, browser()->GetActiveWebContents()->GetURL());
}
@@ -459,7 +460,7 @@ IN_PROC_BROWSER_TEST_F(TabRestoreTest, RestoreWindow) {
ui_test_utils::WindowedNotificationObserver close_window_observer(
chrome::NOTIFICATION_BROWSER_CLOSED,
content::NotificationService::AllSources());
- browser()->CloseWindow();
+ chrome::CloseWindow(browser());
close_window_observer.Wait();
EXPECT_EQ(window_count - 1, BrowserList::size());
diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc
index e84c3ac..7717d06 100644
--- a/chrome/browser/ui/browser.cc
+++ b/chrome/browser/ui/browser.cc
@@ -72,7 +72,6 @@
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/printing/cloud_print/cloud_print_setup_flow.h"
#include "chrome/browser/printing/print_preview_tab_controller.h"
-#include "chrome/browser/printing/print_view_manager.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_destroyer.h"
#include "chrome/browser/profiles/profile_manager.h"
@@ -96,6 +95,7 @@
#include "chrome/browser/ui/app_modal_dialogs/javascript_dialog_creator.h"
#include "chrome/browser/ui/blocked_content/blocked_content_tab_helper.h"
#include "chrome/browser/ui/bookmarks/bookmark_tab_helper.h"
+#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_content_setting_bubble_model_delegate.h"
#include "chrome/browser/ui/browser_dialogs.h"
#include "chrome/browser/ui/browser_finder.h"
@@ -146,7 +146,6 @@
#include "chrome/common/custom_handlers/protocol_handler.h"
#include "chrome/common/extensions/extension.h"
#include "chrome/common/extensions/extension_constants.h"
-#include "chrome/common/net/url_util.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/profiling.h"
#include "chrome/common/url_constants.h"
@@ -200,10 +199,6 @@
#include "ui/base/win/shell.h"
#endif // OS_WIN
-#if defined(OS_MACOSX)
-#include "ui/base/cocoa/find_pasteboard.h"
-#endif
-
#if defined(OS_CHROMEOS)
#include "chrome/browser/chromeos/gdata/gdata_util.h"
#endif
@@ -220,7 +215,6 @@ using content::OpenURLParams;
using content::PluginService;
using content::Referrer;
using content::SiteInstance;
-using content::SSLStatus;
using content::UserMetricsAction;
using content::WebContents;
using extensions::Extension;
@@ -574,63 +568,6 @@ bool Browser::is_devtools() const {
}
///////////////////////////////////////////////////////////////////////////////
-// Browser, Creation Helpers:
-
-// static
-void Browser::NewEmptyWindow(Profile* profile) {
- bool incognito = profile->IsOffTheRecord();
- PrefService* prefs = profile->GetPrefs();
- if (incognito) {
- if (IncognitoModePrefs::GetAvailability(prefs) ==
- IncognitoModePrefs::DISABLED) {
- incognito = false;
- }
- } else {
- if (browser_defaults::kAlwaysOpenIncognitoWindow &&
- IncognitoModePrefs::ShouldLaunchIncognito(
- *CommandLine::ForCurrentProcess(), prefs)) {
- incognito = true;
- }
- }
-
- if (incognito) {
- content::RecordAction(UserMetricsAction("NewIncognitoWindow"));
- OpenEmptyWindow(profile->GetOffTheRecordProfile());
- } else {
- content::RecordAction(UserMetricsAction("NewWindow"));
- SessionService* session_service =
- SessionServiceFactory::GetForProfile(profile->GetOriginalProfile());
- if (!session_service ||
- !session_service->RestoreIfNecessary(std::vector<GURL>())) {
- OpenEmptyWindow(profile->GetOriginalProfile());
- }
- }
-}
-
-// static
-Browser* Browser::OpenEmptyWindow(Profile* profile) {
- Browser* browser = Browser::Create(profile);
- browser->AddBlankTab(true);
- browser->window()->Show();
- return browser;
-}
-
-// static
-void Browser::OpenWindowWithRestoredTabs(Profile* profile) {
- TabRestoreService* service = TabRestoreServiceFactory::GetForProfile(profile);
- if (service)
- service->RestoreMostRecentEntry(NULL);
-}
-
-// static
-void Browser::OpenURLOffTheRecord(Profile* profile, const GURL& url) {
- Browser* browser = browser::FindOrCreateTabbedBrowser(
- profile->GetOffTheRecordProfile());
- browser->AddSelectedTabWithURL(url, content::PAGE_TRANSITION_LINK);
- browser->window()->Show();
-}
-
-///////////////////////////////////////////////////////////////////////////////
// Browser, State Storage and Retrieval for UI:
SkBitmap Browser::GetCurrentPageIcon() const {
@@ -748,7 +685,7 @@ void Browser::OnWindowActivated() {
base::TERMINATION_STATUS_PROCESS_WAS_KILLED) {
if (CommandLine::ForCurrentProcess()->HasSwitch(
switches::kReloadKilledTabs)) {
- Reload(CURRENT_TAB);
+ chrome::Reload(this, CURRENT_TAB);
}
}
}
@@ -759,7 +696,7 @@ void Browser::OnWindowActivated() {
void Browser::InProgressDownloadResponse(bool cancel_downloads) {
if (cancel_downloads) {
cancel_download_confirmation_state_ = RESPONSE_RECEIVED;
- CloseWindow();
+ chrome::CloseWindow(this);
return;
}
@@ -1007,16 +944,6 @@ void Browser::ReplaceRestoredTab(
tab_strip_model_->ReplaceNavigationControllerAt(active_index(), tab_contents);
}
-bool Browser::NavigateToIndexWithDisposition(int index,
- WindowOpenDisposition disp) {
- NavigationController& controller =
- GetOrCloneTabForDisposition(disp)->GetController();
- if (index < 0 || index >= controller.GetEntryCount())
- return false;
- controller.GoToIndex(index);
- return true;
-}
-
void Browser::WindowFullscreenStateChanged() {
fullscreen_controller_->WindowFullscreenStateChanged();
FullScreenMode fullscreen_mode = FULLSCREEN_DISABLED;
@@ -1035,206 +962,6 @@ void Browser::WindowFullscreenStateChanged() {
///////////////////////////////////////////////////////////////////////////////
// Browser, Assorted browser commands:
-bool Browser::CanGoBack() const {
- return GetActiveWebContents()->GetController().CanGoBack();
-}
-
-void Browser::GoBack(WindowOpenDisposition disposition) {
- content::RecordAction(UserMetricsAction("Back"));
-
- TabContents* current_tab = GetActiveTabContents();
- if (CanGoBack()) {
- WebContents* new_tab = GetOrCloneTabForDisposition(disposition);
- // If we are on an interstitial page and clone the tab, it won't be copied
- // to the new tab, so we don't need to go back.
- if (current_tab->web_contents()->ShowingInterstitialPage() &&
- (new_tab != current_tab->web_contents()))
- return;
- new_tab->GetController().GoBack();
- }
-}
-
-bool Browser::CanGoForward() const {
- return GetActiveWebContents()->GetController().CanGoForward();
-}
-
-void Browser::GoForward(WindowOpenDisposition disposition) {
- content::RecordAction(UserMetricsAction("Forward"));
- if (CanGoForward())
- GetOrCloneTabForDisposition(disposition)->GetController().GoForward();
-}
-
-void Browser::Reload(WindowOpenDisposition disposition) {
- content::RecordAction(UserMetricsAction("Reload"));
- ReloadInternal(disposition, false);
-}
-
-void Browser::ReloadIgnoringCache(WindowOpenDisposition disposition) {
- content::RecordAction(UserMetricsAction("ReloadIgnoringCache"));
- ReloadInternal(disposition, true);
-}
-
-void Browser::Home(WindowOpenDisposition disposition) {
- content::RecordAction(UserMetricsAction("Home"));
- OpenURL(OpenURLParams(
- profile_->GetHomePage(), Referrer(), disposition,
- content::PageTransitionFromInt(
- content::PAGE_TRANSITION_AUTO_BOOKMARK |
- content::PAGE_TRANSITION_HOME_PAGE),
- false));
-}
-
-void Browser::OpenCurrentURL() {
- content::RecordAction(UserMetricsAction("LoadURL"));
- LocationBar* location_bar = window_->GetLocationBar();
- if (!location_bar)
- return;
-
- WindowOpenDisposition open_disposition =
- location_bar->GetWindowOpenDisposition();
- if (OpenInstant(open_disposition))
- return;
-
- GURL url(location_bar->GetInputString());
-
- browser::NavigateParams params(this, url, location_bar->GetPageTransition());
- params.disposition = open_disposition;
- // Use ADD_INHERIT_OPENER so that all pages opened by the omnibox at least
- // inherit the opener. In some cases the tabstrip will determine the group
- // should be inherited, in which case the group is inherited instead of the
- // opener.
- params.tabstrip_add_types =
- TabStripModel::ADD_FORCE_INDEX | TabStripModel::ADD_INHERIT_OPENER;
- browser::Navigate(&params);
-
- DCHECK(profile_->GetExtensionService());
- if (profile_->GetExtensionService()->IsInstalledApp(url)) {
- AppLauncherHandler::RecordAppLaunchType(
- extension_misc::APP_LAUNCH_OMNIBOX_LOCATION);
- }
-}
-
-void Browser::Stop() {
- content::RecordAction(UserMetricsAction("Stop"));
- GetActiveWebContents()->Stop();
-}
-
-#if !defined(OS_WIN)
-void Browser::NewWindow() {
- NewEmptyWindow(profile_->GetOriginalProfile());
-}
-
-void Browser::NewIncognitoWindow() {
- NewEmptyWindow(profile_->GetOffTheRecordProfile());
-}
-#endif // OS_WIN
-
-void Browser::CloseWindow() {
- content::RecordAction(UserMetricsAction("CloseWindow"));
- window_->Close();
-}
-
-void Browser::NewTab() {
- content::RecordAction(UserMetricsAction("NewTab"));
- // TODO(asvitkine): This is invoked programmatically from several places.
- // Audit the code and change it so that the histogram only gets collected for
- // user-initiated commands.
- UMA_HISTOGRAM_ENUMERATION("Tab.NewTab", TabStripModel::NEW_TAB_COMMAND,
- TabStripModel::NEW_TAB_ENUM_COUNT);
-
- if (is_type_tabbed()) {
- AddBlankTab(true);
- GetActiveWebContents()->GetView()->RestoreFocus();
- } else {
- Browser* b = browser::FindOrCreateTabbedBrowser(profile_);
- b->AddBlankTab(true);
- b->window()->Show();
- // The call to AddBlankTab above did not set the focus to the tab as its
- // window was not active, so we have to do it explicitly.
- // See http://crbug.com/6380.
- b->GetActiveWebContents()->GetView()->RestoreFocus();
- }
-}
-
-void Browser::CloseTab() {
- content::RecordAction(UserMetricsAction("CloseTab_Accelerator"));
- tab_strip_model_->CloseSelectedTabs();
-}
-
-void Browser::SelectNextTab() {
- content::RecordAction(UserMetricsAction("SelectNextTab"));
- tab_strip_model_->SelectNextTab();
-}
-
-void Browser::SelectPreviousTab() {
- content::RecordAction(UserMetricsAction("SelectPrevTab"));
- tab_strip_model_->SelectPreviousTab();
-}
-
-void Browser::OpenTabpose() {
-#if defined(OS_MACOSX)
- if (!CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kEnableExposeForTabs)) {
- return;
- }
-
- content::RecordAction(UserMetricsAction("OpenTabpose"));
- window()->OpenTabpose();
-#else
- NOTREACHED();
-#endif
-}
-
-void Browser::MoveTabNext() {
- content::RecordAction(UserMetricsAction("MoveTabNext"));
- tab_strip_model_->MoveTabNext();
-}
-
-void Browser::MoveTabPrevious() {
- content::RecordAction(UserMetricsAction("MoveTabPrevious"));
- tab_strip_model_->MoveTabPrevious();
-}
-
-void Browser::SelectNumberedTab(int index) {
- if (index < tab_count()) {
- content::RecordAction(UserMetricsAction("SelectNumberedTab"));
- ActivateTabAt(index, true);
- }
-}
-
-void Browser::SelectLastTab() {
- content::RecordAction(UserMetricsAction("SelectLastTab"));
- tab_strip_model_->SelectLastTab();
-}
-
-void Browser::DuplicateTab() {
- content::RecordAction(UserMetricsAction("Duplicate"));
- DuplicateContentsAt(active_index());
-}
-
-void Browser::WriteCurrentURLToClipboard() {
- // TODO(ericu): There isn't currently a metric for this. Should there be?
- // We don't appear to track the action when it comes from the
- // RenderContextViewMenu.
-
- WebContents* contents = GetActiveWebContents();
- if (!toolbar_model_->ShouldDisplayURL())
- return;
-
- chrome_common_net::WriteURLToClipboard(
- contents->GetURL(),
- profile_->GetPrefs()->GetString(prefs::kAcceptLanguages),
- g_browser_process->clipboard());
-}
-
-void Browser::ConvertPopupToTabbedBrowser() {
- content::RecordAction(UserMetricsAction("ShowAsTab"));
- TabContents* contents = tab_strip_model_->DetachTabContentsAt(active_index());
- Browser* browser = Browser::Create(profile_);
- browser->tab_strip_model()->AppendTabContents(contents, true);
- browser->window()->Show();
-}
-
void Browser::ToggleFullscreenMode() {
fullscreen_controller_->ToggleFullscreenMode();
}
@@ -1249,83 +976,10 @@ void Browser::TogglePresentationMode() {
}
#endif
-void Browser::Exit() {
- content::RecordAction(UserMetricsAction("Exit"));
- browser::AttemptUserExit();
-}
-
-void Browser::BookmarkCurrentPage() {
- content::RecordAction(UserMetricsAction("Star"));
-
- BookmarkModel* model = profile()->GetBookmarkModel();
- if (!model || !model->IsLoaded())
- return; // Ignore requests until bookmarks are loaded.
-
- GURL url;
- string16 title;
- TabContents* tab = GetActiveTabContents();
- bookmark_utils::GetURLAndTitleToBookmark(tab->web_contents(), &url, &title);
- bool was_bookmarked = model->IsBookmarked(url);
- if (!was_bookmarked && profile_->IsOffTheRecord()) {
- // If we're incognito the favicon may not have been saved. Save it now
- // so that bookmarks have an icon for the page.
- tab->favicon_tab_helper()->SaveFavicon();
- }
- bookmark_utils::AddIfNotBookmarked(model, url, title);
- // Make sure the model actually added a bookmark before showing the star. A
- // bookmark isn't created if the url is invalid.
- if (window_->IsActive() && model->IsBookmarked(url)) {
- // Only show the bubble if the window is active, otherwise we may get into
- // weird situations where the bubble is deleted as soon as it is shown.
- window_->ShowBookmarkBubble(url, was_bookmarked);
- }
-}
-
-#if !defined(OS_WIN)
-void Browser::PinCurrentPageToStartScreen() {
-}
-#endif
-
-void Browser::SavePage() {
- content::RecordAction(UserMetricsAction("SavePage"));
- WebContents* current_tab = GetActiveWebContents();
- if (current_tab && current_tab->GetContentsMimeType() == "application/pdf")
- content::RecordAction(UserMetricsAction("PDF.SavePage"));
- GetActiveWebContents()->OnSavePage();
-}
-
void Browser::ViewSelectedSource() {
ViewSource(GetActiveTabContents());
}
-void Browser::ShowFindBar() {
- GetFindBarController()->Show();
-}
-
-void Browser::ShowPageInfo(content::WebContents* web_contents,
- const GURL& url,
- const SSLStatus& ssl,
- bool show_history) {
- Profile* profile = Profile::FromBrowserContext(
- web_contents->GetBrowserContext());
- TabContents* tab_contents = TabContents::FromWebContents(web_contents);
-
- if (CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kEnableWebsiteSettings)) {
- window()->ShowWebsiteSettings(
- profile, tab_contents, url, ssl, show_history);
- } else {
- window()->ShowPageInfo(web_contents, url, ssl, show_history);
- }
-}
-
-void Browser::ShowChromeToMobileBubble() {
- // Only show the bubble if the window is active, otherwise we may get into
- // weird situations where the bubble is deleted as soon as it is shown.
- if (window_->IsActive())
- window_->ShowChromeToMobileBubble();
-}
-
bool Browser::SupportsWindowFeature(WindowFeature feature) const {
return SupportsWindowFeatureImpl(feature, true);
}
@@ -1334,32 +988,6 @@ bool Browser::CanSupportWindowFeature(WindowFeature feature) const {
return SupportsWindowFeatureImpl(feature, false);
}
-void Browser::Print() {
- if (g_browser_process->local_state()->GetBoolean(
- prefs::kPrintPreviewDisabled)) {
- GetActiveTabContents()->print_view_manager()->PrintNow();
- } else {
- GetActiveTabContents()->print_view_manager()->PrintPreviewNow();
- }
-}
-
-void Browser::AdvancedPrint() {
- GetActiveTabContents()->print_view_manager()->AdvancedPrintNow();
-}
-
-void Browser::EmailPageLocation() {
- content::RecordAction(UserMetricsAction("EmailPageLocation"));
- WebContents* wc = GetActiveWebContents();
- DCHECK(wc);
-
- std::string title = net::EscapeQueryParamValue(
- UTF16ToUTF8(wc->GetTitle()), false);
- std::string page_url = net::EscapeQueryParamValue(wc->GetURL().spec(), false);
- std::string mailto = std::string("mailto:?subject=Fwd:%20") +
- title + "&body=%0A%0A" + page_url;
- platform_util::OpenExternal(GURL(mailto));
-}
-
void Browser::ToggleEncodingAutoDetect() {
content::RecordAction(UserMetricsAction("AutoDetectChange"));
encoding_auto_detect_.SetValue(!encoding_auto_detect_.GetValue());
@@ -1392,125 +1020,6 @@ void Browser::OverrideEncoding(int encoding_id) {
}
}
-void Browser::Cut() {
- content::RecordAction(UserMetricsAction("Cut"));
- window()->Cut();
-}
-
-void Browser::Copy() {
- content::RecordAction(UserMetricsAction("Copy"));
- window()->Copy();
-}
-
-void Browser::Paste() {
- content::RecordAction(UserMetricsAction("Paste"));
- window()->Paste();
-}
-
-void Browser::Find() {
- content::RecordAction(UserMetricsAction("Find"));
- FindInPage(false, false);
-}
-
-void Browser::FindNext() {
- content::RecordAction(UserMetricsAction("FindNext"));
- FindInPage(true, true);
-}
-
-void Browser::FindPrevious() {
- content::RecordAction(UserMetricsAction("FindPrevious"));
- FindInPage(true, false);
-}
-
-void Browser::Zoom(content::PageZoom zoom) {
- if (is_devtools())
- return;
-
- content::RenderViewHost* host = GetActiveWebContents()->GetRenderViewHost();
- if (zoom == content::PAGE_ZOOM_RESET) {
- host->SetZoomLevel(0);
- content::RecordAction(UserMetricsAction("ZoomNormal"));
- return;
- }
-
- double current_zoom_level = GetActiveWebContents()->GetZoomLevel();
- double default_zoom_level =
- profile_->GetPrefs()->GetDouble(prefs::kDefaultZoomLevel);
-
- // Generate a vector of zoom levels from an array of known presets along with
- // the default level added if necessary.
- std::vector<double> zoom_levels =
- chrome_page_zoom::PresetZoomLevels(default_zoom_level);
-
- if (zoom == content::PAGE_ZOOM_OUT) {
- // Iterate through the zoom levels in reverse order to find the next
- // lower level based on the current zoom level for this page.
- for (std::vector<double>::reverse_iterator i = zoom_levels.rbegin();
- i != zoom_levels.rend(); ++i) {
- double zoom_level = *i;
- if (content::ZoomValuesEqual(zoom_level, current_zoom_level))
- continue;
- if (zoom_level < current_zoom_level) {
- host->SetZoomLevel(zoom_level);
- content::RecordAction(UserMetricsAction("ZoomMinus"));
- return;
- }
- content::RecordAction(UserMetricsAction("ZoomMinus_AtMinimum"));
- }
- } else {
- // Iterate through the zoom levels in normal order to find the next
- // higher level based on the current zoom level for this page.
- for (std::vector<double>::const_iterator i = zoom_levels.begin();
- i != zoom_levels.end(); ++i) {
- double zoom_level = *i;
- if (content::ZoomValuesEqual(zoom_level, current_zoom_level))
- continue;
- if (zoom_level > current_zoom_level) {
- host->SetZoomLevel(zoom_level);
- content::RecordAction(UserMetricsAction("ZoomPlus"));
- return;
- }
- }
- content::RecordAction(UserMetricsAction("ZoomPlus_AtMaximum"));
- }
-}
-
-void Browser::FocusToolbar() {
- content::RecordAction(UserMetricsAction("FocusToolbar"));
- window_->FocusToolbar();
-}
-
-void Browser::FocusLocationBar() {
- content::RecordAction(UserMetricsAction("FocusLocation"));
- window_->SetFocusToLocationBar(true);
-}
-
-void Browser::FocusSearch() {
- // TODO(beng): replace this with FocusLocationBar
- content::RecordAction(UserMetricsAction("FocusSearch"));
- window_->GetLocationBar()->FocusSearch();
-}
-
-void Browser::FocusAppMenu() {
- content::RecordAction(UserMetricsAction("FocusAppMenu"));
- window_->FocusAppMenu();
-}
-
-void Browser::FocusBookmarksToolbar() {
- content::RecordAction(UserMetricsAction("FocusBookmarksToolbar"));
- window_->FocusBookmarksToolbar();
-}
-
-void Browser::FocusNextPane() {
- content::RecordAction(UserMetricsAction("FocusNextPane"));
- window_->RotatePaneFocus(true);
-}
-
-void Browser::FocusPreviousPane() {
- content::RecordAction(UserMetricsAction("FocusPreviousPane"));
- window_->RotatePaneFocus(false);
-}
-
void Browser::OpenFile() {
content::RecordAction(UserMetricsAction("OpenFile"));
if (!select_file_dialog_.get())
@@ -1552,67 +1061,53 @@ void Browser::OpenCreateShortcutsDialog() {
#endif
}
-void Browser::ToggleDevToolsWindow(DevToolsToggleAction action) {
- if (action == DEVTOOLS_TOGGLE_ACTION_SHOW_CONSOLE)
- content::RecordAction(UserMetricsAction("DevTools_ToggleConsole"));
- else
- content::RecordAction(UserMetricsAction("DevTools_ToggleWindow"));
-
- DevToolsWindow::ToggleDevToolsWindow(
- GetActiveWebContents()->GetRenderViewHost(),
- action);
-}
-
-bool Browser::CanOpenTaskManager() {
-#if defined(OS_WIN)
- // In metro we can't display the task manager, as it is a native window.
- return !base::win::IsMetroProcess();
-#else
- return true;
-#endif
-}
-
-void Browser::OpenTaskManager(bool highlight_background_resources) {
- content::RecordAction(UserMetricsAction("TaskManager"));
- if (highlight_background_resources)
- window_->ShowBackgroundPages();
- else
- window_->ShowTaskManager();
-}
-
-void Browser::OpenFeedbackDialog() {
- content::RecordAction(UserMetricsAction("Feedback"));
- browser::ShowWebFeedbackView(this, std::string(), std::string());
-}
-
-void Browser::ToggleBookmarkBar() {
- content::RecordAction(UserMetricsAction("ShowBookmarksBar"));
- window_->ToggleBookmarkBar();
-}
-
-void Browser::ShowAppMenu() {
- // We record the user metric for this event in WrenchMenu::RunMenu.
- window_->ShowAppMenu();
-}
-
-void Browser::ShowAvatarMenu() {
- window_->ShowAvatarBubbleFromAvatarButton();
-}
-
-void Browser::OpenUpdateChromeDialog() {
- content::RecordAction(UserMetricsAction("UpdateChrome"));
- window_->ShowUpdateChromeDialog();
-}
-
-void Browser::ToggleSpeechInput() {
- GetActiveWebContents()->GetRenderViewHost()->ToggleSpeechInput();
-}
-
void Browser::UpdateDownloadShelfVisibility(bool visible) {
if (GetStatusBubble())
GetStatusBubble()->UpdateDownloadShelfVisibility(visible);
}
+bool Browser::OpenInstant(WindowOpenDisposition disposition) {
+ if (!instant() || !instant()->PrepareForCommit() ||
+ disposition == NEW_BACKGROUND_TAB) {
+ // NEW_BACKGROUND_TAB results in leaving the omnibox open, so we don't
+ // attempt to use the instant preview.
+ return false;
+ }
+
+ if (disposition == CURRENT_TAB) {
+ content::NotificationService::current()->Notify(
+ chrome::NOTIFICATION_INSTANT_COMMITTED,
+ content::Source<TabContents>(instant()->CommitCurrentPreview(
+ INSTANT_COMMIT_PRESSED_ENTER)),
+ content::NotificationService::NoDetails());
+ return true;
+ }
+ if (disposition == NEW_FOREGROUND_TAB) {
+ TabContents* preview_contents = instant()->ReleasePreviewContents(
+ INSTANT_COMMIT_PRESSED_ENTER, NULL);
+ // HideInstant is invoked after release so that InstantController is not
+ // active when HideInstant asks it for its state.
+ HideInstant();
+ preview_contents->web_contents()->GetController().PruneAllButActive();
+ tab_strip_model_->AddTabContents(
+ preview_contents,
+ -1,
+ instant()->last_transition_type(),
+ TabStripModel::ADD_ACTIVE);
+ instant()->CompleteRelease(preview_contents);
+ content::NotificationService::current()->Notify(
+ chrome::NOTIFICATION_INSTANT_COMMITTED,
+ content::Source<TabContents>(preview_contents),
+ content::NotificationService::NoDetails());
+ return true;
+ }
+ // The omnibox currently doesn't use other dispositions, so we don't attempt
+ // to handle them. If you hit this NOTREACHED file a bug and I'll (sky) add
+ // support for the new disposition.
+ NOTREACHED();
+ return false;
+}
+
///////////////////////////////////////////////////////////////////////////////
// static
@@ -1997,25 +1492,29 @@ void Browser::ExecuteCommandWithDisposition(
// declaration order in browser.h!
switch (id) {
// Navigation commands
- case IDC_BACK: GoBack(disposition); break;
- case IDC_FORWARD: GoForward(disposition); break;
- case IDC_RELOAD: Reload(disposition); break;
- case IDC_RELOAD_IGNORING_CACHE: ReloadIgnoringCache(disposition); break;
- case IDC_HOME: Home(disposition); break;
- case IDC_OPEN_CURRENT_URL: OpenCurrentURL(); break;
- case IDC_STOP: Stop(); break;
+ case IDC_BACK: chrome::GoBack(this, disposition);break;
+ case IDC_FORWARD:
+ chrome::GoForward(this, disposition);
+ break;
+ case IDC_RELOAD: chrome::Reload(this, disposition);break;
+ case IDC_RELOAD_IGNORING_CACHE:
+ chrome::ReloadIgnoringCache(this, disposition);
+ break;
+ case IDC_HOME: chrome::Home(this, disposition); break;
+ case IDC_OPEN_CURRENT_URL: chrome::OpenCurrentURL(this); break;
+ case IDC_STOP: chrome::Stop(this); break;
// Window management commands
- case IDC_NEW_WINDOW: NewWindow(); break;
- case IDC_NEW_INCOGNITO_WINDOW: NewIncognitoWindow(); break;
- case IDC_CLOSE_WINDOW: CloseWindow(); break;
- case IDC_NEW_TAB: NewTab(); break;
- case IDC_CLOSE_TAB: CloseTab(); break;
- case IDC_SELECT_NEXT_TAB: SelectNextTab(); break;
- case IDC_SELECT_PREVIOUS_TAB: SelectPreviousTab(); break;
- case IDC_TABPOSE: OpenTabpose(); break;
- case IDC_MOVE_TAB_NEXT: MoveTabNext(); break;
- case IDC_MOVE_TAB_PREVIOUS: MoveTabPrevious(); break;
+ case IDC_NEW_WINDOW: chrome::NewWindow(this); break;
+ case IDC_NEW_INCOGNITO_WINDOW: chrome::NewIncognitoWindow(this); break;
+ case IDC_CLOSE_WINDOW: chrome::CloseWindow(this); break;
+ case IDC_NEW_TAB: chrome::NewTab(this); break;
+ case IDC_CLOSE_TAB: chrome::CloseTab(this); break;
+ case IDC_SELECT_NEXT_TAB: chrome::SelectNextTab(this); break;
+ case IDC_SELECT_PREVIOUS_TAB: chrome::SelectPreviousTab(this); break;
+ case IDC_TABPOSE: chrome::OpenTabpose(this); break;
+ case IDC_MOVE_TAB_NEXT: chrome::MoveTabNext(this); break;
+ case IDC_MOVE_TAB_PREVIOUS: chrome::MoveTabPrevious(this); break;
case IDC_SELECT_TAB_0:
case IDC_SELECT_TAB_1:
case IDC_SELECT_TAB_2:
@@ -2023,13 +1522,18 @@ void Browser::ExecuteCommandWithDisposition(
case IDC_SELECT_TAB_4:
case IDC_SELECT_TAB_5:
case IDC_SELECT_TAB_6:
- case IDC_SELECT_TAB_7: SelectNumberedTab(id - IDC_SELECT_TAB_0);
- break;
- case IDC_SELECT_LAST_TAB: SelectLastTab(); break;
- case IDC_DUPLICATE_TAB: DuplicateTab(); break;
+ case IDC_SELECT_TAB_7:
+ chrome::SelectNumberedTab(this, id - IDC_SELECT_TAB_0);
+ break;
+ case IDC_SELECT_LAST_TAB: chrome::SelectLastTab(this); break;
+ case IDC_DUPLICATE_TAB: chrome::DuplicateTab(this); break;
case IDC_RESTORE_TAB: RestoreTab(); break;
- case IDC_COPY_URL: WriteCurrentURLToClipboard(); break;
- case IDC_SHOW_AS_TAB: ConvertPopupToTabbedBrowser(); break;
+ case IDC_COPY_URL:
+ chrome::WriteCurrentURLToClipboard(this);
+ break;
+ case IDC_SHOW_AS_TAB:
+ chrome::ConvertPopupToTabbedBrowser(this);
+ break;
case IDC_FULLSCREEN: ToggleFullscreenMode(); break;
#if defined(OS_WIN)
case IDC_METRO_SNAP_ENABLE: SetMetroSnapMode(true); break;
@@ -2038,18 +1542,22 @@ void Browser::ExecuteCommandWithDisposition(
#if defined(OS_MACOSX)
case IDC_PRESENTATION_MODE: TogglePresentationMode(); break;
#endif
- case IDC_EXIT: Exit(); break;
+ case IDC_EXIT: chrome::Exit(); break;
// Page-related commands
- case IDC_SAVE_PAGE: SavePage(); break;
- case IDC_BOOKMARK_PAGE: BookmarkCurrentPage(); break;
- case IDC_PIN_TO_START_SCREEN: PinCurrentPageToStartScreen(); break;
+ case IDC_SAVE_PAGE: chrome::SavePage(this); break;
+ case IDC_BOOKMARK_PAGE: chrome::BookmarkCurrentPage(this);break;
+ case IDC_PIN_TO_START_SCREEN:
+ chrome::PinCurrentPageToStartScreen(this);
+ break;
case IDC_BOOKMARK_ALL_TABS: BookmarkAllTabs(); break;
case IDC_VIEW_SOURCE: ViewSelectedSource(); break;
- case IDC_EMAIL_PAGE_LOCATION: EmailPageLocation(); break;
- case IDC_PRINT: Print(); break;
- case IDC_ADVANCED_PRINT: AdvancedPrint(); break;
- case IDC_CHROME_TO_MOBILE_PAGE: ShowChromeToMobileBubble(); break;
+ case IDC_EMAIL_PAGE_LOCATION: chrome::EmailPageLocation(this); break;
+ case IDC_PRINT: chrome::Print(this); break;
+ case IDC_ADVANCED_PRINT: chrome::AdvancedPrint(this); break;
+ case IDC_CHROME_TO_MOBILE_PAGE:
+ chrome::ShowChromeToMobileBubble(this);
+ break;
case IDC_ENCODING_AUTO_DETECT: ToggleEncodingAutoDetect(); break;
case IDC_ENCODING_UTF8:
case IDC_ENCODING_UTF16LE:
@@ -2090,51 +1598,65 @@ void Browser::ExecuteCommandWithDisposition(
case IDC_ENCODING_WINDOWS1258: OverrideEncoding(id); break;
// Clipboard commands
- case IDC_CUT: Cut(); break;
- case IDC_COPY: Copy(); break;
- case IDC_PASTE: Paste(); break;
+ case IDC_CUT: chrome::Cut(this); break;
+ case IDC_COPY: chrome::Copy(this); break;
+ case IDC_PASTE: chrome::Paste(this); break;
// Find-in-page
- case IDC_FIND: Find(); break;
- case IDC_FIND_NEXT: FindNext(); break;
- case IDC_FIND_PREVIOUS: FindPrevious(); break;
+ case IDC_FIND: chrome::Find(this); break;
+ case IDC_FIND_NEXT: chrome::FindNext(this); break;
+ case IDC_FIND_PREVIOUS: chrome::FindPrevious(this); break;
// Zoom
- case IDC_ZOOM_PLUS: Zoom(content::PAGE_ZOOM_IN); break;
- case IDC_ZOOM_NORMAL: Zoom(content::PAGE_ZOOM_RESET); break;
- case IDC_ZOOM_MINUS: Zoom(content::PAGE_ZOOM_OUT); break;
+ case IDC_ZOOM_PLUS:
+ chrome::Zoom(this, content::PAGE_ZOOM_IN);
+ break;
+ case IDC_ZOOM_NORMAL:
+ chrome::Zoom(this, content::PAGE_ZOOM_RESET);
+ break;
+ case IDC_ZOOM_MINUS:
+ chrome::Zoom(this, content::PAGE_ZOOM_OUT);
+ break;
// Focus various bits of UI
- case IDC_FOCUS_TOOLBAR: FocusToolbar(); break;
- case IDC_FOCUS_LOCATION: FocusLocationBar(); break;
- case IDC_FOCUS_SEARCH: FocusSearch(); break;
- case IDC_FOCUS_MENU_BAR: FocusAppMenu(); break;
- case IDC_FOCUS_BOOKMARKS: FocusBookmarksToolbar(); break;
- case IDC_FOCUS_NEXT_PANE: FocusNextPane(); break;
- case IDC_FOCUS_PREVIOUS_PANE: FocusPreviousPane(); break;
+ case IDC_FOCUS_TOOLBAR: chrome::FocusToolbar(this); break;
+ case IDC_FOCUS_LOCATION: chrome::FocusLocationBar(this); break;
+ case IDC_FOCUS_SEARCH: chrome::FocusSearch(this); break;
+ case IDC_FOCUS_MENU_BAR: chrome::FocusAppMenu(this); break;
+ case IDC_FOCUS_BOOKMARKS:
+ chrome::FocusBookmarksToolbar(this);
+ break;
+ case IDC_FOCUS_NEXT_PANE: chrome::FocusNextPane(this); break;
+ case IDC_FOCUS_PREVIOUS_PANE: chrome::FocusPreviousPane(this); break;
// Show various bits of UI
case IDC_OPEN_FILE: OpenFile(); break;
case IDC_CREATE_SHORTCUTS: OpenCreateShortcutsDialog(); break;
- case IDC_DEV_TOOLS: ToggleDevToolsWindow(
- DEVTOOLS_TOGGLE_ACTION_NONE);
- break;
- case IDC_DEV_TOOLS_CONSOLE: ToggleDevToolsWindow(
- DEVTOOLS_TOGGLE_ACTION_SHOW_CONSOLE);
- break;
- case IDC_DEV_TOOLS_INSPECT: ToggleDevToolsWindow(
- DEVTOOLS_TOGGLE_ACTION_INSPECT);
- break;
- case IDC_TASK_MANAGER: OpenTaskManager(false); break;
- case IDC_VIEW_BACKGROUND_PAGES: OpenTaskManager(true); break;
- case IDC_FEEDBACK: OpenFeedbackDialog(); break;
-
- case IDC_SHOW_BOOKMARK_BAR: ToggleBookmarkBar(); break;
+ case IDC_DEV_TOOLS:
+ chrome::ToggleDevToolsWindow(this, DEVTOOLS_TOGGLE_ACTION_NONE);
+ break;
+ case IDC_DEV_TOOLS_CONSOLE:
+ chrome::ToggleDevToolsWindow(this, DEVTOOLS_TOGGLE_ACTION_SHOW_CONSOLE);
+ break;
+ case IDC_DEV_TOOLS_INSPECT:
+ chrome::ToggleDevToolsWindow(this, DEVTOOLS_TOGGLE_ACTION_INSPECT);
+ break;
+ case IDC_TASK_MANAGER:
+ chrome::OpenTaskManager(this, false);
+ break;
+ case IDC_VIEW_BACKGROUND_PAGES:
+ chrome::OpenTaskManager(this, true);
+ break;
+ case IDC_FEEDBACK:
+ chrome::OpenFeedbackDialog(this);
+ break;
+
+ case IDC_SHOW_BOOKMARK_BAR: chrome::ToggleBookmarkBar(this); break;
case IDC_PROFILING_ENABLED: Profiling::Toggle(); break;
case IDC_SHOW_BOOKMARK_MANAGER: chrome::ShowBookmarkManager(this);break;
- case IDC_SHOW_APP_MENU: ShowAppMenu(); break;
- case IDC_SHOW_AVATAR_MENU: ShowAvatarMenu(); break;
+ case IDC_SHOW_APP_MENU: chrome::ShowAppMenu(this); break;
+ case IDC_SHOW_AVATAR_MENU: chrome::ShowAvatarMenu(this); break;
case IDC_SHOW_HISTORY: chrome::ShowHistory(this); break;
case IDC_SHOW_DOWNLOADS: chrome::ShowDownloads(this); break;
case IDC_MANAGE_EXTENSIONS: chrome::ShowExtensions(this); break;
@@ -2148,7 +1670,9 @@ void Browser::ExecuteCommandWithDisposition(
break;
case IDC_IMPORT_SETTINGS: chrome::ShowImportDialog(this); break;
case IDC_ABOUT: chrome::ShowAboutChrome(this); break;
- case IDC_UPGRADE_DIALOG: OpenUpdateChromeDialog(); break;
+ case IDC_UPGRADE_DIALOG:
+ chrome::OpenUpdateChromeDialog(this);
+ break;
case IDC_VIEW_INCOMPATIBILITIES:
chrome::ShowConflicts(this);
break;
@@ -2161,7 +1685,7 @@ void Browser::ExecuteCommandWithDisposition(
case IDC_SHOW_SYNC_SETUP:
chrome::ShowSyncSetup(this, SyncPromoUI::SOURCE_MENU);
break;
- case IDC_TOGGLE_SPEECH_INPUT: ToggleSpeechInput(); break;
+ case IDC_TOGGLE_SPEECH_INPUT: chrome::ToggleSpeechInput(this); break;
default:
LOG(WARNING) << "Received Unimplemented Command: " << id;
@@ -2453,7 +1977,7 @@ void Browser::ActiveTabChanged(TabContents* old_contents,
static int reload_count = 0;
UMA_HISTOGRAM_CUSTOM_COUNTS(
"Tabs.SadTab.ReloadCount", ++reload_count, 1, 1000, 50);
- Reload(CURRENT_TAB);
+ chrome::Reload(this, CURRENT_TAB);
did_reload = true;
}
}
@@ -2464,7 +1988,7 @@ void Browser::ActiveTabChanged(TabContents* old_contents,
static int reload_count = 0;
UMA_HISTOGRAM_CUSTOM_COUNTS(
"Tabs.Discard.ReloadCount", ++reload_count, 1, 1000, 50);
- Reload(CURRENT_TAB);
+ chrome::Reload(this, CURRENT_TAB);
}
// If we have any update pending, do it now.
@@ -3676,7 +3200,8 @@ void Browser::InitCommandState() {
UpdateOpenFileState();
command_updater_.UpdateCommandEnabled(IDC_CREATE_SHORTCUTS, false);
UpdateCommandsForDevTools();
- command_updater_.UpdateCommandEnabled(IDC_TASK_MANAGER, CanOpenTaskManager());
+ command_updater_.UpdateCommandEnabled(IDC_TASK_MANAGER,
+ chrome::CanOpenTaskManager());
command_updater_.UpdateCommandEnabled(IDC_SHOW_HISTORY, true);
command_updater_.UpdateCommandEnabled(IDC_SHOW_DOWNLOADS, true);
command_updater_.UpdateCommandEnabled(IDC_HELP_PAGE_VIA_KEYBOARD, true);
@@ -4322,21 +3847,6 @@ void Browser::SetAsDelegate(TabContents* tab, Browser* delegate) {
tab->search_engine_tab_helper()->set_delegate(delegate);
}
-void Browser::FindInPage(bool find_next, bool forward_direction) {
- ShowFindBar();
- if (find_next) {
- string16 find_text;
-#if defined(OS_MACOSX)
- // We always want to search for the contents of the find pasteboard on OS X.
- find_text = GetFindPboardText();
-#endif
- GetActiveTabContents()->
- find_tab_helper()->StartFinding(find_text,
- forward_direction,
- false); // Not case sensitive.
- }
-}
-
void Browser::CloseFrame() {
window_->Close();
}
@@ -4397,61 +3907,6 @@ void Browser::RegisterAppPrefs(const std::string& app_name, Profile* profile) {
}
}
-void Browser::ReloadInternal(WindowOpenDisposition disposition,
- bool ignore_cache) {
- // If we are showing an interstitial, treat this as an OpenURL.
- WebContents* current_tab = GetActiveWebContents();
- if (current_tab && current_tab->ShowingInterstitialPage()) {
- NavigationEntry* entry = current_tab->GetController().GetActiveEntry();
- DCHECK(entry); // Should exist if interstitial is showing.
- OpenURL(OpenURLParams(
- entry->GetURL(), Referrer(), disposition,
- content::PAGE_TRANSITION_RELOAD, false));
- return;
- }
-
- // As this is caused by a user action, give the focus to the page.
- //
- // Also notify RenderViewHostDelegate of the user gesture; this is
- // normally done in Browser::Navigate, but a reload bypasses Navigate.
- WebContents* web_contents = GetOrCloneTabForDisposition(disposition);
- web_contents->UserGestureDone();
- if (!web_contents->FocusLocationBarByDefault())
- web_contents->Focus();
- if (ignore_cache)
- web_contents->GetController().ReloadIgnoringCache(true);
- else
- web_contents->GetController().Reload(true);
-}
-
-WebContents* Browser::GetOrCloneTabForDisposition(
- WindowOpenDisposition disposition) {
- TabContents* current_tab = GetActiveTabContents();
- switch (disposition) {
- case NEW_FOREGROUND_TAB:
- case NEW_BACKGROUND_TAB: {
- current_tab = current_tab->Clone();
- tab_strip_model_->AddTabContents(
- current_tab, -1, content::PAGE_TRANSITION_LINK,
- disposition == NEW_FOREGROUND_TAB ? TabStripModel::ADD_ACTIVE :
- TabStripModel::ADD_NONE);
- break;
- }
- case NEW_WINDOW: {
- current_tab = current_tab->Clone();
- Browser* browser = Browser::Create(profile_);
- browser->tab_strip_model()->AddTabContents(
- current_tab, -1, content::PAGE_TRANSITION_LINK,
- TabStripModel::ADD_ACTIVE);
- browser->window()->Show();
- break;
- }
- default:
- break;
- }
- return current_tab->web_contents();
-}
-
bool Browser::SupportsWindowFeatureImpl(WindowFeature feature,
bool check_fullscreen) const {
// On Mac, fullscreen mode has most normal things (in a slide-down panel). On
@@ -4483,48 +3938,6 @@ bool Browser::SupportsWindowFeatureImpl(WindowFeature feature,
return !!(features & feature);
}
-bool Browser::OpenInstant(WindowOpenDisposition disposition) {
- if (!instant() || !instant()->PrepareForCommit() ||
- disposition == NEW_BACKGROUND_TAB) {
- // NEW_BACKGROUND_TAB results in leaving the omnibox open, so we don't
- // attempt to use the instant preview.
- return false;
- }
-
- if (disposition == CURRENT_TAB) {
- content::NotificationService::current()->Notify(
- chrome::NOTIFICATION_INSTANT_COMMITTED,
- content::Source<TabContents>(instant()->CommitCurrentPreview(
- INSTANT_COMMIT_PRESSED_ENTER)),
- content::NotificationService::NoDetails());
- return true;
- }
- if (disposition == NEW_FOREGROUND_TAB) {
- TabContents* preview_contents = instant()->ReleasePreviewContents(
- INSTANT_COMMIT_PRESSED_ENTER, NULL);
- // HideInstant is invoked after release so that InstantController is not
- // active when HideInstant asks it for its state.
- HideInstant();
- preview_contents->web_contents()->GetController().PruneAllButActive();
- tab_strip_model_->AddTabContents(
- preview_contents,
- -1,
- instant()->last_transition_type(),
- TabStripModel::ADD_ACTIVE);
- instant()->CompleteRelease(preview_contents);
- content::NotificationService::current()->Notify(
- chrome::NOTIFICATION_INSTANT_COMMITTED,
- content::Source<TabContents>(preview_contents),
- content::NotificationService::NoDetails());
- return true;
- }
- // The omnibox currently doesn't use other dispositions, so we don't attempt
- // to handle them. If you hit this NOTREACHED file a bug and I'll (sky) add
- // support for the new disposition.
- NOTREACHED();
- return false;
-}
-
void Browser::CreateInstantIfNecessary() {
if (is_type_tabbed() && InstantController::IsEnabled(profile()) &&
!profile()->IsOffTheRecord()) {
diff --git a/chrome/browser/ui/browser.h b/chrome/browser/ui/browser.h
index d3f3fb3..11a585e 100644
--- a/chrome/browser/ui/browser.h
+++ b/chrome/browser/ui/browser.h
@@ -296,23 +296,6 @@ class Browser : public TabStripModelDelegate,
// Returns the state of the bookmark bar.
BookmarkBar::State bookmark_bar_state() const { return bookmark_bar_state_; }
- // Browser Creation Helpers /////////////////////////////////////////////////
-
- // Opens a new window with the default blank tab.
- static void NewEmptyWindow(Profile* profile);
-
- // Opens a new window with the default blank tab. This bypasses metrics and
- // various internal bookkeeping; NewEmptyWindow (above) is preferred.
- static Browser* OpenEmptyWindow(Profile* profile);
-
- // Opens a new window with the tabs from |profile|'s TabRestoreService.
- static void OpenWindowWithRestoredTabs(Profile* profile);
-
- // Opens the specified URL in a new browser window in an incognito session.
- // If there is already an existing active incognito session for the specified
- // |profile|, that session is re-used.
- static void OpenURLOffTheRecord(Profile* profile, const GURL& url);
-
// State Storage and Retrieval for UI ///////////////////////////////////////
// Gets the Favicon of the page in the selected tab.
@@ -447,10 +430,6 @@ class Browser : public TabStripModelDelegate,
const std::string& extension_app_id,
content::SessionStorageNamespace* session_storage_namespace);
- // Navigate to an index in the tab history, opening a new tab depending on the
- // disposition.
- bool NavigateToIndexWithDisposition(int index, WindowOpenDisposition disp);
-
// Invoked when the fullscreen state of the window changes.
// BrowserWindow::EnterFullscreen invokes this after the window has become
// fullscreen.
@@ -461,32 +440,6 @@ class Browser : public TabStripModelDelegate,
// NOTE: Within each of the following sections, the IDs are ordered roughly by
// how they appear in the GUI/menus (left to right, top to bottom, etc.).
- // Navigation commands
- bool CanGoBack() const;
- void GoBack(WindowOpenDisposition disposition);
- bool CanGoForward() const;
- void GoForward(WindowOpenDisposition disposition);
- void Reload(WindowOpenDisposition disposition);
- void ReloadIgnoringCache(WindowOpenDisposition disposition); // Shift-reload.
- void Home(WindowOpenDisposition disposition);
- void OpenCurrentURL();
- void Stop();
- // Window management commands
- void NewWindow();
- void NewIncognitoWindow();
- void CloseWindow();
- void NewTab();
- void CloseTab();
- void SelectNextTab();
- void SelectPreviousTab();
- void OpenTabpose();
- void MoveTabNext();
- void MoveTabPrevious();
- void SelectNumberedTab(int index);
- void SelectLastTab();
- void DuplicateTab();
- void WriteCurrentURLToClipboard();
- void ConvertPopupToTabbedBrowser();
// In kiosk mode, the first toggle is valid, the rest is discarded.
void ToggleFullscreenMode();
// See the description of
@@ -499,19 +452,9 @@ class Browser : public TabStripModelDelegate,
#if defined(OS_MACOSX)
void TogglePresentationMode();
#endif
- void Exit();
// Page-related commands
- void BookmarkCurrentPage();
- void PinCurrentPageToStartScreen();
- void SavePage();
void ViewSelectedSource();
- void ShowFindBar();
- void ShowPageInfo(content::WebContents* web_contents,
- const GURL& url,
- const content::SSLStatus& ssl,
- bool show_history);
- void ShowChromeToMobileBubble();
// Returns true if the Browser supports the specified feature. The value of
// this varies during the lifetime of the browser. For example, if the window
@@ -526,52 +469,18 @@ class Browser : public TabStripModelDelegate,
// TODO(port): port these, and re-merge the two function declaration lists.
// Page-related commands.
- void Print();
- void AdvancedPrint();
- void EmailPageLocation();
void ToggleEncodingAutoDetect();
void OverrideEncoding(int encoding_id);
- // Clipboard commands
- void Cut();
- void Copy();
- void Paste();
-
- // Find-in-page
- void Find();
- void FindNext();
- void FindPrevious();
-
- // Zoom
- void Zoom(content::PageZoom zoom);
-
- // Focus various bits of UI
- void FocusToolbar();
- void FocusLocationBar(); // Also selects any existing text.
- void FocusSearch();
- void FocusAppMenu();
- void FocusBookmarksToolbar();
- void FocusNextPane();
- void FocusPreviousPane();
-
// Show various bits of UI
void OpenFile();
void OpenCreateShortcutsDialog();
- void ToggleDevToolsWindow(DevToolsToggleAction action);
- // Returns true if the task manager can be opened.
- bool CanOpenTaskManager();
- void OpenTaskManager(bool highlight_background_resources);
- void OpenFeedbackDialog();
+ void UpdateDownloadShelfVisibility(bool visible);
- void ToggleBookmarkBar();
-
- void ShowAppMenu();
- void ShowAvatarMenu();
- void OpenUpdateChromeDialog();
- void ToggleSpeechInput();
-
- virtual void UpdateDownloadShelfVisibility(bool visible);
+ // Commits the current instant, returning true on success. This is intended
+ // for use from OpenCurrentURL.
+ bool OpenInstant(WindowOpenDisposition disposition);
/////////////////////////////////////////////////////////////////////////////
@@ -1190,10 +1099,6 @@ class Browser : public TabStripModelDelegate,
bool SupportsWindowFeatureImpl(WindowFeature feature,
bool check_fullscreen) const;
- // Commits the current instant, returning true on success. This is intended
- // for use from OpenCurrentURL.
- bool OpenInstant(WindowOpenDisposition disposition);
-
// If this browser should have instant one is created, otherwise does nothing.
void CreateInstantIfNecessary();
diff --git a/chrome/browser/ui/browser_browsertest.cc b/chrome/browser/ui/browser_browsertest.cc
index 2c58cb8..09f4919 100644
--- a/chrome/browser/ui/browser_browsertest.cc
+++ b/chrome/browser/ui/browser_browsertest.cc
@@ -28,6 +28,7 @@
#include "chrome/browser/ui/app_modal_dialogs/javascript_app_modal_dialog.h"
#include "chrome/browser/ui/app_modal_dialogs/native_app_modal_dialog.h"
#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/browser_navigator.h"
@@ -143,7 +144,7 @@ class MockTabStripModelObserver : public TabStripModelObserver {
// Used by CloseWithAppMenuOpen. Invokes CloseWindow on the supplied browser.
void CloseWindowCallback(Browser* browser) {
- browser->CloseWindow();
+ chrome::CloseWindow(browser);
}
// Used by CloseWithAppMenuOpen. Posts a CloseWindowCallback and shows the app
@@ -152,7 +153,7 @@ void RunCloseWithAppMenuCallback(Browser* browser) {
// ShowAppMenu is modal under views. Schedule a task that closes the window.
MessageLoop::current()->PostTask(
FROM_HERE, base::Bind(&CloseWindowCallback, browser));
- browser->ShowAppMenu();
+ chrome::ShowAppMenu(browser);
}
// Displays "INTERSTITIAL" while the interstitial is attached.
@@ -312,7 +313,7 @@ IN_PROC_BROWSER_TEST_F(BrowserTest, ReloadThenCancelBeforeUnload) {
// Navigate to another page, but click cancel in the dialog. Make sure that
// the throbber stops spinning.
- browser()->Reload(CURRENT_TAB);
+ chrome::Reload(browser(), CURRENT_TAB);
AppModalDialog* alert = ui_test_utils::WaitForAppModalDialog();
alert->CloseModalDialog();
EXPECT_FALSE(browser()->GetActiveWebContents()->IsLoading());
@@ -402,7 +403,7 @@ IN_PROC_BROWSER_TEST_F(BrowserTest, MAYBE_BeforeUnloadVsBeforeReload) {
ui_test_utils::NavigateToURL(browser(), url);
// Reload the page, and check that we get a "before reload" dialog.
- browser()->Reload(CURRENT_TAB);
+ chrome::Reload(browser(), CURRENT_TAB);
AppModalDialog* alert = ui_test_utils::WaitForAppModalDialog();
EXPECT_TRUE(static_cast<JavaScriptAppModalDialog*>(alert)->is_reload());
@@ -911,10 +912,10 @@ IN_PROC_BROWSER_TEST_F(BrowserTest, RestorePinnedTabs) {
ui_test_utils::NavigateToURL(browser(), url);
// Add a non pinned tab.
- browser()->NewTab();
+ chrome::NewTab(browser());
// Add a pinned non-app tab.
- browser()->NewTab();
+ chrome::NewTab(browser());
ui_test_utils::NavigateToURL(browser(), GURL(chrome::kAboutBlankURL));
model->SetTabPinned(2, true);
@@ -1071,7 +1072,7 @@ IN_PROC_BROWSER_TEST_F(BrowserTest, ForwardDisabledOnForward) {
content::NOTIFICATION_LOAD_STOP,
content::Source<NavigationController>(
&browser()->GetActiveWebContents()->GetController()));
- browser()->GoBack(CURRENT_TAB);
+ chrome::GoBack(browser(), CURRENT_TAB);
back_nav_load_observer.Wait();
EXPECT_TRUE(browser()->command_updater()->IsCommandEnabled(IDC_FORWARD));
@@ -1079,7 +1080,7 @@ IN_PROC_BROWSER_TEST_F(BrowserTest, ForwardDisabledOnForward) {
content::NOTIFICATION_LOAD_STOP,
content::Source<NavigationController>(
&browser()->GetActiveWebContents()->GetController()));
- browser()->GoForward(CURRENT_TAB);
+ chrome::GoForward(browser(), CURRENT_TAB);
// This check will happen before the navigation completes, since the browser
// won't process the renderer's response until the Wait() call below.
EXPECT_FALSE(browser()->command_updater()->IsCommandEnabled(IDC_FORWARD));
@@ -1212,7 +1213,7 @@ IN_PROC_BROWSER_TEST_F(BrowserTest, PageZoom) {
ui_test_utils::WindowedNotificationObserver zoom_in_observer(
content::NOTIFICATION_ZOOM_LEVEL_CHANGED,
content::NotificationService::AllSources());
- browser()->Zoom(content::PAGE_ZOOM_IN);
+ chrome::Zoom(browser(), content::PAGE_ZOOM_IN);
zoom_in_observer.Wait();
EXPECT_EQ(contents->GetZoomPercent(&enable_plus, &enable_minus), 110);
EXPECT_TRUE(enable_plus);
@@ -1221,7 +1222,7 @@ IN_PROC_BROWSER_TEST_F(BrowserTest, PageZoom) {
ui_test_utils::WindowedNotificationObserver zoom_reset_observer(
content::NOTIFICATION_ZOOM_LEVEL_CHANGED,
content::NotificationService::AllSources());
- browser()->Zoom(content::PAGE_ZOOM_RESET);
+ chrome::Zoom(browser(), content::PAGE_ZOOM_RESET);
zoom_reset_observer.Wait();
EXPECT_EQ(contents->GetZoomPercent(&enable_plus, &enable_minus), 100);
EXPECT_TRUE(enable_plus);
@@ -1230,13 +1231,13 @@ IN_PROC_BROWSER_TEST_F(BrowserTest, PageZoom) {
ui_test_utils::WindowedNotificationObserver zoom_out_observer(
content::NOTIFICATION_ZOOM_LEVEL_CHANGED,
content::NotificationService::AllSources());
- browser()->Zoom(content::PAGE_ZOOM_OUT);
+ chrome::Zoom(browser(), content::PAGE_ZOOM_OUT);
zoom_out_observer.Wait();
EXPECT_EQ(contents->GetZoomPercent(&enable_plus, &enable_minus), 90);
EXPECT_TRUE(enable_plus);
EXPECT_TRUE(enable_minus);
- browser()->Zoom(content::PAGE_ZOOM_RESET);
+ chrome::Zoom(browser(), content::PAGE_ZOOM_RESET);
}
IN_PROC_BROWSER_TEST_F(BrowserTest, InterstitialCommandDisable) {
@@ -1319,7 +1320,7 @@ IN_PROC_BROWSER_TEST_F(BrowserTest, UserGesturesReported) {
EXPECT_TRUE(mock_observer.got_user_gesture());
mock_observer.set_got_user_gesture(false);
- browser()->Reload(CURRENT_TAB);
+ chrome::Reload(browser(), CURRENT_TAB);
EXPECT_TRUE(mock_observer.got_user_gesture());
}
@@ -1519,12 +1520,12 @@ IN_PROC_BROWSER_TEST_F(RunInBackgroundTest, RunInBackgroundBasicTest) {
ui_test_utils::WindowedNotificationObserver observer(
chrome::NOTIFICATION_BROWSER_CLOSED,
content::Source<Browser>(browser()));
- browser()->CloseWindow();
+ chrome::CloseWindow(browser());
observer.Wait();
EXPECT_EQ(0u, BrowserList::size());
ui_test_utils::BrowserAddedObserver browser_added_observer;
- Browser::NewEmptyWindow(profile);
+ chrome::NewEmptyWindow(profile);
browser_added_observer.WaitForSingleNewBrowser();
EXPECT_EQ(1u, BrowserList::size());
diff --git a/chrome/browser/ui/browser_commands.cc b/chrome/browser/ui/browser_commands.cc
new file mode 100644
index 0000000..48e666e
--- /dev/null
+++ b/chrome/browser/ui/browser_commands.cc
@@ -0,0 +1,682 @@
+// Copyright (c) 2012 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/ui/browser_commands.h"
+
+#include "base/command_line.h"
+#include "base/metrics/histogram.h"
+#include "base/utf_string_conversions.h"
+#include "chrome/browser/bookmarks/bookmark_model.h"
+#include "chrome/browser/bookmarks/bookmark_utils.h"
+#include "chrome/browser/browser_process.h"
+#include "chrome/browser/chrome_page_zoom.h"
+#include "chrome/browser/debugger/devtools_window.h"
+#include "chrome/browser/extensions/extension_service.h"
+#include "chrome/browser/favicon/favicon_tab_helper.h"
+#include "chrome/browser/lifetime/application_lifetime.h"
+#include "chrome/browser/platform_util.h"
+#include "chrome/browser/prefs/incognito_mode_prefs.h"
+#include "chrome/browser/prefs/pref_service.h"
+#include "chrome/browser/printing/print_view_manager.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/sessions/session_service_factory.h"
+#include "chrome/browser/sessions/tab_restore_service_factory.h"
+#include "chrome/browser/sessions/tab_restore_service.h"
+#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_finder.h"
+#include "chrome/browser/ui/browser_window.h"
+#include "chrome/browser/ui/find_bar/find_bar_controller.h"
+#include "chrome/browser/ui/find_bar/find_tab_helper.h"
+#include "chrome/browser/ui/omnibox/location_bar.h"
+#include "chrome/browser/ui/status_bubble.h"
+#include "chrome/browser/ui/tab_contents/tab_contents.h"
+#include "chrome/browser/ui/tabs/tab_strip_model.h"
+#include "chrome/browser/ui/webui/feedback_ui.h"
+#include "chrome/browser/ui/webui/ntp/app_launcher_handler.h"
+#include "chrome/common/chrome_switches.h"
+#include "chrome/common/net/url_util.h"
+#include "chrome/common/pref_names.h"
+#include "content/public/browser/navigation_controller.h"
+#include "content/public/browser/navigation_entry.h"
+#include "content/public/browser/page_navigator.h"
+#include "content/public/browser/render_view_host.h"
+#include "content/public/browser/user_metrics.h"
+#include "content/public/browser/web_contents.h"
+#include "content/public/browser/web_contents_view.h"
+#include "net/base/escape.h"
+
+#if defined(OS_MACOSX)
+#include "ui/base/cocoa/find_pasteboard.h"
+#endif
+
+#if defined(OS_WIN)
+#include "base/win/metro.h"
+#endif
+
+using content::NavigationController;
+using content::NavigationEntry;
+using content::OpenURLParams;
+using content::Referrer;
+using content::SSLStatus;
+using content::UserMetricsAction;
+using content::WebContents;
+
+namespace chrome {
+namespace {
+
+WebContents* GetOrCloneTabForDisposition(Browser* browser,
+ WindowOpenDisposition disposition) {
+ TabContents* current_tab = browser->GetActiveTabContents();
+ switch (disposition) {
+ case NEW_FOREGROUND_TAB:
+ case NEW_BACKGROUND_TAB: {
+ current_tab = current_tab->Clone();
+ browser->tab_strip_model()->AddTabContents(
+ current_tab, -1, content::PAGE_TRANSITION_LINK,
+ disposition == NEW_FOREGROUND_TAB ? TabStripModel::ADD_ACTIVE :
+ TabStripModel::ADD_NONE);
+ break;
+ }
+ case NEW_WINDOW: {
+ current_tab = current_tab->Clone();
+ Browser* b = Browser::Create(browser->profile());
+ b->tab_strip_model()->AddTabContents(
+ current_tab, -1, content::PAGE_TRANSITION_LINK,
+ TabStripModel::ADD_ACTIVE);
+ b->window()->Show();
+ break;
+ }
+ default:
+ break;
+ }
+ return current_tab->web_contents();
+}
+
+void ReloadInternal(Browser* browser,
+ WindowOpenDisposition disposition,
+ bool ignore_cache) {
+ // If we are showing an interstitial, treat this as an OpenURL.
+ WebContents* current_tab = browser->GetActiveWebContents();
+ if (current_tab && current_tab->ShowingInterstitialPage()) {
+ NavigationEntry* entry = current_tab->GetController().GetActiveEntry();
+ DCHECK(entry); // Should exist if interstitial is showing.
+ browser->OpenURL(OpenURLParams(
+ entry->GetURL(), Referrer(), disposition,
+ content::PAGE_TRANSITION_RELOAD, false));
+ return;
+ }
+
+ // As this is caused by a user action, give the focus to the page.
+ //
+ // Also notify RenderViewHostDelegate of the user gesture; this is
+ // normally done in Browser::Navigate, but a reload bypasses Navigate.
+ WebContents* web_contents = GetOrCloneTabForDisposition(browser, disposition);
+ web_contents->UserGestureDone();
+ if (!web_contents->FocusLocationBarByDefault())
+ web_contents->Focus();
+ if (ignore_cache)
+ web_contents->GetController().ReloadIgnoringCache(true);
+ else
+ web_contents->GetController().Reload(true);
+}
+
+} // namespace
+
+void NewEmptyWindow(Profile* profile) {
+ bool incognito = profile->IsOffTheRecord();
+ PrefService* prefs = profile->GetPrefs();
+ if (incognito) {
+ if (IncognitoModePrefs::GetAvailability(prefs) ==
+ IncognitoModePrefs::DISABLED) {
+ incognito = false;
+ }
+ } else {
+ if (browser_defaults::kAlwaysOpenIncognitoWindow &&
+ IncognitoModePrefs::ShouldLaunchIncognito(
+ *CommandLine::ForCurrentProcess(), prefs)) {
+ incognito = true;
+ }
+ }
+
+ if (incognito) {
+ content::RecordAction(UserMetricsAction("NewIncognitoWindow"));
+ OpenEmptyWindow(profile->GetOffTheRecordProfile());
+ } else {
+ content::RecordAction(UserMetricsAction("NewWindow"));
+ SessionService* session_service =
+ SessionServiceFactory::GetForProfile(profile->GetOriginalProfile());
+ if (!session_service ||
+ !session_service->RestoreIfNecessary(std::vector<GURL>())) {
+ OpenEmptyWindow(profile->GetOriginalProfile());
+ }
+ }
+}
+
+Browser* OpenEmptyWindow(Profile* profile) {
+ Browser* browser = Browser::Create(profile);
+ browser->AddBlankTab(true);
+ browser->window()->Show();
+ return browser;
+}
+
+void OpenWindowWithRestoredTabs(Profile* profile) {
+ TabRestoreService* service = TabRestoreServiceFactory::GetForProfile(profile);
+ if (service)
+ service->RestoreMostRecentEntry(NULL);
+}
+
+void OpenURLOffTheRecord(Profile* profile, const GURL& url) {
+ Browser* browser = browser::FindOrCreateTabbedBrowser(
+ profile->GetOffTheRecordProfile());
+ browser->AddSelectedTabWithURL(url, content::PAGE_TRANSITION_LINK);
+ browser->window()->Show();
+}
+
+bool CanGoBack(Browser* browser) {
+ return browser->GetActiveWebContents()->GetController().CanGoBack();
+}
+
+void GoBack(Browser* browser, WindowOpenDisposition disposition) {
+ content::RecordAction(UserMetricsAction("Back"));
+
+ TabContents* current_tab = browser->GetActiveTabContents();
+ if (CanGoBack(browser)) {
+ WebContents* new_tab = GetOrCloneTabForDisposition(browser, disposition);
+ // If we are on an interstitial page and clone the tab, it won't be copied
+ // to the new tab, so we don't need to go back.
+ if (current_tab->web_contents()->ShowingInterstitialPage() &&
+ (new_tab != current_tab->web_contents()))
+ return;
+ new_tab->GetController().GoBack();
+ }
+}
+
+bool CanGoForward(Browser* browser) {
+ return browser->GetActiveWebContents()->GetController().CanGoForward();
+}
+
+void GoForward(Browser* browser, WindowOpenDisposition disposition) {
+ content::RecordAction(UserMetricsAction("Forward"));
+ if (CanGoForward(browser)) {
+ GetOrCloneTabForDisposition(browser, disposition)->
+ GetController().GoForward();
+ }
+}
+
+bool NavigateToIndexWithDisposition(Browser* browser,
+ int index,
+ WindowOpenDisposition disp) {
+ NavigationController& controller =
+ GetOrCloneTabForDisposition(browser, disp)->GetController();
+ if (index < 0 || index >= controller.GetEntryCount())
+ return false;
+ controller.GoToIndex(index);
+ return true;
+}
+
+void Reload(Browser* browser, WindowOpenDisposition disposition) {
+ content::RecordAction(UserMetricsAction("Reload"));
+ ReloadInternal(browser, disposition, false);
+}
+
+void ReloadIgnoringCache(Browser* browser, WindowOpenDisposition disposition) {
+ content::RecordAction(UserMetricsAction("ReloadIgnoringCache"));
+ ReloadInternal(browser, disposition, true);
+}
+
+void Home(Browser* browser, WindowOpenDisposition disposition) {
+ content::RecordAction(UserMetricsAction("Home"));
+ browser->OpenURL(OpenURLParams(
+ browser->profile()->GetHomePage(), Referrer(), disposition,
+ content::PageTransitionFromInt(
+ content::PAGE_TRANSITION_AUTO_BOOKMARK |
+ content::PAGE_TRANSITION_HOME_PAGE),
+ false));
+}
+
+void OpenCurrentURL(Browser* browser) {
+ content::RecordAction(UserMetricsAction("LoadURL"));
+ LocationBar* location_bar = browser->window()->GetLocationBar();
+ if (!location_bar)
+ return;
+
+ WindowOpenDisposition open_disposition =
+ location_bar->GetWindowOpenDisposition();
+ if (browser->OpenInstant(open_disposition))
+ return;
+
+ GURL url(location_bar->GetInputString());
+
+ browser::NavigateParams params(browser, url,
+ location_bar->GetPageTransition());
+ params.disposition = open_disposition;
+ // Use ADD_INHERIT_OPENER so that all pages opened by the omnibox at least
+ // inherit the opener. In some cases the tabstrip will determine the group
+ // should be inherited, in which case the group is inherited instead of the
+ // opener.
+ params.tabstrip_add_types =
+ TabStripModel::ADD_FORCE_INDEX | TabStripModel::ADD_INHERIT_OPENER;
+ browser::Navigate(&params);
+
+ DCHECK(browser->profile()->GetExtensionService());
+ if (browser->profile()->GetExtensionService()->IsInstalledApp(url)) {
+ AppLauncherHandler::RecordAppLaunchType(
+ extension_misc::APP_LAUNCH_OMNIBOX_LOCATION);
+ }
+}
+
+void Stop(Browser* browser) {
+ content::RecordAction(UserMetricsAction("Stop"));
+ browser->GetActiveWebContents()->Stop();
+}
+
+#if !defined(OS_WIN)
+void NewWindow(Browser* browser) {
+ NewEmptyWindow(browser->profile()->GetOriginalProfile());
+}
+
+void NewIncognitoWindow(Browser* browser) {
+ NewEmptyWindow(browser->profile()->GetOffTheRecordProfile());
+}
+#endif // OS_WIN
+
+void CloseWindow(Browser* browser) {
+ content::RecordAction(UserMetricsAction("CloseWindow"));
+ browser->window()->Close();
+}
+
+void NewTab(Browser* browser) {
+ content::RecordAction(UserMetricsAction("NewTab"));
+ // TODO(asvitkine): This is invoked programmatically from several places.
+ // Audit the code and change it so that the histogram only gets collected for
+ // user-initiated commands.
+ UMA_HISTOGRAM_ENUMERATION("Tab.NewTab", TabStripModel::NEW_TAB_COMMAND,
+ TabStripModel::NEW_TAB_ENUM_COUNT);
+
+ if (browser->is_type_tabbed()) {
+ browser->AddBlankTab(true);
+ browser->GetActiveWebContents()->GetView()->RestoreFocus();
+ } else {
+ Browser* b = browser::FindOrCreateTabbedBrowser(browser->profile());
+ b->AddBlankTab(true);
+ b->window()->Show();
+ // The call to AddBlankTab above did not set the focus to the tab as its
+ // window was not active, so we have to do it explicitly.
+ // See http://crbug.com/6380.
+ b->GetActiveWebContents()->GetView()->RestoreFocus();
+ }
+}
+
+void CloseTab(Browser* browser) {
+ content::RecordAction(UserMetricsAction("CloseTab_Accelerator"));
+ browser->tab_strip_model()->CloseSelectedTabs();
+}
+
+void SelectNextTab(Browser* browser) {
+ content::RecordAction(UserMetricsAction("SelectNextTab"));
+ browser->tab_strip_model()->SelectNextTab();
+}
+
+void SelectPreviousTab(Browser* browser) {
+ content::RecordAction(UserMetricsAction("SelectPrevTab"));
+ browser->tab_strip_model()->SelectPreviousTab();
+}
+
+void OpenTabpose(Browser* browser) {
+#if defined(OS_MACOSX)
+ if (!CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kEnableExposeForTabs)) {
+ return;
+ }
+
+ content::RecordAction(UserMetricsAction("OpenTabpose"));
+ browser->window()->OpenTabpose();
+#else
+ NOTREACHED();
+#endif
+}
+
+void MoveTabNext(Browser* browser) {
+ content::RecordAction(UserMetricsAction("MoveTabNext"));
+ browser->tab_strip_model()->MoveTabNext();
+}
+
+void MoveTabPrevious(Browser* browser) {
+ content::RecordAction(UserMetricsAction("MoveTabPrevious"));
+ browser->tab_strip_model()->MoveTabPrevious();
+}
+
+void SelectNumberedTab(Browser* browser, int index) {
+ if (index < browser->tab_count()) {
+ content::RecordAction(UserMetricsAction("SelectNumberedTab"));
+ browser->ActivateTabAt(index, true);
+ }
+}
+
+void SelectLastTab(Browser* browser) {
+ content::RecordAction(UserMetricsAction("SelectLastTab"));
+ browser->tab_strip_model()->SelectLastTab();
+}
+
+void DuplicateTab(Browser* browser) {
+ content::RecordAction(UserMetricsAction("Duplicate"));
+ browser->DuplicateContentsAt(browser->active_index());
+}
+
+void WriteCurrentURLToClipboard(Browser* browser) {
+ // TODO(ericu): There isn't currently a metric for this. Should there be?
+ // We don't appear to track the action when it comes from the
+ // RenderContextViewMenu.
+
+ WebContents* contents = browser->GetActiveWebContents();
+ if (!browser->toolbar_model()->ShouldDisplayURL())
+ return;
+
+ chrome_common_net::WriteURLToClipboard(
+ contents->GetURL(),
+ browser->profile()->GetPrefs()->GetString(prefs::kAcceptLanguages),
+ g_browser_process->clipboard());
+}
+
+void ConvertPopupToTabbedBrowser(Browser* browser) {
+ content::RecordAction(UserMetricsAction("ShowAsTab"));
+ TabContents* contents =
+ browser->tab_strip_model()->DetachTabContentsAt(browser->active_index());
+ Browser* b = Browser::Create(browser->profile());
+ b->tab_strip_model()->AppendTabContents(contents, true);
+ b->window()->Show();
+}
+
+void Exit() {
+ content::RecordAction(UserMetricsAction("Exit"));
+ browser::AttemptUserExit();
+}
+
+void BookmarkCurrentPage(Browser* browser) {
+ content::RecordAction(UserMetricsAction("Star"));
+
+ BookmarkModel* model = browser->profile()->GetBookmarkModel();
+ if (!model || !model->IsLoaded())
+ return; // Ignore requests until bookmarks are loaded.
+
+ GURL url;
+ string16 title;
+ TabContents* tab = browser->GetActiveTabContents();
+ bookmark_utils::GetURLAndTitleToBookmark(tab->web_contents(), &url, &title);
+ bool was_bookmarked = model->IsBookmarked(url);
+ if (!was_bookmarked && browser->profile()->IsOffTheRecord()) {
+ // If we're incognito the favicon may not have been saved. Save it now
+ // so that bookmarks have an icon for the page.
+ tab->favicon_tab_helper()->SaveFavicon();
+ }
+ bookmark_utils::AddIfNotBookmarked(model, url, title);
+ // Make sure the model actually added a bookmark before showing the star. A
+ // bookmark isn't created if the url is invalid.
+ if (browser->window()->IsActive() && model->IsBookmarked(url)) {
+ // Only show the bubble if the window is active, otherwise we may get into
+ // weird situations where the bubble is deleted as soon as it is shown.
+ browser->window()->ShowBookmarkBubble(url, was_bookmarked);
+ }
+}
+
+#if !defined(OS_WIN)
+void PinCurrentPageToStartScreen(Browser* browser) {
+}
+#endif
+
+void SavePage(Browser* browser) {
+ content::RecordAction(UserMetricsAction("SavePage"));
+ WebContents* current_tab = browser->GetActiveWebContents();
+ if (current_tab && current_tab->GetContentsMimeType() == "application/pdf")
+ content::RecordAction(UserMetricsAction("PDF.SavePage"));
+ current_tab->OnSavePage();
+}
+
+void ShowFindBar(Browser* browser) {
+ browser->GetFindBarController()->Show();
+}
+
+void ShowPageInfo(Browser* browser,
+ content::WebContents* web_contents,
+ const GURL& url,
+ const SSLStatus& ssl,
+ bool show_history) {
+ Profile* profile = Profile::FromBrowserContext(
+ web_contents->GetBrowserContext());
+ TabContents* tab_contents = TabContents::FromWebContents(web_contents);
+
+ if (CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kEnableWebsiteSettings)) {
+ browser->window()->ShowWebsiteSettings(
+ profile, tab_contents, url, ssl, show_history);
+ } else {
+ browser->window()->ShowPageInfo(web_contents, url, ssl, show_history);
+ }
+}
+
+void ShowChromeToMobileBubble(Browser* browser) {
+ // Only show the bubble if the window is active, otherwise we may get into
+ // weird situations where the bubble is deleted as soon as it is shown.
+ if (browser->window()->IsActive())
+ browser->window()->ShowChromeToMobileBubble();
+}
+
+void Print(Browser* browser) {
+ if (g_browser_process->local_state()->GetBoolean(
+ prefs::kPrintPreviewDisabled)) {
+ browser->GetActiveTabContents()->print_view_manager()->PrintNow();
+ } else {
+ browser->GetActiveTabContents()->print_view_manager()->PrintPreviewNow();
+ }
+}
+
+void AdvancedPrint(Browser* browser) {
+ browser->GetActiveTabContents()->print_view_manager()->AdvancedPrintNow();
+}
+
+void EmailPageLocation(Browser* browser) {
+ content::RecordAction(UserMetricsAction("EmailPageLocation"));
+ WebContents* wc = browser->GetActiveWebContents();
+ DCHECK(wc);
+
+ std::string title = net::EscapeQueryParamValue(
+ UTF16ToUTF8(wc->GetTitle()), false);
+ std::string page_url = net::EscapeQueryParamValue(wc->GetURL().spec(), false);
+ std::string mailto = std::string("mailto:?subject=Fwd:%20") +
+ title + "&body=%0A%0A" + page_url;
+ platform_util::OpenExternal(GURL(mailto));
+}
+
+void Cut(Browser* browser) {
+ content::RecordAction(UserMetricsAction("Cut"));
+ browser->window()->Cut();
+}
+
+void Copy(Browser* browser) {
+ content::RecordAction(UserMetricsAction("Copy"));
+ browser->window()->Copy();
+}
+
+void Paste(Browser* browser) {
+ content::RecordAction(UserMetricsAction("Paste"));
+ browser->window()->Paste();
+}
+
+void Find(Browser* browser) {
+ content::RecordAction(UserMetricsAction("Find"));
+ FindInPage(browser, false, false);
+}
+
+void FindNext(Browser* browser) {
+ content::RecordAction(UserMetricsAction("FindNext"));
+ FindInPage(browser, true, true);
+}
+
+void FindPrevious(Browser* browser) {
+ content::RecordAction(UserMetricsAction("FindPrevious"));
+ FindInPage(browser, true, false);
+}
+
+void FindInPage(Browser* browser, bool find_next, bool forward_direction) {
+ ShowFindBar(browser);
+ if (find_next) {
+ string16 find_text;
+#if defined(OS_MACOSX)
+ // We always want to search for the contents of the find pasteboard on OS X.
+ find_text = GetFindPboardText();
+#endif
+ browser->GetActiveTabContents()->
+ find_tab_helper()->StartFinding(find_text,
+ forward_direction,
+ false); // Not case sensitive.
+ }
+}
+
+void Zoom(Browser* browser, content::PageZoom zoom) {
+ if (browser->is_devtools())
+ return;
+
+ content::RenderViewHost* host =
+ browser->GetActiveWebContents()->GetRenderViewHost();
+ if (zoom == content::PAGE_ZOOM_RESET) {
+ host->SetZoomLevel(0);
+ content::RecordAction(UserMetricsAction("ZoomNormal"));
+ return;
+ }
+
+ double current_zoom_level = browser->GetActiveWebContents()->GetZoomLevel();
+ double default_zoom_level =
+ browser->profile()->GetPrefs()->GetDouble(prefs::kDefaultZoomLevel);
+
+ // Generate a vector of zoom levels from an array of known presets along with
+ // the default level added if necessary.
+ std::vector<double> zoom_levels =
+ chrome_page_zoom::PresetZoomLevels(default_zoom_level);
+
+ if (zoom == content::PAGE_ZOOM_OUT) {
+ // Iterate through the zoom levels in reverse order to find the next
+ // lower level based on the current zoom level for this page.
+ for (std::vector<double>::reverse_iterator i = zoom_levels.rbegin();
+ i != zoom_levels.rend(); ++i) {
+ double zoom_level = *i;
+ if (content::ZoomValuesEqual(zoom_level, current_zoom_level))
+ continue;
+ if (zoom_level < current_zoom_level) {
+ host->SetZoomLevel(zoom_level);
+ content::RecordAction(UserMetricsAction("ZoomMinus"));
+ return;
+ }
+ content::RecordAction(UserMetricsAction("ZoomMinus_AtMinimum"));
+ }
+ } else {
+ // Iterate through the zoom levels in normal order to find the next
+ // higher level based on the current zoom level for this page.
+ for (std::vector<double>::const_iterator i = zoom_levels.begin();
+ i != zoom_levels.end(); ++i) {
+ double zoom_level = *i;
+ if (content::ZoomValuesEqual(zoom_level, current_zoom_level))
+ continue;
+ if (zoom_level > current_zoom_level) {
+ host->SetZoomLevel(zoom_level);
+ content::RecordAction(UserMetricsAction("ZoomPlus"));
+ return;
+ }
+ }
+ content::RecordAction(UserMetricsAction("ZoomPlus_AtMaximum"));
+ }
+}
+
+void FocusToolbar(Browser* browser) {
+ content::RecordAction(UserMetricsAction("FocusToolbar"));
+ browser->window()->FocusToolbar();
+}
+
+void FocusLocationBar(Browser* browser) {
+ content::RecordAction(UserMetricsAction("FocusLocation"));
+ browser->window()->SetFocusToLocationBar(true);
+}
+
+void FocusSearch(Browser* browser) {
+ // TODO(beng): replace this with FocusLocationBar
+ content::RecordAction(UserMetricsAction("FocusSearch"));
+ browser->window()->GetLocationBar()->FocusSearch();
+}
+
+void FocusAppMenu(Browser* browser) {
+ content::RecordAction(UserMetricsAction("FocusAppMenu"));
+ browser->window()->FocusAppMenu();
+}
+
+void FocusBookmarksToolbar(Browser* browser) {
+ content::RecordAction(UserMetricsAction("FocusBookmarksToolbar"));
+ browser->window()->FocusBookmarksToolbar();
+}
+
+void FocusNextPane(Browser* browser) {
+ content::RecordAction(UserMetricsAction("FocusNextPane"));
+ browser->window()->RotatePaneFocus(true);
+}
+
+void FocusPreviousPane(Browser* browser) {
+ content::RecordAction(UserMetricsAction("FocusPreviousPane"));
+ browser->window()->RotatePaneFocus(false);
+}
+
+void ToggleDevToolsWindow(Browser* browser, DevToolsToggleAction action) {
+ if (action == DEVTOOLS_TOGGLE_ACTION_SHOW_CONSOLE)
+ content::RecordAction(UserMetricsAction("DevTools_ToggleConsole"));
+ else
+ content::RecordAction(UserMetricsAction("DevTools_ToggleWindow"));
+
+ DevToolsWindow::ToggleDevToolsWindow(
+ browser->GetActiveWebContents()->GetRenderViewHost(),
+ action);
+}
+
+bool CanOpenTaskManager() {
+#if defined(OS_WIN)
+ // In metro we can't display the task manager, as it is a native window.
+ return !base::win::IsMetroProcess();
+#else
+ return true;
+#endif
+}
+
+void OpenTaskManager(Browser* browser, bool highlight_background_resources) {
+ content::RecordAction(UserMetricsAction("TaskManager"));
+ if (highlight_background_resources)
+ browser->window()->ShowBackgroundPages();
+ else
+ browser->window()->ShowTaskManager();
+}
+
+void OpenFeedbackDialog(Browser* browser) {
+ content::RecordAction(UserMetricsAction("Feedback"));
+ browser::ShowWebFeedbackView(browser, std::string(), std::string());
+}
+
+void ToggleBookmarkBar(Browser* browser) {
+ content::RecordAction(UserMetricsAction("ShowBookmarksBar"));
+ browser->window()->ToggleBookmarkBar();
+}
+
+void ShowAppMenu(Browser* browser) {
+ // We record the user metric for this event in WrenchMenu::RunMenu.
+ browser->window()->ShowAppMenu();
+}
+
+void ShowAvatarMenu(Browser* browser) {
+ browser->window()->ShowAvatarBubbleFromAvatarButton();
+}
+
+void OpenUpdateChromeDialog(Browser* browser) {
+ content::RecordAction(UserMetricsAction("UpdateChrome"));
+ browser->window()->ShowUpdateChromeDialog();
+}
+
+void ToggleSpeechInput(Browser* browser) {
+ browser->GetActiveWebContents()->GetRenderViewHost()->ToggleSpeechInput();
+}
+
+} // namespace chrome
diff --git a/chrome/browser/ui/browser_commands.h b/chrome/browser/ui/browser_commands.h
new file mode 100644
index 0000000..862e510
--- /dev/null
+++ b/chrome/browser/ui/browser_commands.h
@@ -0,0 +1,107 @@
+// Copyright (c) 2012 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_UI_BROWSER_COMMANDS_H_
+#define CHROME_BROWSER_UI_BROWSER_COMMANDS_H_
+#pragma once
+
+#include "chrome/browser/debugger/devtools_toggle_action.h"
+#include "content/public/common/page_zoom.h"
+#include "webkit/glue/window_open_disposition.h"
+
+class Browser;
+class GURL;
+class Profile;
+
+namespace content {
+class WebContents;
+struct SSLStatus;
+}
+
+namespace chrome {
+
+// Opens a new window with the default blank tab.
+void NewEmptyWindow(Profile* profile);
+
+// Opens a new window with the default blank tab. This bypasses metrics and
+// various internal bookkeeping; NewEmptyWindow (above) is preferred.
+Browser* OpenEmptyWindow(Profile* profile);
+
+// Opens a new window with the tabs from |profile|'s TabRestoreService.
+void OpenWindowWithRestoredTabs(Profile* profile);
+
+// Opens the specified URL in a new browser window in an incognito session.
+// If there is already an existing active incognito session for the specified
+// |profile|, that session is re-used.
+void OpenURLOffTheRecord(Profile* profile, const GURL& url);
+
+bool CanGoBack(Browser* browser);
+void GoBack(Browser* browser, WindowOpenDisposition disposition);
+bool CanGoForward(Browser* browser);
+void GoForward(Browser* browser, WindowOpenDisposition disposition);
+bool NavigateToIndexWithDisposition(Browser* browser,
+ int index,
+ WindowOpenDisposition disp);
+void Reload(Browser* browser, WindowOpenDisposition disposition);
+void ReloadIgnoringCache(Browser* browser, WindowOpenDisposition disposition);
+void Home(Browser* browser, WindowOpenDisposition disposition);
+void OpenCurrentURL(Browser* browser);
+void Stop(Browser* browser);
+void NewWindow(Browser* browser);
+void NewIncognitoWindow(Browser* browser);
+void CloseWindow(Browser* browser);
+void NewTab(Browser* browser);
+void CloseTab(Browser* browser);
+void SelectNextTab(Browser* browser);
+void SelectPreviousTab(Browser* browser);
+void OpenTabpose(Browser* browser); // Mac-only
+void MoveTabNext(Browser* browser);
+void MoveTabPrevious(Browser* browser);
+void SelectNumberedTab(Browser* browser, int index);
+void SelectLastTab(Browser* browser);
+void DuplicateTab(Browser* browser);
+void WriteCurrentURLToClipboard(Browser* browser);
+void ConvertPopupToTabbedBrowser(Browser* browser);
+void Exit();
+void BookmarkCurrentPage(Browser* browser);
+void PinCurrentPageToStartScreen(Browser* browser);
+void SavePage(Browser* browser);
+void ShowFindBar(Browser* browser);
+void ShowPageInfo(Browser* browser,
+ content::WebContents* web_contents,
+ const GURL& url,
+ const content::SSLStatus& ssl,
+ bool show_history);
+void ShowChromeToMobileBubble(Browser* browser);
+void Print(Browser* browser);
+void AdvancedPrint(Browser* browser);
+void EmailPageLocation(Browser* browser);
+void Cut(Browser* browser);
+void Copy(Browser* browser);
+void Paste(Browser* browser);
+void Find(Browser* browser);
+void FindNext(Browser* browser);
+void FindPrevious(Browser* browser);
+void FindInPage(Browser* browser, bool find_next, bool forward_direction);
+void Zoom(Browser* browser, content::PageZoom zoom);
+void FocusToolbar(Browser* browser);
+void FocusLocationBar(Browser* browser);
+void FocusSearch(Browser* browser);
+void FocusAppMenu(Browser* browser);
+void FocusBookmarksToolbar(Browser* browser);
+void FocusNextPane(Browser* browser);
+void FocusPreviousPane(Browser* browser);
+void ToggleDevToolsWindow(Browser* browser, DevToolsToggleAction action);
+bool CanOpenTaskManager();
+void OpenTaskManager(Browser* browser, bool highlight_background_resources);
+void OpenFeedbackDialog(Browser* browser);
+void ToggleBookmarkBar(Browser* browser);
+void ShowAppMenu(Browser* browser);
+void ShowAvatarMenu(Browser* browser);
+void OpenUpdateChromeDialog(Browser* browser);
+void ToggleSpeechInput(Browser* browser);
+
+} // namespace chrome
+
+#endif // CHROME_BROWSER_UI_BROWSER_COMMANDS_H_
diff --git a/chrome/browser/ui/browser_navigator_browsertest.cc b/chrome/browser/ui/browser_navigator_browsertest.cc
index d462275..e44ad7b 100644
--- a/chrome/browser/ui/browser_navigator_browsertest.cc
+++ b/chrome/browser/ui/browser_navigator_browsertest.cc
@@ -9,6 +9,7 @@
#include "chrome/browser/prefs/incognito_mode_prefs.h"
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/browser_navigator.h"
#include "chrome/browser/ui/browser_window.h"
@@ -1117,7 +1118,7 @@ IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
}
EXPECT_EQ(1, browser()->tab_count());
- browser()->NewTab();
+ chrome::NewTab(browser());
EXPECT_EQ(2, browser()->tab_count());
{
@@ -1144,7 +1145,7 @@ IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
EXPECT_EQ(GetClearBrowsingDataURL(),
browser()->GetActiveWebContents()->GetURL());
- browser()->NewTab();
+ chrome::NewTab(browser());
EXPECT_EQ(2, browser()->tab_count());
{
@@ -1210,7 +1211,7 @@ IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
browser::Navigate(&p);
// Focus the omnibox.
- browser()->FocusLocationBar();
+ chrome::FocusLocationBar(browser());
OmniboxEditController* controller =
browser()->window()->GetLocationBar()->GetLocationEntry()->model()->
@@ -1227,7 +1228,7 @@ IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_TAB_CONTAINER));
// Go back to the first tab. The focus should not be in the omnibox.
- browser()->SelectPreviousTab();
+ chrome::SelectPreviousTab(browser());
EXPECT_EQ(0, browser()->active_index());
EXPECT_FALSE(ui_test_utils::IsViewFocused(browser(),
VIEW_ID_LOCATION_BAR));
diff --git a/chrome/browser/ui/browser_tab_restore_service_delegate.cc b/chrome/browser/ui/browser_tab_restore_service_delegate.cc
index 488a623..3c985f2 100644
--- a/chrome/browser/ui/browser_tab_restore_service_delegate.cc
+++ b/chrome/browser/ui/browser_tab_restore_service_delegate.cc
@@ -5,6 +5,7 @@
#include "chrome/browser/ui/browser_tab_restore_service_delegate.h"
#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/browser_window.h"
#include "content/public/browser/navigation_controller.h"
@@ -72,7 +73,7 @@ void BrowserTabRestoreServiceDelegate::ReplaceRestoredTab(
}
void BrowserTabRestoreServiceDelegate::CloseTab() {
- browser_->CloseTab();
+ chrome::CloseTab(browser_);
}
// Implementations of TabRestoreServiceDelegate static methods
diff --git a/chrome/browser/ui/browser_win.cc b/chrome/browser/ui/browser_win.cc
index 9f67cb5..118e702 100644
--- a/chrome/browser/ui/browser_win.cc
+++ b/chrome/browser/ui/browser_win.cc
@@ -8,6 +8,7 @@
#include "base/win/metro.h"
#include "chrome/browser/bookmarks/bookmark_utils.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/fullscreen_controller.h"
#include "chrome/browser/ui/tab_contents/tab_contents.h"
@@ -23,11 +24,11 @@ void NewMetroWindow(Browser* source_browser, Profile* profile) {
Browser* browser = browser::FindTabbedBrowser(profile, false);
if (!browser) {
- Browser::OpenEmptyWindow(profile);
+ chrome::OpenEmptyWindow(profile);
return;
}
- browser->NewTab();
+ chrome::NewTab(browser);
if (browser != source_browser) {
// Tell the metro_driver to flip our window. This causes the current
@@ -38,32 +39,30 @@ void NewMetroWindow(Browser* source_browser, Profile* profile) {
} // namespace
-void Browser::NewWindow() {
+namespace chrome {
+
+void NewWindow(Browser* browser) {
if (base::win::IsMetroProcess()) {
- NewMetroWindow(this, profile_->GetOriginalProfile());
+ NewMetroWindow(browser, browser->profile()->GetOriginalProfile());
return;
}
- NewEmptyWindow(profile_->GetOriginalProfile());
+ NewEmptyWindow(browser->profile()->GetOriginalProfile());
}
-void Browser::NewIncognitoWindow() {
+void NewIncognitoWindow(Browser* browser) {
if (base::win::IsMetroProcess()) {
- NewMetroWindow(this, profile_->GetOffTheRecordProfile());
+ NewMetroWindow(browser, browser->profile()->GetOffTheRecordProfile());
return;
}
- NewEmptyWindow(profile_->GetOffTheRecordProfile());
-}
-
-void Browser::SetMetroSnapMode(bool enable) {
- fullscreen_controller_->SetMetroSnapMode(enable);
+ NewEmptyWindow(browser->profile()->GetOffTheRecordProfile());
}
-void Browser::PinCurrentPageToStartScreen() {
+void PinCurrentPageToStartScreen(Browser* browser) {
HMODULE metro_module = base::win::GetMetroModule();
if (metro_module) {
GURL url;
string16 title;
- TabContents* tab = GetActiveTabContents();
+ TabContents* tab = browser->GetActiveTabContents();
bookmark_utils::GetURLAndTitleToBookmark(tab->web_contents(), &url, &title);
typedef BOOL (*MetroPinUrlToStartScreen)(const string16&, const string16&);
@@ -81,3 +80,9 @@ void Browser::PinCurrentPageToStartScreen() {
return;
}
}
+
+} // namespace chrome
+
+void Browser::SetMetroSnapMode(bool enable) {
+ fullscreen_controller_->SetMetroSnapMode(enable);
+}
diff --git a/chrome/browser/ui/cocoa/applescript/window_applescript.mm b/chrome/browser/ui/cocoa/applescript/window_applescript.mm
index e94e795..619c80d 100644
--- a/chrome/browser/ui/cocoa/applescript/window_applescript.mm
+++ b/chrome/browser/ui/cocoa/applescript/window_applescript.mm
@@ -12,6 +12,7 @@
#import "chrome/browser/chrome_browser_application_mac.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/browser_navigator.h"
#include "chrome/browser/ui/browser_window.h"
@@ -69,7 +70,7 @@
if ((self = [super init])) {
browser_ = Browser::Create(aProfile);
- browser_->NewTab();
+ chrome::NewTab(browser_);
browser_->window()->Show();
scoped_nsobject<NSNumber> numID(
[[NSNumber alloc] initWithInt:browser_->session_id().id()]);
diff --git a/chrome/browser/ui/cocoa/cocoa_profile_test.mm b/chrome/browser/ui/cocoa/cocoa_profile_test.mm
index b1b691e..b33e967 100644
--- a/chrome/browser/ui/cocoa/cocoa_profile_test.mm
+++ b/chrome/browser/ui/cocoa/cocoa_profile_test.mm
@@ -7,6 +7,7 @@
#include "chrome/browser/autocomplete/autocomplete_classifier_factory.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/search_engines/template_url_service_factory.h"
+#include "chrome/browser/ui/browser_commands.h"
#include "chrome/test/base/testing_browser_process.h"
#include "content/public/test/test_browser_thread.h"
@@ -89,7 +90,7 @@ void CocoaProfileTest::CloseBrowserWindow() {
// Check to make sure a window was actually created.
DCHECK(browser_->window());
browser_->CloseAllTabs();
- browser_->CloseWindow();
+ chrome::CloseWindow(browser_.get());
// |browser_| will be deleted by its BrowserWindowController.
ignore_result(browser_.release());
}
diff --git a/chrome/browser/ui/cocoa/location_bar/location_icon_decoration.mm b/chrome/browser/ui/cocoa/location_bar/location_icon_decoration.mm
index 8ae6f3b2..61c8fc1 100644
--- a/chrome/browser/ui/cocoa/location_bar/location_icon_decoration.mm
+++ b/chrome/browser/ui/cocoa/location_bar/location_icon_decoration.mm
@@ -7,6 +7,7 @@
#include "base/sys_string_conversions.h"
#import "chrome/browser/bookmarks/bookmark_pasteboard_helper_mac.h"
#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_finder.h"
#import "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h"
#include "content/public/browser/navigation_controller.h"
@@ -106,7 +107,8 @@ bool LocationIconDecoration::OnMousePressed(NSRect frame) {
return true;
}
Browser* browser = browser::FindBrowserWithWebContents(tab);
- browser->ShowPageInfo(tab, nav_entry->GetURL(), nav_entry->GetSSL(), true);
+ chrome::ShowPageInfo(browser, tab, nav_entry->GetURL(), nav_entry->GetSSL(),
+ true);
return true;
}
diff --git a/chrome/browser/ui/cocoa/view_id_util_browsertest.mm b/chrome/browser/ui/cocoa/view_id_util_browsertest.mm
index 9143bb8..92ea8d8 100644
--- a/chrome/browser/ui/cocoa/view_id_util_browsertest.mm
+++ b/chrome/browser/ui/cocoa/view_id_util_browsertest.mm
@@ -11,6 +11,7 @@
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/cocoa/view_id_util.h"
#include "chrome/browser/ui/tab_contents/tab_contents.h"
@@ -43,12 +44,12 @@ class ViewIDTest : public InProcessBrowserTest {
void DoTest() {
// Make sure FindBar is created to test
// VIEW_ID_FIND_IN_PAGE_TEXT_FIELD and VIEW_ID_FIND_IN_PAGE.
- browser()->ShowFindBar();
+ chrome::ShowFindBar(browser());
// Make sure docked devtools is created to test VIEW_ID_DEV_TOOLS_DOCKED
browser()->profile()->GetPrefs()->SetBoolean(prefs::kDevToolsOpenDocked,
true);
- browser()->ToggleDevToolsWindow(DEVTOOLS_TOGGLE_ACTION_INSPECT);
+ chrome::ToggleDevToolsWindow(browser(), DEVTOOLS_TOGGLE_ACTION_INSPECT);
// Make sure download shelf is created to test VIEW_ID_DOWNLOAD_SHELF
browser()->window()->GetDownloadShelf()->Show();
diff --git a/chrome/browser/ui/find_bar/find_bar_host_browsertest.cc b/chrome/browser/ui/find_bar/find_bar_host_browsertest.cc
index 99e1aaa..8eb6e67 100644
--- a/chrome/browser/ui/find_bar/find_bar_host_browsertest.cc
+++ b/chrome/browser/ui/find_bar/find_bar_host_browsertest.cc
@@ -8,6 +8,7 @@
#include "base/utf_string_conversions.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_navigator.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/chrome_pages.h"
@@ -118,7 +119,7 @@ class FindInPageControllerTest : public InProcessBrowserTest {
}
void EnsureFindBoxOpenForBrowser(Browser* browser) {
- browser->ShowFindBar();
+ chrome::ShowFindBar(browser);
gfx::Point position;
bool fully_visible = false;
EXPECT_TRUE(GetFindBarWindowInfoForBrowser(
@@ -625,7 +626,7 @@ IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindDisappearOnNavigate) {
GURL url2 = GetURL(kFramePage);
ui_test_utils::NavigateToURL(browser(), url);
- browser()->ShowFindBar();
+ chrome::ShowFindBar(browser());
gfx::Point position;
bool fully_visible = false;
@@ -640,7 +641,7 @@ IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindDisappearOnNavigate) {
content::Source<NavigationController>(
&browser()->GetActiveTabContents()->web_contents()->
GetController()));
- browser()->Reload(CURRENT_TAB);
+ chrome::Reload(browser(), CURRENT_TAB);
observer.Wait();
EXPECT_TRUE(GetFindBarWindowInfo(&position, &fully_visible));
@@ -658,7 +659,7 @@ IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindStayVisibleOnAnchorLoad) {
GURL url = GetURL(kAnchorPage);
ui_test_utils::NavigateToURL(browser(), url);
- browser()->ShowFindBar();
+ chrome::ShowFindBar(browser());
gfx::Point position;
bool fully_visible = false;
@@ -691,7 +692,7 @@ IN_PROC_BROWSER_TEST_F(FindInPageControllerTest,
GURL url = GetURL(kSimple);
ui_test_utils::NavigateToURL(browser(), url);
- browser()->ShowFindBar();
+ chrome::ShowFindBar(browser());
gfx::Point position;
bool fully_visible = false;
@@ -701,7 +702,7 @@ IN_PROC_BROWSER_TEST_F(FindInPageControllerTest,
EXPECT_TRUE(fully_visible);
// Open another tab (tab B).
- browser()->NewTab();
+ chrome::NewTab(browser());
ui_test_utils::NavigateToURL(browser(), url);
// Make sure Find box is closed.
@@ -709,7 +710,7 @@ IN_PROC_BROWSER_TEST_F(FindInPageControllerTest,
EXPECT_FALSE(fully_visible);
// Close tab B.
- browser()->CloseTab();
+ chrome::CloseTab(browser());
// Make sure Find window appears again.
EXPECT_TRUE(GetFindBarWindowInfo(&position, &fully_visible));
@@ -727,7 +728,7 @@ IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindMovesWhenObscuring) {
GURL url = GetURL(kMoveIfOver);
ui_test_utils::NavigateToURL(browser(), url);
- browser()->ShowFindBar();
+ chrome::ShowFindBar(browser());
// This is needed on GTK because the reposition operation is asynchronous.
MessageLoop::current()->RunAllPending();
@@ -804,7 +805,7 @@ IN_PROC_BROWSER_TEST_F(FindInPageControllerTest,
EXPECT_EQ(0, ordinal);
// Open another tab (tab B).
- browser()->NewTab();
+ chrome::NewTab(browser());
ui_test_utils::NavigateToURL(browser(), url);
// Simulate what happens when you press F3 for FindNext. We should get a
@@ -814,7 +815,7 @@ IN_PROC_BROWSER_TEST_F(FindInPageControllerTest,
EXPECT_EQ(0, ordinal);
// Open another tab (tab C).
- browser()->NewTab();
+ chrome::NewTab(browser());
ui_test_utils::NavigateToURL(browser(), url);
// Simulate what happens when you press F3 for FindNext. We should get a
@@ -841,7 +842,7 @@ IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, AcceleratorRestoring) {
focus_manager->GetCurrentTargetForAccelerator(escape);
EXPECT_TRUE(old_target != NULL);
- browser()->ShowFindBar();
+ chrome::ShowFindBar(browser());
// Our Find bar should be the new target.
ui::AcceleratorTarget* new_target =
@@ -862,7 +863,7 @@ IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, AcceleratorRestoring) {
// Show find bar again with animation on, and the target should be
// on find bar.
DropdownBarHost::disable_animations_during_testing_ = false;
- browser()->ShowFindBar();
+ chrome::ShowFindBar(browser());
EXPECT_EQ(new_target,
focus_manager->GetCurrentTargetForAccelerator(escape));
}
@@ -875,7 +876,7 @@ IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, StayActive) {
GURL url = GetURL(kSimple);
ui_test_utils::NavigateToURL(browser(), url);
- browser()->ShowFindBar();
+ chrome::ShowFindBar(browser());
// Simulate a user clearing the search string. Ideally, we should be
// simulating keypresses here for searching for something and pressing
@@ -1224,7 +1225,7 @@ IN_PROC_BROWSER_TEST_F(FindInPageControllerTest,
ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
// Close it.
- browser()->CloseTab();
+ chrome::CloseTab(browser());
// See if the Find window has moved.
gfx::Point position2;
@@ -1235,7 +1236,7 @@ IN_PROC_BROWSER_TEST_F(FindInPageControllerTest,
// there isn't a good way other than looping and polling to see when it's
// done. So instead we change the state and open a new tab, since the new tab
// animation doesn't happen on tab change.
- browser()->ToggleBookmarkBar();
+ chrome::ToggleBookmarkBar(browser());
ui_test_utils::NavigateToURLWithDisposition(
browser(), url, NEW_FOREGROUND_TAB,
@@ -1248,7 +1249,7 @@ IN_PROC_BROWSER_TEST_F(FindInPageControllerTest,
ui_test_utils::NavigateToURLWithDisposition(
browser(), url, NEW_FOREGROUND_TAB,
ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
- browser()->CloseTab();
+ chrome::CloseTab(browser());
EXPECT_TRUE(GetFindBarWindowInfo(&position2, NULL));
EXPECT_EQ(position, position2);
}
diff --git a/chrome/browser/ui/fullscreen_controller_browsertest.cc b/chrome/browser/ui/fullscreen_controller_browsertest.cc
index c42d372..4d0f367 100644
--- a/chrome/browser/ui/fullscreen_controller_browsertest.cc
+++ b/chrome/browser/ui/fullscreen_controller_browsertest.cc
@@ -7,6 +7,7 @@
#include "chrome/browser/content_settings/host_content_settings_map.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/fullscreen_controller_test.h"
#include "chrome/test/base/ui_test_utils.h"
@@ -392,7 +393,7 @@ IN_PROC_BROWSER_TEST_F(FullscreenControllerTest,
// Close tab. Bubble is cleared.
{
MouseLockNotificationObserver mouse_lock_observer;
- browser()->CloseTab();
+ chrome::CloseTab(browser());
mouse_lock_observer.Wait();
}
ASSERT_FALSE(IsFullscreenBubbleDisplayed());
diff --git a/chrome/browser/ui/fullscreen_controller_test.cc b/chrome/browser/ui/fullscreen_controller_test.cc
index 3dae759..39c010c 100644
--- a/chrome/browser/ui/fullscreen_controller_test.cc
+++ b/chrome/browser/ui/fullscreen_controller_test.cc
@@ -6,6 +6,7 @@
#include "base/command_line.h"
#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/fullscreen_controller.h"
#include "chrome/common/chrome_switches.h"
@@ -138,7 +139,7 @@ void FullscreenControllerTest::GoBack() {
content::TestNavigationObserver observer(
content::NotificationService::AllSources(), NULL, 1);
- browser()->GoBack(CURRENT_TAB);
+ chrome::GoBack(browser(), CURRENT_TAB);
observer.Wait();
}
@@ -147,7 +148,7 @@ void FullscreenControllerTest::Reload() {
content::TestNavigationObserver observer(
content::NotificationService::AllSources(), NULL, 1);
- browser()->Reload(CURRENT_TAB);
+ chrome::Reload(browser(), CURRENT_TAB);
observer.Wait();
}
diff --git a/chrome/browser/ui/gtk/bookmarks/bookmark_bar_gtk_interactive_uitest.cc b/chrome/browser/ui/gtk/bookmarks/bookmark_bar_gtk_interactive_uitest.cc
index 5472763..09d046ad 100644
--- a/chrome/browser/ui/gtk/bookmarks/bookmark_bar_gtk_interactive_uitest.cc
+++ b/chrome/browser/ui/gtk/bookmarks/bookmark_bar_gtk_interactive_uitest.cc
@@ -5,6 +5,7 @@
#include <gtk/gtk.h>
#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/gtk/view_id_util.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
@@ -31,8 +32,8 @@ IN_PROC_BROWSER_TEST_F(BookmarkBarGtkInteractiveUITest, FindBarTest) {
ASSERT_TRUE(test_server()->Start());
// Create new tab; open findbar.
- browser()->NewTab();
- browser()->Find();
+ chrome::NewTab(browser());
+ chrome::Find(browser());
// Create new tab with an arbitrary URL.
GURL url = test_server()->GetURL(kSimplePage);
@@ -46,7 +47,7 @@ IN_PROC_BROWSER_TEST_F(BookmarkBarGtkInteractiveUITest, FindBarTest) {
// Set focus somewhere else, so that we can test clicking on the findbar
// works.
- browser()->FocusLocationBar();
+ chrome::FocusLocationBar(browser());
ui_test_utils::ClickOnView(browser(), VIEW_ID_FIND_IN_PAGE_TEXT_FIELD);
ui_test_utils::IsViewFocused(browser(), VIEW_ID_FIND_IN_PAGE_TEXT_FIELD);
}
@@ -65,7 +66,7 @@ IN_PROC_BROWSER_TEST_F(
G_CALLBACK(OnClicked), &has_been_clicked);
// Create new tab.
- browser()->NewTab();
+ chrome::NewTab(browser());
// Wait for the floating bar to appear.
MessageLoop::current()->RunAllPending();
diff --git a/chrome/browser/ui/gtk/browser_titlebar.cc b/chrome/browser/ui/gtk/browser_titlebar.cc
index 84939f9..4121159 100644
--- a/chrome/browser/ui/gtk/browser_titlebar.cc
+++ b/chrome/browser/ui/gtk/browser_titlebar.cc
@@ -25,6 +25,7 @@
#include "chrome/browser/profiles/profile_info_cache.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/gtk/accelerators_gtk.h"
#include "chrome/browser/ui/gtk/avatar_menu_button_gtk.h"
#include "chrome/browser/ui/gtk/browser_window_gtk.h"
@@ -887,9 +888,9 @@ gboolean BrowserTitlebar::OnScroll(GtkWidget* widget, GdkEventScroll* event) {
if (event->direction == GDK_SCROLL_LEFT ||
event->direction == GDK_SCROLL_UP) {
if (index != 0)
- browser->SelectPreviousTab();
+ chrome::SelectPreviousTab(browser);
} else if (index + 1 < browser->tab_count()) {
- browser->SelectNextTab();
+ chrome::SelectNextTab(browser);
}
return TRUE;
}
diff --git a/chrome/browser/ui/gtk/browser_toolbar_gtk.cc b/chrome/browser/ui/gtk/browser_toolbar_gtk.cc
index 4e0aac78..4a89fa6 100644
--- a/chrome/browser/ui/gtk/browser_toolbar_gtk.cc
+++ b/chrome/browser/ui/gtk/browser_toolbar_gtk.cc
@@ -21,6 +21,7 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/themes/theme_service.h"
#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/global_error_service.h"
#include "chrome/browser/ui/global_error_service_factory.h"
#include "chrome/browser/ui/gtk/accelerators_gtk.h"
@@ -602,7 +603,7 @@ void BrowserToolbarGtk::OnButtonClick(GtkWidget* button) {
DCHECK(home_.get() && button == home_->widget()) <<
"Unexpected button click callback";
- browser_->Home(event_utils::DispositionForCurrentButtonPressEvent());
+ chrome::Home(browser_, event_utils::DispositionForCurrentButtonPressEvent());
}
gboolean BrowserToolbarGtk::OnMenuButtonPressEvent(GtkWidget* button,
diff --git a/chrome/browser/ui/gtk/browser_window_gtk.cc b/chrome/browser/ui/gtk/browser_window_gtk.cc
index 677da9e2..b3c76b3 100644
--- a/chrome/browser/ui/gtk/browser_window_gtk.cc
+++ b/chrome/browser/ui/gtk/browser_window_gtk.cc
@@ -37,6 +37,7 @@
#include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog_queue.h"
#include "chrome/browser/ui/bookmarks/bookmark_tab_helper.h"
#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_dialogs.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/browser_window_state.h"
@@ -2287,10 +2288,10 @@ gboolean BrowserWindowGtk::OnButtonPressEvent(GtkWidget* widget,
// Handle back/forward.
if (event->type == GDK_BUTTON_PRESS) {
if (event->button == 8) {
- browser_->GoBack(CURRENT_TAB);
+ chrome::GoBack(browser_.get(), CURRENT_TAB);
return TRUE;
} else if (event->button == 9) {
- browser_->GoForward(CURRENT_TAB);
+ chrome::GoForward(browser_.get(), CURRENT_TAB);
return TRUE;
}
}
diff --git a/chrome/browser/ui/gtk/location_bar_view_gtk.cc b/chrome/browser/ui/gtk/location_bar_view_gtk.cc
index 940a227..7128bdea 100644
--- a/chrome/browser/ui/gtk/location_bar_view_gtk.cc
+++ b/chrome/browser/ui/gtk/location_bar_view_gtk.cc
@@ -38,6 +38,7 @@
#include "chrome/browser/search_engines/template_url_service.h"
#include "chrome/browser/search_engines/template_url_service_factory.h"
#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_content_setting_bubble_model_delegate.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/content_settings/content_setting_bubble_model.h"
@@ -1152,7 +1153,8 @@ gboolean LocationBarViewGtk::OnIconReleased(GtkWidget* sender,
NOTREACHED();
return FALSE;
}
- browser_->ShowPageInfo(tab, nav_entry->GetURL(), nav_entry->GetSSL(), true);
+ chrome::ShowPageInfo(browser_, tab, nav_entry->GetURL(),
+ nav_entry->GetSSL(), true);
return TRUE;
} else if (event->button == 2) {
// When the user middle clicks on the location icon, try to open the
diff --git a/chrome/browser/ui/gtk/reload_button_gtk.cc b/chrome/browser/ui/gtk/reload_button_gtk.cc
index 2bc55d2..f825350 100644
--- a/chrome/browser/ui/gtk/reload_button_gtk.cc
+++ b/chrome/browser/ui/gtk/reload_button_gtk.cc
@@ -10,6 +10,7 @@
#include "base/logging.h"
#include "chrome/app/chrome_command_ids.h"
#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/gtk/event_utils.h"
#include "chrome/browser/ui/gtk/gtk_chrome_button.h"
#include "chrome/browser/ui/gtk/gtk_theme_service.h"
@@ -153,7 +154,7 @@ void ReloadButtonGtk::OnClicked(GtkWidget* /* sender */) {
return;
if (browser_)
- browser_->Stop();
+ chrome::Stop(browser_);
// The user has clicked, so we can feel free to update the button,
// even if the mouse is still hovering.
diff --git a/chrome/browser/ui/gtk/view_id_util_browsertest.cc b/chrome/browser/ui/gtk/view_id_util_browsertest.cc
index c93b684..3ee541f 100644
--- a/chrome/browser/ui/gtk/view_id_util_browsertest.cc
+++ b/chrome/browser/ui/gtk/view_id_util_browsertest.cc
@@ -5,6 +5,7 @@
#include <gtk/gtk.h>
#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/gtk/view_id_util.h"
#include "chrome/common/url_constants.h"
@@ -32,7 +33,7 @@ class ViewIDTest : public InProcessBrowserTest {
IN_PROC_BROWSER_TEST_F(ViewIDTest, Basic) {
// Make sure FindBar is created to test
// VIEW_ID_FIND_IN_PAGE_TEXT_FIELD and VIEW_ID_FIND_IN_PAGE.
- browser()->ShowFindBar();
+ chrome::ShowFindBar(browser());
for (int i = VIEW_ID_TOOLBAR; i < VIEW_ID_PREDEFINED_COUNT; ++i) {
// The following ids are used only in views implementation.
diff --git a/chrome/browser/ui/login/login_prompt_browsertest.cc b/chrome/browser/ui/login/login_prompt_browsertest.cc
index 0841c94..001142e 100644
--- a/chrome/browser/ui/login/login_prompt_browsertest.cc
+++ b/chrome/browser/ui/login/login_prompt_browsertest.cc
@@ -9,6 +9,7 @@
#include "base/utf_string_conversions.h"
#include "chrome/browser/prerender/prerender_manager.h"
#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/login/login_prompt.h"
#include "chrome/browser/ui/tab_contents/tab_contents.h"
#include "chrome/common/chrome_notification_types.h"
@@ -467,8 +468,8 @@ IN_PROC_BROWSER_TEST_F(LoginPromptBrowserTest, TestCancelAuth) {
false));
auth_needed_waiter.Wait();
WindowedAuthCancelledObserver auth_cancelled_waiter(controller);
- ASSERT_TRUE(browser()->CanGoBack());
- browser()->GoBack(CURRENT_TAB);
+ ASSERT_TRUE(chrome::CanGoBack(browser()));
+ chrome::GoBack(browser(), CURRENT_TAB);
auth_cancelled_waiter.Wait();
load_stop_waiter.Wait();
EXPECT_TRUE(observer.handlers_.empty());
@@ -478,7 +479,7 @@ IN_PROC_BROWSER_TEST_F(LoginPromptBrowserTest, TestCancelAuth) {
ui_test_utils::NavigateToURL(browser(), no_auth_page_3);
{
WindowedLoadStopObserver load_stop_waiter(controller, 1);
- browser()->GoBack(CURRENT_TAB); // Should take us to page 1
+ chrome::GoBack(browser(), CURRENT_TAB); // Should take us to page 1
load_stop_waiter.Wait();
}
@@ -491,8 +492,8 @@ IN_PROC_BROWSER_TEST_F(LoginPromptBrowserTest, TestCancelAuth) {
false));
auth_needed_waiter.Wait();
WindowedAuthCancelledObserver auth_cancelled_waiter(controller);
- ASSERT_TRUE(browser()->CanGoForward());
- browser()->GoForward(CURRENT_TAB); // Should take us to page 3
+ ASSERT_TRUE(chrome::CanGoForward(browser()));
+ chrome::GoForward(browser(), CURRENT_TAB); // Should take us to page 3
auth_cancelled_waiter.Wait();
load_stop_waiter.Wait();
EXPECT_TRUE(observer.handlers_.empty());
diff --git a/chrome/browser/ui/omnibox/omnibox_view_browsertest.cc b/chrome/browser/ui/omnibox/omnibox_view_browsertest.cc
index 0414268..6598407 100644
--- a/chrome/browser/ui/omnibox/omnibox_view_browsertest.cc
+++ b/chrome/browser/ui/omnibox/omnibox_view_browsertest.cc
@@ -22,6 +22,7 @@
#include "chrome/browser/search_engines/template_url_service.h"
#include "chrome/browser/search_engines/template_url_service_factory.h"
#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/omnibox/location_bar.h"
#include "chrome/browser/ui/omnibox/omnibox_popup_model.h"
@@ -156,7 +157,7 @@ class OmniboxViewTest : public InProcessBrowserTest,
virtual void SetUpOnMainThread() {
ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser()));
ASSERT_NO_FATAL_FAILURE(SetupComponents());
- browser()->FocusLocationBar();
+ chrome::FocusLocationBar(browser());
// Use Textfield's view id on pure views. See crbug.com/71144.
#if defined(USE_AURA)
location_bar_focus_view_id_ = VIEW_ID_OMNIBOX;
@@ -392,20 +393,20 @@ class OmniboxViewTest : public InProcessBrowserTest,
int tab_count = browser()->tab_count();
// Create a new Tab.
- browser()->NewTab();
+ chrome::NewTab(browser());
ASSERT_NO_FATAL_FAILURE(WaitForTabOpenOrClose(tab_count + 1));
// Select the first Tab.
ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_1, kCtrlOrCmdMask));
ASSERT_EQ(0, browser()->active_index());
- browser()->FocusLocationBar();
+ chrome::FocusLocationBar(browser());
// Select the second Tab.
ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_2, kCtrlOrCmdMask));
ASSERT_EQ(1, browser()->active_index());
- browser()->FocusLocationBar();
+ chrome::FocusLocationBar(browser());
// Try ctrl-w to close a Tab.
ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_W, kCtrlOrCmdMask));
@@ -452,7 +453,7 @@ class OmniboxViewTest : public InProcessBrowserTest,
OmniboxView* omnibox_view = NULL;
ASSERT_NO_FATAL_FAILURE(
GetOmniboxViewForBrowser(popup, &omnibox_view));
- popup->FocusLocationBar();
+ chrome::FocusLocationBar(popup);
EXPECT_TRUE(omnibox_view->IsSelectAll());
#if !defined(OS_MACOSX)
@@ -473,7 +474,7 @@ class OmniboxViewTest : public InProcessBrowserTest,
// Set the edit text to "Hello world".
omnibox_view->SetUserText(ASCIIToUTF16("Hello world"));
- popup->FocusLocationBar();
+ chrome::FocusLocationBar(popup);
EXPECT_TRUE(omnibox_view->IsSelectAll());
// Try editing the location bar text -- should be disallowed.
@@ -550,7 +551,7 @@ class OmniboxViewTest : public InProcessBrowserTest,
void EscapeTest() {
ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIHistoryURL));
- browser()->FocusLocationBar();
+ chrome::FocusLocationBar(browser());
OmniboxView* omnibox_view = NULL;
ASSERT_NO_FATAL_FAILURE(GetOmniboxView(&omnibox_view));
@@ -625,7 +626,7 @@ class OmniboxViewTest : public InProcessBrowserTest,
EXPECT_STREQ(kSearchTextURL, url.spec().c_str());
// Test that entering a single character then Enter performs a search.
- browser()->FocusLocationBar();
+ chrome::FocusLocationBar(browser());
EXPECT_TRUE(omnibox_view->IsSelectAll());
ASSERT_NO_FATAL_FAILURE(SendKeySequence(kSearchSingleCharKeys));
ASSERT_NO_FATAL_FAILURE(WaitForAutocompleteControllerDone());
@@ -683,7 +684,7 @@ class OmniboxViewTest : public InProcessBrowserTest,
void BasicTextOperationsTest() {
ui_test_utils::NavigateToURL(browser(), GURL(chrome::kAboutBlankURL));
- browser()->FocusLocationBar();
+ chrome::FocusLocationBar(browser());
OmniboxView* omnibox_view = NULL;
ASSERT_NO_FATAL_FAILURE(GetOmniboxView(&omnibox_view));
@@ -992,7 +993,7 @@ class OmniboxViewTest : public InProcessBrowserTest,
model->SetDefaultSearchProvider(NULL);
ui_test_utils::NavigateToURL(browser(), GURL(chrome::kAboutBlankURL));
- browser()->FocusLocationBar();
+ chrome::FocusLocationBar(browser());
OmniboxView* omnibox_view = NULL;
ASSERT_NO_FATAL_FAILURE(GetOmniboxView(&omnibox_view));
@@ -1238,7 +1239,7 @@ class OmniboxViewTest : public InProcessBrowserTest,
ASSERT_NO_FATAL_FAILURE(SendKeySequence(kSearchTextKeys));
// Create a new tab.
- browser()->NewTab();
+ chrome::NewTab(browser());
// Switch back to the first tab.
browser()->ActivateTabAt(0, true);
@@ -1478,7 +1479,7 @@ IN_PROC_BROWSER_TEST_F(OmniboxViewTest,
#if defined(TOOLKIT_GTK) || defined(USE_AURA)
IN_PROC_BROWSER_TEST_F(OmniboxViewTest, UndoRedo) {
ui_test_utils::NavigateToURL(browser(), GURL(chrome::kAboutBlankURL));
- browser()->FocusLocationBar();
+ chrome::FocusLocationBar(browser());
OmniboxView* omnibox_view = NULL;
ASSERT_NO_FATAL_FAILURE(GetOmniboxView(&omnibox_view));
diff --git a/chrome/browser/ui/panels/old_panel_browsertest.cc b/chrome/browser/ui/panels/old_panel_browsertest.cc
index dfafd33..02be1e1 100644
--- a/chrome/browser/ui/panels/old_panel_browsertest.cc
+++ b/chrome/browser/ui/panels/old_panel_browsertest.cc
@@ -12,6 +12,7 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog.h"
#include "chrome/browser/ui/app_modal_dialogs/native_app_modal_dialog.h"
+#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/browser_window.h"
@@ -814,7 +815,7 @@ IN_PROC_BROWSER_TEST_F(OldPanelBrowserTest, MAYBE_ActivatePanelOrTabbedWindow) {
browser()->window()->Activate();
WaitForPanelActiveState(panel2, SHOW_AS_INACTIVE);
// Close the main tabbed window. That should move focus back to panel.
- browser()->CloseWindow();
+ chrome::CloseWindow(browser());
WaitForPanelActiveState(panel2, SHOW_AS_ACTIVE);
// Activate another panel.
@@ -1260,7 +1261,7 @@ IN_PROC_BROWSER_TEST_F(OldPanelBrowserTest,
ui_test_utils::WindowedNotificationObserver signal(
chrome::NOTIFICATION_BROWSER_CLOSED,
content::Source<Browser>(browser()));
- browser()->CloseWindow();
+ chrome::CloseWindow(browser());
signal.Wait();
EXPECT_EQ(Panel::EXPANDED, panel1->expansion_state());
@@ -1431,7 +1432,7 @@ IN_PROC_BROWSER_TEST_F(OldPanelBrowserTest,
TabContents* contents = browser()->tab_strip_model()->DetachTabContentsAt(0);
panel_browser->tab_strip_model()->InsertTabContentsAt(
0, contents, TabStripModel::ADD_NONE);
- panel_browser->SelectNumberedTab(0);
+ chrome::SelectNumberedTab(panel_browser, 0);
EXPECT_EQ(contents, panel_browser->GetActiveTabContents());
EXPECT_EQ(1, PanelManager::GetInstance()->num_panels());
@@ -1453,7 +1454,7 @@ IN_PROC_BROWSER_TEST_F(OldPanelBrowserTest,
ui_test_utils::WindowedNotificationObserver signal(
chrome::NOTIFICATION_PANEL_CLOSED,
content::Source<Panel>(panel));
- panel_browser->ConvertPopupToTabbedBrowser();
+ chrome::ConvertPopupToTabbedBrowser(panel_browser);
signal.Wait();
EXPECT_EQ(0, PanelManager::GetInstance()->num_panels());
@@ -1703,8 +1704,8 @@ IN_PROC_BROWSER_TEST_F(OldPanelDownloadTest, Download) {
EXPECT_EQ(1, panel_browser->tab_count());
ASSERT_FALSE(panel_browser->window()->IsDownloadShelfVisible());
- panel_browser->CloseWindow();
- browser()->CloseWindow();
+ chrome::CloseWindow(panel_browser);
+ chrome::CloseWindow(browser());
}
// See crbug 113779.
@@ -1729,7 +1730,7 @@ IN_PROC_BROWSER_TEST_F(OldPanelDownloadTest, MAYBE_DownloadNoTabbedBrowser) {
ui_test_utils::WindowedNotificationObserver signal(
chrome::NOTIFICATION_BROWSER_CLOSED,
content::Source<Browser>(browser()));
- browser()->CloseWindow();
+ chrome::CloseWindow(browser());
signal.Wait();
ASSERT_EQ(1U, BrowserList::size());
ASSERT_EQ(NULL, browser::FindTabbedBrowser(profile, false));
@@ -1749,10 +1750,10 @@ IN_PROC_BROWSER_TEST_F(OldPanelDownloadTest, MAYBE_DownloadNoTabbedBrowser) {
Browser* tabbed_browser = browser::FindTabbedBrowser(profile, false);
EXPECT_EQ(1, tabbed_browser->tab_count());
ASSERT_TRUE(tabbed_browser->window()->IsDownloadShelfVisible());
- tabbed_browser->CloseWindow();
+ chrome::CloseWindow(tabbed_browser);
EXPECT_EQ(1, panel_browser->tab_count());
ASSERT_FALSE(panel_browser->window()->IsDownloadShelfVisible());
- panel_browser->CloseWindow();
+ chrome::CloseWindow(panel_browser);
}
diff --git a/chrome/browser/ui/panels/panel_browser_window.cc b/chrome/browser/ui/panels/panel_browser_window.cc
index a7bfc6f..70214f2 100644
--- a/chrome/browser/ui/panels/panel_browser_window.cc
+++ b/chrome/browser/ui/panels/panel_browser_window.cc
@@ -6,6 +6,7 @@
#include "base/logging.h"
#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/panels/panel.h"
#include "chrome/browser/ui/panels/native_panel.h"
@@ -337,7 +338,7 @@ DownloadShelf* PanelBrowserWindow::GetDownloadShelf() {
Browser::CreateParams params(Browser::TYPE_TABBED, profile);
params.initial_bounds = window_bounds;
tabbed_browser = Browser::CreateWithParams(params);
- tabbed_browser->NewTab();
+ chrome::NewTab(tabbed_browser);
}
tabbed_browser->window()->Show(); // Ensure download shelf is visible.
diff --git a/chrome/browser/ui/panels/panel_browsertest.cc b/chrome/browser/ui/panels/panel_browsertest.cc
index 06ff2e2..5cb4a70 100644
--- a/chrome/browser/ui/panels/panel_browsertest.cc
+++ b/chrome/browser/ui/panels/panel_browsertest.cc
@@ -12,6 +12,7 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog.h"
#include "chrome/browser/ui/app_modal_dialogs/native_app_modal_dialog.h"
+#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/browser_window.h"
@@ -817,7 +818,7 @@ IN_PROC_BROWSER_TEST_F(PanelBrowserTest, MAYBE_ActivatePanelOrTabbedWindow) {
browser()->window()->Activate();
WaitForPanelActiveState(panel2, SHOW_AS_INACTIVE);
// Close the main tabbed window. That should move focus back to panel.
- browser()->CloseWindow();
+ chrome::CloseWindow(browser());
WaitForPanelActiveState(panel2, SHOW_AS_ACTIVE);
// Activate another panel.
@@ -1249,7 +1250,7 @@ IN_PROC_BROWSER_TEST_F(PanelBrowserTest,
ui_test_utils::WindowedNotificationObserver signal(
chrome::NOTIFICATION_BROWSER_CLOSED,
content::Source<Browser>(browser()));
- browser()->CloseWindow();
+ chrome::CloseWindow(browser());
signal.Wait();
EXPECT_EQ(Panel::EXPANDED, panel1->expansion_state());
@@ -1415,7 +1416,7 @@ IN_PROC_BROWSER_TEST_F(PanelBrowserTest, DISABLED_CreateWithExistingContents) {
TabContents* contents = browser()->tab_strip_model()->DetachTabContentsAt(0);
panel_browser->tab_strip_model()->InsertTabContentsAt(
0, contents, TabStripModel::ADD_NONE);
- panel_browser->SelectNumberedTab(0);
+ chrome::SelectNumberedTab(panel_browser, 0);
EXPECT_EQ(contents, panel_browser->GetActiveTabContents());
EXPECT_EQ(1, PanelManager::GetInstance()->num_panels());
@@ -1437,7 +1438,7 @@ IN_PROC_BROWSER_TEST_F(PanelBrowserTest, DISABLED_CreateWithExistingContents) {
ui_test_utils::WindowedNotificationObserver signal(
chrome::NOTIFICATION_PANEL_CLOSED,
content::Source<Panel>(panel));
- panel_browser->ConvertPopupToTabbedBrowser();
+ chrome::ConvertPopupToTabbedBrowser(panel_browser);
signal.Wait();
EXPECT_EQ(0, PanelManager::GetInstance()->num_panels());
@@ -1689,8 +1690,8 @@ IN_PROC_BROWSER_TEST_F(PanelDownloadTest, Download) {
EXPECT_EQ(1, panel_browser->tab_count());
ASSERT_FALSE(panel_browser->window()->IsDownloadShelfVisible());
- panel_browser->CloseWindow();
- browser()->CloseWindow();
+ chrome::CloseWindow(panel_browser);
+ chrome::CloseWindow(browser());
}
// See crbug 113779.
@@ -1715,7 +1716,7 @@ IN_PROC_BROWSER_TEST_F(PanelDownloadTest, MAYBE_DownloadNoTabbedBrowser) {
ui_test_utils::WindowedNotificationObserver signal(
chrome::NOTIFICATION_BROWSER_CLOSED,
content::Source<Browser>(browser()));
- browser()->CloseWindow();
+ chrome::CloseWindow(browser());
signal.Wait();
ASSERT_EQ(1U, BrowserList::size());
ASSERT_EQ(NULL, browser::FindTabbedBrowser(profile, false));
@@ -1735,12 +1736,12 @@ IN_PROC_BROWSER_TEST_F(PanelDownloadTest, MAYBE_DownloadNoTabbedBrowser) {
Browser* tabbed_browser = browser::FindTabbedBrowser(profile, false);
EXPECT_EQ(1, tabbed_browser->tab_count());
ASSERT_TRUE(tabbed_browser->window()->IsDownloadShelfVisible());
- tabbed_browser->CloseWindow();
+ chrome::CloseWindow(tabbed_browser);
EXPECT_EQ(1, panel_browser->tab_count());
ASSERT_FALSE(panel_browser->window()->IsDownloadShelfVisible());
- panel_browser->CloseWindow();
+ chrome::CloseWindow(panel_browser);
}
#endif // OS_MACOSX
diff --git a/chrome/browser/ui/tab_contents/tab_contents_iterator_unittest.cc b/chrome/browser/ui/tab_contents/tab_contents_iterator_unittest.cc
index 4b78289..93a24f9 100644
--- a/chrome/browser/ui/tab_contents/tab_contents_iterator_unittest.cc
+++ b/chrome/browser/ui/tab_contents/tab_contents_iterator_unittest.cc
@@ -10,6 +10,7 @@
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/printing/background_printing_manager.h"
#include "chrome/browser/profiles/profile_manager.h"
+#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/tab_contents/tab_contents.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/url_constants.h"
@@ -71,8 +72,8 @@ TEST_F(BrowserListTest, TabContentsIteratorVerifyCount) {
// Add some tabs.
for (size_t i = 0; i < 3; ++i)
- browser2->NewTab();
- browser3->NewTab();
+ chrome::NewTab(browser2.get());
+ chrome::NewTab(browser3.get());
EXPECT_EQ(4U, CountAllTabs());
@@ -83,7 +84,7 @@ TEST_F(BrowserListTest, TabContentsIteratorVerifyCount) {
// Add lots of tabs.
for (size_t i = 0; i < 41; ++i)
- browser()->NewTab();
+ chrome::NewTab(browser());
EXPECT_EQ(42U, CountAllTabs());
// Close all remaining tabs to keep all the destructors happy.
@@ -114,8 +115,8 @@ TEST_F(BrowserListTest, TabContentsIteratorVerifyBrowser) {
// Add some tabs.
for (size_t i = 0; i < 3; ++i)
- browser2->NewTab();
- browser3->NewTab();
+ chrome::NewTab(browser2.get());
+ chrome::NewTab(browser3.get());
size_t count = 0;
for (TabContentsIterator iterator; !iterator.done(); ++iterator, ++count) {
@@ -139,8 +140,8 @@ TEST_F(BrowserListTest, TabContentsIteratorVerifyBrowser) {
}
// Now make it one tab per browser.
- browser()->NewTab();
- browser2->NewTab();
+ chrome::NewTab(browser());
+ chrome::NewTab(browser2.get());
count = 0;
for (TabContentsIterator iterator; !iterator.done(); ++iterator, ++count) {
@@ -179,8 +180,8 @@ TEST_F(BrowserListTest, TabContentsIteratorBackgroundPrinting) {
// Add some tabs.
for (size_t i = 0; i < 3; ++i)
- browser2->NewTab();
- browser3->NewTab();
+ chrome::NewTab(browser2);
+ chrome::NewTab(browser3);
EXPECT_EQ(4U, CountAllTabs());
@@ -212,8 +213,8 @@ TEST_F(BrowserListTest, TabContentsIteratorBackgroundPrinting) {
// Add some tabs.
for (size_t i = 0; i < 3; ++i) {
- browser2->NewTab();
- browser3->NewTab();
+ chrome::NewTab(browser2.get());
+ chrome::NewTab(browser3.get());
}
EXPECT_EQ(6U, CountAllTabs());
diff --git a/chrome/browser/ui/tabs/tab_menu_model_unittest.cc b/chrome/browser/ui/tabs/tab_menu_model_unittest.cc
index af0d289..ef7e1da 100644
--- a/chrome/browser/ui/tabs/tab_menu_model_unittest.cc
+++ b/chrome/browser/ui/tabs/tab_menu_model_unittest.cc
@@ -4,6 +4,7 @@
#include "chrome/browser/ui/tabs/tab_menu_model.h"
+#include "chrome/browser/ui/browser_commands.h"
#include "chrome/test/base/browser_with_test_window_test.h"
#include "chrome/test/base/menu_model_test.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -13,7 +14,7 @@ class TabMenuModelTest : public MenuModelTest,
};
TEST_F(TabMenuModelTest, Basics) {
- browser()->NewTab();
+ chrome::NewTab(browser());
TabMenuModel model(&delegate_, browser()->tab_strip_model(), 0);
// Verify it has items. The number varies by platform, so we don't check
diff --git a/chrome/browser/ui/toolbar/back_forward_menu_model.cc b/chrome/browser/ui/toolbar/back_forward_menu_model.cc
index 105b769..80db712 100644
--- a/chrome/browser/ui/toolbar/back_forward_menu_model.cc
+++ b/chrome/browser/ui/toolbar/back_forward_menu_model.cc
@@ -13,6 +13,7 @@
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/singleton_tabs.h"
#include "chrome/browser/ui/tab_contents/tab_contents.h"
#include "chrome/common/pref_names.h"
@@ -194,8 +195,11 @@ void BackForwardMenuModel::ActivatedAt(int index, int event_flags) {
int controller_index = MenuIndexToNavEntryIndex(index);
WindowOpenDisposition disposition =
browser::DispositionFromEventFlags(event_flags);
- if (!browser_->NavigateToIndexWithDisposition(controller_index, disposition))
+ if (!chrome::NavigateToIndexWithDisposition(browser_,
+ controller_index,
+ disposition)) {
NOTREACHED();
+ }
}
void BackForwardMenuModel::MenuWillShow() {
diff --git a/chrome/browser/ui/toolbar/wrench_menu_model.cc b/chrome/browser/ui/toolbar/wrench_menu_model.cc
index 9e48e72..8f61a5a 100644
--- a/chrome/browser/ui/toolbar/wrench_menu_model.cc
+++ b/chrome/browser/ui/toolbar/wrench_menu_model.cc
@@ -26,6 +26,7 @@
#include "chrome/browser/sync/sync_ui_util.h"
#include "chrome/browser/task_manager/task_manager.h"
#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/global_error.h"
#include "chrome/browser/ui/global_error_service.h"
@@ -174,7 +175,7 @@ void ToolsMenuModel::Build(Browser* browser) {
AddItemWithStringId(IDC_MANAGE_EXTENSIONS, IDS_SHOW_EXTENSIONS);
- if (browser->CanOpenTaskManager())
+ if (chrome::CanOpenTaskManager())
AddItemWithStringId(IDC_TASK_MANAGER, IDS_TASK_MANAGER);
AddItemWithStringId(IDC_CLEAR_BROWSING_DATA, IDS_CLEAR_BROWSING_DATA);
diff --git a/chrome/browser/ui/views/ash/chrome_shell_delegate.cc b/chrome/browser/ui/views/ash/chrome_shell_delegate.cc
index 8a112db..9901c4c 100644
--- a/chrome/browser/ui/views/ash/chrome_shell_delegate.cc
+++ b/chrome/browser/ui/views/ash/chrome_shell_delegate.cc
@@ -16,6 +16,7 @@
#include "chrome/browser/sessions/tab_restore_service.h"
#include "chrome/browser/sessions/tab_restore_service_factory.h"
#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/views/ash/app_list/app_list_view_delegate.h"
#include "chrome/browser/ui/views/ash/launcher/chrome_launcher_controller.h"
@@ -139,14 +140,14 @@ void ChromeShellDelegate::NewTab() {
// If the browser was not active, we call BrowserWindow::Show to make it
// visible. Otherwise, we let Browser::NewTab handle the active window change.
const bool was_active = browser->window()->IsActive();
- browser->NewTab();
+ chrome::NewTab(browser);
if (!was_active)
browser->window()->Show();
}
void ChromeShellDelegate::NewWindow(bool is_incognito) {
Profile* profile = ProfileManager::GetDefaultProfileOrOffTheRecord();
- Browser::NewEmptyWindow(
+ chrome::NewEmptyWindow(
is_incognito ? profile->GetOffTheRecordProfile() : profile);
}
@@ -236,10 +237,10 @@ bool ChromeShellDelegate::RotatePaneFocus(ash::Shell::Direction direction) {
switch (direction) {
case ash::Shell::FORWARD:
- browser->FocusNextPane();
+ chrome::FocusNextPane(browser);
break;
case ash::Shell::BACKWARD:
- browser->FocusPreviousPane();
+ chrome::FocusPreviousPane(browser);
break;
}
return true;
@@ -255,7 +256,7 @@ void ChromeShellDelegate::ShowKeyboardOverlay() {
void ChromeShellDelegate::ShowTaskManager() {
Browser* browser = browser::FindOrCreateTabbedBrowser(
ProfileManager::GetDefaultProfileOrOffTheRecord());
- browser->OpenTaskManager(false);
+ chrome::OpenTaskManager(browser, false);
}
content::BrowserContext* ChromeShellDelegate::GetCurrentBrowserContext() {
diff --git a/chrome/browser/ui/views/ash/launcher/chrome_launcher_controller.cc b/chrome/browser/ui/views/ash/launcher/chrome_launcher_controller.cc
index 238baa3..09ca711 100644
--- a/chrome/browser/ui/views/ash/launcher/chrome_launcher_controller.cc
+++ b/chrome/browser/ui/views/ash/launcher/chrome_launcher_controller.cc
@@ -23,6 +23,7 @@
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/ui/ash/chrome_launcher_prefs.h"
#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/extensions/shell_window.h"
@@ -408,7 +409,7 @@ bool ChromeLauncherController::IsLoggedInAsGuest() {
}
void ChromeLauncherController::CreateNewIncognitoWindow() {
- Browser::NewEmptyWindow(GetProfileForNewWindows()->GetOffTheRecordProfile());
+ chrome::NewEmptyWindow(GetProfileForNewWindows()->GetOffTheRecordProfile());
}
bool ChromeLauncherController::CanPin() const {
@@ -510,14 +511,14 @@ void ChromeLauncherController::CreateNewTab() {
return;
}
- last_browser->NewTab();
+ chrome::NewTab(last_browser);
aura::Window* window = last_browser->window()->GetNativeWindow();
window->Show();
ash::wm::ActivateWindow(window);
}
void ChromeLauncherController::CreateNewWindow() {
- Browser::NewEmptyWindow(GetProfileForNewWindows());
+ chrome::NewEmptyWindow(GetProfileForNewWindows());
}
void ChromeLauncherController::ItemClicked(const ash::LauncherItem& item,
diff --git a/chrome/browser/ui/views/ash/launcher/chrome_launcher_controller_browsertest.cc b/chrome/browser/ui/views/ash/launcher/chrome_launcher_controller_browsertest.cc
index c09bbf2..43f24e0 100644
--- a/chrome/browser/ui/views/ash/launcher/chrome_launcher_controller_browsertest.cc
+++ b/chrome/browser/ui/views/ash/launcher/chrome_launcher_controller_browsertest.cc
@@ -19,6 +19,7 @@
#include "chrome/browser/extensions/shell_window_registry.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/extensions/application_launch.h"
@@ -474,7 +475,7 @@ IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTest, LaunchMaximized) {
ui_test_utils::WindowedNotificationObserver open_observer(
chrome::NOTIFICATION_BROWSER_WINDOW_READY,
content::NotificationService::AllSources());
- Browser::NewEmptyWindow(browser()->profile());
+ chrome::NewEmptyWindow(browser()->profile());
open_observer.Wait();
Browser* browser2 = browser::FindLastActiveWithProfile(browser()->profile());
printf("browser2 is active: %d\n", browser2->window()->IsActive());
diff --git a/chrome/browser/ui/views/constrained_window_views_browsertest.cc b/chrome/browser/ui/views/constrained_window_views_browsertest.cc
index b78d002..7e47b86 100644
--- a/chrome/browser/ui/views/constrained_window_views_browsertest.cc
+++ b/chrome/browser/ui/views/constrained_window_views_browsertest.cc
@@ -4,6 +4,7 @@
#include "base/memory/weak_ptr.h"
#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/constrained_window_tab_helper.h"
#include "chrome/browser/ui/tab_contents/tab_contents.h"
#include "chrome/browser/ui/views/constrained_window_views.h"
@@ -153,7 +154,7 @@ IN_PROC_BROWSER_TEST_F(ConstrainedWindowViewTest, FocusTest) {
int tab_with_constrained_window = browser()->active_index();
// Create a new tab.
- browser()->NewTab();
+ chrome::NewTab(browser());
// The constrained dialog should no longer be selected.
EXPECT_NE(test_dialog2->GetInitiallyFocusedView(),
diff --git a/chrome/browser/ui/views/find_bar_host_interactive_uitest.cc b/chrome/browser/ui/views/find_bar_host_interactive_uitest.cc
index 629278e..24bc4bd 100644
--- a/chrome/browser/ui/views/find_bar_host_interactive_uitest.cc
+++ b/chrome/browser/ui/views/find_bar_host_interactive_uitest.cc
@@ -6,6 +6,7 @@
#include "base/string_util.h"
#include "base/utf_string_conversions.h"
#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/find_bar/find_bar_controller.h"
#include "chrome/browser/ui/find_bar/find_notification_details.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
@@ -82,12 +83,12 @@ IN_PROC_BROWSER_TEST_F(FindInPageTest, MAYBE_CrashEscHandlers) {
GURL url = test_server()->GetURL(kSimplePage);
ui_test_utils::NavigateToURL(browser(), url);
- browser()->Find();
+ chrome::Find(browser());
// Open another tab (tab B).
browser()->AddSelectedTabWithURL(url, content::PAGE_TRANSITION_TYPED);
- browser()->Find();
+ chrome::Find(browser());
EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(),
VIEW_ID_FIND_IN_PAGE_TEXT_FIELD));
@@ -117,7 +118,7 @@ IN_PROC_BROWSER_TEST_F(FindInPageTest, FocusRestore) {
// Focus the location bar, open and close the find-in-page, focus should
// return to the location bar.
- browser()->FocusLocationBar();
+ chrome::FocusLocationBar(browser());
EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(),
location_bar_focus_view_id_));
// Ensure the creation of the find bar controller.
@@ -132,8 +133,8 @@ IN_PROC_BROWSER_TEST_F(FindInPageTest, FocusRestore) {
// Focus the location bar, find something on the page, close the find box,
// focus should go to the page.
- browser()->FocusLocationBar();
- browser()->Find();
+ chrome::FocusLocationBar(browser());
+ chrome::Find(browser());
EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(),
VIEW_ID_FIND_IN_PAGE_TEXT_FIELD));
ui_test_utils::FindInPage(browser()->GetActiveTabContents(),
@@ -146,7 +147,7 @@ IN_PROC_BROWSER_TEST_F(FindInPageTest, FocusRestore) {
// Focus the location bar, open and close the find box, focus should return to
// the location bar (same as before, just checking that http://crbug.com/23599
// is fixed).
- browser()->FocusLocationBar();
+ chrome::FocusLocationBar(browser());
EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(),
location_bar_focus_view_id_));
browser()->GetFindBarController()->Show();
@@ -171,7 +172,7 @@ IN_PROC_BROWSER_TEST_F(FindInPageTest, MAYBE_FocusRestoreOnTabSwitch) {
GURL url = test_server()->GetURL(kSimplePage);
ui_test_utils::NavigateToURL(browser(), url);
- browser()->Find();
+ chrome::Find(browser());
EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(),
VIEW_ID_FIND_IN_PAGE_TEXT_FIELD));
@@ -191,7 +192,7 @@ IN_PROC_BROWSER_TEST_F(FindInPageTest, MAYBE_FocusRestoreOnTabSwitch) {
observer.Wait();
// Make sure Find box is open.
- browser()->Find();
+ chrome::Find(browser());
EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(),
VIEW_ID_FIND_IN_PAGE_TEXT_FIELD));
@@ -201,7 +202,7 @@ IN_PROC_BROWSER_TEST_F(FindInPageTest, MAYBE_FocusRestoreOnTabSwitch) {
EXPECT_TRUE(ASCIIToUTF16("b") == find_bar->GetFindSelectedText());
// Set focus away from the Find bar (to the Location bar).
- browser()->FocusLocationBar();
+ chrome::FocusLocationBar(browser());
EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(),
location_bar_focus_view_id_));
@@ -334,7 +335,7 @@ IN_PROC_BROWSER_TEST_F(FindInPageTest, MAYBE_PasteWithoutTextChange) {
EXPECT_EQ(ASCIIToUTF16("a"), GetFindBarText());
// Reload the page to clear the matching result.
- browser()->Reload(CURRENT_TAB);
+ chrome::Reload(browser(), CURRENT_TAB);
// Focus the Find bar again to make sure the text is selected.
browser()->GetFindBarController()->Show();
diff --git a/chrome/browser/ui/views/frame/browser_frame_win.cc b/chrome/browser/ui/views/frame/browser_frame_win.cc
index 6702bd3..afb6f70 100644
--- a/chrome/browser/ui/views/frame/browser_frame_win.cc
+++ b/chrome/browser/ui/views/frame/browser_frame_win.cc
@@ -16,6 +16,7 @@
#include "chrome/browser/search_engines/template_url.h"
#include "chrome/browser/search_engines/template_url_service.h"
#include "chrome/browser/search_engines/template_url_service_factory.h"
+#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/toolbar/wrench_menu_model.h"
#include "chrome/browser/ui/views/frame/browser_view.h"
#include "chrome/browser/ui/views/frame/system_menu_model.h"
@@ -409,7 +410,7 @@ void BrowserFrameWin::UpdateDWMFrame() {
void BrowserFrameWin::BuildSystemMenuForBrowserWindow() {
system_menu_contents_->AddSeparator();
- if (browser_view()->browser()->CanOpenTaskManager()) {
+ if (chrome::CanOpenTaskManager()) {
system_menu_contents_->AddItemWithStringId(IDC_TASK_MANAGER,
IDS_TASK_MANAGER);
}
@@ -423,7 +424,7 @@ void BrowserFrameWin::BuildSystemMenuForBrowserWindow() {
void BrowserFrameWin::BuildSystemMenuForAppOrPopupWindow() {
Browser* browser = browser_view()->browser();
- if (browser->is_app() && browser->CanOpenTaskManager()) {
+ if (browser->is_app() && chrome::CanOpenTaskManager()) {
system_menu_contents_->AddSeparator();
system_menu_contents_->AddItemWithStringId(IDC_TASK_MANAGER,
IDS_TASK_MANAGER);
diff --git a/chrome/browser/ui/views/toolbar_view.cc b/chrome/browser/ui/views/toolbar_view.cc
index bee1124..d3293ba 100644
--- a/chrome/browser/ui/views/toolbar_view.cc
+++ b/chrome/browser/ui/views/toolbar_view.cc
@@ -11,6 +11,7 @@
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_content_setting_bubble_model_delegate.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/global_error_service.h"
@@ -405,7 +406,7 @@ void ToolbarView::ShowPageInfo(content::WebContents* web_contents,
const GURL& url,
const content::SSLStatus& ssl,
bool show_history) {
- browser_->ShowPageInfo(web_contents, url, ssl, show_history);
+ chrome::ShowPageInfo(browser_, web_contents, url, ssl, show_history);
}
views::Widget* ToolbarView::CreateViewsBubble(
diff --git a/chrome/browser/ui/webui/help/help_handler.cc b/chrome/browser/ui/webui/help/help_handler.cc
index 93f71c4..7856296 100644
--- a/chrome/browser/ui/webui/help/help_handler.cc
+++ b/chrome/browser/ui/webui/help/help_handler.cc
@@ -17,6 +17,7 @@
#include "chrome/browser/google/google_util.h"
#include "chrome/browser/policy/browser_policy_connector.h"
#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/chrome_pages.h"
#include "chrome/common/chrome_notification_types.h"
@@ -316,7 +317,7 @@ void HelpHandler::OpenFeedbackDialog(const ListValue* args) {
DCHECK(args->empty());
Browser* browser = browser::FindBrowserWithWebContents(
web_ui()->GetWebContents());
- browser->OpenFeedbackDialog();
+ chrome::OpenFeedbackDialog(browser);
}
void HelpHandler::OpenHelpPage(const base::ListValue* args) {
diff --git a/chrome/browser/ui/webui/ntp/new_tab_ui_browsertest.cc b/chrome/browser/ui/webui/ntp/new_tab_ui_browsertest.cc
index 24d1d66..e67ca82 100644
--- a/chrome/browser/ui/webui/ntp/new_tab_ui_browsertest.cc
+++ b/chrome/browser/ui/webui/ntp/new_tab_ui_browsertest.cc
@@ -4,6 +4,7 @@
#include "base/command_line.h"
#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_commands.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/url_constants.h"
#include "chrome/test/base/in_process_browser_test.h"
@@ -74,7 +75,7 @@ IN_PROC_BROWSER_TEST_F(NewTabUIBrowserTest, LoadNTPInExistingProcess) {
browser(), GURL(chrome::kChromeUINewTabURL), NEW_FOREGROUND_TAB,
ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
EXPECT_EQ(1, browser()->GetWebContentsAt(2)->GetMaxPageID());
- browser()->CloseTab();
+ chrome::CloseTab(browser());
// Open another Web UI page in a new tab.
ui_test_utils::NavigateToURLWithDisposition(
@@ -111,7 +112,7 @@ IN_PROC_BROWSER_TEST_F(NewTabUIBrowserTest, ChromeHangInNTP) {
// Visit chrome://hang/ again in another NTP. Don't bother waiting for the
// NTP to load, because it's hung.
- browser()->NewTab();
+ chrome::NewTab(browser());
browser()->OpenURL(OpenURLParams(
GURL(chrome::kChromeUIHangURL), Referrer(), CURRENT_TAB,
content::PAGE_TRANSITION_TYPED, false));
diff --git a/chrome/browser/ui/webui/print_preview/print_preview_handler_unittest.cc b/chrome/browser/ui/webui/print_preview/print_preview_handler_unittest.cc
index 213eca9..61c8d2b 100644
--- a/chrome/browser/ui/webui/print_preview/print_preview_handler_unittest.cc
+++ b/chrome/browser/ui/webui/print_preview/print_preview_handler_unittest.cc
@@ -9,7 +9,7 @@
#include "chrome/browser/printing/print_preview_tab_controller.h"
#include "chrome/browser/printing/print_preview_unit_test_base.h"
#include "chrome/browser/printing/print_view_manager.h"
-#include "chrome/browser/ui/browser_list.h"
+#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/tab_contents/tab_contents.h"
#include "chrome/browser/ui/webui/print_preview/print_preview_handler.h"
#include "chrome/browser/ui/webui/print_preview/print_preview_ui.h"
@@ -45,7 +45,7 @@ class PrintPreviewHandlerTest : public PrintPreviewUnitTestBase {
virtual void SetUp() OVERRIDE {
PrintPreviewUnitTestBase::SetUp();
- browser()->NewTab();
+ chrome::NewTab(browser());
EXPECT_EQ(1, browser()->tab_count());
OpenPrintPreviewTab();
}
diff --git a/chrome/browser/ui/webui/print_preview/print_preview_ui_browsertest.cc b/chrome/browser/ui/webui/print_preview/print_preview_ui_browsertest.cc
index 629d094..79e993d 100644
--- a/chrome/browser/ui/webui/print_preview/print_preview_ui_browsertest.cc
+++ b/chrome/browser/ui/webui/print_preview/print_preview_ui_browsertest.cc
@@ -5,6 +5,7 @@
#include "base/command_line.h"
#include "chrome/app/chrome_command_ids.h"
#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_commands.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/url_constants.h"
#include "chrome/test/base/in_process_browser_test.h"
@@ -58,7 +59,7 @@ IN_PROC_BROWSER_TEST_F(PrintPreviewTest, PrintCommands) {
content::TestNavigationObserver reload_observer(
content::NotificationService::AllSources());
- browser()->Reload(CURRENT_TAB);
+ chrome::Reload(browser(), CURRENT_TAB);
reload_observer.Wait();
ASSERT_TRUE(browser()->command_updater()->IsCommandEnabled(IDC_PRINT));
diff --git a/chrome/browser/ui/webui/print_preview/print_preview_ui_unittest.cc b/chrome/browser/ui/webui/print_preview/print_preview_ui_unittest.cc
index b9cb693..de26a6f 100644
--- a/chrome/browser/ui/webui/print_preview/print_preview_ui_unittest.cc
+++ b/chrome/browser/ui/webui/print_preview/print_preview_ui_unittest.cc
@@ -8,7 +8,7 @@
#include "chrome/browser/printing/print_preview_tab_controller.h"
#include "chrome/browser/printing/print_preview_unit_test_base.h"
#include "chrome/browser/printing/print_view_manager.h"
-#include "chrome/browser/ui/browser_list.h"
+#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/constrained_window_tab_helper.h"
#include "chrome/browser/ui/tab_contents/tab_contents.h"
#include "chrome/browser/ui/webui/print_preview/print_preview_ui.h"
@@ -40,7 +40,7 @@ class PrintPreviewUIUnitTest : public PrintPreviewUnitTestBase {
virtual void SetUp() OVERRIDE {
PrintPreviewUnitTestBase::SetUp();
- browser()->NewTab();
+ chrome::NewTab(browser());
}
};
diff --git a/chrome/browser/ui/webui/web_dialog_controller_browsertest.cc b/chrome/browser/ui/webui/web_dialog_controller_browsertest.cc
index fa20fc9..7b0fe03 100644
--- a/chrome/browser/ui/webui/web_dialog_controller_browsertest.cc
+++ b/chrome/browser/ui/webui/web_dialog_controller_browsertest.cc
@@ -5,6 +5,7 @@
#include "base/memory/scoped_ptr.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/webui/test_web_dialog_delegate.h"
#include "chrome/browser/ui/webui/web_dialog_controller.h"
#include "chrome/common/url_constants.h"
@@ -65,7 +66,7 @@ IN_PROC_BROWSER_TEST_F(WebDialogControllerBrowserTest, IncognitoBrowser) {
ASSERT_FALSE(delegate->dialog_closed());
// Closing the browser should close the dialogs associated with that browser.
- browser->CloseWindow();
+ chrome::CloseWindow(browser);
ui_test_utils::RunAllPendingInMessageLoop();
ASSERT_TRUE(delegate->dialog_closed());
}
diff --git a/chrome/browser/ui/webui/web_ui_browsertest.cc b/chrome/browser/ui/webui/web_ui_browsertest.cc
index 5fa65d9..e9dfda9 100644
--- a/chrome/browser/ui/webui/web_ui_browsertest.cc
+++ b/chrome/browser/ui/webui/web_ui_browsertest.cc
@@ -17,6 +17,7 @@
#include "chrome/browser/printing/print_preview_tab_controller.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_navigator.h"
#include "chrome/browser/ui/webui/chrome_url_data_manager.h"
#include "chrome/browser/ui/webui/test_chrome_web_ui_controller_factory.h"
@@ -213,7 +214,7 @@ void WebUIBrowserTest::BrowsePrintPreload(const GURL& browse_to) {
TestTabStripModelObserver tabstrip_observer(
browser()->tab_strip_model(), this);
- browser()->Print();
+ chrome::Print(browser());
tabstrip_observer.WaitForObservation(
base::Bind(&ui_test_utils::RunMessageLoop),
base::Bind(&MessageLoop::Quit,
diff --git a/chrome/browser/unload_browsertest.cc b/chrome/browser/unload_browsertest.cc
index 55c3861..2706371 100644
--- a/chrome/browser/unload_browsertest.cc
+++ b/chrome/browser/unload_browsertest.cc
@@ -14,6 +14,7 @@
#include "chrome/browser/ui/app_modal_dialogs/javascript_app_modal_dialog.h"
#include "chrome/browser/ui/app_modal_dialogs/native_app_modal_dialog.h"
#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/chrome_switches.h"
@@ -163,7 +164,7 @@ class UnloadTest : public InProcessBrowserTest {
ui_test_utils::WindowedNotificationObserver window_observer(
chrome::NOTIFICATION_BROWSER_CLOSED,
content::NotificationService::AllSources());
- browser()->CloseWindow();
+ chrome::CloseWindow(browser());
window_observer.Wait();
}
@@ -256,7 +257,7 @@ IN_PROC_BROWSER_TEST_F(UnloadTest, BrowserCloseBeforeUnloadOK) {
ui_test_utils::WindowedNotificationObserver window_observer(
chrome::NOTIFICATION_BROWSER_CLOSED,
content::NotificationService::AllSources());
- browser()->CloseWindow();
+ chrome::CloseWindow(browser());
ClickModalDialogButton(true);
window_observer.Wait();
}
@@ -266,7 +267,7 @@ IN_PROC_BROWSER_TEST_F(UnloadTest, BrowserCloseBeforeUnloadOK) {
// If this test flakes, reopen http://crbug.com/123110
IN_PROC_BROWSER_TEST_F(UnloadTest, BrowserCloseBeforeUnloadCancel) {
NavigateToDataURL(BEFORE_UNLOAD_HTML, "beforeunload");
- browser()->CloseWindow();
+ chrome::CloseWindow(browser());
// We wait for the title to change after cancelling the popup to ensure that
// in-flight IPCs from the renderer reach the browser. Otherwise the browser
@@ -281,7 +282,7 @@ IN_PROC_BROWSER_TEST_F(UnloadTest, BrowserCloseBeforeUnloadCancel) {
ui_test_utils::WindowedNotificationObserver window_observer(
chrome::NOTIFICATION_BROWSER_CLOSED,
content::NotificationService::AllSources());
- browser()->CloseWindow();
+ chrome::CloseWindow(browser());
ClickModalDialogButton(true);
window_observer.Wait();
}
@@ -304,7 +305,7 @@ IN_PROC_BROWSER_TEST_F(UnloadTest, BrowserCloseWithInnerFocusedFrame) {
ui_test_utils::WindowedNotificationObserver window_observer(
chrome::NOTIFICATION_BROWSER_CLOSED,
content::NotificationService::AllSources());
- browser()->CloseWindow();
+ chrome::CloseWindow(browser());
ClickModalDialogButton(true);
window_observer.Wait();
}
@@ -397,7 +398,7 @@ IN_PROC_BROWSER_TEST_F(UnloadTest, BrowserCloseTabWhenOtherTabHasListener) {
ui_test_utils::WindowedNotificationObserver tab_close_observer(
content::NOTIFICATION_WEB_CONTENTS_DESTROYED,
content::NotificationService::AllSources());
- browser()->CloseTab();
+ chrome::CloseTab(browser());
tab_close_observer.Wait();
CheckTitle("only_one_unload");