| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/browser.h" | 5 #include "chrome/browser/browser.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "app/animation.h" | 10 #include "app/animation.h" |
| (...skipping 806 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 817 } else { | 817 } else { |
| 818 // Default disposition is CURRENT_TAB. | 818 // Default disposition is CURRENT_TAB. |
| 819 controller = &GetSelectedTabContents()->controller(); | 819 controller = &GetSelectedTabContents()->controller(); |
| 820 } | 820 } |
| 821 controller->GoForward(); | 821 controller->GoForward(); |
| 822 } | 822 } |
| 823 } | 823 } |
| 824 | 824 |
| 825 void Browser::Reload() { | 825 void Browser::Reload() { |
| 826 UserMetrics::RecordAction("Reload", profile_); | 826 UserMetrics::RecordAction("Reload", profile_); |
| 827 ReloadInternal(false); |
| 828 } |
| 827 | 829 |
| 830 void Browser::ReloadIgnoringCache() { |
| 831 UserMetrics::RecordAction("ReloadIgnoringCache", profile_); |
| 832 ReloadInternal(true); |
| 833 } |
| 834 |
| 835 void Browser::ReloadInternal(bool ignore_cache) { |
| 828 // If we are showing an interstitial, treat this as an OpenURL. | 836 // If we are showing an interstitial, treat this as an OpenURL. |
| 829 TabContents* current_tab = GetSelectedTabContents(); | 837 TabContents* current_tab = GetSelectedTabContents(); |
| 830 if (current_tab) { | 838 if (current_tab) { |
| 831 if (current_tab->showing_interstitial_page()) { | 839 if (current_tab->showing_interstitial_page()) { |
| 832 NavigationEntry* entry = current_tab->controller().GetActiveEntry(); | 840 NavigationEntry* entry = current_tab->controller().GetActiveEntry(); |
| 833 DCHECK(entry); // Should exist if interstitial is showing. | 841 DCHECK(entry); // Should exist if interstitial is showing. |
| 834 OpenURL(entry->url(), GURL(), CURRENT_TAB, PageTransition::RELOAD); | 842 OpenURL(entry->url(), GURL(), CURRENT_TAB, PageTransition::RELOAD); |
| 835 return; | 843 return; |
| 836 } | 844 } |
| 837 | 845 |
| 838 // As this is caused by a user action, give the focus to the page. | 846 // As this is caused by a user action, give the focus to the page. |
| 839 if (!current_tab->FocusLocationBarByDefault()) | 847 if (!current_tab->FocusLocationBarByDefault()) |
| 840 current_tab->Focus(); | 848 current_tab->Focus(); |
| 841 current_tab->controller().Reload(true); | 849 if (ignore_cache) |
| 850 current_tab->controller().ReloadIgnoringCache(true); |
| 851 else |
| 852 current_tab->controller().Reload(true); |
| 842 } | 853 } |
| 843 } | 854 } |
| 844 | 855 |
| 845 void Browser::Home(WindowOpenDisposition disposition) { | 856 void Browser::Home(WindowOpenDisposition disposition) { |
| 846 UserMetrics::RecordAction("Home", profile_); | 857 UserMetrics::RecordAction("Home", profile_); |
| 847 OpenURL(GetHomePage(), GURL(), disposition, PageTransition::AUTO_BOOKMARK); | 858 OpenURL(GetHomePage(), GURL(), disposition, PageTransition::AUTO_BOOKMARK); |
| 848 } | 859 } |
| 849 | 860 |
| 850 void Browser::OpenCurrentURL() { | 861 void Browser::OpenCurrentURL() { |
| 851 UserMetrics::RecordAction("LoadURL", profile_); | 862 UserMetrics::RecordAction("LoadURL", profile_); |
| (...skipping 610 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1462 return; | 1473 return; |
| 1463 } | 1474 } |
| 1464 | 1475 |
| 1465 // The order of commands in this switch statement must match the function | 1476 // The order of commands in this switch statement must match the function |
| 1466 // declaration order in browser.h! | 1477 // declaration order in browser.h! |
| 1467 switch (id) { | 1478 switch (id) { |
| 1468 // Navigation commands | 1479 // Navigation commands |
| 1469 case IDC_BACK: GoBack(disposition); break; | 1480 case IDC_BACK: GoBack(disposition); break; |
| 1470 case IDC_FORWARD: GoForward(disposition); break; | 1481 case IDC_FORWARD: GoForward(disposition); break; |
| 1471 case IDC_RELOAD: Reload(); break; | 1482 case IDC_RELOAD: Reload(); break; |
| 1483 case IDC_RELOAD_IGNORING_CACHE: ReloadIgnoringCache(); break; |
| 1472 case IDC_HOME: Home(disposition); break; | 1484 case IDC_HOME: Home(disposition); break; |
| 1473 case IDC_OPEN_CURRENT_URL: OpenCurrentURL(); break; | 1485 case IDC_OPEN_CURRENT_URL: OpenCurrentURL(); break; |
| 1474 case IDC_GO: Go(disposition); break; | 1486 case IDC_GO: Go(disposition); break; |
| 1475 case IDC_STOP: Stop(); break; | 1487 case IDC_STOP: Stop(); break; |
| 1476 | 1488 |
| 1477 // Window management commands | 1489 // Window management commands |
| 1478 case IDC_NEW_WINDOW: NewWindow(); break; | 1490 case IDC_NEW_WINDOW: NewWindow(); break; |
| 1479 case IDC_NEW_INCOGNITO_WINDOW: NewIncognitoWindow(); break; | 1491 case IDC_NEW_INCOGNITO_WINDOW: NewIncognitoWindow(); break; |
| 1480 case IDC_NEW_WINDOW_PROFILE_0: | 1492 case IDC_NEW_WINDOW_PROFILE_0: |
| 1481 case IDC_NEW_WINDOW_PROFILE_1: | 1493 case IDC_NEW_WINDOW_PROFILE_1: |
| (...skipping 1020 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2502 /////////////////////////////////////////////////////////////////////////////// | 2514 /////////////////////////////////////////////////////////////////////////////// |
| 2503 // Browser, Command and state updating (private): | 2515 // Browser, Command and state updating (private): |
| 2504 | 2516 |
| 2505 void Browser::InitCommandState() { | 2517 void Browser::InitCommandState() { |
| 2506 // All browser commands whose state isn't set automagically some other way | 2518 // All browser commands whose state isn't set automagically some other way |
| 2507 // (like Back & Forward with initial page load) must have their state | 2519 // (like Back & Forward with initial page load) must have their state |
| 2508 // initialized here, otherwise they will be forever disabled. | 2520 // initialized here, otherwise they will be forever disabled. |
| 2509 | 2521 |
| 2510 // Navigation commands | 2522 // Navigation commands |
| 2511 command_updater_.UpdateCommandEnabled(IDC_RELOAD, true); | 2523 command_updater_.UpdateCommandEnabled(IDC_RELOAD, true); |
| 2524 command_updater_.UpdateCommandEnabled(IDC_RELOAD_IGNORING_CACHE, true); |
| 2512 | 2525 |
| 2513 // Window management commands | 2526 // Window management commands |
| 2514 command_updater_.UpdateCommandEnabled(IDC_NEW_WINDOW, true); | 2527 command_updater_.UpdateCommandEnabled(IDC_NEW_WINDOW, true); |
| 2515 command_updater_.UpdateCommandEnabled(IDC_NEW_INCOGNITO_WINDOW, true); | 2528 command_updater_.UpdateCommandEnabled(IDC_NEW_INCOGNITO_WINDOW, true); |
| 2516 // TODO(pkasting): Perhaps the code that populates this submenu should do | 2529 // TODO(pkasting): Perhaps the code that populates this submenu should do |
| 2517 // this? | 2530 // this? |
| 2518 command_updater_.UpdateCommandEnabled(IDC_NEW_WINDOW_PROFILE_0, true); | 2531 command_updater_.UpdateCommandEnabled(IDC_NEW_WINDOW_PROFILE_0, true); |
| 2519 command_updater_.UpdateCommandEnabled(IDC_NEW_WINDOW_PROFILE_1, true); | 2532 command_updater_.UpdateCommandEnabled(IDC_NEW_WINDOW_PROFILE_1, true); |
| 2520 command_updater_.UpdateCommandEnabled(IDC_NEW_WINDOW_PROFILE_2, true); | 2533 command_updater_.UpdateCommandEnabled(IDC_NEW_WINDOW_PROFILE_2, true); |
| 2521 command_updater_.UpdateCommandEnabled(IDC_NEW_WINDOW_PROFILE_3, true); | 2534 command_updater_.UpdateCommandEnabled(IDC_NEW_WINDOW_PROFILE_3, true); |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2693 | 2706 |
| 2694 command_updater_.UpdateCommandEnabled(IDC_SAVE_PAGE, | 2707 command_updater_.UpdateCommandEnabled(IDC_SAVE_PAGE, |
| 2695 SavePackage::IsSavableURL(savable_url)); | 2708 SavePackage::IsSavableURL(savable_url)); |
| 2696 command_updater_.UpdateCommandEnabled(IDC_ENCODING_MENU, | 2709 command_updater_.UpdateCommandEnabled(IDC_ENCODING_MENU, |
| 2697 SavePackage::IsSavableContents(current_tab->contents_mime_type()) && | 2710 SavePackage::IsSavableContents(current_tab->contents_mime_type()) && |
| 2698 SavePackage::IsSavableURL(savable_url)); | 2711 SavePackage::IsSavableURL(savable_url)); |
| 2699 | 2712 |
| 2700 // Disable certain items if running DevTools | 2713 // Disable certain items if running DevTools |
| 2701 command_updater_.UpdateCommandEnabled(IDC_RELOAD, | 2714 command_updater_.UpdateCommandEnabled(IDC_RELOAD, |
| 2702 CanReloadContents(current_tab)); | 2715 CanReloadContents(current_tab)); |
| 2716 command_updater_.UpdateCommandEnabled(IDC_RELOAD_IGNORING_CACHE, |
| 2717 CanReloadContents(current_tab)); |
| 2703 bool enabled_for_non_devtools = type() != TYPE_DEVTOOLS; | 2718 bool enabled_for_non_devtools = type() != TYPE_DEVTOOLS; |
| 2704 command_updater_.UpdateCommandEnabled(IDC_FIND, enabled_for_non_devtools); | 2719 command_updater_.UpdateCommandEnabled(IDC_FIND, enabled_for_non_devtools); |
| 2705 command_updater_.UpdateCommandEnabled(IDC_FIND_NEXT, | 2720 command_updater_.UpdateCommandEnabled(IDC_FIND_NEXT, |
| 2706 enabled_for_non_devtools); | 2721 enabled_for_non_devtools); |
| 2707 command_updater_.UpdateCommandEnabled(IDC_FIND_PREVIOUS, | 2722 command_updater_.UpdateCommandEnabled(IDC_FIND_PREVIOUS, |
| 2708 enabled_for_non_devtools); | 2723 enabled_for_non_devtools); |
| 2709 command_updater_.UpdateCommandEnabled(IDC_COPY_URL, | 2724 command_updater_.UpdateCommandEnabled(IDC_COPY_URL, |
| 2710 enabled_for_non_devtools); | 2725 enabled_for_non_devtools); |
| 2711 | 2726 |
| 2712 // Show various bits of UI | 2727 // Show various bits of UI |
| (...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3282 return; | 3297 return; |
| 3283 | 3298 |
| 3284 ExtensionsService* extension_service = profile()->GetExtensionsService(); | 3299 ExtensionsService* extension_service = profile()->GetExtensionsService(); |
| 3285 if (extension_service && extension_service->is_ready()) { | 3300 if (extension_service && extension_service->is_ready()) { |
| 3286 Extension* extension = | 3301 Extension* extension = |
| 3287 extension_service->GetExtensionById(app_extension_id, false); | 3302 extension_service->GetExtensionById(app_extension_id, false); |
| 3288 if (extension) | 3303 if (extension) |
| 3289 contents->SetAppExtension(extension); | 3304 contents->SetAppExtension(extension); |
| 3290 } | 3305 } |
| 3291 } | 3306 } |
| OLD | NEW |