| 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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 #include "chrome/common/custom_handlers/protocol_handler.h" | 143 #include "chrome/common/custom_handlers/protocol_handler.h" |
| 144 #include "chrome/common/extensions/background_info.h" | 144 #include "chrome/common/extensions/background_info.h" |
| 145 #include "chrome/common/extensions/extension.h" | 145 #include "chrome/common/extensions/extension.h" |
| 146 #include "chrome/common/extensions/extension_constants.h" | 146 #include "chrome/common/extensions/extension_constants.h" |
| 147 #include "chrome/common/pref_names.h" | 147 #include "chrome/common/pref_names.h" |
| 148 #include "chrome/common/profiling.h" | 148 #include "chrome/common/profiling.h" |
| 149 #include "chrome/common/search_types.h" | 149 #include "chrome/common/search_types.h" |
| 150 #include "chrome/common/startup_metric_utils.h" | 150 #include "chrome/common/startup_metric_utils.h" |
| 151 #include "chrome/common/url_constants.h" | 151 #include "chrome/common/url_constants.h" |
| 152 #include "components/web_modal/web_contents_modal_dialog_manager.h" | 152 #include "components/web_modal/web_contents_modal_dialog_manager.h" |
| 153 #include "content/public/browser/color_chooser.h" | |
| 154 #include "content/public/browser/devtools_manager.h" | 153 #include "content/public/browser/devtools_manager.h" |
| 155 #include "content/public/browser/download_item.h" | 154 #include "content/public/browser/download_item.h" |
| 156 #include "content/public/browser/download_manager.h" | 155 #include "content/public/browser/download_manager.h" |
| 157 #include "content/public/browser/interstitial_page.h" | 156 #include "content/public/browser/interstitial_page.h" |
| 158 #include "content/public/browser/invalidate_type.h" | 157 #include "content/public/browser/invalidate_type.h" |
| 159 #include "content/public/browser/navigation_controller.h" | 158 #include "content/public/browser/navigation_controller.h" |
| 160 #include "content/public/browser/navigation_entry.h" | 159 #include "content/public/browser/navigation_entry.h" |
| 161 #include "content/public/browser/notification_details.h" | 160 #include "content/public/browser/notification_details.h" |
| 162 #include "content/public/browser/notification_service.h" | 161 #include "content/public/browser/notification_service.h" |
| 163 #include "content/public/browser/plugin_service.h" | 162 #include "content/public/browser/plugin_service.h" |
| (...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 589 if (!ShouldCloseWindow()) | 588 if (!ShouldCloseWindow()) |
| 590 return; | 589 return; |
| 591 | 590 |
| 592 // Application should shutdown on last window close if the user is explicitly | 591 // Application should shutdown on last window close if the user is explicitly |
| 593 // trying to quit, or if there is nothing keeping the browser alive (such as | 592 // trying to quit, or if there is nothing keeping the browser alive (such as |
| 594 // AppController on the Mac, or BackgroundContentsService for background | 593 // AppController on the Mac, or BackgroundContentsService for background |
| 595 // pages). | 594 // pages). |
| 596 bool should_quit_if_last_browser = | 595 bool should_quit_if_last_browser = |
| 597 browser_shutdown::IsTryingToQuit() || !chrome::WillKeepAlive(); | 596 browser_shutdown::IsTryingToQuit() || !chrome::WillKeepAlive(); |
| 598 | 597 |
| 599 if (should_quit_if_last_browser && chrome::ShouldStartShutdown(this)) | 598 if (should_quit_if_last_browser && |
| 599 BrowserList::GetInstance(host_desktop_type_)->size() == 1) { |
| 600 browser_shutdown::OnShutdownStarting(browser_shutdown::WINDOW_CLOSE); | 600 browser_shutdown::OnShutdownStarting(browser_shutdown::WINDOW_CLOSE); |
| 601 } |
| 601 | 602 |
| 602 // Don't use GetForProfileIfExisting here, we want to force creation of the | 603 // Don't use GetForProfileIfExisting here, we want to force creation of the |
| 603 // session service so that user can restore what was open. | 604 // session service so that user can restore what was open. |
| 604 SessionService* session_service = | 605 SessionService* session_service = |
| 605 SessionServiceFactory::GetForProfile(profile()); | 606 SessionServiceFactory::GetForProfile(profile()); |
| 606 if (session_service) | 607 if (session_service) |
| 607 session_service->WindowClosing(session_id()); | 608 session_service->WindowClosing(session_id()); |
| 608 | 609 |
| 609 TabRestoreService* tab_restore_service = | 610 TabRestoreService* tab_restore_service = |
| 610 TabRestoreServiceFactory::GetForProfile(profile()); | 611 TabRestoreServiceFactory::GetForProfile(profile()); |
| (...skipping 877 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1488 void Browser::DidNavigateToPendingEntry(WebContents* web_contents) { | 1489 void Browser::DidNavigateToPendingEntry(WebContents* web_contents) { |
| 1489 if (web_contents == tab_strip_model_->GetActiveWebContents()) | 1490 if (web_contents == tab_strip_model_->GetActiveWebContents()) |
| 1490 UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_TAB_STATE); | 1491 UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_TAB_STATE); |
| 1491 } | 1492 } |
| 1492 | 1493 |
| 1493 content::JavaScriptDialogManager* Browser::GetJavaScriptDialogManager() { | 1494 content::JavaScriptDialogManager* Browser::GetJavaScriptDialogManager() { |
| 1494 return GetJavaScriptDialogManagerInstance(); | 1495 return GetJavaScriptDialogManagerInstance(); |
| 1495 } | 1496 } |
| 1496 | 1497 |
| 1497 content::ColorChooser* Browser::OpenColorChooser(WebContents* web_contents, | 1498 content::ColorChooser* Browser::OpenColorChooser(WebContents* web_contents, |
| 1498 int color_chooser_id, | 1499 SkColor initial_color) { |
| 1499 SkColor color) { | 1500 return chrome::ShowColorChooser(web_contents, initial_color); |
| 1500 #if defined(OS_WIN) | |
| 1501 // On Windows, only create a color chooser if one doesn't exist, because we | |
| 1502 // can't close the old color chooser dialog. | |
| 1503 if (!color_chooser_.get()) | |
| 1504 color_chooser_.reset(content::ColorChooser::Create(color_chooser_id, | |
| 1505 web_contents, | |
| 1506 color)); | |
| 1507 #else | |
| 1508 if (color_chooser_.get()) | |
| 1509 color_chooser_->End(); | |
| 1510 color_chooser_.reset(content::ColorChooser::Create(color_chooser_id, | |
| 1511 web_contents, | |
| 1512 color)); | |
| 1513 #endif | |
| 1514 return color_chooser_.get(); | |
| 1515 } | |
| 1516 | |
| 1517 void Browser::DidEndColorChooser() { | |
| 1518 color_chooser_.reset(); | |
| 1519 } | 1501 } |
| 1520 | 1502 |
| 1521 void Browser::RunFileChooser(WebContents* web_contents, | 1503 void Browser::RunFileChooser(WebContents* web_contents, |
| 1522 const content::FileChooserParams& params) { | 1504 const content::FileChooserParams& params) { |
| 1523 FileSelectHelper::RunFileChooser(web_contents, params); | 1505 FileSelectHelper::RunFileChooser(web_contents, params); |
| 1524 } | 1506 } |
| 1525 | 1507 |
| 1526 void Browser::EnumerateDirectory(WebContents* web_contents, | 1508 void Browser::EnumerateDirectory(WebContents* web_contents, |
| 1527 int request_id, | 1509 int request_id, |
| 1528 const base::FilePath& path) { | 1510 const base::FilePath& path) { |
| (...skipping 700 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2229 if (contents && !allow_js_access) { | 2211 if (contents && !allow_js_access) { |
| 2230 contents->web_contents()->GetController().LoadURL( | 2212 contents->web_contents()->GetController().LoadURL( |
| 2231 target_url, | 2213 target_url, |
| 2232 content::Referrer(), | 2214 content::Referrer(), |
| 2233 content::PAGE_TRANSITION_LINK, | 2215 content::PAGE_TRANSITION_LINK, |
| 2234 std::string()); // No extra headers. | 2216 std::string()); // No extra headers. |
| 2235 } | 2217 } |
| 2236 | 2218 |
| 2237 return contents != NULL; | 2219 return contents != NULL; |
| 2238 } | 2220 } |
| OLD | NEW |