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 // On Mac, one can't make shortcuts with command-line arguments. Instead, we | 5 // On Mac, one can't make shortcuts with command-line arguments. Instead, we |
6 // produce small app bundles which locate the Chromium framework and load it, | 6 // produce small app bundles which locate the Chromium framework and load it, |
7 // passing the appropriate data. This is the entry point into the framework for | 7 // passing the appropriate data. This is the entry point into the framework for |
8 // those app bundles. | 8 // those app bundles. |
9 | 9 |
10 #import <Cocoa/Cocoa.h> | 10 #import <Cocoa/Cocoa.h> |
11 | 11 |
12 #include "apps/app_shim/app_shim_messages.h" | 12 #include "apps/app_shim/app_shim_messages.h" |
13 #include "base/at_exit.h" | 13 #include "base/at_exit.h" |
14 #include "base/logging.h" | 14 #include "base/logging.h" |
15 #include "base/mac/mac_logging.h" | 15 #include "base/mac/mac_logging.h" |
16 #include "base/mac/mac_util.h" | 16 #include "base/mac/mac_util.h" |
17 #include "base/mac/scoped_nsautorelease_pool.h" | 17 #include "base/mac/scoped_nsautorelease_pool.h" |
18 #include "base/message_loop.h" | 18 #include "base/message_loop.h" |
19 #include "base/path_service.h" | 19 #include "base/path_service.h" |
20 #include "base/sys_string_conversions.h" | 20 #include "base/sys_string_conversions.h" |
21 #include "base/threading/thread.h" | 21 #include "base/threading/thread.h" |
22 #include "chrome/common/chrome_paths.h" | 22 #include "chrome/common/chrome_paths_internal.h" |
23 #include "chrome/common/chrome_switches.h" | 23 #include "chrome/common/chrome_switches.h" |
24 #include "chrome/common/mac/app_mode_common.h" | 24 #include "chrome/common/mac/app_mode_common.h" |
25 #include "ipc/ipc_channel_proxy.h" | 25 #include "ipc/ipc_channel_proxy.h" |
26 #include "ipc/ipc_listener.h" | 26 #include "ipc/ipc_listener.h" |
27 #include "ipc/ipc_message.h" | 27 #include "ipc/ipc_message.h" |
28 | 28 |
29 namespace { | 29 namespace { |
30 | 30 |
31 const app_mode::ChromeAppModeInfo* g_info; | 31 const app_mode::ChromeAppModeInfo* g_info; |
32 base::Thread* g_io_thread = NULL; | 32 base::Thread* g_io_thread = NULL; |
(...skipping 28 matching lines...) Expand all Loading... | |
61 IPC::ChannelProxy* channel_; | 61 IPC::ChannelProxy* channel_; |
62 | 62 |
63 DISALLOW_COPY_AND_ASSIGN(AppShimController); | 63 DISALLOW_COPY_AND_ASSIGN(AppShimController); |
64 }; | 64 }; |
65 | 65 |
66 AppShimController::AppShimController() : channel_(NULL) { | 66 AppShimController::AppShimController() : channel_(NULL) { |
67 } | 67 } |
68 | 68 |
69 void AppShimController::Init() { | 69 void AppShimController::Init() { |
70 DCHECK(g_io_thread); | 70 DCHECK(g_io_thread); |
71 NSString* chrome_bundle_path = | |
72 base::SysUTF8ToNSString(g_info->chrome_outer_bundle_path.value()); | |
73 NSBundle* chrome_bundle = [NSBundle bundleWithPath:chrome_bundle_path]; | |
71 base::FilePath user_data_dir; | 74 base::FilePath user_data_dir; |
72 if (!PathService::Get(chrome::DIR_USER_DATA, &user_data_dir)) { | 75 if (!chrome::GetUserDataDirectoryForBundle(chrome_bundle, &user_data_dir)) { |
Mark Mentovai
2013/03/22 18:08:41
It’s more cumbersome, but …ForBrowserAppBundle wou
jeremya
2013/04/01 23:30:22
I went for "...ForBrowserBundle". I think that's s
| |
73 Quit(); | 76 Quit(); |
74 return; | 77 return; |
75 } | 78 } |
79 | |
76 base::FilePath socket_path = | 80 base::FilePath socket_path = |
77 user_data_dir.Append(app_mode::kAppShimSocketName); | 81 user_data_dir.Append(app_mode::kAppShimSocketName); |
78 IPC::ChannelHandle handle(socket_path.value()); | 82 IPC::ChannelHandle handle(socket_path.value()); |
79 channel_ = new IPC::ChannelProxy(handle, IPC::Channel::MODE_NAMED_CLIENT, | 83 channel_ = new IPC::ChannelProxy(handle, IPC::Channel::MODE_NAMED_CLIENT, |
80 this, g_io_thread->message_loop_proxy()); | 84 this, g_io_thread->message_loop_proxy()); |
81 | 85 |
82 channel_->Send(new AppShimHostMsg_LaunchApp( | 86 channel_->Send(new AppShimHostMsg_LaunchApp( |
83 g_info->profile_dir.value(), g_info->app_mode_id)); | 87 g_info->profile_dir.value(), g_info->app_mode_id)); |
84 } | 88 } |
85 | 89 |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
246 // |ChromeAppModeStart()| is the point of entry into the framework from the app | 250 // |ChromeAppModeStart()| is the point of entry into the framework from the app |
247 // mode loader. | 251 // mode loader. |
248 __attribute__((visibility("default"))) | 252 __attribute__((visibility("default"))) |
249 int ChromeAppModeStart(const app_mode::ChromeAppModeInfo* info); | 253 int ChromeAppModeStart(const app_mode::ChromeAppModeInfo* info); |
250 | 254 |
251 } // extern "C" | 255 } // extern "C" |
252 | 256 |
253 int ChromeAppModeStart(const app_mode::ChromeAppModeInfo* info) { | 257 int ChromeAppModeStart(const app_mode::ChromeAppModeInfo* info) { |
254 base::mac::ScopedNSAutoreleasePool scoped_pool; | 258 base::mac::ScopedNSAutoreleasePool scoped_pool; |
255 base::AtExitManager exit_manager; | 259 base::AtExitManager exit_manager; |
256 chrome::RegisterPathProvider(); | |
Mark Mentovai
2013/03/22 18:08:41
As long as we’re positive that nothing else needs
jeremya
2013/04/01 23:30:22
Actually we might still need it for DIR_APP_DATA
| |
257 | 260 |
258 if (info->major_version < app_mode::kCurrentChromeAppModeInfoMajorVersion) { | 261 if (info->major_version < app_mode::kCurrentChromeAppModeInfoMajorVersion) { |
259 RAW_LOG(ERROR, "App Mode Loader too old."); | 262 RAW_LOG(ERROR, "App Mode Loader too old."); |
260 return 1; | 263 return 1; |
261 } | 264 } |
262 if (info->major_version > app_mode::kCurrentChromeAppModeInfoMajorVersion) { | 265 if (info->major_version > app_mode::kCurrentChromeAppModeInfoMajorVersion) { |
263 RAW_LOG(ERROR, "Browser Framework too old to load App Shortcut."); | 266 RAW_LOG(ERROR, "Browser Framework too old to load App Shortcut."); |
264 return 1; | 267 return 1; |
265 } | 268 } |
266 | 269 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
307 // fully initialized don't receive a reply until its run loop starts. Once | 310 // fully initialized don't receive a reply until its run loop starts. Once |
308 // the reply is received, Chrome will have opened its IPC port, guaranteed. | 311 // the reply is received, Chrome will have opened its IPC port, guaranteed. |
309 [ReplyEventHandler pingProcess:psn andCall:base::Bind(&OnPingChromeReply)]; | 312 [ReplyEventHandler pingProcess:psn andCall:base::Bind(&OnPingChromeReply)]; |
310 | 313 |
311 MessageLoopForUI main_message_loop; | 314 MessageLoopForUI main_message_loop; |
312 main_message_loop.set_thread_name("MainThread"); | 315 main_message_loop.set_thread_name("MainThread"); |
313 base::PlatformThread::SetName("CrAppShimMain"); | 316 base::PlatformThread::SetName("CrAppShimMain"); |
314 main_message_loop.Run(); | 317 main_message_loop.Run(); |
315 return 0; | 318 return 0; |
316 } | 319 } |
OLD | NEW |