| 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/strings/sys_string_conversions.h" | 20 #include "base/strings/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.h" |
| 23 #include "chrome/common/chrome_paths_internal.h" |
| 23 #include "chrome/common/chrome_switches.h" | 24 #include "chrome/common/chrome_switches.h" |
| 24 #include "chrome/common/mac/app_mode_common.h" | 25 #include "chrome/common/mac/app_mode_common.h" |
| 25 #include "ipc/ipc_channel_proxy.h" | 26 #include "ipc/ipc_channel_proxy.h" |
| 26 #include "ipc/ipc_listener.h" | 27 #include "ipc/ipc_listener.h" |
| 27 #include "ipc/ipc_message.h" | 28 #include "ipc/ipc_message.h" |
| 28 | 29 |
| 29 namespace { | 30 namespace { |
| 30 | 31 |
| 31 const app_mode::ChromeAppModeInfo* g_info; | 32 const app_mode::ChromeAppModeInfo* g_info; |
| 32 base::Thread* g_io_thread = NULL; | 33 base::Thread* g_io_thread = NULL; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 61 IPC::ChannelProxy* channel_; | 62 IPC::ChannelProxy* channel_; |
| 62 | 63 |
| 63 DISALLOW_COPY_AND_ASSIGN(AppShimController); | 64 DISALLOW_COPY_AND_ASSIGN(AppShimController); |
| 64 }; | 65 }; |
| 65 | 66 |
| 66 AppShimController::AppShimController() : channel_(NULL) { | 67 AppShimController::AppShimController() : channel_(NULL) { |
| 67 } | 68 } |
| 68 | 69 |
| 69 void AppShimController::Init() { | 70 void AppShimController::Init() { |
| 70 DCHECK(g_io_thread); | 71 DCHECK(g_io_thread); |
| 72 NSString* chrome_bundle_path = |
| 73 base::SysUTF8ToNSString(g_info->chrome_outer_bundle_path.value()); |
| 74 NSBundle* chrome_bundle = [NSBundle bundleWithPath:chrome_bundle_path]; |
| 71 base::FilePath user_data_dir; | 75 base::FilePath user_data_dir; |
| 72 if (!PathService::Get(chrome::DIR_USER_DATA, &user_data_dir)) { | 76 if (!chrome::GetUserDataDirectoryForBrowserBundle(chrome_bundle, |
| 77 &user_data_dir)) { |
| 73 Quit(); | 78 Quit(); |
| 74 return; | 79 return; |
| 75 } | 80 } |
| 81 |
| 76 base::FilePath socket_path = | 82 base::FilePath socket_path = |
| 77 user_data_dir.Append(app_mode::kAppShimSocketName); | 83 user_data_dir.Append(app_mode::kAppShimSocketName); |
| 78 IPC::ChannelHandle handle(socket_path.value()); | 84 IPC::ChannelHandle handle(socket_path.value()); |
| 79 channel_ = new IPC::ChannelProxy(handle, IPC::Channel::MODE_NAMED_CLIENT, | 85 channel_ = new IPC::ChannelProxy(handle, IPC::Channel::MODE_NAMED_CLIENT, |
| 80 this, g_io_thread->message_loop_proxy()); | 86 this, g_io_thread->message_loop_proxy()); |
| 81 | 87 |
| 82 channel_->Send(new AppShimHostMsg_LaunchApp( | 88 channel_->Send(new AppShimHostMsg_LaunchApp( |
| 83 g_info->profile_dir.value(), g_info->app_mode_id)); | 89 g_info->profile_dir.value(), g_info->app_mode_id)); |
| 84 } | 90 } |
| 85 | 91 |
| (...skipping 221 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 | 313 // 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. | 314 // the reply is received, Chrome will have opened its IPC port, guaranteed. |
| 309 [ReplyEventHandler pingProcess:psn andCall:base::Bind(&OnPingChromeReply)]; | 315 [ReplyEventHandler pingProcess:psn andCall:base::Bind(&OnPingChromeReply)]; |
| 310 | 316 |
| 311 MessageLoopForUI main_message_loop; | 317 MessageLoopForUI main_message_loop; |
| 312 main_message_loop.set_thread_name("MainThread"); | 318 main_message_loop.set_thread_name("MainThread"); |
| 313 base::PlatformThread::SetName("CrAppShimMain"); | 319 base::PlatformThread::SetName("CrAppShimMain"); |
| 314 main_message_loop.Run(); | 320 main_message_loop.Run(); |
| 315 return 0; | 321 return 0; |
| 316 } | 322 } |
| OLD | NEW |