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

Side by Side Diff: apps/app_shim/chrome_main_app_mode_mac.mm

Issue 19503003: Use the shim bundle's user_data_dir instead of GetUserDataDirectoryForBrowserBundle. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sync and rebase Created 7 years, 4 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
« no previous file with comments | « apps/DEPS ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/command_line.h" 14 #include "base/command_line.h"
15 #include "base/logging.h" 15 #include "base/logging.h"
16 #include "base/mac/bundle_locations.h" 16 #include "base/mac/bundle_locations.h"
17 #include "base/mac/launch_services_util.h" 17 #include "base/mac/launch_services_util.h"
18 #include "base/mac/mac_logging.h" 18 #include "base/mac/mac_logging.h"
19 #include "base/mac/mac_util.h" 19 #include "base/mac/mac_util.h"
20 #include "base/mac/scoped_nsautorelease_pool.h" 20 #include "base/mac/scoped_nsautorelease_pool.h"
21 #include "base/mac/scoped_nsobject.h" 21 #include "base/mac/scoped_nsobject.h"
22 #include "base/message_loop/message_loop.h" 22 #include "base/message_loop/message_loop.h"
23 #include "base/path_service.h" 23 #include "base/path_service.h"
24 #include "base/strings/sys_string_conversions.h" 24 #include "base/strings/sys_string_conversions.h"
25 #include "base/threading/thread.h" 25 #include "base/threading/thread.h"
26 #include "chrome/common/chrome_constants.h" 26 #include "chrome/common/chrome_constants.h"
27 #include "chrome/common/chrome_paths.h" 27 #include "chrome/common/chrome_paths.h"
28 #include "chrome/common/chrome_paths_internal.h"
29 #include "chrome/common/chrome_switches.h" 28 #include "chrome/common/chrome_switches.h"
30 #include "chrome/common/mac/app_mode_common.h" 29 #include "chrome/common/mac/app_mode_common.h"
31 #include "grit/generated_resources.h" 30 #include "grit/generated_resources.h"
32 #include "ipc/ipc_channel_proxy.h" 31 #include "ipc/ipc_channel_proxy.h"
33 #include "ipc/ipc_listener.h" 32 #include "ipc/ipc_listener.h"
34 #include "ipc/ipc_message.h" 33 #include "ipc/ipc_message.h"
35 #include "ui/base/resource/resource_bundle.h" 34 #include "ui/base/resource/resource_bundle.h"
36 #include "ui/base/l10n/l10n_util.h" 35 #include "ui/base/l10n/l10n_util.h"
37 36
38 namespace { 37 namespace {
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 }; 99 };
101 100
102 AppShimController::AppShimController() : channel_(NULL), 101 AppShimController::AppShimController() : channel_(NULL),
103 launch_app_done_(false) {} 102 launch_app_done_(false) {}
104 103
105 void AppShimController::Init() { 104 void AppShimController::Init() {
106 DCHECK(g_io_thread); 105 DCHECK(g_io_thread);
107 106
108 SetUpMenu(); 107 SetUpMenu();
109 108
110 // Open an IPC channel to Chrome and send the initial app launch message. 109 // The user_data_dir for shims actually contains the app_data_path.
111 NSString* chrome_bundle_path = 110 // I.e. <user_data_dir>/<profile_dir>/Web Applications/_crx_extensionid/
112 base::SysUTF8ToNSString(g_info->chrome_outer_bundle_path.value()); 111 base::FilePath user_data_dir =
113 NSBundle* chrome_bundle = [NSBundle bundleWithPath:chrome_bundle_path]; 112 g_info->user_data_dir.DirName().DirName().DirName();
114 base::FilePath user_data_dir; 113 CHECK(!user_data_dir.empty());
115 if (!chrome::GetUserDataDirectoryForBrowserBundle(chrome_bundle,
116 &user_data_dir)) {
117 Close();
118 return;
119 }
120 114
121 base::FilePath socket_path = 115 base::FilePath socket_path =
122 user_data_dir.Append(app_mode::kAppShimSocketName); 116 user_data_dir.Append(app_mode::kAppShimSocketName);
123 IPC::ChannelHandle handle(socket_path.value()); 117 IPC::ChannelHandle handle(socket_path.value());
124 channel_ = new IPC::ChannelProxy(handle, IPC::Channel::MODE_NAMED_CLIENT, 118 channel_ = new IPC::ChannelProxy(handle, IPC::Channel::MODE_NAMED_CLIENT,
125 this, g_io_thread->message_loop_proxy().get()); 119 this, g_io_thread->message_loop_proxy().get());
126 120
127 channel_->Send(new AppShimHostMsg_LaunchApp( 121 channel_->Send(new AppShimHostMsg_LaunchApp(
128 g_info->profile_dir, g_info->app_mode_id, 122 g_info->profile_dir, g_info->app_mode_id,
129 CommandLine::ForCurrentProcess()->HasSwitch(app_mode::kNoLaunchApp) ? 123 CommandLine::ForCurrentProcess()->HasSwitch(app_mode::kNoLaunchApp) ?
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 // fully initialized don't receive a reply until its run loop starts. Once 462 // fully initialized don't receive a reply until its run loop starts. Once
469 // the reply is received, Chrome will have opened its IPC port, guaranteed. 463 // the reply is received, Chrome will have opened its IPC port, guaranteed.
470 [ReplyEventHandler pingProcess:psn andCall:base::Bind(&OnPingChromeReply)]; 464 [ReplyEventHandler pingProcess:psn andCall:base::Bind(&OnPingChromeReply)];
471 465
472 base::MessageLoopForUI main_message_loop; 466 base::MessageLoopForUI main_message_loop;
473 main_message_loop.set_thread_name("MainThread"); 467 main_message_loop.set_thread_name("MainThread");
474 base::PlatformThread::SetName("CrAppShimMain"); 468 base::PlatformThread::SetName("CrAppShimMain");
475 main_message_loop.Run(); 469 main_message_loop.Run();
476 return 0; 470 return 0;
477 } 471 }
OLDNEW
« no previous file with comments | « apps/DEPS ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698