Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(34)

Unified Diff: chrome/browser/ui/browser.cc

Issue 6893046: added CTRL+Click and SHIFT+Click handler for context menu, Back and Forward. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: fixed some mistakes again Created 9 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/browser.cc
diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc
index edebe564bb01b50a69d42a5fcc0014c72de7af9f..5e27cfcdcd4a522c05e8c5435a2f738b8a20cf55 100644
--- a/chrome/browser/ui/browser.cc
+++ b/chrome/browser/ui/browser.cc
@@ -1273,21 +1273,56 @@ void Browser::GoBack(WindowOpenDisposition disposition) {
UserMetrics::RecordAction(UserMetricsAction("Back"));
TabContentsWrapper* current_tab = GetSelectedTabContentsWrapper();
- if (current_tab->controller().CanGoBack()) {
- TabContents* new_tab = GetOrCloneTabForDisposition(disposition);
+ if (!current_tab->controller().CanGoBack())
+ return;
+
+ if (disposition == NEW_WINDOW) {
+ TabContentsWrapper* new_wrapper = current_tab->Clone();
+
// 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->tab_contents()->showing_interstitial_page() &&
+ (new_wrapper->tab_contents() != current_tab->tab_contents()))
+ return;
+
+ new_wrapper->tab_contents()->controller().GoBack();
+
+ // Make a new normal browser window.
+ Browser* browser = new Browser(Browser::TYPE_NORMAL, profile_);
+ browser->InitBrowserWindow();
+ browser->AddTab(new_wrapper, PageTransition::LINK);
+ browser->window()->Show();
+ } else {
+ TabContents* new_tab = GetOrCloneTabForDisposition(disposition);
+
+ if (current_tab->tab_contents()->showing_interstitial_page() &&
(new_tab != current_tab->tab_contents()))
return;
+
new_tab->controller().GoBack();
}
}
void Browser::GoForward(WindowOpenDisposition disposition) {
UserMetrics::RecordAction(UserMetricsAction("Forward"));
- if (GetSelectedTabContentsWrapper()->controller().CanGoForward())
+
+ TabContentsWrapper* current_tab = GetSelectedTabContentsWrapper();
+ if (!current_tab->controller().CanGoForward())
+ return;
+
+ if (disposition == NEW_WINDOW) {
+ TabContentsWrapper* new_wrapper = current_tab->Clone();
+
+ new_wrapper->tab_contents()->controller().GoForward();
+
+ // Make a new normal browser window.
+ Browser* browser = new Browser(Browser::TYPE_NORMAL, profile_);
brettw 2011/05/03 19:43:53 It seems like this logic should be inside GetOrClo
+ browser->InitBrowserWindow();
+ browser->AddTab(new_wrapper, PageTransition::LINK);
+ browser->window()->Show();
+ } else {
GetOrCloneTabForDisposition(disposition)->controller().GoForward();
+ }
}
void Browser::Reload(WindowOpenDisposition disposition) {

Powered by Google App Engine
This is Rietveld 408576698