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

Side by Side 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: 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/browser.h" 5 #include "chrome/browser/ui/browser.h"
6 6
7 #if defined(OS_WIN) 7 #if defined(OS_WIN)
8 #include <shellapi.h> 8 #include <shellapi.h>
9 #include <windows.h> 9 #include <windows.h>
10 #endif // OS_WIN 10 #endif // OS_WIN
(...skipping 1189 matching lines...) Expand 10 before | Expand all | Expand 10 after
1200 1200
1201 bool Browser::ShouldOpenNewTabForWindowDisposition( 1201 bool Browser::ShouldOpenNewTabForWindowDisposition(
1202 WindowOpenDisposition disposition) { 1202 WindowOpenDisposition disposition) {
1203 return (disposition == NEW_FOREGROUND_TAB || 1203 return (disposition == NEW_FOREGROUND_TAB ||
1204 disposition == NEW_BACKGROUND_TAB); 1204 disposition == NEW_BACKGROUND_TAB);
1205 } 1205 }
1206 1206
1207 TabContents* Browser::GetOrCloneTabForDisposition( 1207 TabContents* Browser::GetOrCloneTabForDisposition(
1208 WindowOpenDisposition disposition) { 1208 WindowOpenDisposition disposition) {
1209 TabContentsWrapper* current_tab = GetSelectedTabContentsWrapper(); 1209 TabContentsWrapper* current_tab = GetSelectedTabContentsWrapper();
1210
1210 if (ShouldOpenNewTabForWindowDisposition(disposition)) { 1211 if (ShouldOpenNewTabForWindowDisposition(disposition)) {
1211 current_tab = current_tab->Clone(); 1212 current_tab = current_tab->Clone();
1212 tab_handler_->GetTabStripModel()->AddTabContents( 1213 tab_handler_->GetTabStripModel()->AddTabContents(
1213 current_tab, -1, PageTransition::LINK, 1214 current_tab, -1, PageTransition::LINK,
1214 disposition == NEW_FOREGROUND_TAB ? TabStripModel::ADD_ACTIVE : 1215 disposition == NEW_FOREGROUND_TAB ? TabStripModel::ADD_ACTIVE :
1215 TabStripModel::ADD_NONE); 1216 TabStripModel::ADD_NONE);
1216 } 1217 }
1218
1217 return current_tab->tab_contents(); 1219 return current_tab->tab_contents();
1218 } 1220 }
1219 1221
1220 void Browser::UpdateTabStripModelInsertionPolicy() { 1222 void Browser::UpdateTabStripModelInsertionPolicy() {
1221 tab_handler_->GetTabStripModel()->SetInsertionPolicy(UseVerticalTabs() ? 1223 tab_handler_->GetTabStripModel()->SetInsertionPolicy(UseVerticalTabs() ?
1222 TabStripModel::INSERT_BEFORE : TabStripModel::INSERT_AFTER); 1224 TabStripModel::INSERT_BEFORE : TabStripModel::INSERT_AFTER);
1223 } 1225 }
1224 1226
1225 void Browser::UseVerticalTabsChanged() { 1227 void Browser::UseVerticalTabsChanged() {
1226 UpdateTabStripModelInsertionPolicy(); 1228 UpdateTabStripModelInsertionPolicy();
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
1271 bool can_close = !watcher || watcher->CanCloseBrowser(this); 1273 bool can_close = !watcher || watcher->CanCloseBrowser(this);
1272 if (!can_close && is_attempting_to_close_browser_) 1274 if (!can_close && is_attempting_to_close_browser_)
1273 CancelWindowClose(); 1275 CancelWindowClose();
1274 return can_close; 1276 return can_close;
1275 } 1277 }
1276 1278
1277 void Browser::GoBack(WindowOpenDisposition disposition) { 1279 void Browser::GoBack(WindowOpenDisposition disposition) {
1278 UserMetrics::RecordAction(UserMetricsAction("Back"), profile_); 1280 UserMetrics::RecordAction(UserMetricsAction("Back"), profile_);
1279 1281
1280 TabContentsWrapper* current_tab = GetSelectedTabContentsWrapper(); 1282 TabContentsWrapper* current_tab = GetSelectedTabContentsWrapper();
1281 if (current_tab->controller().CanGoBack()) { 1283 if (!current_tab->controller().CanGoBack())
1282 TabContents* new_tab = GetOrCloneTabForDisposition(disposition); 1284 return;
1285
1286 if (disposition == NEW_WINDOW) {
1287 TabContentsWrapper* new_wrapper = current_tab->Clone();
1288
1283 // If we are on an interstitial page and clone the tab, it won't be copied 1289 // If we are on an interstitial page and clone the tab, it won't be copied
1284 // to the new tab, so we don't need to go back. 1290 // to the new tab, so we don't need to go back.
1285 if (current_tab->tab_contents()->showing_interstitial_page() && 1291 if (current_tab->tab_contents()->showing_interstitial_page() &&
1292 (new_wrapper->tab_contents() != current_tab->tab_contents()))
1293 return;
1294
1295 new_wrapper->tab_contents()->controller().GoBack();
1296
1297 // Make a new normal browser window.
1298 Browser* browser = new Browser(Browser::TYPE_NORMAL, profile_);
1299 browser->InitBrowserWindow();
1300 browser->AddTab(new_wrapper, PageTransition::LINK);
1301 browser->window()->Show();
1302 } else {
1303 TabContents* new_tab = GetOrCloneTabForDisposition(disposition);
1304
1305 if (current_tab->tab_contents()->showing_interstitial_page() &&
1286 (new_tab != current_tab->tab_contents())) 1306 (new_tab != current_tab->tab_contents()))
1287 return; 1307 return;
1308
1288 new_tab->controller().GoBack(); 1309 new_tab->controller().GoBack();
1289 } 1310 }
1290 } 1311 }
1291 1312
1292 void Browser::GoForward(WindowOpenDisposition disposition) { 1313 void Browser::GoForward(WindowOpenDisposition disposition) {
1293 UserMetrics::RecordAction(UserMetricsAction("Forward"), profile_); 1314 UserMetrics::RecordAction(UserMetricsAction("Forward"), profile_);
1294 if (GetSelectedTabContentsWrapper()->controller().CanGoForward()) 1315
1316 TabContentsWrapper* current_tab = GetSelectedTabContentsWrapper();
1317 if (!current_tab->controller().CanGoForward())
1318 return;
1319
1320 if (disposition == NEW_WINDOW) {
1321 TabContentsWrapper* new_wrapper = current_tab->Clone();
1322
1323 new_wrapper->tab_contents()->controller().GoForward();
1324
1325 // Make a new normal browser window.
1326 Browser* browser = new Browser(Browser::TYPE_NORMAL, profile_);
1327 browser->InitBrowserWindow();
1328 browser->AddTab(new_wrapper, PageTransition::LINK);
1329 browser->window()->Show();
1330 } else {
1295 GetOrCloneTabForDisposition(disposition)->controller().GoForward(); 1331 GetOrCloneTabForDisposition(disposition)->controller().GoForward();
1332 }
1296 } 1333 }
1297 1334
1298 void Browser::Reload(WindowOpenDisposition disposition) { 1335 void Browser::Reload(WindowOpenDisposition disposition) {
1299 UserMetrics::RecordAction(UserMetricsAction("Reload"), profile_); 1336 UserMetrics::RecordAction(UserMetricsAction("Reload"), profile_);
1300 ReloadInternal(disposition, false); 1337 ReloadInternal(disposition, false);
1301 } 1338 }
1302 1339
1303 void Browser::ReloadIgnoringCache(WindowOpenDisposition disposition) { 1340 void Browser::ReloadIgnoringCache(WindowOpenDisposition disposition) {
1304 UserMetrics::RecordAction(UserMetricsAction("ReloadIgnoringCache"), profile_); 1341 UserMetrics::RecordAction(UserMetricsAction("ReloadIgnoringCache"), profile_);
1305 ReloadInternal(disposition, true); 1342 ReloadInternal(disposition, true);
(...skipping 3171 matching lines...) Expand 10 before | Expand all | Expand 10 after
4477 TabContents* current_tab = GetSelectedTabContents(); 4514 TabContents* current_tab = GetSelectedTabContents();
4478 if (current_tab) { 4515 if (current_tab) {
4479 content_restrictions = current_tab->content_restrictions(); 4516 content_restrictions = current_tab->content_restrictions();
4480 NavigationEntry* active_entry = current_tab->controller().GetActiveEntry(); 4517 NavigationEntry* active_entry = current_tab->controller().GetActiveEntry();
4481 // See comment in UpdateCommandsForTabState about why we call url(). 4518 // See comment in UpdateCommandsForTabState about why we call url().
4482 if (!SavePackage::IsSavableURL(active_entry ? active_entry->url() : GURL())) 4519 if (!SavePackage::IsSavableURL(active_entry ? active_entry->url() : GURL()))
4483 content_restrictions |= CONTENT_RESTRICTION_SAVE; 4520 content_restrictions |= CONTENT_RESTRICTION_SAVE;
4484 } 4521 }
4485 return content_restrictions; 4522 return content_restrictions;
4486 } 4523 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698