OLD | NEW |
---|---|
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 1255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1266 bool can_close = !watcher || watcher->CanCloseBrowser(this); | 1266 bool can_close = !watcher || watcher->CanCloseBrowser(this); |
1267 if (!can_close && is_attempting_to_close_browser_) | 1267 if (!can_close && is_attempting_to_close_browser_) |
1268 CancelWindowClose(); | 1268 CancelWindowClose(); |
1269 return can_close; | 1269 return can_close; |
1270 } | 1270 } |
1271 | 1271 |
1272 void Browser::GoBack(WindowOpenDisposition disposition) { | 1272 void Browser::GoBack(WindowOpenDisposition disposition) { |
1273 UserMetrics::RecordAction(UserMetricsAction("Back")); | 1273 UserMetrics::RecordAction(UserMetricsAction("Back")); |
1274 | 1274 |
1275 TabContentsWrapper* current_tab = GetSelectedTabContentsWrapper(); | 1275 TabContentsWrapper* current_tab = GetSelectedTabContentsWrapper(); |
1276 if (current_tab->controller().CanGoBack()) { | 1276 if (!current_tab->controller().CanGoBack()) |
1277 TabContents* new_tab = GetOrCloneTabForDisposition(disposition); | 1277 return; |
1278 | |
1279 if (disposition == NEW_WINDOW) { | |
1280 TabContentsWrapper* new_wrapper = current_tab->Clone(); | |
1281 | |
1278 // If we are on an interstitial page and clone the tab, it won't be copied | 1282 // If we are on an interstitial page and clone the tab, it won't be copied |
1279 // to the new tab, so we don't need to go back. | 1283 // to the new tab, so we don't need to go back. |
1280 if (current_tab->tab_contents()->showing_interstitial_page() && | 1284 if (current_tab->tab_contents()->showing_interstitial_page() && |
1285 (new_wrapper->tab_contents() != current_tab->tab_contents())) | |
1286 return; | |
1287 | |
1288 new_wrapper->tab_contents()->controller().GoBack(); | |
1289 | |
1290 // Make a new normal browser window. | |
1291 Browser* browser = new Browser(Browser::TYPE_NORMAL, profile_); | |
1292 browser->InitBrowserWindow(); | |
1293 browser->AddTab(new_wrapper, PageTransition::LINK); | |
1294 browser->window()->Show(); | |
1295 } else { | |
1296 TabContents* new_tab = GetOrCloneTabForDisposition(disposition); | |
1297 | |
1298 if (current_tab->tab_contents()->showing_interstitial_page() && | |
1281 (new_tab != current_tab->tab_contents())) | 1299 (new_tab != current_tab->tab_contents())) |
1282 return; | 1300 return; |
1301 | |
1283 new_tab->controller().GoBack(); | 1302 new_tab->controller().GoBack(); |
1284 } | 1303 } |
1285 } | 1304 } |
1286 | 1305 |
1287 void Browser::GoForward(WindowOpenDisposition disposition) { | 1306 void Browser::GoForward(WindowOpenDisposition disposition) { |
1288 UserMetrics::RecordAction(UserMetricsAction("Forward")); | 1307 UserMetrics::RecordAction(UserMetricsAction("Forward")); |
1289 if (GetSelectedTabContentsWrapper()->controller().CanGoForward()) | 1308 |
1309 TabContentsWrapper* current_tab = GetSelectedTabContentsWrapper(); | |
1310 if (!current_tab->controller().CanGoForward()) | |
1311 return; | |
1312 | |
1313 if (disposition == NEW_WINDOW) { | |
1314 TabContentsWrapper* new_wrapper = current_tab->Clone(); | |
1315 | |
1316 new_wrapper->tab_contents()->controller().GoForward(); | |
1317 | |
1318 // Make a new normal browser window. | |
1319 Browser* browser = new Browser(Browser::TYPE_NORMAL, profile_); | |
brettw
2011/05/03 19:43:53
It seems like this logic should be inside GetOrClo
| |
1320 browser->InitBrowserWindow(); | |
1321 browser->AddTab(new_wrapper, PageTransition::LINK); | |
1322 browser->window()->Show(); | |
1323 } else { | |
1290 GetOrCloneTabForDisposition(disposition)->controller().GoForward(); | 1324 GetOrCloneTabForDisposition(disposition)->controller().GoForward(); |
1325 } | |
1291 } | 1326 } |
1292 | 1327 |
1293 void Browser::Reload(WindowOpenDisposition disposition) { | 1328 void Browser::Reload(WindowOpenDisposition disposition) { |
1294 UserMetrics::RecordAction(UserMetricsAction("Reload")); | 1329 UserMetrics::RecordAction(UserMetricsAction("Reload")); |
1295 ReloadInternal(disposition, false); | 1330 ReloadInternal(disposition, false); |
1296 } | 1331 } |
1297 | 1332 |
1298 void Browser::ReloadIgnoringCache(WindowOpenDisposition disposition) { | 1333 void Browser::ReloadIgnoringCache(WindowOpenDisposition disposition) { |
1299 UserMetrics::RecordAction(UserMetricsAction("ReloadIgnoringCache")); | 1334 UserMetrics::RecordAction(UserMetricsAction("ReloadIgnoringCache")); |
1300 ReloadInternal(disposition, true); | 1335 ReloadInternal(disposition, true); |
(...skipping 3159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4460 TabContents* current_tab = GetSelectedTabContents(); | 4495 TabContents* current_tab = GetSelectedTabContents(); |
4461 if (current_tab) { | 4496 if (current_tab) { |
4462 content_restrictions = current_tab->content_restrictions(); | 4497 content_restrictions = current_tab->content_restrictions(); |
4463 NavigationEntry* active_entry = current_tab->controller().GetActiveEntry(); | 4498 NavigationEntry* active_entry = current_tab->controller().GetActiveEntry(); |
4464 // See comment in UpdateCommandsForTabState about why we call url(). | 4499 // See comment in UpdateCommandsForTabState about why we call url(). |
4465 if (!SavePackage::IsSavableURL(active_entry ? active_entry->url() : GURL())) | 4500 if (!SavePackage::IsSavableURL(active_entry ? active_entry->url() : GURL())) |
4466 content_restrictions |= CONTENT_RESTRICTION_SAVE; | 4501 content_restrictions |= CONTENT_RESTRICTION_SAVE; |
4467 } | 4502 } |
4468 return content_restrictions; | 4503 return content_restrictions; |
4469 } | 4504 } |
OLD | NEW |