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 "chrome/browser/apps/app_shim/app_shim_host_manager_mac.h" | 5 #include "chrome/browser/apps/app_shim/app_shim_host_manager_mac.h" |
6 | 6 |
7 #include <unistd.h> | 7 #include <unistd.h> |
8 | 8 |
9 #include "base/base64.h" | 9 #include "base/base64.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
12 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
13 #include "base/files/file_util.h" | 13 #include "base/files/file_util.h" |
14 #include "base/logging.h" | 14 #include "base/logging.h" |
15 #include "base/path_service.h" | 15 #include "base/path_service.h" |
16 #include "base/sha1.h" | 16 #include "base/sha1.h" |
17 #include "base/strings/string_util.h" | 17 #include "base/strings/string_util.h" |
18 #include "chrome/browser/apps/app_shim/app_shim_handler_mac.h" | 18 #include "chrome/browser/apps/app_shim/app_shim_handler_mac.h" |
19 #include "chrome/browser/apps/app_shim/app_shim_host_mac.h" | 19 #include "chrome/browser/apps/app_shim/app_shim_host_mac.h" |
20 #include "chrome/browser/apps/app_shim/extension_app_shim_handler_mac.h" | 20 #include "chrome/browser/apps/app_shim/extension_app_shim_handler_mac.h" |
21 #include "chrome/browser/browser_process.h" | 21 #include "chrome/browser/browser_process.h" |
22 #include "chrome/common/chrome_paths.h" | 22 #include "chrome/common/chrome_paths.h" |
23 #include "chrome/common/chrome_switches.h" | 23 #include "chrome/common/chrome_switches.h" |
24 #include "chrome/common/chrome_version_info.h" | |
25 #include "chrome/common/mac/app_mode_common.h" | 24 #include "chrome/common/mac/app_mode_common.h" |
| 25 #include "components/version_info/version_info.h" |
26 | 26 |
27 using content::BrowserThread; | 27 using content::BrowserThread; |
28 | 28 |
29 namespace { | 29 namespace { |
30 | 30 |
31 void CreateAppShimHost(const IPC::ChannelHandle& handle) { | 31 void CreateAppShimHost(const IPC::ChannelHandle& handle) { |
32 // AppShimHost takes ownership of itself. | 32 // AppShimHost takes ownership of itself. |
33 (new AppShimHost)->ServeChannel(handle); | 33 (new AppShimHost)->ServeChannel(handle); |
34 } | 34 } |
35 | 35 |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 user_data_dir.Append(app_mode::kAppShimSocketSymlinkName); | 133 user_data_dir.Append(app_mode::kAppShimSocketSymlinkName); |
134 base::DeleteFile(symlink_path, false); | 134 base::DeleteFile(symlink_path, false); |
135 base::CreateSymbolicLink(socket_path, symlink_path); | 135 base::CreateSymbolicLink(socket_path, symlink_path); |
136 | 136 |
137 // Create a symlink containing the current version string. This allows the | 137 // Create a symlink containing the current version string. This allows the |
138 // shim to load the same framework version as the currently running Chrome | 138 // shim to load the same framework version as the currently running Chrome |
139 // process. | 139 // process. |
140 base::FilePath version_path = | 140 base::FilePath version_path = |
141 user_data_dir.Append(app_mode::kRunningChromeVersionSymlinkName); | 141 user_data_dir.Append(app_mode::kRunningChromeVersionSymlinkName); |
142 base::DeleteFile(version_path, false); | 142 base::DeleteFile(version_path, false); |
143 base::CreateSymbolicLink(base::FilePath(chrome::VersionInfo().Version()), | 143 base::CreateSymbolicLink(base::FilePath(version_info::GetVersionNumber()), |
144 version_path); | 144 version_path); |
145 | 145 |
146 BrowserThread::PostTask( | 146 BrowserThread::PostTask( |
147 BrowserThread::IO, FROM_HERE, | 147 BrowserThread::IO, FROM_HERE, |
148 base::Bind(&AppShimHostManager::ListenOnIOThread, this)); | 148 base::Bind(&AppShimHostManager::ListenOnIOThread, this)); |
149 } | 149 } |
150 | 150 |
151 void AppShimHostManager::ListenOnIOThread() { | 151 void AppShimHostManager::ListenOnIOThread() { |
152 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 152 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
153 if (!acceptor_->Listen()) { | 153 if (!acceptor_->Listen()) { |
(...skipping 10 matching lines...) Expand all Loading... |
164 BrowserThread::UI, FROM_HERE, | 164 BrowserThread::UI, FROM_HERE, |
165 base::Bind(&CreateAppShimHost, handle)); | 165 base::Bind(&CreateAppShimHost, handle)); |
166 } | 166 } |
167 | 167 |
168 void AppShimHostManager::OnListenError() { | 168 void AppShimHostManager::OnListenError() { |
169 // TODO(tapted): Set a timeout and attempt to reconstruct the channel. Until | 169 // TODO(tapted): Set a timeout and attempt to reconstruct the channel. Until |
170 // cases where the error could occur are better known, just reset the acceptor | 170 // cases where the error could occur are better known, just reset the acceptor |
171 // to allow failure to be communicated via the test API. | 171 // to allow failure to be communicated via the test API. |
172 acceptor_.reset(); | 172 acceptor_.reset(); |
173 } | 173 } |
OLD | NEW |