| 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 <windows.h> | 8 #include <windows.h> |
| 9 #include <shellapi.h> | 9 #include <shellapi.h> |
| 10 #endif // OS_WIN | 10 #endif // OS_WIN |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 #include "chrome/common/profiling.h" | 139 #include "chrome/common/profiling.h" |
| 140 #include "chrome/common/url_constants.h" | 140 #include "chrome/common/url_constants.h" |
| 141 #include "chrome/common/web_apps.h" | 141 #include "chrome/common/web_apps.h" |
| 142 #include "content/browser/browser_url_handler.h" | 142 #include "content/browser/browser_url_handler.h" |
| 143 #include "content/browser/child_process_security_policy.h" | 143 #include "content/browser/child_process_security_policy.h" |
| 144 #include "content/browser/download/save_package.h" | 144 #include "content/browser/download/save_package.h" |
| 145 #include "content/browser/host_zoom_map.h" | 145 #include "content/browser/host_zoom_map.h" |
| 146 #include "content/browser/renderer_host/render_view_host.h" | 146 #include "content/browser/renderer_host/render_view_host.h" |
| 147 #include "content/browser/site_instance.h" | 147 #include "content/browser/site_instance.h" |
| 148 #include "content/browser/tab_contents/interstitial_page.h" | 148 #include "content/browser/tab_contents/interstitial_page.h" |
| 149 #include "content/browser/tab_contents/navigation_controller.h" | |
| 150 #include "content/browser/tab_contents/tab_contents.h" | 149 #include "content/browser/tab_contents/tab_contents.h" |
| 151 #include "content/browser/tab_contents/tab_contents_view.h" | 150 #include "content/browser/tab_contents/tab_contents_view.h" |
| 152 #include "content/public/browser/devtools_manager.h" | 151 #include "content/public/browser/devtools_manager.h" |
| 153 #include "content/public/browser/download_item.h" | 152 #include "content/public/browser/download_item.h" |
| 154 #include "content/public/browser/download_manager.h" | 153 #include "content/public/browser/download_manager.h" |
| 154 #include "content/public/browser/navigation_controller.h" |
| 155 #include "content/public/browser/navigation_entry.h" | 155 #include "content/public/browser/navigation_entry.h" |
| 156 #include "content/public/browser/notification_details.h" | 156 #include "content/public/browser/notification_details.h" |
| 157 #include "content/public/browser/notification_service.h" | 157 #include "content/public/browser/notification_service.h" |
| 158 #include "content/public/browser/plugin_service.h" | 158 #include "content/public/browser/plugin_service.h" |
| 159 #include "content/public/browser/user_metrics.h" | 159 #include "content/public/browser/user_metrics.h" |
| 160 #include "content/public/browser/web_intents_dispatcher.h" | 160 #include "content/public/browser/web_intents_dispatcher.h" |
| 161 #include "content/public/common/content_restriction.h" | 161 #include "content/public/common/content_restriction.h" |
| 162 #include "content/public/common/content_switches.h" | 162 #include "content/public/common/content_switches.h" |
| 163 #include "content/public/common/page_zoom.h" | 163 #include "content/public/common/page_zoom.h" |
| 164 #include "grit/chromium_strings.h" | 164 #include "grit/chromium_strings.h" |
| (...skipping 1201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1366 tab_handler_->GetTabStripModel()->active_index(), | 1366 tab_handler_->GetTabStripModel()->active_index(), |
| 1367 wrapper); | 1367 wrapper); |
| 1368 } | 1368 } |
| 1369 | 1369 |
| 1370 bool Browser::CanRestoreTab() { | 1370 bool Browser::CanRestoreTab() { |
| 1371 return command_updater_.IsCommandEnabled(IDC_RESTORE_TAB); | 1371 return command_updater_.IsCommandEnabled(IDC_RESTORE_TAB); |
| 1372 } | 1372 } |
| 1373 | 1373 |
| 1374 bool Browser::NavigateToIndexWithDisposition(int index, | 1374 bool Browser::NavigateToIndexWithDisposition(int index, |
| 1375 WindowOpenDisposition disp) { | 1375 WindowOpenDisposition disp) { |
| 1376 NavigationController& controller = | 1376 content::NavigationController& controller = |
| 1377 GetOrCloneTabForDisposition(disp)->GetController(); | 1377 GetOrCloneTabForDisposition(disp)->GetController(); |
| 1378 if (index < 0 || index >= controller.GetEntryCount()) | 1378 if (index < 0 || index >= controller.GetEntryCount()) |
| 1379 return false; | 1379 return false; |
| 1380 controller.GoToIndex(index); | 1380 controller.GoToIndex(index); |
| 1381 return true; | 1381 return true; |
| 1382 } | 1382 } |
| 1383 | 1383 |
| 1384 browser::NavigateParams Browser::GetSingletonTabNavigateParams( | 1384 browser::NavigateParams Browser::GetSingletonTabNavigateParams( |
| 1385 const GURL& url) { | 1385 const GURL& url) { |
| 1386 browser::NavigateParams params( | 1386 browser::NavigateParams params( |
| (...skipping 1709 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3096 // Load the initial URL before adding the new tab contents to the tab strip | 3096 // Load the initial URL before adding the new tab contents to the tab strip |
| 3097 // so that the tab contents has navigation state. | 3097 // so that the tab contents has navigation state. |
| 3098 contents->tab_contents()->GetController().LoadURL( | 3098 contents->tab_contents()->GetController().LoadURL( |
| 3099 url, referrer, transition, std::string()); | 3099 url, referrer, transition, std::string()); |
| 3100 } | 3100 } |
| 3101 | 3101 |
| 3102 return contents; | 3102 return contents; |
| 3103 } | 3103 } |
| 3104 | 3104 |
| 3105 bool Browser::CanDuplicateContentsAt(int index) { | 3105 bool Browser::CanDuplicateContentsAt(int index) { |
| 3106 NavigationController& nc = GetTabContentsAt(index)->GetController(); | 3106 content::NavigationController& nc = GetTabContentsAt(index)->GetController(); |
| 3107 return nc.GetWebContents() && nc.GetLastCommittedEntry(); | 3107 return nc.GetWebContents() && nc.GetLastCommittedEntry(); |
| 3108 } | 3108 } |
| 3109 | 3109 |
| 3110 void Browser::DuplicateContentsAt(int index) { | 3110 void Browser::DuplicateContentsAt(int index) { |
| 3111 TabContentsWrapper* contents = GetTabContentsWrapperAt(index); | 3111 TabContentsWrapper* contents = GetTabContentsWrapperAt(index); |
| 3112 CHECK(contents); | 3112 CHECK(contents); |
| 3113 TabContentsWrapper* contents_dupe = contents->Clone(); | 3113 TabContentsWrapper* contents_dupe = contents->Clone(); |
| 3114 | 3114 |
| 3115 bool pinned = false; | 3115 bool pinned = false; |
| 3116 if (CanSupportWindowFeature(FEATURE_TABSTRIP)) { | 3116 if (CanSupportWindowFeature(FEATURE_TABSTRIP)) { |
| (...skipping 1472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4589 UpdateCommandsForBookmarkBar(); | 4589 UpdateCommandsForBookmarkBar(); |
| 4590 } | 4590 } |
| 4591 | 4591 |
| 4592 void Browser::UpdateCommandsForTabState() { | 4592 void Browser::UpdateCommandsForTabState() { |
| 4593 WebContents* current_tab = GetSelectedWebContents(); | 4593 WebContents* current_tab = GetSelectedWebContents(); |
| 4594 TabContentsWrapper* current_tab_wrapper = GetSelectedTabContentsWrapper(); | 4594 TabContentsWrapper* current_tab_wrapper = GetSelectedTabContentsWrapper(); |
| 4595 if (!current_tab || !current_tab_wrapper) // May be NULL during tab restore. | 4595 if (!current_tab || !current_tab_wrapper) // May be NULL during tab restore. |
| 4596 return; | 4596 return; |
| 4597 | 4597 |
| 4598 // Navigation commands | 4598 // Navigation commands |
| 4599 NavigationController& nc = current_tab->GetController(); | 4599 content::NavigationController& nc = current_tab->GetController(); |
| 4600 command_updater_.UpdateCommandEnabled(IDC_BACK, nc.CanGoBack()); | 4600 command_updater_.UpdateCommandEnabled(IDC_BACK, nc.CanGoBack()); |
| 4601 command_updater_.UpdateCommandEnabled(IDC_FORWARD, nc.CanGoForward()); | 4601 command_updater_.UpdateCommandEnabled(IDC_FORWARD, nc.CanGoForward()); |
| 4602 command_updater_.UpdateCommandEnabled(IDC_RELOAD, | 4602 command_updater_.UpdateCommandEnabled(IDC_RELOAD, |
| 4603 CanReloadContents(current_tab)); | 4603 CanReloadContents(current_tab)); |
| 4604 command_updater_.UpdateCommandEnabled(IDC_RELOAD_IGNORING_CACHE, | 4604 command_updater_.UpdateCommandEnabled(IDC_RELOAD_IGNORING_CACHE, |
| 4605 CanReloadContents(current_tab)); | 4605 CanReloadContents(current_tab)); |
| 4606 | 4606 |
| 4607 // Window management commands | 4607 // Window management commands |
| 4608 command_updater_.UpdateCommandEnabled(IDC_DUPLICATE_TAB, | 4608 command_updater_.UpdateCommandEnabled(IDC_DUPLICATE_TAB, |
| 4609 !is_app() && CanDuplicateContentsAt(active_index())); | 4609 !is_app() && CanDuplicateContentsAt(active_index())); |
| (...skipping 780 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5390 window_->GetLocationBar()->ShowFirstRunBubble(bubble_type); | 5390 window_->GetLocationBar()->ShowFirstRunBubble(bubble_type); |
| 5391 } else { | 5391 } else { |
| 5392 GlobalErrorService* service = | 5392 GlobalErrorService* service = |
| 5393 GlobalErrorServiceFactory::GetForProfile(profile()); | 5393 GlobalErrorServiceFactory::GetForProfile(profile()); |
| 5394 GlobalError* error = service->GetFirstGlobalErrorWithBubbleView(); | 5394 GlobalError* error = service->GetFirstGlobalErrorWithBubbleView(); |
| 5395 if (error) { | 5395 if (error) { |
| 5396 error->ShowBubbleView(this); | 5396 error->ShowBubbleView(this); |
| 5397 } | 5397 } |
| 5398 } | 5398 } |
| 5399 } | 5399 } |
| OLD | NEW |