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

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

Issue 14514003: Make OSX App Launcher Launchable from the Dock. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: rebase off cl14603002 Created 7 years, 7 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
« no previous file with comments | « apps/app_shim/app_shim_messages.h ('k') | chrome/app/chromium_strings.grd » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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>
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 47
48 private: 48 private:
49 // IPC::Listener implemetation. 49 // IPC::Listener implemetation.
50 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; 50 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
51 virtual void OnChannelError() OVERRIDE; 51 virtual void OnChannelError() OVERRIDE;
52 52
53 // If Chrome failed to launch the app, |success| will be false and the app 53 // If Chrome failed to launch the app, |success| will be false and the app
54 // shim process should die. 54 // shim process should die.
55 void OnLaunchAppDone(bool success); 55 void OnLaunchAppDone(bool success);
56 56
57 // Called when the Chrome process observes the app list dismissal.
58 void OnAppListDismissed();
59
57 // Called when the app is activated, either by the user clicking on it in the 60 // Called when the app is activated, either by the user clicking on it in the
58 // dock or by Cmd+Tabbing to it. 61 // dock or by Cmd+Tabbing to it.
59 void OnDidActivateApplication(); 62 void OnDidActivateApplication();
60 63
61 // Quits the app shim process. 64 // Quits the app shim process.
62 void Quit(); 65 void Quit();
63 66
64 IPC::ChannelProxy* channel_; 67 IPC::ChannelProxy* channel_;
65 68
66 DISALLOW_COPY_AND_ASSIGN(AppShimController); 69 DISALLOW_COPY_AND_ASSIGN(AppShimController);
(...skipping 13 matching lines...) Expand all
80 Quit(); 83 Quit();
81 return; 84 return;
82 } 85 }
83 86
84 base::FilePath socket_path = 87 base::FilePath socket_path =
85 user_data_dir.Append(app_mode::kAppShimSocketName); 88 user_data_dir.Append(app_mode::kAppShimSocketName);
86 IPC::ChannelHandle handle(socket_path.value()); 89 IPC::ChannelHandle handle(socket_path.value());
87 channel_ = new IPC::ChannelProxy(handle, IPC::Channel::MODE_NAMED_CLIENT, 90 channel_ = new IPC::ChannelProxy(handle, IPC::Channel::MODE_NAMED_CLIENT,
88 this, g_io_thread->message_loop_proxy()); 91 this, g_io_thread->message_loop_proxy());
89 92
93 // Check if this ia a shim for showing the app list.
94 if (g_info->app_mode_id == app_mode::kAppListModeId) {
95 channel_->Send(new AppShimHostMsg_LaunchAppList());
96 return;
97 }
98
90 channel_->Send(new AppShimHostMsg_LaunchApp( 99 channel_->Send(new AppShimHostMsg_LaunchApp(
91 g_info->profile_dir.value(), g_info->app_mode_id)); 100 g_info->profile_dir.value(), g_info->app_mode_id));
92 } 101 }
93 102
94 bool AppShimController::OnMessageReceived(const IPC::Message& message) { 103 bool AppShimController::OnMessageReceived(const IPC::Message& message) {
95 bool handled = true; 104 bool handled = true;
96 IPC_BEGIN_MESSAGE_MAP(AppShimController, message) 105 IPC_BEGIN_MESSAGE_MAP(AppShimController, message)
97 IPC_MESSAGE_HANDLER(AppShimMsg_LaunchApp_Done, OnLaunchAppDone) 106 IPC_MESSAGE_HANDLER(AppShimMsg_LaunchApp_Done, OnLaunchAppDone)
107 IPC_MESSAGE_HANDLER(AppShimMsg_AppListDismissed, OnAppListDismissed)
98 IPC_MESSAGE_UNHANDLED(handled = false) 108 IPC_MESSAGE_UNHANDLED(handled = false)
99 IPC_END_MESSAGE_MAP() 109 IPC_END_MESSAGE_MAP()
100 110
101 return handled; 111 return handled;
102 } 112 }
103 113
104 void AppShimController::OnChannelError() { 114 void AppShimController::OnChannelError() {
105 LOG(ERROR) << "App shim channel error."; 115 LOG(ERROR) << "App shim channel error.";
106 Quit(); 116 Quit();
107 } 117 }
108 118
109 void AppShimController::OnLaunchAppDone(bool success) { 119 void AppShimController::OnLaunchAppDone(bool success) {
110 if (!success) { 120 if (!success) {
111 Quit(); 121 Quit();
112 return; 122 return;
113 } 123 }
114 [[[NSWorkspace sharedWorkspace] notificationCenter] 124 [[[NSWorkspace sharedWorkspace] notificationCenter]
115 addObserverForName:NSWorkspaceDidActivateApplicationNotification 125 addObserverForName:NSWorkspaceDidActivateApplicationNotification
116 object:nil 126 object:nil
117 queue:nil 127 queue:nil
118 usingBlock:^(NSNotification* notification) { 128 usingBlock:^(NSNotification* notification) {
119 NSRunningApplication* activated_app = 129 NSRunningApplication* activated_app =
120 [[notification userInfo] objectForKey:NSWorkspaceApplicationKey]; 130 [[notification userInfo] objectForKey:NSWorkspaceApplicationKey];
121 if ([activated_app isEqual:[NSRunningApplication currentApplication]]) 131 if ([activated_app isEqual:[NSRunningApplication currentApplication]])
122 OnDidActivateApplication(); 132 OnDidActivateApplication();
123 }]; 133 }];
124 } 134 }
125 135
136 void AppShimController::OnAppListDismissed() {
137 Quit();
138 }
139
126 void AppShimController::Quit() { 140 void AppShimController::Quit() {
127 [NSApp terminate:nil]; 141 [NSApp terminate:nil];
128 } 142 }
129 143
130 void AppShimController::OnDidActivateApplication() { 144 void AppShimController::OnDidActivateApplication() {
131 channel_->Send(new AppShimHostMsg_FocusApp); 145 channel_->Send(new AppShimHostMsg_FocusApp);
132 } 146 }
133 147
134 //----------------------------------------------------------------------------- 148 //-----------------------------------------------------------------------------
135 149
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 // 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
299 // 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.
300 [ReplyEventHandler pingProcess:psn andCall:base::Bind(&OnPingChromeReply)]; 314 [ReplyEventHandler pingProcess:psn andCall:base::Bind(&OnPingChromeReply)];
301 315
302 MessageLoopForUI main_message_loop; 316 MessageLoopForUI main_message_loop;
303 main_message_loop.set_thread_name("MainThread"); 317 main_message_loop.set_thread_name("MainThread");
304 base::PlatformThread::SetName("CrAppShimMain"); 318 base::PlatformThread::SetName("CrAppShimMain");
305 main_message_loop.Run(); 319 main_message_loop.Run();
306 return 0; 320 return 0;
307 } 321 }
OLDNEW
« no previous file with comments | « apps/app_shim/app_shim_messages.h ('k') | chrome/app/chromium_strings.grd » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698