Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(595)

Side by Side Diff: chrome/browser/app_controller_mac.mm

Issue 790043002: Hosted apps on OS X now act more like a native app. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@creating-app-shims-2
Patch Set: Refactored code and addressed comments Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 1069 matching lines...) Expand 10 before | Expand all | Expand 10 after
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;
1188 for (chrome::BrowserIterator iter; !iter.done(); iter.Next()) { 1192 for (chrome::BrowserIterator iter; !iter.done(); iter.Next()) {
1189 Browser* browser = *iter; 1193 Browser* browser = *iter;
1194 if (browser && browser->is_app()) {
1195 ExtensionAppShimHandler* handler = g_browser_process->platform_part()
1196 ->app_shim_host_manager()
1197 ->extension_app_shim_handler();
1198 AppShimHandler::Host* host = handler->FindHost(
1199 browser->profile(),
1200 web_app::GetExtensionIdFromApplicationName(browser->app_name()));
1201 if (host) {
1202 continue;
1203 }
1204 }
1190 browserWindows.insert(browser->window()->GetNativeWindow()); 1205 browserWindows.insert(browser->window()->GetNativeWindow());
1191 } 1206 }
1192 if (!browserWindows.empty()) { 1207 if (!browserWindows.empty()) {
1193 NSWindow* keyWindow = [NSApp keyWindow]; 1208 NSWindow* keyWindow = [NSApp keyWindow];
1194 if (keyWindow && ![keyWindow isOnActiveSpace]) { 1209 if (keyWindow && ![keyWindow isOnActiveSpace]) {
1195 // The key window is not on the active space. We must be mid-animation 1210 // 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 1211 // for a space transition triggered by the dock. Delay the call to
1197 // |ui::FocusWindowSet| until the transition completes. Otherwise, the 1212 // |ui::FocusWindowSet| until the transition completes. Otherwise, the
1198 // wrong space's windows get raised, resulting in an off-screen key 1213 // wrong space's windows get raised, resulting in an off-screen key
1199 // window. It does not work to |ui::FocusWindowSet| twice, once here 1214 // window. It does not work to |ui::FocusWindowSet| twice, once here
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after
1642 1657
1643 //--------------------------------------------------------------------------- 1658 //---------------------------------------------------------------------------
1644 1659
1645 namespace app_controller_mac { 1660 namespace app_controller_mac {
1646 1661
1647 bool IsOpeningNewWindow() { 1662 bool IsOpeningNewWindow() {
1648 return g_is_opening_new_window; 1663 return g_is_opening_new_window;
1649 } 1664 }
1650 1665
1651 } // namespace app_controller_mac 1666 } // namespace app_controller_mac
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698