Chromium Code Reviews| 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 #import "chrome/browser/app_controller_mac.h" | 5 #import "chrome/browser/app_controller_mac.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 46 #include "chrome/browser/sessions/tab_restore_service_factory.h" | 46 #include "chrome/browser/sessions/tab_restore_service_factory.h" |
| 47 #include "chrome/browser/signin/signin_manager_factory.h" | 47 #include "chrome/browser/signin/signin_manager_factory.h" |
| 48 #include "chrome/browser/signin/signin_promo.h" | 48 #include "chrome/browser/signin/signin_promo.h" |
| 49 #include "chrome/browser/signin/signin_ui_util.h" | 49 #include "chrome/browser/signin/signin_ui_util.h" |
| 50 #include "chrome/browser/sync/sync_ui_util.h" | 50 #include "chrome/browser/sync/sync_ui_util.h" |
| 51 #include "chrome/browser/ui/browser.h" | 51 #include "chrome/browser/ui/browser.h" |
| 52 #include "chrome/browser/ui/browser_command_controller.h" | 52 #include "chrome/browser/ui/browser_command_controller.h" |
| 53 #include "chrome/browser/ui/browser_commands.h" | 53 #include "chrome/browser/ui/browser_commands.h" |
| 54 #include "chrome/browser/ui/browser_dialogs.h" | 54 #include "chrome/browser/ui/browser_dialogs.h" |
| 55 #include "chrome/browser/ui/browser_finder.h" | 55 #include "chrome/browser/ui/browser_finder.h" |
| 56 #include "chrome/browser/ui/browser_iterator.h" | 56 #include "chrome/browser/ui/browser_list.h" |
| 57 #include "chrome/browser/ui/browser_mac.h" | 57 #include "chrome/browser/ui/browser_mac.h" |
| 58 #include "chrome/browser/ui/browser_window.h" | 58 #include "chrome/browser/ui/browser_window.h" |
| 59 #include "chrome/browser/ui/chrome_pages.h" | 59 #include "chrome/browser/ui/chrome_pages.h" |
| 60 #import "chrome/browser/ui/cocoa/apps/app_shim_menu_controller_mac.h" | 60 #import "chrome/browser/ui/cocoa/apps/app_shim_menu_controller_mac.h" |
| 61 #include "chrome/browser/ui/cocoa/apps/quit_with_apps_controller_mac.h" | 61 #include "chrome/browser/ui/cocoa/apps/quit_with_apps_controller_mac.h" |
| 62 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_menu_bridge.h" | 62 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_menu_bridge.h" |
| 63 #import "chrome/browser/ui/cocoa/confirm_quit.h" | 63 #import "chrome/browser/ui/cocoa/confirm_quit.h" |
| 64 #import "chrome/browser/ui/cocoa/confirm_quit_panel_controller.h" | 64 #import "chrome/browser/ui/cocoa/confirm_quit_panel_controller.h" |
| 65 #import "chrome/browser/ui/cocoa/encoding_menu_controller_delegate_mac.h" | 65 #import "chrome/browser/ui/cocoa/encoding_menu_controller_delegate_mac.h" |
| 66 #include "chrome/browser/ui/cocoa/handoff_active_url_observer_bridge.h" | 66 #include "chrome/browser/ui/cocoa/handoff_active_url_observer_bridge.h" |
| (...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 483 // will no longer lead to termination. | 483 // will no longer lead to termination. |
| 484 browser_shutdown::SetTryingToQuit(false); | 484 browser_shutdown::SetTryingToQuit(false); |
| 485 | 485 |
| 486 // TODO(viettrungluu): Were we to remove Apple Event handlers above, we | 486 // TODO(viettrungluu): Were we to remove Apple Event handlers above, we |
| 487 // would have to reinstall them here. http://crbug.com/40861 | 487 // would have to reinstall them here. http://crbug.com/40861 |
| 488 } | 488 } |
| 489 } | 489 } |
| 490 | 490 |
| 491 - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication*)app { | 491 - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication*)app { |
| 492 // If there are no windows, quit immediately. | 492 // If there are no windows, quit immediately. |
| 493 if (chrome::BrowserIterator().done() && | 493 if (BrowserList::GetInstance()->empty() && |
| 494 !AppWindowRegistryUtil::IsAppWindowVisibleInAnyProfile(0)) { | 494 !AppWindowRegistryUtil::IsAppWindowVisibleInAnyProfile(0)) { |
| 495 return NSTerminateNow; | 495 return NSTerminateNow; |
| 496 } | 496 } |
| 497 | 497 |
| 498 // Check if the preference is turned on. | 498 // Check if the preference is turned on. |
| 499 const PrefService* prefs = g_browser_process->local_state(); | 499 const PrefService* prefs = g_browser_process->local_state(); |
| 500 if (!prefs->GetBoolean(prefs::kConfirmToQuitEnabled)) { | 500 if (!prefs->GetBoolean(prefs::kConfirmToQuitEnabled)) { |
| 501 confirm_quit::RecordHistogram(confirm_quit::kNoConfirm); | 501 confirm_quit::RecordHistogram(confirm_quit::kNoConfirm); |
| 502 return NSTerminateNow; | 502 return NSTerminateNow; |
| 503 } | 503 } |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 628 (base::TimeTicks::Now() - reopenTime_).InMilliseconds() > | 628 (base::TimeTicks::Now() - reopenTime_).InMilliseconds() > |
| 629 kWorkspaceChangeTimeoutMs) { | 629 kWorkspaceChangeTimeoutMs) { |
| 630 return; | 630 return; |
| 631 } | 631 } |
| 632 | 632 |
| 633 // The last applicationShouldHandleReopen:hasVisibleWindows: call | 633 // The last applicationShouldHandleReopen:hasVisibleWindows: call |
| 634 // happened during a space change. Now that the change has | 634 // happened during a space change. Now that the change has |
| 635 // completed, raise browser windows. | 635 // completed, raise browser windows. |
| 636 reopenTime_ = base::TimeTicks(); | 636 reopenTime_ = base::TimeTicks(); |
| 637 std::set<NSWindow*> browserWindows; | 637 std::set<NSWindow*> browserWindows; |
| 638 for (chrome::BrowserIterator iter; !iter.done(); iter.Next()) { | 638 for (auto& browser : *BrowserList::GetInstance()) { |
|
sky
2016/01/28 03:04:05
Similar comment as to this working.
| |
| 639 Browser* browser = *iter; | |
| 640 browserWindows.insert(browser->window()->GetNativeWindow()); | 639 browserWindows.insert(browser->window()->GetNativeWindow()); |
| 641 } | 640 } |
| 642 if (!browserWindows.empty()) { | 641 if (!browserWindows.empty()) { |
| 643 ui::FocusWindowSetOnCurrentSpace(browserWindows); | 642 ui::FocusWindowSetOnCurrentSpace(browserWindows); |
| 644 } | 643 } |
| 645 } | 644 } |
| 646 | 645 |
| 647 // Called when shutting down or logging out. | 646 // Called when shutting down or logging out. |
| 648 - (void)willPowerOff:(NSNotification*)notify { | 647 - (void)willPowerOff:(NSNotification*)notify { |
| 649 // Don't attempt any shutdown here. Cocoa will shortly call | 648 // Don't attempt any shutdown here. Cocoa will shortly call |
| (...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1184 if (browser_shutdown::IsTryingToQuit()) | 1183 if (browser_shutdown::IsTryingToQuit()) |
| 1185 return NO; | 1184 return NO; |
| 1186 | 1185 |
| 1187 // Bring all browser windows to the front. Specifically, this brings them in | 1186 // Bring all browser windows to the front. Specifically, this brings them in |
| 1188 // front of any app windows. FocusWindowSet will also unminimize the most | 1187 // front of any app windows. FocusWindowSet will also unminimize the most |
| 1189 // recently minimized window if no windows in the set are visible. | 1188 // recently minimized window if no windows in the set are visible. |
| 1190 // If there are any, return here. Otherwise, the windows are panels or | 1189 // If there are any, return here. Otherwise, the windows are panels or |
| 1191 // notifications so we still need to open a new window. | 1190 // notifications so we still need to open a new window. |
| 1192 if (hasVisibleWindows) { | 1191 if (hasVisibleWindows) { |
| 1193 std::set<NSWindow*> browserWindows; | 1192 std::set<NSWindow*> browserWindows; |
| 1194 for (chrome::BrowserIterator iter; !iter.done(); iter.Next()) { | 1193 for (auto& browser : *BrowserList::GetInstance()) { |
| 1195 Browser* browser = *iter; | |
| 1196 // When focusing Chrome, don't focus any browser windows associated with | 1194 // When focusing Chrome, don't focus any browser windows associated with |
| 1197 // a currently running app shim, so ignore them. | 1195 // a currently running app shim, so ignore them. |
| 1198 if (browser && browser->is_app()) { | 1196 if (browser && browser->is_app()) { |
| 1199 extensions::ExtensionRegistry* registry = | 1197 extensions::ExtensionRegistry* registry = |
| 1200 extensions::ExtensionRegistry::Get(browser->profile()); | 1198 extensions::ExtensionRegistry::Get(browser->profile()); |
| 1201 const extensions::Extension* extension = registry->GetExtensionById( | 1199 const extensions::Extension* extension = registry->GetExtensionById( |
| 1202 web_app::GetExtensionIdFromApplicationName(browser->app_name()), | 1200 web_app::GetExtensionIdFromApplicationName(browser->app_name()), |
| 1203 extensions::ExtensionRegistry::ENABLED); | 1201 extensions::ExtensionRegistry::ENABLED); |
| 1204 if (extension && extension->is_hosted_app()) | 1202 if (extension && extension->is_hosted_app()) |
| 1205 continue; | 1203 continue; |
| (...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1705 | 1703 |
| 1706 //--------------------------------------------------------------------------- | 1704 //--------------------------------------------------------------------------- |
| 1707 | 1705 |
| 1708 namespace app_controller_mac { | 1706 namespace app_controller_mac { |
| 1709 | 1707 |
| 1710 bool IsOpeningNewWindow() { | 1708 bool IsOpeningNewWindow() { |
| 1711 return g_is_opening_new_window; | 1709 return g_is_opening_new_window; |
| 1712 } | 1710 } |
| 1713 | 1711 |
| 1714 } // namespace app_controller_mac | 1712 } // namespace app_controller_mac |
| OLD | NEW |