diff options
-rw-r--r-- | chrome/app/nibs/SideToolbar.xib | 2 | ||||
-rw-r--r-- | chrome/app/nibs/Toolbar.xib | 2 | ||||
-rw-r--r-- | chrome/browser/automation/automation_provider.cc | 8 | ||||
-rw-r--r-- | chrome/browser/browser.cc | 233 | ||||
-rw-r--r-- | chrome/browser/browser.h | 13 | ||||
-rw-r--r-- | chrome/browser/browser_browsertest.cc | 2 | ||||
-rw-r--r-- | chrome/browser/browser_focus_uitest.cc | 6 | ||||
-rw-r--r-- | chrome/browser/chromeos/compact_location_bar_view.cc | 11 | ||||
-rw-r--r-- | chrome/browser/cocoa/browser_window_controller.mm | 47 | ||||
-rw-r--r-- | chrome/browser/crash_recovery_browsertest.cc | 6 | ||||
-rw-r--r-- | chrome/browser/extensions/extension_browsertests_misc.cc | 4 | ||||
-rw-r--r-- | chrome/browser/find_bar_host_browsertest.cc | 2 | ||||
-rw-r--r-- | chrome/browser/gtk/browser_toolbar_gtk.cc | 34 | ||||
-rw-r--r-- | chrome/browser/views/toolbar_view.cc | 42 |
14 files changed, 212 insertions, 200 deletions
diff --git a/chrome/app/nibs/SideToolbar.xib b/chrome/app/nibs/SideToolbar.xib index fc4b014..742fd25 100644 --- a/chrome/app/nibs/SideToolbar.xib +++ b/chrome/app/nibs/SideToolbar.xib @@ -372,7 +372,7 @@ </object> <object class="IBConnectionRecord"> <object class="IBActionConnection" key="connection"> - <string key="label">commandDispatch:</string> + <string key="label">commandDispatchUsingKeyModifiers:</string> <reference key="source" ref="1003"/> <reference key="destination" ref="458854861"/> </object> diff --git a/chrome/app/nibs/Toolbar.xib b/chrome/app/nibs/Toolbar.xib index b7f4d46..3db1282 100644 --- a/chrome/app/nibs/Toolbar.xib +++ b/chrome/app/nibs/Toolbar.xib @@ -336,7 +336,7 @@ </object> <object class="IBConnectionRecord"> <object class="IBActionConnection" key="connection"> - <string key="label">commandDispatch:</string> + <string key="label">commandDispatchUsingKeyModifiers:</string> <reference key="source" ref="1003"/> <reference key="destination" ref="458854861"/> </object> diff --git a/chrome/browser/automation/automation_provider.cc b/chrome/browser/automation/automation_provider.cc index dd1a07b..98f05e7 100644 --- a/chrome/browser/automation/automation_provider.cc +++ b/chrome/browser/automation/automation_provider.cc @@ -709,7 +709,7 @@ void AutomationProvider::Reload(int handle, IPC::Message* reply_message) { Browser* browser = FindAndActivateTab(tab); if (browser && browser->command_updater()->IsCommandEnabled(IDC_RELOAD)) { AddNavigationStatusListener(tab, reply_message, 1, false); - browser->Reload(); + browser->Reload(CURRENT_TAB); return; } } @@ -2079,11 +2079,11 @@ void AutomationProvider::OmniboxMovePopupSelection( void AutomationProvider::OmniboxAcceptInput(Browser* browser, DictionaryValue* args, IPC::Message* reply_message) { - NavigationController& tab = - browser->GetOrCloneNavigationControllerForDisposition(CURRENT_TAB); + NavigationController& controller = + browser->GetSelectedTabContents()->controller(); // Setup observer to wait until the selected item loads. NotificationObserver* observer = - new OmniboxAcceptNotificationObserver(&tab, this, reply_message); + new OmniboxAcceptNotificationObserver(&controller, this, reply_message); notification_observer_list_.AddObserver(observer); browser->window()->GetLocationBar()->AcceptInput(); diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc index 5300f18..a4620f6 100644 --- a/chrome/browser/browser.cc +++ b/chrome/browser/browser.cc @@ -982,14 +982,11 @@ bool Browser::CanRestoreTab() { bool Browser::NavigateToIndexWithDisposition(int index, WindowOpenDisposition disp) { NavigationController& controller = - GetOrCloneNavigationControllerForDisposition(disp); - - if (index >= 0 && index < controller.entry_count()) { - controller.GoToIndex(index); - return true; - } else { + GetOrCloneTabForDisposition(disp)->controller(); + if (index < 0 || index >= controller.entry_count()) return false; - } + controller.GoToIndex(index); + return true; } void Browser::ShowSingletonTab(const GURL& url) { @@ -1076,19 +1073,15 @@ bool Browser::ShouldOpenNewTabForWindowDisposition( disposition == NEW_BACKGROUND_TAB); } -NavigationController& Browser::GetOrCloneNavigationControllerForDisposition( +TabContents* Browser::GetOrCloneTabForDisposition( WindowOpenDisposition disposition) { TabContents* current_tab = GetSelectedTabContents(); if (ShouldOpenNewTabForWindowDisposition(disposition)) { - TabContents* cloned = current_tab->Clone(); - tabstrip_model_.AddTabContents(cloned, -1, false, - PageTransition::LINK, + current_tab = current_tab->Clone(); + tabstrip_model_.AddTabContents(current_tab, -1, false, PageTransition::LINK, disposition == NEW_FOREGROUND_TAB); - return cloned->controller(); - } else { - // Default disposition is CURRENT_TAB. - return current_tab->controller(); } + return current_tab; } void Browser::UpdateTabStripModelInsertionPolicy() { @@ -1148,56 +1141,50 @@ void Browser::GoBack(WindowOpenDisposition disposition) { TabContents* current_tab = GetSelectedTabContents(); if (current_tab->controller().CanGoBack()) { - NavigationController& controller = - GetOrCloneNavigationControllerForDisposition(disposition); + TabContents* 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->interstitial_page() && - ShouldOpenNewTabForWindowDisposition(disposition)) { + if (current_tab->showing_interstitial_page() && (new_tab != current_tab)) return; - } - controller.GoBack(); + new_tab->controller().GoBack(); } } void Browser::GoForward(WindowOpenDisposition disposition) { UserMetrics::RecordAction(UserMetricsAction("Forward"), profile_); - if (GetSelectedTabContents()->controller().CanGoForward()) { - NavigationController& controller = - GetOrCloneNavigationControllerForDisposition(disposition); - controller.GoForward(); - } + if (GetSelectedTabContents()->controller().CanGoForward()) + GetOrCloneTabForDisposition(disposition)->controller().GoForward(); } -void Browser::Reload() { +void Browser::Reload(WindowOpenDisposition disposition) { UserMetrics::RecordAction(UserMetricsAction("Reload"), profile_); - ReloadInternal(false); + ReloadInternal(disposition, false); } -void Browser::ReloadIgnoringCache() { +void Browser::ReloadIgnoringCache(WindowOpenDisposition disposition) { UserMetrics::RecordAction(UserMetricsAction("ReloadIgnoringCache"), profile_); - ReloadInternal(true); + ReloadInternal(disposition, true); } -void Browser::ReloadInternal(bool ignore_cache) { +void Browser::ReloadInternal(WindowOpenDisposition disposition, + bool ignore_cache) { // If we are showing an interstitial, treat this as an OpenURL. TabContents* current_tab = GetSelectedTabContents(); - if (current_tab) { - if (current_tab->showing_interstitial_page()) { - NavigationEntry* entry = current_tab->controller().GetActiveEntry(); - DCHECK(entry); // Should exist if interstitial is showing. - OpenURL(entry->url(), GURL(), CURRENT_TAB, PageTransition::RELOAD); - return; - } - - // As this is caused by a user action, give the focus to the page. - if (!current_tab->FocusLocationBarByDefault()) - current_tab->Focus(); - if (ignore_cache) - current_tab->controller().ReloadIgnoringCache(true); - else - current_tab->controller().Reload(true); + if (current_tab && current_tab->showing_interstitial_page()) { + NavigationEntry* entry = current_tab->controller().GetActiveEntry(); + DCHECK(entry); // Should exist if interstitial is showing. + OpenURL(entry->url(), GURL(), disposition, PageTransition::RELOAD); + return; } + + // As this is caused by a user action, give the focus to the page. + current_tab = GetOrCloneTabForDisposition(disposition); + if (!current_tab->FocusLocationBarByDefault()) + current_tab->Focus(); + if (ignore_cache) + current_tab->controller().ReloadIgnoringCache(true); + else + current_tab->controller().Reload(true); } void Browser::Home(WindowOpenDisposition disposition) { @@ -1920,18 +1907,18 @@ 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(); break; - case IDC_RELOAD_IGNORING_CACHE: ReloadIgnoringCache(); break; - case IDC_HOME: Home(disposition); break; - case IDC_OPEN_CURRENT_URL: OpenCurrentURL(); break; - case IDC_GO: Go(disposition); break; - case IDC_STOP: Stop(); break; + 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_GO: Go(disposition); break; + case IDC_STOP: Stop(); break; // Window management commands - case IDC_NEW_WINDOW: NewWindow(); break; - case IDC_NEW_INCOGNITO_WINDOW: NewIncognitoWindow(); break; + case IDC_NEW_WINDOW: NewWindow(); break; + case IDC_NEW_INCOGNITO_WINDOW: NewIncognitoWindow(); break; case IDC_NEW_WINDOW_PROFILE_0: case IDC_NEW_WINDOW_PROFILE_1: case IDC_NEW_WINDOW_PROFILE_2: @@ -1943,13 +1930,13 @@ void Browser::ExecuteCommandWithDisposition( case IDC_NEW_WINDOW_PROFILE_8: NewProfileWindowByIndex(id - IDC_NEW_WINDOW_PROFILE_0); 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_MOVE_TAB_NEXT: MoveTabNext(); break; - case IDC_MOVE_TAB_PREVIOUS: MoveTabPrevious(); 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_MOVE_TAB_NEXT: MoveTabNext(); break; + case IDC_MOVE_TAB_PREVIOUS: MoveTabPrevious(); break; case IDC_SELECT_TAB_0: case IDC_SELECT_TAB_1: case IDC_SELECT_TAB_2: @@ -1958,28 +1945,28 @@ void Browser::ExecuteCommandWithDisposition( 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_RESTORE_TAB: RestoreTab(); break; - case IDC_COPY_URL: WriteCurrentURLToClipboard(); break; - case IDC_SHOW_AS_TAB: ConvertPopupToTabbedBrowser(); break; - case IDC_FULLSCREEN: ToggleFullscreenMode(); break; - case IDC_EXIT: Exit(); break; - case IDC_TOGGLE_VERTICAL_TABS: ToggleUseVerticalTabs(); break; + break; + case IDC_SELECT_LAST_TAB: SelectLastTab(); break; + case IDC_DUPLICATE_TAB: DuplicateTab(); break; + case IDC_RESTORE_TAB: RestoreTab(); break; + case IDC_COPY_URL: WriteCurrentURLToClipboard(); break; + case IDC_SHOW_AS_TAB: ConvertPopupToTabbedBrowser(); break; + case IDC_FULLSCREEN: ToggleFullscreenMode(); break; + case IDC_EXIT: Exit(); break; + case IDC_TOGGLE_VERTICAL_TABS: ToggleUseVerticalTabs(); break; #if defined(OS_CHROMEOS) - case IDC_COMPACT_NAVBAR: ToggleCompactNavigationBar(); break; - case IDC_SEARCH: Search(); break; + case IDC_COMPACT_NAVBAR: ToggleCompactNavigationBar(); break; + case IDC_SEARCH: Search(); break; #endif // Page-related commands - case IDC_SAVE_PAGE: SavePage(); break; - case IDC_BOOKMARK_PAGE: BookmarkCurrentPage(); break; - case IDC_BOOKMARK_ALL_TABS: BookmarkAllTabs(); break; - case IDC_VIEW_SOURCE: ViewSource(); break; - case IDC_EMAIL_PAGE_LOCATION: EmailPageLocation(); break; - case IDC_PRINT: Print(); break; - case IDC_ENCODING_AUTO_DETECT: ToggleEncodingAutoDetect(); break; + case IDC_SAVE_PAGE: SavePage(); break; + case IDC_BOOKMARK_PAGE: BookmarkCurrentPage(); break; + case IDC_BOOKMARK_ALL_TABS: BookmarkAllTabs(); break; + case IDC_VIEW_SOURCE: ViewSource(); break; + case IDC_EMAIL_PAGE_LOCATION: EmailPageLocation(); break; + case IDC_PRINT: Print(); break; + case IDC_ENCODING_AUTO_DETECT: ToggleEncodingAutoDetect(); break; case IDC_ENCODING_UTF8: case IDC_ENCODING_UTF16LE: case IDC_ENCODING_ISO88591: @@ -2016,68 +2003,68 @@ void Browser::ExecuteCommandWithDisposition( case IDC_ENCODING_ISO88598: case IDC_ENCODING_ISO88598I: case IDC_ENCODING_WINDOWS1255: - case IDC_ENCODING_WINDOWS1258: OverrideEncoding(id); break; + 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: Cut(); break; + case IDC_COPY: Copy(); break; + case IDC_PASTE: Paste(); break; // Find-in-page - case IDC_FIND: Find(); break; - case IDC_FIND_NEXT: FindNext(); break; - case IDC_FIND_PREVIOUS: FindPrevious(); break; + case IDC_FIND: Find(); break; + case IDC_FIND_NEXT: FindNext(); break; + case IDC_FIND_PREVIOUS: FindPrevious(); break; // Zoom - case IDC_ZOOM_PLUS: Zoom(PageZoom::ZOOM_IN); break; - case IDC_ZOOM_NORMAL: Zoom(PageZoom::RESET); break; - case IDC_ZOOM_MINUS: Zoom(PageZoom::ZOOM_OUT); break; + case IDC_ZOOM_PLUS: Zoom(PageZoom::ZOOM_IN); break; + case IDC_ZOOM_NORMAL: Zoom(PageZoom::RESET); break; + case IDC_ZOOM_MINUS: Zoom(PageZoom::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: FocusPageAndAppMenus(); break; + case IDC_FOCUS_TOOLBAR: FocusToolbar(); break; + case IDC_FOCUS_LOCATION: FocusLocationBar(); break; + case IDC_FOCUS_SEARCH: FocusSearch(); break; + case IDC_FOCUS_MENU_BAR: FocusPageAndAppMenus(); break; // Show various bits of UI - case IDC_OPEN_FILE: OpenFile(); break; - case IDC_CREATE_SHORTCUTS: OpenCreateShortcutsDialog(); break; - case IDC_DEV_TOOLS: ToggleDevToolsWindow(false); break; - case IDC_DEV_TOOLS_CONSOLE: ToggleDevToolsWindow(true); break; - case IDC_TASK_MANAGER: OpenTaskManager(); break; - case IDC_SELECT_PROFILE: OpenSelectProfileDialog(); break; - case IDC_NEW_PROFILE: OpenNewProfileDialog(); break; - case IDC_REPORT_BUG: OpenBugReportDialog(); break; - - case IDC_SHOW_BOOKMARK_BAR: ToggleBookmarkBar(); break; - case IDC_SHOW_EXTENSION_SHELF: ToggleExtensionShelf(); break; - - case IDC_SHOW_BOOKMARK_MANAGER: OpenBookmarkManager(); break; - case IDC_SHOW_APP_MENU: ShowAppMenu(); break; - case IDC_SHOW_PAGE_MENU: ShowPageMenu(); break; - case IDC_SHOW_HISTORY: ShowHistoryTab(); break; - case IDC_SHOW_DOWNLOADS: ShowDownloadsTab(); break; - case IDC_MANAGE_EXTENSIONS: ShowExtensionsTab(); break; - case IDC_SYNC_BOOKMARKS: OpenSyncMyBookmarksDialog(); break; - case IDC_OPTIONS: OpenOptionsDialog(); break; - case IDC_EDIT_SEARCH_ENGINES: OpenKeywordEditor(); break; - case IDC_VIEW_PASSWORDS: OpenPasswordManager(); break; - case IDC_CLEAR_BROWSING_DATA: OpenClearBrowsingDataDialog(); break; - case IDC_IMPORT_SETTINGS: OpenImportSettingsDialog(); break; + case IDC_OPEN_FILE: OpenFile(); break; + case IDC_CREATE_SHORTCUTS: OpenCreateShortcutsDialog(); break; + case IDC_DEV_TOOLS: ToggleDevToolsWindow(false); break; + case IDC_DEV_TOOLS_CONSOLE: ToggleDevToolsWindow(true); break; + case IDC_TASK_MANAGER: OpenTaskManager(); break; + case IDC_SELECT_PROFILE: OpenSelectProfileDialog(); break; + case IDC_NEW_PROFILE: OpenNewProfileDialog(); break; + case IDC_REPORT_BUG: OpenBugReportDialog(); break; + + case IDC_SHOW_BOOKMARK_BAR: ToggleBookmarkBar(); break; + case IDC_SHOW_EXTENSION_SHELF: ToggleExtensionShelf(); break; + + case IDC_SHOW_BOOKMARK_MANAGER: OpenBookmarkManager(); break; + case IDC_SHOW_APP_MENU: ShowAppMenu(); break; + case IDC_SHOW_PAGE_MENU: ShowPageMenu(); break; + case IDC_SHOW_HISTORY: ShowHistoryTab(); break; + case IDC_SHOW_DOWNLOADS: ShowDownloadsTab(); break; + case IDC_MANAGE_EXTENSIONS: ShowExtensionsTab(); break; + case IDC_SYNC_BOOKMARKS: OpenSyncMyBookmarksDialog(); break; + case IDC_OPTIONS: OpenOptionsDialog(); break; + case IDC_EDIT_SEARCH_ENGINES: OpenKeywordEditor(); break; + case IDC_VIEW_PASSWORDS: OpenPasswordManager(); break; + case IDC_CLEAR_BROWSING_DATA: OpenClearBrowsingDataDialog(); break; + case IDC_IMPORT_SETTINGS: OpenImportSettingsDialog(); break; case IDC_ABOUT: if (Singleton<UpgradeDetector>::get()->notify_upgrade()) OpenUpdateChromeDialog(); else OpenAboutChromeDialog(); break; - case IDC_HELP_PAGE: OpenHelpTab(); break; + case IDC_HELP_PAGE: OpenHelpTab(); break; #if defined(OS_CHROMEOS) - case IDC_SYSTEM_OPTIONS: OpenSystemOptionsDialog(); break; - case IDC_INTERNET_OPTIONS: OpenInternetOptionsDialog(); break; + case IDC_SYSTEM_OPTIONS: OpenSystemOptionsDialog(); break; + case IDC_INTERNET_OPTIONS: OpenInternetOptionsDialog(); break; #endif // AutoFill - case IDC_AUTOFILL_DEFAULT: AutoFillDefaultProfile(); break; + case IDC_AUTOFILL_DEFAULT: AutoFillDefaultProfile(); break; default: LOG(WARNING) << "Received Unimplemented Command: " << id; diff --git a/chrome/browser/browser.h b/chrome/browser/browser.h index d67cf4a..5a3a636 100644 --- a/chrome/browser/browser.h +++ b/chrome/browser/browser.h @@ -431,8 +431,8 @@ class Browser : public TabStripModelDelegate, // Navigation commands void GoBack(WindowOpenDisposition disposition); void GoForward(WindowOpenDisposition disposition); - void Reload(); - void ReloadIgnoringCache(); // AKA shift-reload. + void Reload(WindowOpenDisposition disposition); + void ReloadIgnoringCache(WindowOpenDisposition disposition); // Shift-reload. void Home(WindowOpenDisposition disposition); void OpenCurrentURL(); void Go(WindowOpenDisposition disposition); @@ -894,15 +894,14 @@ class Browser : public TabStripModelDelegate, static void RegisterAppPrefs(const std::wstring& app_name); // Shared code between Reload() and ReloadAll(). - void ReloadInternal(bool ignore_cache); + void ReloadInternal(WindowOpenDisposition disposition, bool ignore_cache); // Return true if the window dispositions means opening a new tab. bool ShouldOpenNewTabForWindowDisposition(WindowOpenDisposition disposition); - // Depending on the disposition, return the |NavigationController| for the - // current tab or clone the current tab and return its |NavigationController|. - NavigationController& GetOrCloneNavigationControllerForDisposition( - WindowOpenDisposition disp); + // Depending on the disposition, return the current tab or a clone of the + // current tab. + TabContents* GetOrCloneTabForDisposition(WindowOpenDisposition disposition); // Sets the insertion policy of the tabstrip based on whether vertical tabs // are enabled. diff --git a/chrome/browser/browser_browsertest.cc b/chrome/browser/browser_browsertest.cc index 055e4cc..c4dbd39 100644 --- a/chrome/browser/browser_browsertest.cc +++ b/chrome/browser/browser_browsertest.cc @@ -260,7 +260,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(); + browser()->Reload(CURRENT_TAB); AppModalDialog* alert = ui_test_utils::WaitForAppModalDialog(); alert->CloseModalDialog(); EXPECT_FALSE(browser()->GetSelectedTabContents()->is_loading()); diff --git a/chrome/browser/browser_focus_uitest.cc b/chrome/browser/browser_focus_uitest.cc index a24e1b6..93f7998 100644 --- a/chrome/browser/browser_focus_uitest.cc +++ b/chrome/browser/browser_focus_uitest.cc @@ -738,7 +738,7 @@ IN_PROC_BROWSER_TEST_F(BrowserFocusTest, FocusOnReload) { ui_test_utils::RunAllPendingInMessageLoop(); - browser()->Reload(); + browser()->Reload(CURRENT_TAB); ASSERT_TRUE(ui_test_utils::WaitForNavigationInCurrentTab(browser())); // Focus should stay on the location bar. ASSERT_TRUE(IsViewFocused(VIEW_ID_LOCATION_BAR)); @@ -747,7 +747,7 @@ IN_PROC_BROWSER_TEST_F(BrowserFocusTest, FocusOnReload) { ui_test_utils::NavigateToURL(browser(), server->TestServerPage(kSimplePage)); browser()->FocusLocationBar(); ASSERT_TRUE(IsViewFocused(VIEW_ID_LOCATION_BAR)); - browser()->Reload(); + browser()->Reload(CURRENT_TAB); ASSERT_TRUE(ui_test_utils::WaitForNavigationInCurrentTab(browser())); // Focus should now be on the tab contents. browser()->ShowDownloadsTab(); @@ -761,7 +761,7 @@ IN_PROC_BROWSER_TEST_F(BrowserFocusTest, FocusOnReloadCrashedTab) { // Open a regular page, crash, reload. ui_test_utils::NavigateToURL(browser(), server->TestServerPage(kSimplePage)); ui_test_utils::CrashTab(browser()->GetSelectedTabContents()); - browser()->Reload(); + browser()->Reload(CURRENT_TAB); ASSERT_TRUE(ui_test_utils::WaitForNavigationInCurrentTab(browser())); // Focus should now be on the tab contents. browser()->ShowDownloadsTab(); diff --git a/chrome/browser/chromeos/compact_location_bar_view.cc b/chrome/browser/chromeos/compact_location_bar_view.cc index cfffec2..bec7646f 100644 --- a/chrome/browser/chromeos/compact_location_bar_view.cc +++ b/chrome/browser/chromeos/compact_location_bar_view.cc @@ -195,14 +195,19 @@ void CompactLocationBarView::Focus() { void CompactLocationBarView::ButtonPressed(views::Button* sender, const views::Event& event) { int id = sender->tag(); - // Shift-clicking or Ctrl-clicking the reload button means we should + int flags = sender->mouse_event_flags(); + // Shift-clicking or ctrl-clicking the reload button means we should // ignore any cached content. // TODO(avayvod): eliminate duplication of this logic in // CompactLocationBarView. - if (id == IDC_RELOAD && (event.IsShiftDown() || event.IsControlDown())) + if (id == IDC_RELOAD && (event.IsShiftDown() || event.IsControlDown())) { id = IDC_RELOAD_IGNORING_CACHE; + // Mask off shift/ctrl so they aren't interpreted as affecting the + // disposition below. + flags &= ~(views::Event::EF_SHIFT_DOWN | views::Event::EF_CONTROL_DOWN); + } browser()->ExecuteCommandWithDisposition( - id, event_utils::DispositionFromEventFlags(sender->mouse_event_flags())); + id, event_utils::DispositionFromEventFlags(flags)); } //////////////////////////////////////////////////////////////////////////////// diff --git a/chrome/browser/cocoa/browser_window_controller.mm b/chrome/browser/cocoa/browser_window_controller.mm index 345eb00..fa33dfb0 100644 --- a/chrome/browser/cocoa/browser_window_controller.mm +++ b/chrome/browser/cocoa/browser_window_controller.mm @@ -918,25 +918,8 @@ if ([sender respondsToSelector:@selector(window)]) targetController = [[sender window] windowController]; DCHECK([targetController isKindOfClass:[BrowserWindowController class]]); - NSInteger tag = [sender tag]; - switch (tag) { - case IDC_RELOAD: - if ([sender isKindOfClass:[NSButton class]]) { - // We revert the bar when the reload button is pressed, but don't when - // Command+r is pressed (Issue 15464). Unlike the event handler function - // for Windows (ToolbarView::ButtonPressed()), this function handles - // both reload button press event and Command+r press event. Thus the - // 'isKindofClass' check is necessary. - [targetController locationBarBridge]->Revert(); - } - NSUInteger modifierFlags = [[NSApp currentEvent] modifierFlags]; - if (modifierFlags & NSShiftKeyMask) { - tag = IDC_RELOAD_IGNORING_CACHE; - } - break; - } DCHECK(targetController->browser_.get()); - targetController->browser_->ExecuteCommand(tag); + targetController->browser_->ExecuteCommand([sender tag]); } // Same as |-commandDispatch:|, but executes commands using a disposition @@ -949,17 +932,37 @@ if ([sender respondsToSelector:@selector(window)]) targetController = [[sender window] windowController]; DCHECK([targetController isKindOfClass:[BrowserWindowController class]]); - NSInteger tag = [sender tag]; - DCHECK(targetController->browser_.get()); + NSInteger command = [sender tag]; NSUInteger modifierFlags = [[NSApp currentEvent] modifierFlags]; + if ((command == IDC_RELOAD) && (modifierFlags & NSShiftKeyMask)) { + command = IDC_RELOAD_IGNORING_CACHE; + // Mask off shift so it isn't interpreted as affecting the disposition + // below. + modifierFlags &= ~NSShiftKeyMask; + } if (![[sender window] isMainWindow]) { // Remove the command key from the flags, it means "keep the window in // the background" in this case. modifierFlags &= ~NSCommandKeyMask; } - targetController->browser_->ExecuteCommandWithDisposition(tag, + WindowOpenDisposition disposition = event_utils::WindowOpenDispositionFromNSEventWithFlags( - [NSApp currentEvent], modifierFlags)); + [NSApp currentEvent], modifierFlags); + switch (command) { + case IDC_BACK: + case IDC_FORWARD: + case IDC_RELOAD: + case IDC_RELOAD_IGNORING_CACHE: + if (disposition == CURRENT_TAB) { + // Forcibly reset the location bar, since otherwise it won't discard any + // ongoing user edits, since it doesn't realize this is a user-initiated + // action. + [targetController locationBarBridge]->Revert(); + } + } + DCHECK(targetController->browser_.get()); + targetController->browser_->ExecuteCommandWithDisposition(command, + disposition); } // Called when another part of the internal codebase needs to execute a diff --git a/chrome/browser/crash_recovery_browsertest.cc b/chrome/browser/crash_recovery_browsertest.cc index 1ee4cc4..08cb32c 100644 --- a/chrome/browser/crash_recovery_browsertest.cc +++ b/chrome/browser/crash_recovery_browsertest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -51,7 +51,7 @@ IN_PROC_BROWSER_TEST_F(CrashRecoveryBrowserTest, MAYBE_Reload) { ASSERT_TRUE(ui_test_utils::GetCurrentTabTitle(browser(), &title_before_crash)); SimulateRendererCrash(browser()); - browser()->Reload(); + browser()->Reload(CURRENT_TAB); ASSERT_TRUE(ui_test_utils::WaitForNavigationInCurrentTab(browser())); ASSERT_TRUE(ui_test_utils::GetCurrentTabTitle(browser(), &title_after_crash)); @@ -75,7 +75,7 @@ IN_PROC_BROWSER_TEST_F(CrashRecoveryBrowserTest, MAYBE_LoadInNewTab) { ASSERT_TRUE(ui_test_utils::GetCurrentTabTitle(browser(), &title_before_crash)); SimulateRendererCrash(browser()); - browser()->Reload(); + browser()->Reload(CURRENT_TAB); ASSERT_TRUE(ui_test_utils::WaitForNavigationInCurrentTab(browser())); ASSERT_TRUE(ui_test_utils::GetCurrentTabTitle(browser(), &title_after_crash)); diff --git a/chrome/browser/extensions/extension_browsertests_misc.cc b/chrome/browser/extensions/extension_browsertests_misc.cc index dc0ce7e..9ac8fbb 100644 --- a/chrome/browser/extensions/extension_browsertests_misc.cc +++ b/chrome/browser/extensions/extension_browsertests_misc.cc @@ -741,7 +741,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, MAYBE_PluginLoadUnload) { ui_test_utils::ExecuteJavaScriptAndExtractBool( tab->render_view_host(), L"", L"testPluginWorks()", &result); EXPECT_FALSE(result); - browser()->Reload(); + browser()->Reload(CURRENT_TAB); ui_test_utils::WaitForNavigationInCurrentTab(browser()); ui_test_utils::ExecuteJavaScriptAndExtractBool( tab->render_view_host(), L"", L"testPluginWorks()", &result); @@ -761,7 +761,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, MAYBE_PluginLoadUnload) { ASSERT_TRUE(LoadExtension(extension_dir)); EXPECT_EQ(size_before + 1, service->extensions()->size()); - browser()->Reload(); + browser()->Reload(CURRENT_TAB); ui_test_utils::WaitForNavigationInCurrentTab(browser()); ui_test_utils::ExecuteJavaScriptAndExtractBool( tab->render_view_host(), L"", L"testPluginWorks()", &result); diff --git a/chrome/browser/find_bar_host_browsertest.cc b/chrome/browser/find_bar_host_browsertest.cc index 9ffaf72..edf0bdd 100644 --- a/chrome/browser/find_bar_host_browsertest.cc +++ b/chrome/browser/find_bar_host_browsertest.cc @@ -548,7 +548,7 @@ IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindDisappearOnNavigate) { EXPECT_TRUE(fully_visible); // Reload the tab and make sure Find window doesn't go away. - browser()->Reload(); + browser()->Reload(CURRENT_TAB); ui_test_utils::WaitForNavigationInCurrentTab(browser()); EXPECT_TRUE(GetFindBarWindowInfo(&position, &fully_visible)); diff --git a/chrome/browser/gtk/browser_toolbar_gtk.cc b/chrome/browser/gtk/browser_toolbar_gtk.cc index 961adb9..30115f3 100644 --- a/chrome/browser/gtk/browser_toolbar_gtk.cc +++ b/chrome/browser/gtk/browser_toolbar_gtk.cc @@ -699,29 +699,35 @@ gboolean BrowserToolbarGtk::OnLocationHboxExpose(GtkWidget* location_hbox, } void BrowserToolbarGtk::OnButtonClick(GtkWidget* button) { - if ((button == back_->widget()) || - (button == forward_->widget())) { - location_bar_->Revert(); + if ((button == back_->widget()) || (button == forward_->widget())) { + if (gtk_util::DispositionForCurrentButtonPressEvent() == CURRENT_TAB) + location_bar_->Revert(); return; } - int tag = -1; + int command = -1; + GdkModifierType modifier_state; + gtk_get_current_event_state(&modifier_state); + guint modifier_state_uint = modifier_state; if (button == reload_->widget()) { - GdkModifierType modifier_state; - if (gtk_get_current_event_state(&modifier_state) && - modifier_state & GDK_SHIFT_MASK) { - tag = IDC_RELOAD_IGNORING_CACHE; + if (modifier_state_uint & GDK_SHIFT_MASK) { + command = IDC_RELOAD_IGNORING_CACHE; + // Mask off shift so it isn't interpreted as affecting the disposition + // below. + modifier_state_uint &= ~GDK_SHIFT_MASK; } else { - tag = IDC_RELOAD; + command = IDC_RELOAD; } - location_bar_->Revert(); + if (event_utils::DispositionFromEventFlags(modifier_state_uint) == + CURRENT_TAB) + location_bar_->Revert(); } else if (home_.get() && button == home_->widget()) { - tag = IDC_HOME; + command = IDC_HOME; } - DCHECK_NE(tag, -1) << "Unexpected button click callback"; - browser_->ExecuteCommandWithDisposition(tag, - gtk_util::DispositionForCurrentButtonPressEvent()); + DCHECK_NE(command, -1) << "Unexpected button click callback"; + browser_->ExecuteCommandWithDisposition(command, + event_utils::DispositionFromEventFlags(modifier_state_uint)); } gboolean BrowserToolbarGtk::OnMenuButtonPressEvent(GtkWidget* button, diff --git a/chrome/browser/views/toolbar_view.cc b/chrome/browser/views/toolbar_view.cc index 7dce5fe..05f892d 100644 --- a/chrome/browser/views/toolbar_view.cc +++ b/chrome/browser/views/toolbar_view.cc @@ -87,6 +87,7 @@ ToolbarView::ToolbarView(Browser* browser) destroyed_flag_(NULL), collapsed_(false) { SetID(VIEW_ID_TOOLBAR); + browser_->command_updater()->AddCommandObserver(IDC_BACK, this); browser_->command_updater()->AddCommandObserver(IDC_FORWARD, this); browser_->command_updater()->AddCommandObserver(IDC_HOME, this); @@ -153,6 +154,8 @@ void ToolbarView::Init(Profile* profile) { home_->SetID(VIEW_ID_HOME_BUTTON); reload_ = new views::ImageButton(this); + reload_->set_triggerable_event_flags(views::Event::EF_LEFT_BUTTON_DOWN | + views::Event::EF_MIDDLE_BUTTON_DOWN); reload_->set_tag(IDC_RELOAD); reload_->SetTooltipText(l10n_util::GetString(IDS_TOOLTIP_RELOAD)); reload_->SetAccessibleName(l10n_util::GetString(IDS_ACCNAME_RELOAD)); @@ -403,25 +406,34 @@ void ToolbarView::EnabledStateChangedForCommand(int id, bool enabled) { void ToolbarView::ButtonPressed(views::Button* sender, const views::Event& event) { - int id = sender->tag(); - switch (id) { + int command = sender->tag(); + int flags = sender->mouse_event_flags(); + // Shift-clicking or Ctrl-clicking the reload button means we should ignore + // any cached content. + // TODO(avayvod): eliminate duplication of this logic in + // CompactLocationBarView. + if ((command == IDC_RELOAD) && + (event.IsShiftDown() || event.IsControlDown())) { + command = IDC_RELOAD_IGNORING_CACHE; + // Mask off shift/ctrl so they aren't interpreted as affecting the + // disposition below. + flags &= ~(views::Event::EF_SHIFT_DOWN | views::Event::EF_CONTROL_DOWN); + } + WindowOpenDisposition disposition = + event_utils::DispositionFromEventFlags(flags); + switch (command) { case IDC_BACK: case IDC_FORWARD: case IDC_RELOAD: - // Forcibly reset the location bar, since otherwise it won't discard any - // ongoing user edits, since it doesn't realize this is a user-initiated - // action. - location_bar_->Revert(); - // Shift-clicking or Ctrl-clicking the reload button means we should - // ignore any cached content. - // TODO(avayvod): eliminate duplication of this logic in - // CompactLocationBarView. - if (id == IDC_RELOAD && (event.IsShiftDown() || event.IsControlDown())) - id = IDC_RELOAD_IGNORING_CACHE; - break; + case IDC_RELOAD_IGNORING_CACHE: + if (disposition == CURRENT_TAB) { + // Forcibly reset the location bar, since otherwise it won't discard any + // ongoing user edits, since it doesn't realize this is a user-initiated + // action. + location_bar_->Revert(); + } } - browser_->ExecuteCommandWithDisposition( - id, event_utils::DispositionFromEventFlags(sender->mouse_event_flags())); + browser_->ExecuteCommandWithDisposition(command, disposition); } //////////////////////////////////////////////////////////////////////////////// |