| 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 581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 592 /////////////////////////////////////////////////////////////////////////////// | 592 /////////////////////////////////////////////////////////////////////////////// |
| 593 // Browser, OnBeforeUnload handling: | 593 // Browser, OnBeforeUnload handling: |
| 594 | 594 |
| 595 bool Browser::ShouldCloseWindow() { | 595 bool Browser::ShouldCloseWindow() { |
| 596 if (!CanCloseWithInProgressDownloads()) | 596 if (!CanCloseWithInProgressDownloads()) |
| 597 return false; | 597 return false; |
| 598 | 598 |
| 599 return unload_controller_->ShouldCloseWindow(); | 599 return unload_controller_->ShouldCloseWindow(); |
| 600 } | 600 } |
| 601 | 601 |
| 602 bool Browser::TabsNeedBeforeUnloadFired() { | |
| 603 return unload_controller_->TabsNeedBeforeUnloadFired(); | |
| 604 } | |
| 605 | |
| 606 bool Browser::HasCompletedUnloadProcessing() const { | |
| 607 return unload_controller_->HasCompletedUnloadProcessing(); | |
| 608 } | |
| 609 | |
| 610 bool Browser::IsAttemptingToCloseBrowser() const { | 602 bool Browser::IsAttemptingToCloseBrowser() const { |
| 611 return unload_controller_->is_attempting_to_close_browser(); | 603 return unload_controller_->is_attempting_to_close_browser(); |
| 612 } | 604 } |
| 613 | 605 |
| 614 void Browser::OnWindowClosing() { | 606 void Browser::OnWindowClosing() { |
| 615 if (!ShouldCloseWindow()) | 607 if (!ShouldCloseWindow()) |
| 616 return; | 608 return; |
| 617 | 609 |
| 618 // Application should shutdown on last window close if the user is explicitly | 610 // Application should shutdown on last window close if the user is explicitly |
| 619 // trying to quit, or if there is nothing keeping the browser alive (such as | 611 // trying to quit, or if there is nothing keeping the browser alive (such as |
| (...skipping 21 matching lines...) Expand all Loading... |
| 641 #endif | 633 #endif |
| 642 | 634 |
| 643 if (tab_restore_service && is_type_tabbed() && tab_strip_model_->count()) | 635 if (tab_restore_service && is_type_tabbed() && tab_strip_model_->count()) |
| 644 tab_restore_service->BrowserClosing(tab_restore_service_delegate()); | 636 tab_restore_service->BrowserClosing(tab_restore_service_delegate()); |
| 645 | 637 |
| 646 // TODO(sky): convert session/tab restore to use notification. | 638 // TODO(sky): convert session/tab restore to use notification. |
| 647 content::NotificationService::current()->Notify( | 639 content::NotificationService::current()->Notify( |
| 648 chrome::NOTIFICATION_BROWSER_CLOSING, | 640 chrome::NOTIFICATION_BROWSER_CLOSING, |
| 649 content::Source<Browser>(this), | 641 content::Source<Browser>(this), |
| 650 content::NotificationService::NoDetails()); | 642 content::NotificationService::NoDetails()); |
| 651 } | |
| 652 | 643 |
| 653 void Browser::OnUnloadProcessingCompleted() { | 644 tab_strip_model_->CloseAllTabs(); |
| 654 MessageLoop::current()->PostTask( | |
| 655 FROM_HERE, base::Bind(&Browser::CloseFrame, weak_factory_.GetWeakPtr())); | |
| 656 } | 645 } |
| 657 | 646 |
| 658 void Browser::OnWindowActivated() { | 647 void Browser::OnWindowActivated() { |
| 659 // On some platforms we want to automatically reload tabs that are | 648 // On some platforms we want to automatically reload tabs that are |
| 660 // killed when the user selects them. | 649 // killed when the user selects them. |
| 661 WebContents* contents = tab_strip_model_->GetActiveWebContents(); | 650 WebContents* contents = tab_strip_model_->GetActiveWebContents(); |
| 662 if (contents && ShouldReloadCrashedTab(contents)) { | 651 if (contents && ShouldReloadCrashedTab(contents)) { |
| 663 chrome::Reload(this, CURRENT_TAB); | 652 chrome::Reload(this, CURRENT_TAB); |
| 664 // The reload above will change the toolbar reload button into a stop | 653 // The reload above will change the toolbar reload button into a stop |
| 665 // button. If the user activated the window with a mouse press on the | 654 // button. If the user activated the window with a mouse press on the |
| (...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1196 return true; | 1185 return true; |
| 1197 } | 1186 } |
| 1198 return window()->PreHandleKeyboardEvent(event, is_keyboard_shortcut); | 1187 return window()->PreHandleKeyboardEvent(event, is_keyboard_shortcut); |
| 1199 } | 1188 } |
| 1200 | 1189 |
| 1201 void Browser::HandleKeyboardEvent(content::WebContents* source, | 1190 void Browser::HandleKeyboardEvent(content::WebContents* source, |
| 1202 const NativeWebKeyboardEvent& event) { | 1191 const NativeWebKeyboardEvent& event) { |
| 1203 window()->HandleKeyboardEvent(event); | 1192 window()->HandleKeyboardEvent(event); |
| 1204 } | 1193 } |
| 1205 | 1194 |
| 1195 bool Browser::TabsNeedBeforeUnloadFired() { |
| 1196 return unload_controller_->TabsNeedBeforeUnloadFired(); |
| 1197 } |
| 1198 |
| 1206 bool Browser::IsMouseLocked() const { | 1199 bool Browser::IsMouseLocked() const { |
| 1207 return fullscreen_controller_->IsMouseLocked(); | 1200 return fullscreen_controller_->IsMouseLocked(); |
| 1208 } | 1201 } |
| 1209 | 1202 |
| 1210 void Browser::OnWindowDidShow() { | 1203 void Browser::OnWindowDidShow() { |
| 1211 if (window_has_shown_) | 1204 if (window_has_shown_) |
| 1212 return; | 1205 return; |
| 1213 window_has_shown_ = true; | 1206 window_has_shown_ = true; |
| 1214 | 1207 |
| 1215 // CurrentProcessInfo::CreationTime() is currently only implemented on Mac and | 1208 // CurrentProcessInfo::CreationTime() is currently only implemented on Mac and |
| (...skipping 1044 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2260 if (contents && !allow_js_access) { | 2253 if (contents && !allow_js_access) { |
| 2261 contents->web_contents()->GetController().LoadURL( | 2254 contents->web_contents()->GetController().LoadURL( |
| 2262 target_url, | 2255 target_url, |
| 2263 content::Referrer(), | 2256 content::Referrer(), |
| 2264 content::PAGE_TRANSITION_LINK, | 2257 content::PAGE_TRANSITION_LINK, |
| 2265 std::string()); // No extra headers. | 2258 std::string()); // No extra headers. |
| 2266 } | 2259 } |
| 2267 | 2260 |
| 2268 return contents != NULL; | 2261 return contents != NULL; |
| 2269 } | 2262 } |
| OLD | NEW |