OLD | NEW |
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 #include "chrome/browser/extensions/webstore_installer.h" | 5 #include "chrome/browser/extensions/webstore_installer.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 return url; | 92 return url; |
93 } | 93 } |
94 | 94 |
95 // Must be executed on the FILE thread. | 95 // Must be executed on the FILE thread. |
96 void GetDownloadFilePath( | 96 void GetDownloadFilePath( |
97 const base::FilePath& download_directory, const std::string& id, | 97 const base::FilePath& download_directory, const std::string& id, |
98 const base::Callback<void(const base::FilePath&)>& callback) { | 98 const base::Callback<void(const base::FilePath&)>& callback) { |
99 base::FilePath directory(g_download_directory_for_tests ? | 99 base::FilePath directory(g_download_directory_for_tests ? |
100 *g_download_directory_for_tests : download_directory); | 100 *g_download_directory_for_tests : download_directory); |
101 | 101 |
102 #if defined (OS_CHROMEOS) | 102 #if defined(OS_CHROMEOS) |
103 // Do not use drive for extension downloads. | 103 // Do not use drive for extension downloads. |
104 if (drive::util::IsUnderDriveMountPoint(directory)) | 104 if (drive::util::IsUnderDriveMountPoint(directory)) |
105 directory = download_util::GetDefaultDownloadDirectory(); | 105 directory = download_util::GetDefaultDownloadDirectory(); |
106 #endif | 106 #endif |
107 | 107 |
108 // Ensure the download directory exists. TODO(asargent) - make this use | 108 // Ensure the download directory exists. TODO(asargent) - make this use |
109 // common code from the downloads system. | 109 // common code from the downloads system. |
110 if (!file_util::DirectoryExists(directory)) { | 110 if (!file_util::DirectoryExists(directory)) { |
111 if (!file_util::CreateDirectory(directory)) { | 111 if (!file_util::CreateDirectory(directory)) { |
112 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 112 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 break; | 249 break; |
250 } | 250 } |
251 | 251 |
252 case chrome::NOTIFICATION_EXTENSION_INSTALL_ERROR: { | 252 case chrome::NOTIFICATION_EXTENSION_INSTALL_ERROR: { |
253 CrxInstaller* crx_installer = content::Source<CrxInstaller>(source).ptr(); | 253 CrxInstaller* crx_installer = content::Source<CrxInstaller>(source).ptr(); |
254 CHECK(crx_installer); | 254 CHECK(crx_installer); |
255 if (!profile_->IsSameProfile(crx_installer->profile())) | 255 if (!profile_->IsSameProfile(crx_installer->profile())) |
256 return; | 256 return; |
257 | 257 |
258 // TODO(rdevlin.cronin): Continue removing std::string errors and | 258 // TODO(rdevlin.cronin): Continue removing std::string errors and |
259 // replacing with string16 | 259 // replacing with string16. See crbug.com/71980. |
260 const string16* error = content::Details<const string16>(details).ptr(); | 260 const string16* error = content::Details<const string16>(details).ptr(); |
261 const std::string utf8_error = UTF16ToUTF8(*error); | 261 const std::string utf8_error = UTF16ToUTF8(*error); |
262 if (download_url_ == crx_installer->original_download_url()) | 262 if (download_url_ == crx_installer->original_download_url()) |
263 ReportFailure(utf8_error, FAILURE_REASON_OTHER); | 263 ReportFailure(utf8_error, FAILURE_REASON_OTHER); |
264 break; | 264 break; |
265 } | 265 } |
266 | 266 |
267 default: | 267 default: |
268 NOTREACHED(); | 268 NOTREACHED(); |
269 } | 269 } |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
420 void WebstoreInstaller::ReportSuccess() { | 420 void WebstoreInstaller::ReportSuccess() { |
421 if (delegate_) { | 421 if (delegate_) { |
422 delegate_->OnExtensionInstallSuccess(id_); | 422 delegate_->OnExtensionInstallSuccess(id_); |
423 delegate_ = NULL; | 423 delegate_ = NULL; |
424 } | 424 } |
425 | 425 |
426 Release(); // Balanced in Start(). | 426 Release(); // Balanced in Start(). |
427 } | 427 } |
428 | 428 |
429 } // namespace extensions | 429 } // namespace extensions |
OLD | NEW |