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

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

Issue 9617010: Move chrome.downloads out of experimental to dev (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix EDER incognito Created 8 years, 6 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 | Annotate | Revision Log
OLDNEW
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/download/chrome_download_manager_delegate.h" 5 #include "chrome/browser/download/chrome_download_manager_delegate.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
11 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "base/file_util.h" 12 #include "base/file_util.h"
13 #include "base/path_service.h" 13 #include "base/path_service.h"
14 #include "base/rand_util.h" 14 #include "base/rand_util.h"
15 #include "base/stringprintf.h" 15 #include "base/stringprintf.h"
16 #include "base/time.h" 16 #include "base/time.h"
17 #include "base/utf_string_conversions.h" 17 #include "base/utf_string_conversions.h"
18 #include "chrome/browser/browser_process.h" 18 #include "chrome/browser/browser_process.h"
19 #include "chrome/browser/download/download_completion_blocker.h" 19 #include "chrome/browser/download/download_completion_blocker.h"
20 #include "chrome/browser/download/download_crx_util.h" 20 #include "chrome/browser/download/download_crx_util.h"
21 #include "chrome/browser/download/download_extensions.h" 21 #include "chrome/browser/download/download_extensions.h"
22 #include "chrome/browser/download/download_file_picker.h" 22 #include "chrome/browser/download/download_file_picker.h"
23 #include "chrome/browser/download/download_history.h" 23 #include "chrome/browser/download/download_history.h"
24 #include "chrome/browser/download/download_prefs.h" 24 #include "chrome/browser/download/download_prefs.h"
25 #include "chrome/browser/download/download_status_updater.h" 25 #include "chrome/browser/download/download_status_updater.h"
26 #include "chrome/browser/download/download_util.h" 26 #include "chrome/browser/download/download_util.h"
27 #include "chrome/browser/download/save_package_file_picker.h" 27 #include "chrome/browser/download/save_package_file_picker.h"
28 #include "chrome/browser/extensions/api/downloads/downloads_api.h"
28 #include "chrome/browser/extensions/crx_installer.h" 29 #include "chrome/browser/extensions/crx_installer.h"
29 #include "chrome/browser/extensions/extension_service.h" 30 #include "chrome/browser/extensions/extension_service.h"
30 #include "chrome/browser/prefs/pref_member.h" 31 #include "chrome/browser/prefs/pref_member.h"
31 #include "chrome/browser/prefs/pref_service.h" 32 #include "chrome/browser/prefs/pref_service.h"
32 #include "chrome/browser/profiles/profile.h" 33 #include "chrome/browser/profiles/profile.h"
33 #include "chrome/browser/safe_browsing/safe_browsing_service.h" 34 #include "chrome/browser/safe_browsing/safe_browsing_service.h"
34 #include "chrome/common/chrome_notification_types.h" 35 #include "chrome/common/chrome_notification_types.h"
35 #include "chrome/common/chrome_paths.h" 36 #include "chrome/common/chrome_paths.h"
36 #include "chrome/common/extensions/extension_switch_utils.h" 37 #include "chrome/common/extensions/extension_switch_utils.h"
37 #include "chrome/common/extensions/user_script.h" 38 #include "chrome/common/extensions/user_script.h"
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 download_prefs_.reset(); 116 download_prefs_.reset();
116 } 117 }
117 118
118 void ChromeDownloadManagerDelegate::SetDownloadManager(DownloadManager* dm) { 119 void ChromeDownloadManagerDelegate::SetDownloadManager(DownloadManager* dm) {
119 AddRef(); // Will be balanced in Shutdown(). 120 AddRef(); // Will be balanced in Shutdown().
120 download_manager_ = dm; 121 download_manager_ = dm;
121 download_history_.reset(new DownloadHistory(profile_)); 122 download_history_.reset(new DownloadHistory(profile_));
122 download_history_->Load( 123 download_history_->Load(
123 base::Bind(&DownloadManager::OnPersistentStoreQueryComplete, 124 base::Bind(&DownloadManager::OnPersistentStoreQueryComplete,
124 base::Unretained(dm))); 125 base::Unretained(dm)));
126 extension_event_router_.reset(new ExtensionDownloadsEventRouter(profile));
125 } 127 }
126 128
127 void ChromeDownloadManagerDelegate::Shutdown() { 129 void ChromeDownloadManagerDelegate::Shutdown() {
128 Release(); // Balance the AddRef in SetDownloadManager. 130 Release(); // Balance the AddRef in SetDownloadManager.
129 } 131 }
130 132
131 DownloadId ChromeDownloadManagerDelegate::GetNextId() { 133 DownloadId ChromeDownloadManagerDelegate::GetNextId() {
132 if (!profile_->IsOffTheRecord()) 134 if (!profile_->IsOffTheRecord())
133 return DownloadId(this, next_download_id_++); 135 return DownloadId(this, next_download_id_++);
134 136
(...skipping 674 matching lines...) Expand 10 before | Expand all | Expand 10 after
809 int32 download_id, int64 db_handle) { 811 int32 download_id, int64 db_handle) {
810 // It's not immediately obvious, but HistoryBackend::CreateDownload() can 812 // It's not immediately obvious, but HistoryBackend::CreateDownload() can
811 // call this function with an invalid |db_handle|. For instance, this can 813 // call this function with an invalid |db_handle|. For instance, this can
812 // happen when the history database is offline. We cannot have multiple 814 // happen when the history database is offline. We cannot have multiple
813 // DownloadItems with the same invalid db_handle, so we need to assign a 815 // DownloadItems with the same invalid db_handle, so we need to assign a
814 // unique |db_handle| here. 816 // unique |db_handle| here.
815 if (db_handle == DownloadItem::kUninitializedHandle) 817 if (db_handle == DownloadItem::kUninitializedHandle)
816 db_handle = download_history_->GetNextFakeDbHandle(); 818 db_handle = download_history_->GetNextFakeDbHandle();
817 download_manager_->OnItemAddedToPersistentStore(download_id, db_handle); 819 download_manager_->OnItemAddedToPersistentStore(download_id, db_handle);
818 } 820 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698