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

Side by Side Diff: chrome/browser/download/download_manager.cc

Issue 160501: Try again to land: http://codereview.chromium.org/160483 (Closed)
Patch Set: Created 11 years, 4 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 | « no previous file | chrome/browser/extensions/crx_installer.h » ('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) 2006-2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2009 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/download/download_manager.h" 5 #include "chrome/browser/download/download_manager.h"
6 6
7 #include "app/l10n_util.h" 7 #include "app/l10n_util.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
11 #include "base/path_service.h" 11 #include "base/path_service.h"
12 #include "base/rand_util.h" 12 #include "base/rand_util.h"
13 #include "base/stl_util-inl.h" 13 #include "base/stl_util-inl.h"
14 #include "base/string_util.h" 14 #include "base/string_util.h"
15 #include "base/sys_string_conversions.h" 15 #include "base/sys_string_conversions.h"
16 #include "base/task.h" 16 #include "base/task.h"
17 #include "base/thread.h" 17 #include "base/thread.h"
18 #include "base/timer.h" 18 #include "base/timer.h"
19 #include "chrome/browser/browser_list.h" 19 #include "chrome/browser/browser_list.h"
20 #include "chrome/browser/browser_process.h" 20 #include "chrome/browser/browser_process.h"
21 #include "chrome/browser/download/download_file.h" 21 #include "chrome/browser/download/download_file.h"
22 #include "chrome/browser/extensions/extension_install_ui.h"
22 #include "chrome/browser/extensions/extensions_service.h" 23 #include "chrome/browser/extensions/extensions_service.h"
23 #include "chrome/browser/profile.h" 24 #include "chrome/browser/profile.h"
24 #include "chrome/browser/renderer_host/render_process_host.h" 25 #include "chrome/browser/renderer_host/render_process_host.h"
25 #include "chrome/browser/renderer_host/render_view_host.h" 26 #include "chrome/browser/renderer_host/render_view_host.h"
26 #include "chrome/browser/renderer_host/resource_dispatcher_host.h" 27 #include "chrome/browser/renderer_host/resource_dispatcher_host.h"
27 #include "chrome/browser/tab_contents/tab_util.h" 28 #include "chrome/browser/tab_contents/tab_util.h"
28 #include "chrome/browser/tab_contents/tab_contents.h" 29 #include "chrome/browser/tab_contents/tab_contents.h"
29 #include "chrome/common/chrome_constants.h" 30 #include "chrome/common/chrome_constants.h"
30 #include "chrome/common/chrome_paths.h" 31 #include "chrome/common/chrome_paths.h"
31 #include "chrome/common/extensions/extension.h" 32 #include "chrome/common/extensions/extension.h"
(...skipping 1212 matching lines...) Expand 10 before | Expand all | Expand 10 after
1244 download->referrer_url()); 1245 download->referrer_url());
1245 } else { 1246 } else {
1246 OpenDownloadInShell(download, parent_window); 1247 OpenDownloadInShell(download, parent_window);
1247 } 1248 }
1248 } 1249 }
1249 1250
1250 void DownloadManager::OpenChromeExtension(const FilePath& full_path, 1251 void DownloadManager::OpenChromeExtension(const FilePath& full_path,
1251 const GURL& download_url, 1252 const GURL& download_url,
1252 const GURL& referrer_url) { 1253 const GURL& referrer_url) {
1253 // We don't support extensions in OTR mode. 1254 // We don't support extensions in OTR mode.
1254 if (profile_->GetExtensionsService()) 1255 ExtensionsService* service = profile_->GetExtensionsService();
1255 profile_->GetExtensionsService()->InstallExtension(full_path, download_url, 1256 if (service) {
1256 referrer_url); 1257 CrxInstaller::Start(full_path,
1258 service->install_directory(),
1259 Extension::INTERNAL,
1260 "", // no expected id
1261 true, // please delete crx on completion
1262 g_browser_process->file_thread()->message_loop(),
1263 service,
1264 new ExtensionInstallUI(profile_));
1265 }
1257 } 1266 }
1258 1267
1259 void DownloadManager::OpenDownloadInShell(const DownloadItem* download, 1268 void DownloadManager::OpenDownloadInShell(const DownloadItem* download,
1260 gfx::NativeView parent_window) { 1269 gfx::NativeView parent_window) {
1261 DCHECK(file_manager_); 1270 DCHECK(file_manager_);
1262 file_loop_->PostTask(FROM_HERE, 1271 file_loop_->PostTask(FROM_HERE,
1263 NewRunnableMethod(file_manager_, 1272 NewRunnableMethod(file_manager_,
1264 &DownloadFileManager::OnOpenDownloadInShell, 1273 &DownloadFileManager::OnOpenDownloadInShell,
1265 download->full_path(), download->url(), parent_window)); 1274 download->full_path(), download->url(), parent_window));
1266 } 1275 }
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
1517 1526
1518 if (contents) 1527 if (contents)
1519 contents->OnStartDownload(download); 1528 contents->OnStartDownload(download);
1520 } 1529 }
1521 1530
1522 // Clears the last download path, used to initialize "save as" dialogs. 1531 // Clears the last download path, used to initialize "save as" dialogs.
1523 void DownloadManager::ClearLastDownloadPath() { 1532 void DownloadManager::ClearLastDownloadPath() {
1524 last_download_path_ = FilePath(); 1533 last_download_path_ = FilePath();
1525 } 1534 }
1526 1535
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/crx_installer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698