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 "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 #include "chrome/browser/ui/cocoa/last_active_browser_cocoa.h" | 67 #include "chrome/browser/ui/cocoa/last_active_browser_cocoa.h" |
68 #import "chrome/browser/ui/cocoa/profiles/profile_menu_controller.h" | 68 #import "chrome/browser/ui/cocoa/profiles/profile_menu_controller.h" |
69 #import "chrome/browser/ui/cocoa/tabs/tab_strip_controller.h" | 69 #import "chrome/browser/ui/cocoa/tabs/tab_strip_controller.h" |
70 #import "chrome/browser/ui/cocoa/tabs/tab_window_controller.h" | 70 #import "chrome/browser/ui/cocoa/tabs/tab_window_controller.h" |
71 #include "chrome/browser/ui/cocoa/task_manager_mac.h" | 71 #include "chrome/browser/ui/cocoa/task_manager_mac.h" |
72 #include "chrome/browser/ui/extensions/application_launch.h" | 72 #include "chrome/browser/ui/extensions/application_launch.h" |
73 #include "chrome/browser/ui/host_desktop.h" | 73 #include "chrome/browser/ui/host_desktop.h" |
74 #include "chrome/browser/ui/startup/startup_browser_creator.h" | 74 #include "chrome/browser/ui/startup/startup_browser_creator.h" |
75 #include "chrome/browser/ui/startup/startup_browser_creator_impl.h" | 75 #include "chrome/browser/ui/startup/startup_browser_creator_impl.h" |
76 #include "chrome/browser/ui/user_manager.h" | 76 #include "chrome/browser/ui/user_manager.h" |
| 77 #include "chrome/browser/web_applications/web_app_mac.h" |
77 #include "chrome/common/chrome_paths_internal.h" | 78 #include "chrome/common/chrome_paths_internal.h" |
78 #include "chrome/common/chrome_switches.h" | 79 #include "chrome/common/chrome_switches.h" |
79 #include "chrome/common/cloud_print/cloud_print_class_mac.h" | 80 #include "chrome/common/cloud_print/cloud_print_class_mac.h" |
80 #include "chrome/common/extensions/extension_constants.h" | 81 #include "chrome/common/extensions/extension_constants.h" |
81 #include "chrome/common/mac/app_mode_common.h" | 82 #include "chrome/common/mac/app_mode_common.h" |
82 #include "chrome/common/pref_names.h" | 83 #include "chrome/common/pref_names.h" |
83 #include "chrome/common/url_constants.h" | 84 #include "chrome/common/url_constants.h" |
84 #include "chrome/grit/chromium_strings.h" | 85 #include "chrome/grit/chromium_strings.h" |
85 #include "chrome/grit/generated_resources.h" | 86 #include "chrome/grit/generated_resources.h" |
86 #include "components/handoff/handoff_utility.h" | 87 #include "components/handoff/handoff_utility.h" |
87 #include "components/signin/core/browser/signin_manager.h" | 88 #include "components/signin/core/browser/signin_manager.h" |
88 #include "components/signin/core/common/profile_management_switches.h" | 89 #include "components/signin/core/common/profile_management_switches.h" |
89 #include "content/public/browser/browser_thread.h" | 90 #include "content/public/browser/browser_thread.h" |
90 #include "content/public/browser/download_manager.h" | 91 #include "content/public/browser/download_manager.h" |
91 #include "content/public/browser/notification_service.h" | 92 #include "content/public/browser/notification_service.h" |
92 #include "content/public/browser/notification_types.h" | 93 #include "content/public/browser/notification_types.h" |
93 #include "content/public/browser/plugin_service.h" | 94 #include "content/public/browser/plugin_service.h" |
94 #include "content/public/browser/user_metrics.h" | 95 #include "content/public/browser/user_metrics.h" |
95 #include "extensions/browser/extension_system.h" | 96 #include "extensions/browser/extension_system.h" |
| 97 #include "extensions/browser/extension_registry.h" |
96 #include "net/base/filename_util.h" | 98 #include "net/base/filename_util.h" |
97 #include "ui/base/cocoa/focus_window_set.h" | 99 #include "ui/base/cocoa/focus_window_set.h" |
98 #include "ui/base/l10n/l10n_util.h" | 100 #include "ui/base/l10n/l10n_util.h" |
99 #include "ui/base/l10n/l10n_util_mac.h" | 101 #include "ui/base/l10n/l10n_util_mac.h" |
100 | 102 |
| 103 using apps::AppShimHandler; |
| 104 using apps::ExtensionAppShimHandler; |
101 using base::UserMetricsAction; | 105 using base::UserMetricsAction; |
102 using content::BrowserContext; | 106 using content::BrowserContext; |
103 using content::BrowserThread; | 107 using content::BrowserThread; |
104 using content::DownloadManager; | 108 using content::DownloadManager; |
105 | 109 |
106 namespace { | 110 namespace { |
107 | 111 |
108 // Declare notification names from the 10.7 SDK. | 112 // Declare notification names from the 10.7 SDK. |
109 #if !defined(MAC_OS_X_VERSION_10_7) || \ | 113 #if !defined(MAC_OS_X_VERSION_10_7) || \ |
110 MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7 | 114 MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7 |
(...skipping 1067 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1178 if (browser_shutdown::IsTryingToQuit()) | 1182 if (browser_shutdown::IsTryingToQuit()) |
1179 return NO; | 1183 return NO; |
1180 | 1184 |
1181 // Bring all browser windows to the front. Specifically, this brings them in | 1185 // Bring all browser windows to the front. Specifically, this brings them in |
1182 // front of any app windows. FocusWindowSet will also unminimize the most | 1186 // front of any app windows. FocusWindowSet will also unminimize the most |
1183 // recently minimized window if no windows in the set are visible. | 1187 // recently minimized window if no windows in the set are visible. |
1184 // If there are any, return here. Otherwise, the windows are panels or | 1188 // If there are any, return here. Otherwise, the windows are panels or |
1185 // notifications so we still need to open a new window. | 1189 // notifications so we still need to open a new window. |
1186 if (hasVisibleWindows) { | 1190 if (hasVisibleWindows) { |
1187 std::set<NSWindow*> browserWindows; | 1191 std::set<NSWindow*> browserWindows; |
| 1192 ExtensionAppShimHandler* appShimHandler = |
| 1193 g_browser_process->platform_part() |
| 1194 ->app_shim_host_manager() |
| 1195 ->extension_app_shim_handler(); |
1188 for (chrome::BrowserIterator iter; !iter.done(); iter.Next()) { | 1196 for (chrome::BrowserIterator iter; !iter.done(); iter.Next()) { |
1189 Browser* browser = *iter; | 1197 Browser* browser = *iter; |
| 1198 // When focusing Chrome, don't focus any browser windows associated with |
| 1199 // a currently running app shim, so ignore them. |
| 1200 if (browser && browser->is_app()) { |
| 1201 AppShimHandler::Host* host = appShimHandler->FindHost( |
| 1202 browser->profile(), |
| 1203 web_app::GetExtensionIdFromApplicationName(browser->app_name())); |
| 1204 if (host) { |
| 1205 continue; |
| 1206 } |
| 1207 } |
1190 browserWindows.insert(browser->window()->GetNativeWindow()); | 1208 browserWindows.insert(browser->window()->GetNativeWindow()); |
1191 } | 1209 } |
1192 if (!browserWindows.empty()) { | 1210 if (!browserWindows.empty()) { |
1193 NSWindow* keyWindow = [NSApp keyWindow]; | 1211 NSWindow* keyWindow = [NSApp keyWindow]; |
1194 if (keyWindow && ![keyWindow isOnActiveSpace]) { | 1212 if (keyWindow && ![keyWindow isOnActiveSpace]) { |
1195 // The key window is not on the active space. We must be mid-animation | 1213 // The key window is not on the active space. We must be mid-animation |
1196 // for a space transition triggered by the dock. Delay the call to | 1214 // for a space transition triggered by the dock. Delay the call to |
1197 // |ui::FocusWindowSet| until the transition completes. Otherwise, the | 1215 // |ui::FocusWindowSet| until the transition completes. Otherwise, the |
1198 // wrong space's windows get raised, resulting in an off-screen key | 1216 // wrong space's windows get raised, resulting in an off-screen key |
1199 // window. It does not work to |ui::FocusWindowSet| twice, once here | 1217 // window. It does not work to |ui::FocusWindowSet| twice, once here |
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1642 | 1660 |
1643 //--------------------------------------------------------------------------- | 1661 //--------------------------------------------------------------------------- |
1644 | 1662 |
1645 namespace app_controller_mac { | 1663 namespace app_controller_mac { |
1646 | 1664 |
1647 bool IsOpeningNewWindow() { | 1665 bool IsOpeningNewWindow() { |
1648 return g_is_opening_new_window; | 1666 return g_is_opening_new_window; |
1649 } | 1667 } |
1650 | 1668 |
1651 } // namespace app_controller_mac | 1669 } // namespace app_controller_mac |
OLD | NEW |