| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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 // defined(OS_WIN) | 10 #endif // defined(OS_WIN) |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 #include "chrome/browser/ui/browser_navigator.h" | 101 #include "chrome/browser/ui/browser_navigator.h" |
| 102 #include "chrome/browser/ui/browser_tab_contents.h" | 102 #include "chrome/browser/ui/browser_tab_contents.h" |
| 103 #include "chrome/browser/ui/browser_tab_restore_service_delegate.h" | 103 #include "chrome/browser/ui/browser_tab_restore_service_delegate.h" |
| 104 #include "chrome/browser/ui/browser_tab_strip_model_delegate.h" | 104 #include "chrome/browser/ui/browser_tab_strip_model_delegate.h" |
| 105 #include "chrome/browser/ui/browser_tabstrip.h" | 105 #include "chrome/browser/ui/browser_tabstrip.h" |
| 106 #include "chrome/browser/ui/browser_toolbar_model_delegate.h" | 106 #include "chrome/browser/ui/browser_toolbar_model_delegate.h" |
| 107 #include "chrome/browser/ui/browser_ui_prefs.h" | 107 #include "chrome/browser/ui/browser_ui_prefs.h" |
| 108 #include "chrome/browser/ui/browser_window.h" | 108 #include "chrome/browser/ui/browser_window.h" |
| 109 #include "chrome/browser/ui/chrome_pages.h" | 109 #include "chrome/browser/ui/chrome_pages.h" |
| 110 #include "chrome/browser/ui/chrome_select_file_policy.h" | 110 #include "chrome/browser/ui/chrome_select_file_policy.h" |
| 111 #include "chrome/browser/ui/color_chooser_util.h" |
| 111 #include "chrome/browser/ui/extensions/shell_window.h" | 112 #include "chrome/browser/ui/extensions/shell_window.h" |
| 112 #include "chrome/browser/ui/find_bar/find_bar.h" | 113 #include "chrome/browser/ui/find_bar/find_bar.h" |
| 113 #include "chrome/browser/ui/find_bar/find_bar_controller.h" | 114 #include "chrome/browser/ui/find_bar/find_bar_controller.h" |
| 114 #include "chrome/browser/ui/find_bar/find_tab_helper.h" | 115 #include "chrome/browser/ui/find_bar/find_tab_helper.h" |
| 115 #include "chrome/browser/ui/fullscreen/fullscreen_controller.h" | 116 #include "chrome/browser/ui/fullscreen/fullscreen_controller.h" |
| 116 #include "chrome/browser/ui/global_error/global_error.h" | 117 #include "chrome/browser/ui/global_error/global_error.h" |
| 117 #include "chrome/browser/ui/global_error/global_error_service.h" | 118 #include "chrome/browser/ui/global_error/global_error_service.h" |
| 118 #include "chrome/browser/ui/global_error/global_error_service_factory.h" | 119 #include "chrome/browser/ui/global_error/global_error_service_factory.h" |
| 119 #include "chrome/browser/ui/omnibox/location_bar.h" | 120 #include "chrome/browser/ui/omnibox/location_bar.h" |
| 120 #include "chrome/browser/ui/search/search_delegate.h" | 121 #include "chrome/browser/ui/search/search_delegate.h" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 143 #include "chrome/common/chrome_switches.h" | 144 #include "chrome/common/chrome_switches.h" |
| 144 #include "chrome/common/custom_handlers/protocol_handler.h" | 145 #include "chrome/common/custom_handlers/protocol_handler.h" |
| 145 #include "chrome/common/extensions/background_info.h" | 146 #include "chrome/common/extensions/background_info.h" |
| 146 #include "chrome/common/extensions/extension.h" | 147 #include "chrome/common/extensions/extension.h" |
| 147 #include "chrome/common/extensions/extension_constants.h" | 148 #include "chrome/common/extensions/extension_constants.h" |
| 148 #include "chrome/common/pref_names.h" | 149 #include "chrome/common/pref_names.h" |
| 149 #include "chrome/common/profiling.h" | 150 #include "chrome/common/profiling.h" |
| 150 #include "chrome/common/search_types.h" | 151 #include "chrome/common/search_types.h" |
| 151 #include "chrome/common/startup_metric_utils.h" | 152 #include "chrome/common/startup_metric_utils.h" |
| 152 #include "chrome/common/url_constants.h" | 153 #include "chrome/common/url_constants.h" |
| 153 #include "content/public/browser/color_chooser.h" | |
| 154 #include "content/public/browser/devtools_manager.h" | 154 #include "content/public/browser/devtools_manager.h" |
| 155 #include "content/public/browser/download_item.h" | 155 #include "content/public/browser/download_item.h" |
| 156 #include "content/public/browser/download_manager.h" | 156 #include "content/public/browser/download_manager.h" |
| 157 #include "content/public/browser/interstitial_page.h" | 157 #include "content/public/browser/interstitial_page.h" |
| 158 #include "content/public/browser/invalidate_type.h" | 158 #include "content/public/browser/invalidate_type.h" |
| 159 #include "content/public/browser/navigation_controller.h" | 159 #include "content/public/browser/navigation_controller.h" |
| 160 #include "content/public/browser/navigation_entry.h" | 160 #include "content/public/browser/navigation_entry.h" |
| 161 #include "content/public/browser/notification_details.h" | 161 #include "content/public/browser/notification_details.h" |
| 162 #include "content/public/browser/notification_service.h" | 162 #include "content/public/browser/notification_service.h" |
| 163 #include "content/public/browser/plugin_service.h" | 163 #include "content/public/browser/plugin_service.h" |
| (...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 596 if (!ShouldCloseWindow()) | 596 if (!ShouldCloseWindow()) |
| 597 return; | 597 return; |
| 598 | 598 |
| 599 // Application should shutdown on last window close if the user is explicitly | 599 // Application should shutdown on last window close if the user is explicitly |
| 600 // trying to quit, or if there is nothing keeping the browser alive (such as | 600 // trying to quit, or if there is nothing keeping the browser alive (such as |
| 601 // AppController on the Mac, or BackgroundContentsService for background | 601 // AppController on the Mac, or BackgroundContentsService for background |
| 602 // pages). | 602 // pages). |
| 603 bool should_quit_if_last_browser = | 603 bool should_quit_if_last_browser = |
| 604 browser_shutdown::IsTryingToQuit() || !chrome::WillKeepAlive(); | 604 browser_shutdown::IsTryingToQuit() || !chrome::WillKeepAlive(); |
| 605 | 605 |
| 606 if (should_quit_if_last_browser && chrome::ShouldStartShutdown(this)) | 606 if (should_quit_if_last_browser && |
| 607 BrowserList::GetInstance(host_desktop_type_)->size() == 1) { |
| 607 browser_shutdown::OnShutdownStarting(browser_shutdown::WINDOW_CLOSE); | 608 browser_shutdown::OnShutdownStarting(browser_shutdown::WINDOW_CLOSE); |
| 609 } |
| 608 | 610 |
| 609 // Don't use GetForProfileIfExisting here, we want to force creation of the | 611 // Don't use GetForProfileIfExisting here, we want to force creation of the |
| 610 // session service so that user can restore what was open. | 612 // session service so that user can restore what was open. |
| 611 SessionService* session_service = | 613 SessionService* session_service = |
| 612 SessionServiceFactory::GetForProfile(profile()); | 614 SessionServiceFactory::GetForProfile(profile()); |
| 613 if (session_service) | 615 if (session_service) |
| 614 session_service->WindowClosing(session_id()); | 616 session_service->WindowClosing(session_id()); |
| 615 | 617 |
| 616 TabRestoreService* tab_restore_service = | 618 TabRestoreService* tab_restore_service = |
| 617 TabRestoreServiceFactory::GetForProfile(profile()); | 619 TabRestoreServiceFactory::GetForProfile(profile()); |
| (...skipping 906 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1524 void Browser::DidNavigateToPendingEntry(WebContents* web_contents) { | 1526 void Browser::DidNavigateToPendingEntry(WebContents* web_contents) { |
| 1525 if (web_contents == tab_strip_model_->GetActiveWebContents()) | 1527 if (web_contents == tab_strip_model_->GetActiveWebContents()) |
| 1526 UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_TAB_STATE); | 1528 UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_TAB_STATE); |
| 1527 } | 1529 } |
| 1528 | 1530 |
| 1529 content::JavaScriptDialogManager* Browser::GetJavaScriptDialogManager() { | 1531 content::JavaScriptDialogManager* Browser::GetJavaScriptDialogManager() { |
| 1530 return GetJavaScriptDialogManagerInstance(); | 1532 return GetJavaScriptDialogManagerInstance(); |
| 1531 } | 1533 } |
| 1532 | 1534 |
| 1533 content::ColorChooser* Browser::OpenColorChooser(WebContents* web_contents, | 1535 content::ColorChooser* Browser::OpenColorChooser(WebContents* web_contents, |
| 1534 int color_chooser_id, | 1536 SkColor initial_color) { |
| 1535 SkColor color) { | 1537 return ::OpenColorChooser(web_contents, initial_color); |
| 1536 #if defined(OS_WIN) | |
| 1537 // On Windows, only create a color chooser if one doesn't exist, because we | |
| 1538 // can't close the old color chooser dialog. | |
| 1539 if (!color_chooser_.get()) | |
| 1540 color_chooser_.reset(content::ColorChooser::Create(color_chooser_id, | |
| 1541 web_contents, | |
| 1542 color)); | |
| 1543 #else | |
| 1544 if (color_chooser_.get()) | |
| 1545 color_chooser_->End(); | |
| 1546 color_chooser_.reset(content::ColorChooser::Create(color_chooser_id, | |
| 1547 web_contents, | |
| 1548 color)); | |
| 1549 #endif | |
| 1550 return color_chooser_.get(); | |
| 1551 } | |
| 1552 | |
| 1553 void Browser::DidEndColorChooser() { | |
| 1554 color_chooser_.reset(); | |
| 1555 } | 1538 } |
| 1556 | 1539 |
| 1557 void Browser::RunFileChooser(WebContents* web_contents, | 1540 void Browser::RunFileChooser(WebContents* web_contents, |
| 1558 const content::FileChooserParams& params) { | 1541 const content::FileChooserParams& params) { |
| 1559 FileSelectHelper::RunFileChooser(web_contents, params); | 1542 FileSelectHelper::RunFileChooser(web_contents, params); |
| 1560 } | 1543 } |
| 1561 | 1544 |
| 1562 void Browser::EnumerateDirectory(WebContents* web_contents, | 1545 void Browser::EnumerateDirectory(WebContents* web_contents, |
| 1563 int request_id, | 1546 int request_id, |
| 1564 const base::FilePath& path) { | 1547 const base::FilePath& path) { |
| (...skipping 697 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2262 if (contents && !allow_js_access) { | 2245 if (contents && !allow_js_access) { |
| 2263 contents->web_contents()->GetController().LoadURL( | 2246 contents->web_contents()->GetController().LoadURL( |
| 2264 target_url, | 2247 target_url, |
| 2265 content::Referrer(), | 2248 content::Referrer(), |
| 2266 content::PAGE_TRANSITION_LINK, | 2249 content::PAGE_TRANSITION_LINK, |
| 2267 std::string()); // No extra headers. | 2250 std::string()); // No extra headers. |
| 2268 } | 2251 } |
| 2269 | 2252 |
| 2270 return contents != NULL; | 2253 return contents != NULL; |
| 2271 } | 2254 } |
| OLD | NEW |