OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 // OS_WIN | 10 #endif // OS_WIN |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 #include "chrome/browser/extensions/extension_tabs_module.h" | 58 #include "chrome/browser/extensions/extension_tabs_module.h" |
59 #include "chrome/browser/favicon/favicon_tab_helper.h" | 59 #include "chrome/browser/favicon/favicon_tab_helper.h" |
60 #include "chrome/browser/file_select_helper.h" | 60 #include "chrome/browser/file_select_helper.h" |
61 #include "chrome/browser/first_run/first_run.h" | 61 #include "chrome/browser/first_run/first_run.h" |
62 #include "chrome/browser/google/google_url_tracker.h" | 62 #include "chrome/browser/google/google_url_tracker.h" |
63 #include "chrome/browser/infobars/infobar_tab_helper.h" | 63 #include "chrome/browser/infobars/infobar_tab_helper.h" |
64 #include "chrome/browser/instant/instant_controller.h" | 64 #include "chrome/browser/instant/instant_controller.h" |
65 #include "chrome/browser/instant/instant_unload_handler.h" | 65 #include "chrome/browser/instant/instant_unload_handler.h" |
66 #include "chrome/browser/intents/register_intent_handler_infobar_delegate.h" | 66 #include "chrome/browser/intents/register_intent_handler_infobar_delegate.h" |
67 #include "chrome/browser/intents/web_intents_util.h" | 67 #include "chrome/browser/intents/web_intents_util.h" |
| 68 #include "chrome/browser/lifetime/application_lifetime.h" |
68 #include "chrome/browser/net/url_fixer_upper.h" | 69 #include "chrome/browser/net/url_fixer_upper.h" |
69 #include "chrome/browser/notifications/notification_ui_manager.h" | 70 #include "chrome/browser/notifications/notification_ui_manager.h" |
70 #include "chrome/browser/platform_util.h" | 71 #include "chrome/browser/platform_util.h" |
71 #include "chrome/browser/prefs/incognito_mode_prefs.h" | 72 #include "chrome/browser/prefs/incognito_mode_prefs.h" |
72 #include "chrome/browser/prefs/pref_service.h" | 73 #include "chrome/browser/prefs/pref_service.h" |
73 #include "chrome/browser/prerender/prerender_manager.h" | 74 #include "chrome/browser/prerender/prerender_manager.h" |
74 #include "chrome/browser/prerender/prerender_manager_factory.h" | 75 #include "chrome/browser/prerender/prerender_manager_factory.h" |
75 #include "chrome/browser/prerender/prerender_tab_helper.h" | 76 #include "chrome/browser/prerender/prerender_tab_helper.h" |
76 #include "chrome/browser/printing/cloud_print/cloud_print_setup_flow.h" | 77 #include "chrome/browser/printing/cloud_print/cloud_print_setup_flow.h" |
77 #include "chrome/browser/printing/print_preview_tab_controller.h" | 78 #include "chrome/browser/printing/print_preview_tab_controller.h" |
(...skipping 1118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1196 if (!ShouldCloseWindow()) | 1197 if (!ShouldCloseWindow()) |
1197 return; | 1198 return; |
1198 | 1199 |
1199 bool exiting = false; | 1200 bool exiting = false; |
1200 | 1201 |
1201 // Application should shutdown on last window close if the user is explicitly | 1202 // Application should shutdown on last window close if the user is explicitly |
1202 // trying to quit, or if there is nothing keeping the browser alive (such as | 1203 // trying to quit, or if there is nothing keeping the browser alive (such as |
1203 // AppController on the Mac, or BackgroundContentsService for background | 1204 // AppController on the Mac, or BackgroundContentsService for background |
1204 // pages). | 1205 // pages). |
1205 bool should_quit_if_last_browser = | 1206 bool should_quit_if_last_browser = |
1206 browser_shutdown::IsTryingToQuit() || !BrowserList::WillKeepAlive(); | 1207 browser_shutdown::IsTryingToQuit() || !browser::WillKeepAlive(); |
1207 | 1208 |
1208 if (should_quit_if_last_browser && BrowserList::size() == 1) { | 1209 if (should_quit_if_last_browser && BrowserList::size() == 1) { |
1209 browser_shutdown::OnShutdownStarting(browser_shutdown::WINDOW_CLOSE); | 1210 browser_shutdown::OnShutdownStarting(browser_shutdown::WINDOW_CLOSE); |
1210 exiting = true; | 1211 exiting = true; |
1211 } | 1212 } |
1212 | 1213 |
1213 // Don't use GetForProfileIfExisting here, we want to force creation of the | 1214 // Don't use GetForProfileIfExisting here, we want to force creation of the |
1214 // session service so that user can restore what was open. | 1215 // session service so that user can restore what was open. |
1215 SessionService* session_service = | 1216 SessionService* session_service = |
1216 SessionServiceFactory::GetForProfile(profile()); | 1217 SessionServiceFactory::GetForProfile(profile()); |
(...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1782 } | 1783 } |
1783 | 1784 |
1784 #if defined(OS_MACOSX) | 1785 #if defined(OS_MACOSX) |
1785 void Browser::TogglePresentationMode() { | 1786 void Browser::TogglePresentationMode() { |
1786 fullscreen_controller_->TogglePresentationMode(); | 1787 fullscreen_controller_->TogglePresentationMode(); |
1787 } | 1788 } |
1788 #endif | 1789 #endif |
1789 | 1790 |
1790 void Browser::Exit() { | 1791 void Browser::Exit() { |
1791 content::RecordAction(UserMetricsAction("Exit")); | 1792 content::RecordAction(UserMetricsAction("Exit")); |
1792 BrowserList::AttemptUserExit(); | 1793 browser::AttemptUserExit(); |
1793 } | 1794 } |
1794 | 1795 |
1795 void Browser::BookmarkCurrentPage() { | 1796 void Browser::BookmarkCurrentPage() { |
1796 content::RecordAction(UserMetricsAction("Star")); | 1797 content::RecordAction(UserMetricsAction("Star")); |
1797 | 1798 |
1798 BookmarkModel* model = profile()->GetBookmarkModel(); | 1799 BookmarkModel* model = profile()->GetBookmarkModel(); |
1799 if (!model || !model->IsLoaded()) | 1800 if (!model || !model->IsLoaded()) |
1800 return; // Ignore requests until bookmarks are loaded. | 1801 return; // Ignore requests until bookmarks are loaded. |
1801 | 1802 |
1802 GURL url; | 1803 GURL url; |
(...skipping 1511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3314 } | 3315 } |
3315 } | 3316 } |
3316 | 3317 |
3317 void Browser::TabStripEmpty() { | 3318 void Browser::TabStripEmpty() { |
3318 // Close the frame after we return to the message loop (not immediately, | 3319 // Close the frame after we return to the message loop (not immediately, |
3319 // otherwise it will destroy this object before the stack has a chance to | 3320 // otherwise it will destroy this object before the stack has a chance to |
3320 // cleanly unwind.) | 3321 // cleanly unwind.) |
3321 // Note: This will be called several times if TabStripEmpty is called several | 3322 // Note: This will be called several times if TabStripEmpty is called several |
3322 // times. This is because it does not close the window if tabs are | 3323 // times. This is because it does not close the window if tabs are |
3323 // still present. | 3324 // still present. |
3324 // NOTE: If you change to be immediate (no invokeLater) then you'll need to | |
3325 // update BrowserList::CloseAllBrowsers. | |
3326 MessageLoop::current()->PostTask( | 3325 MessageLoop::current()->PostTask( |
3327 FROM_HERE, base::Bind(&Browser::CloseFrame, weak_factory_.GetWeakPtr())); | 3326 FROM_HERE, base::Bind(&Browser::CloseFrame, weak_factory_.GetWeakPtr())); |
3328 // Set is_attempting_to_close_browser_ here, so that extensions, etc, do not | 3327 // Set is_attempting_to_close_browser_ here, so that extensions, etc, do not |
3329 // attempt to add tabs to the browser before it closes. | 3328 // attempt to add tabs to the browser before it closes. |
3330 is_attempting_to_close_browser_ = true; | 3329 is_attempting_to_close_browser_ = true; |
3331 } | 3330 } |
3332 | 3331 |
3333 void Browser::OnAcceptFullscreenPermission( | 3332 void Browser::OnAcceptFullscreenPermission( |
3334 const GURL& url, | 3333 const GURL& url, |
3335 FullscreenExitBubbleType bubble_type) { | 3334 FullscreenExitBubbleType bubble_type) { |
(...skipping 2088 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5424 if (contents && !allow_js_access) { | 5423 if (contents && !allow_js_access) { |
5425 contents->web_contents()->GetController().LoadURL( | 5424 contents->web_contents()->GetController().LoadURL( |
5426 target_url, | 5425 target_url, |
5427 content::Referrer(), | 5426 content::Referrer(), |
5428 content::PAGE_TRANSITION_LINK, | 5427 content::PAGE_TRANSITION_LINK, |
5429 std::string()); // No extra headers. | 5428 std::string()); // No extra headers. |
5430 } | 5429 } |
5431 | 5430 |
5432 return contents != NULL; | 5431 return contents != NULL; |
5433 } | 5432 } |
OLD | NEW |