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

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

Issue 10375021: Move Extension into extensions namespace (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Take 2 Created 8 years, 7 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
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"
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 } 85 }
86 86
87 ChromeDownloadManagerDelegate::~ChromeDownloadManagerDelegate() { 87 ChromeDownloadManagerDelegate::~ChromeDownloadManagerDelegate() {
88 } 88 }
89 89
90 bool ChromeDownloadManagerDelegate::IsExtensionDownload( 90 bool ChromeDownloadManagerDelegate::IsExtensionDownload(
91 const DownloadItem* item) { 91 const DownloadItem* item) {
92 if (item->PromptUserForSaveLocation()) 92 if (item->PromptUserForSaveLocation())
93 return false; 93 return false;
94 94
95 if ((item->GetMimeType() != Extension::kMimeType) && 95 if ((item->GetMimeType() != extensions::Extension::kMimeType) &&
96 !UserScript::IsURLUserScript(item->GetURL(), item->GetMimeType())) { 96 !UserScript::IsURLUserScript(item->GetURL(), item->GetMimeType())) {
97 return false; 97 return false;
98 } 98 }
99 99
100 return download_crx_util::ShouldOpenExtensionDownload(*item); 100 return download_crx_util::ShouldOpenExtensionDownload(*item);
101 } 101 }
102 102
103 void ChromeDownloadManagerDelegate::SetDownloadManager(DownloadManager* dm) { 103 void ChromeDownloadManagerDelegate::SetDownloadManager(DownloadManager* dm) {
104 download_manager_ = dm; 104 download_manager_ = dm;
105 download_history_.reset(new DownloadHistory(profile_)); 105 download_history_.reset(new DownloadHistory(profile_));
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 return last_active ? last_active->GetSelectedWebContents() : NULL; 183 return last_active ? last_active->GetSelectedWebContents() : NULL;
184 #endif 184 #endif
185 } 185 }
186 186
187 187
188 bool ChromeDownloadManagerDelegate::ShouldOpenFileBasedOnExtension( 188 bool ChromeDownloadManagerDelegate::ShouldOpenFileBasedOnExtension(
189 const FilePath& path) { 189 const FilePath& path) {
190 FilePath::StringType extension = path.Extension(); 190 FilePath::StringType extension = path.Extension();
191 if (extension.empty()) 191 if (extension.empty())
192 return false; 192 return false;
193 if (Extension::IsExtension(path)) 193 if (extensions::Extension::IsExtension(path))
194 return false; 194 return false;
195 DCHECK(extension[0] == FilePath::kExtensionSeparator); 195 DCHECK(extension[0] == FilePath::kExtensionSeparator);
196 extension.erase(0, 1); 196 extension.erase(0, 1);
197 return download_prefs_->IsAutoOpenEnabledForExtension(extension); 197 return download_prefs_->IsAutoOpenEnabledForExtension(extension);
198 } 198 }
199 199
200 // static 200 // static
201 void ChromeDownloadManagerDelegate::DisableSafeBrowsing(DownloadItem* item) { 201 void ChromeDownloadManagerDelegate::DisableSafeBrowsing(DownloadItem* item) {
202 #if defined(ENABLE_SAFE_BROWSING) 202 #if defined(ENABLE_SAFE_BROWSING)
203 SafeBrowsingState* state = static_cast<SafeBrowsingState*>( 203 SafeBrowsingState* state = static_cast<SafeBrowsingState*>(
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after
719 int32 download_id, int64 db_handle) { 719 int32 download_id, int64 db_handle) {
720 // It's not immediately obvious, but HistoryBackend::CreateDownload() can 720 // It's not immediately obvious, but HistoryBackend::CreateDownload() can
721 // call this function with an invalid |db_handle|. For instance, this can 721 // call this function with an invalid |db_handle|. For instance, this can
722 // happen when the history database is offline. We cannot have multiple 722 // happen when the history database is offline. We cannot have multiple
723 // DownloadItems with the same invalid db_handle, so we need to assign a 723 // DownloadItems with the same invalid db_handle, so we need to assign a
724 // unique |db_handle| here. 724 // unique |db_handle| here.
725 if (db_handle == DownloadItem::kUninitializedHandle) 725 if (db_handle == DownloadItem::kUninitializedHandle)
726 db_handle = download_history_->GetNextFakeDbHandle(); 726 db_handle = download_history_->GetNextFakeDbHandle();
727 download_manager_->OnItemAddedToPersistentStore(download_id, db_handle); 727 download_manager_->OnItemAddedToPersistentStore(download_id, db_handle);
728 } 728 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698