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 29 matching lines...) Expand all Loading... |
40 std::string AppShimHost::GetAppId() const { | 40 std::string AppShimHost::GetAppId() const { |
41 return app_id_; | 41 return app_id_; |
42 } | 42 } |
43 | 43 |
44 bool AppShimHost::OnMessageReceived(const IPC::Message& message) { | 44 bool AppShimHost::OnMessageReceived(const IPC::Message& message) { |
45 DCHECK(CalledOnValidThread()); | 45 DCHECK(CalledOnValidThread()); |
46 bool handled = true; | 46 bool handled = true; |
47 IPC_BEGIN_MESSAGE_MAP(AppShimHost, message) | 47 IPC_BEGIN_MESSAGE_MAP(AppShimHost, message) |
48 IPC_MESSAGE_HANDLER(AppShimHostMsg_LaunchApp, OnLaunchApp) | 48 IPC_MESSAGE_HANDLER(AppShimHostMsg_LaunchApp, OnLaunchApp) |
49 IPC_MESSAGE_HANDLER(AppShimHostMsg_FocusApp, OnFocus) | 49 IPC_MESSAGE_HANDLER(AppShimHostMsg_FocusApp, OnFocus) |
| 50 IPC_MESSAGE_HANDLER(AppShimHostMsg_QuitApp, OnQuit) |
50 IPC_MESSAGE_UNHANDLED(handled = false) | 51 IPC_MESSAGE_UNHANDLED(handled = false) |
51 IPC_END_MESSAGE_MAP() | 52 IPC_END_MESSAGE_MAP() |
52 | 53 |
53 return handled; | 54 return handled; |
54 } | 55 } |
55 | 56 |
56 void AppShimHost::OnChannelError() { | 57 void AppShimHost::OnChannelError() { |
57 Close(); | 58 Close(); |
58 } | 59 } |
59 | 60 |
(...skipping 18 matching lines...) Expand all Loading... |
78 Send(new AppShimMsg_LaunchApp_Done(success)); | 79 Send(new AppShimMsg_LaunchApp_Done(success)); |
79 } | 80 } |
80 | 81 |
81 void AppShimHost::OnFocus() { | 82 void AppShimHost::OnFocus() { |
82 DCHECK(CalledOnValidThread()); | 83 DCHECK(CalledOnValidThread()); |
83 apps::AppShimHandler* handler = apps::AppShimHandler::GetForAppMode(app_id_); | 84 apps::AppShimHandler* handler = apps::AppShimHandler::GetForAppMode(app_id_); |
84 if (handler) | 85 if (handler) |
85 handler->OnShimFocus(this); | 86 handler->OnShimFocus(this); |
86 } | 87 } |
87 | 88 |
| 89 void AppShimHost::OnQuit() { |
| 90 DCHECK(CalledOnValidThread()); |
| 91 apps::AppShimHandler* handler = apps::AppShimHandler::GetForAppMode(app_id_); |
| 92 if (handler) |
| 93 handler->OnShimQuit(this); |
| 94 } |
| 95 |
88 Profile* AppShimHost::FetchProfileForDirectory(const std::string& profile_dir) { | 96 Profile* AppShimHost::FetchProfileForDirectory(const std::string& profile_dir) { |
89 ProfileManager* profileManager = g_browser_process->profile_manager(); | 97 ProfileManager* profileManager = g_browser_process->profile_manager(); |
90 // Even though the name of this function is "unsafe", there's no security | 98 // Even though the name of this function is "unsafe", there's no security |
91 // issue here -- the check for the profile name in the profile info cache | 99 // issue here -- the check for the profile name in the profile info cache |
92 // ensures that we never access any directory that isn't a known profile. | 100 // ensures that we never access any directory that isn't a known profile. |
93 base::FilePath path = base::FilePath::FromUTF8Unsafe(profile_dir); | 101 base::FilePath path = base::FilePath::FromUTF8Unsafe(profile_dir); |
94 path = profileManager->user_data_dir().Append(path); | 102 path = profileManager->user_data_dir().Append(path); |
95 ProfileInfoCache& cache = profileManager->GetProfileInfoCache(); | 103 ProfileInfoCache& cache = profileManager->GetProfileInfoCache(); |
96 // This ensures that the given profile path is acutally a profile that we | 104 // This ensures that the given profile path is acutally a profile that we |
97 // already know about. | 105 // already know about. |
(...skipping 11 matching lines...) Expand all Loading... |
109 } | 117 } |
110 | 118 |
111 void AppShimHost::OnAppClosed() { | 119 void AppShimHost::OnAppClosed() { |
112 Close(); | 120 Close(); |
113 } | 121 } |
114 | 122 |
115 void AppShimHost::Close() { | 123 void AppShimHost::Close() { |
116 DCHECK(CalledOnValidThread()); | 124 DCHECK(CalledOnValidThread()); |
117 delete this; | 125 delete this; |
118 } | 126 } |
OLD | NEW |