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

Side by Side Diff: chrome/app/chrome_main_app_mode_mac.mm

Issue 12663023: [mac] Make app shims look in the correct user data dir on Canary. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address comments Created 7 years, 8 months 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 | Annotate | Revision Log
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 // 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_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
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::GetUserDataDirectoryForBrowserBundle(
Mark Mentovai 2013/04/03 17:52:01 This kind of thing reads a tiny bit better formatt
76 chrome_bundle, &user_data_dir)) {
73 Quit(); 77 Quit();
74 return; 78 return;
75 } 79 }
80
76 base::FilePath socket_path = 81 base::FilePath socket_path =
77 user_data_dir.Append(app_mode::kAppShimSocketName); 82 user_data_dir.Append(app_mode::kAppShimSocketName);
78 IPC::ChannelHandle handle(socket_path.value()); 83 IPC::ChannelHandle handle(socket_path.value());
79 channel_ = new IPC::ChannelProxy(handle, IPC::Channel::MODE_NAMED_CLIENT, 84 channel_ = new IPC::ChannelProxy(handle, IPC::Channel::MODE_NAMED_CLIENT,
80 this, g_io_thread->message_loop_proxy()); 85 this, g_io_thread->message_loop_proxy());
81 86
82 channel_->Send(new AppShimHostMsg_LaunchApp( 87 channel_->Send(new AppShimHostMsg_LaunchApp(
83 g_info->profile_dir.value(), g_info->app_mode_id)); 88 g_info->profile_dir.value(), g_info->app_mode_id));
84 } 89 }
85 90
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 // fully initialized don't receive a reply until its run loop starts. Once 312 // 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. 313 // the reply is received, Chrome will have opened its IPC port, guaranteed.
309 [ReplyEventHandler pingProcess:psn andCall:base::Bind(&OnPingChromeReply)]; 314 [ReplyEventHandler pingProcess:psn andCall:base::Bind(&OnPingChromeReply)];
310 315
311 MessageLoopForUI main_message_loop; 316 MessageLoopForUI main_message_loop;
312 main_message_loop.set_thread_name("MainThread"); 317 main_message_loop.set_thread_name("MainThread");
313 base::PlatformThread::SetName("CrAppShimMain"); 318 base::PlatformThread::SetName("CrAppShimMain");
314 main_message_loop.Run(); 319 main_message_loop.Run();
315 return 0; 320 return 0;
316 } 321 }
OLDNEW
« no previous file with comments | « no previous file | chrome/common/chrome_paths_internal.h » ('j') | chrome/common/chrome_paths_internal.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698