| OLD | NEW |
| 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 #include "apps/app_shim/app_shim_host_mac.h" | 5 #include "apps/app_shim/app_shim_host_mac.h" |
| 6 | 6 |
| 7 #include "apps/app_shim/app_shim_handler_mac.h" | 7 #include "apps/app_shim/app_shim_handler_mac.h" |
| 8 #include "apps/app_shim/app_shim_messages.h" | 8 #include "apps/app_shim/app_shim_messages.h" |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 | 55 |
| 56 void AppShimHost::OnChannelError() { | 56 void AppShimHost::OnChannelError() { |
| 57 Close(); | 57 Close(); |
| 58 } | 58 } |
| 59 | 59 |
| 60 bool AppShimHost::Send(IPC::Message* message) { | 60 bool AppShimHost::Send(IPC::Message* message) { |
| 61 DCHECK(channel_.get()); | 61 DCHECK(channel_.get()); |
| 62 return channel_->Send(message); | 62 return channel_->Send(message); |
| 63 } | 63 } |
| 64 | 64 |
| 65 void AppShimHost::OnLaunchApp(std::string profile_dir, std::string app_id) { | 65 void AppShimHost::OnLaunchApp(std::string profile_dir, |
| 66 std::string app_id, |
| 67 bool launch_now) { |
| 66 DCHECK(CalledOnValidThread()); | 68 DCHECK(CalledOnValidThread()); |
| 67 DCHECK(!profile_); | 69 DCHECK(!profile_); |
| 68 if (profile_) { | 70 if (profile_) { |
| 69 // Only one app launch message per channel. | 71 // Only one app launch message per channel. |
| 70 Send(new AppShimMsg_LaunchApp_Done(false)); | 72 Send(new AppShimMsg_LaunchApp_Done(false)); |
| 71 return; | 73 return; |
| 72 } | 74 } |
| 73 | 75 |
| 74 profile_ = FetchProfileForDirectory(profile_dir); | 76 if (!(profile_ = FetchProfileForDirectory(profile_dir))) { |
| 77 Send(new AppShimMsg_LaunchApp_Done(false)); |
| 78 return; |
| 79 } |
| 80 |
| 75 app_id_ = app_id; | 81 app_id_ = app_id; |
| 82 |
| 76 apps::AppShimHandler* handler = apps::AppShimHandler::GetForAppMode(app_id_); | 83 apps::AppShimHandler* handler = apps::AppShimHandler::GetForAppMode(app_id_); |
| 77 bool success = handler && handler->OnShimLaunch(this); | 84 bool success = handler && handler->OnShimLaunch(this, launch_now); |
| 78 Send(new AppShimMsg_LaunchApp_Done(success)); | 85 Send(new AppShimMsg_LaunchApp_Done(success)); |
| 79 } | 86 } |
| 80 | 87 |
| 81 void AppShimHost::OnFocus() { | 88 void AppShimHost::OnFocus() { |
| 82 DCHECK(CalledOnValidThread()); | 89 DCHECK(CalledOnValidThread()); |
| 83 apps::AppShimHandler* handler = apps::AppShimHandler::GetForAppMode(app_id_); | 90 apps::AppShimHandler* handler = apps::AppShimHandler::GetForAppMode(app_id_); |
| 84 if (handler) | 91 if (handler) |
| 85 handler->OnShimFocus(this); | 92 handler->OnShimFocus(this); |
| 86 } | 93 } |
| 87 | 94 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 109 } | 116 } |
| 110 | 117 |
| 111 void AppShimHost::OnAppClosed() { | 118 void AppShimHost::OnAppClosed() { |
| 112 Close(); | 119 Close(); |
| 113 } | 120 } |
| 114 | 121 |
| 115 void AppShimHost::Close() { | 122 void AppShimHost::Close() { |
| 116 DCHECK(CalledOnValidThread()); | 123 DCHECK(CalledOnValidThread()); |
| 117 delete this; | 124 delete this; |
| 118 } | 125 } |
| OLD | NEW |