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

Side by Side Diff: chrome/browser/extensions/api/downloads/downloads_api.cc

Issue 257983002: Move downloads API to extensions namespace (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 8 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/extensions/api/downloads/downloads_api.h" 5 #include "chrome/browser/extensions/api/downloads/downloads_api.h"
6 6
7 #include <set> 7 #include <set>
8 #include <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 const char kTooManyListeners[] = "Each extension may have at most one " 106 const char kTooManyListeners[] = "Each extension may have at most one "
107 "onDeterminingFilename listener between all of its renderer execution " 107 "onDeterminingFilename listener between all of its renderer execution "
108 "contexts."; 108 "contexts.";
109 const char kUnexpectedDeterminer[] = "Unexpected determineFilename call"; 109 const char kUnexpectedDeterminer[] = "Unexpected determineFilename call";
110 const char kUserGesture[] = "User gesture required"; 110 const char kUserGesture[] = "User gesture required";
111 111
112 } // namespace download_extension_errors 112 } // namespace download_extension_errors
113 113
114 namespace errors = download_extension_errors; 114 namespace errors = download_extension_errors;
115 115
116 namespace extensions {
117
116 namespace { 118 namespace {
117 119
118 namespace downloads = extensions::api::downloads; 120 namespace downloads = extensions::api::downloads;
119 121
120 // Default icon size for getFileIcon() in pixels. 122 // Default icon size for getFileIcon() in pixels.
121 const int kDefaultIconSize = 32; 123 const int kDefaultIconSize = 32;
122 124
123 // Parameter keys 125 // Parameter keys
124 const char kByExtensionIdKey[] = "byExtensionId"; 126 const char kByExtensionIdKey[] = "byExtensionId";
125 const char kByExtensionNameKey[] = "byExtensionName"; 127 const char kByExtensionNameKey[] = "byExtensionName";
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 content::DownloadInterruptReasonToString( 267 content::DownloadInterruptReasonToString(
266 content::DOWNLOAD_INTERRUPT_REASON_USER_CANCELED)); 268 content::DOWNLOAD_INTERRUPT_REASON_USER_CANCELED));
267 } 269 }
268 if (!download_item->GetEndTime().is_null()) 270 if (!download_item->GetEndTime().is_null())
269 json->SetString(kEndTimeKey, TimeToISO8601(download_item->GetEndTime())); 271 json->SetString(kEndTimeKey, TimeToISO8601(download_item->GetEndTime()));
270 base::TimeDelta time_remaining; 272 base::TimeDelta time_remaining;
271 if (download_item->TimeRemaining(&time_remaining)) { 273 if (download_item->TimeRemaining(&time_remaining)) {
272 base::Time now = base::Time::Now(); 274 base::Time now = base::Time::Now();
273 json->SetString(kEstimatedEndTimeKey, TimeToISO8601(now + time_remaining)); 275 json->SetString(kEstimatedEndTimeKey, TimeToISO8601(now + time_remaining));
274 } 276 }
275 DownloadedByExtension* by_ext = DownloadedByExtension::Get(download_item); 277 DownloadedByExtension* by_ext =
Pam (message me for reviews) 2014/04/28 07:55:18 Extra newline
limasdf 2014/04/28 10:07:29 Done.
278 DownloadedByExtension::Get(download_item);
276 if (by_ext) { 279 if (by_ext) {
277 json->SetString(kByExtensionIdKey, by_ext->id()); 280 json->SetString(kByExtensionIdKey, by_ext->id());
278 json->SetString(kByExtensionNameKey, by_ext->name()); 281 json->SetString(kByExtensionNameKey, by_ext->name());
279 // Lookup the extension's current name() in case the user changed their 282 // Lookup the extension's current name() in case the user changed their
280 // language. This won't work if the extension was uninstalled, so the name 283 // language. This won't work if the extension was uninstalled, so the name
281 // might be the wrong language. 284 // might be the wrong language.
282 bool include_disabled = true; 285 bool include_disabled = true;
283 const extensions::Extension* extension = extensions::ExtensionSystem::Get( 286 const extensions::Extension* extension = extensions::ExtensionSystem::Get(
284 profile)->extension_service()->GetExtensionById( 287 profile)->extension_service()->GetExtensionById(
285 by_ext->id(), include_disabled); 288 by_ext->id(), include_disabled);
(...skipping 1607 matching lines...) Expand 10 before | Expand all | Expand 10 after
1893 void ExtensionDownloadsEventRouter::OnExtensionUnloaded( 1896 void ExtensionDownloadsEventRouter::OnExtensionUnloaded(
1894 content::BrowserContext* browser_context, 1897 content::BrowserContext* browser_context,
1895 const extensions::Extension* extension, 1898 const extensions::Extension* extension,
1896 extensions::UnloadedExtensionInfo::Reason reason) { 1899 extensions::UnloadedExtensionInfo::Reason reason) {
1897 DCHECK_CURRENTLY_ON(BrowserThread::UI); 1900 DCHECK_CURRENTLY_ON(BrowserThread::UI);
1898 std::set<const extensions::Extension*>::iterator iter = 1901 std::set<const extensions::Extension*>::iterator iter =
1899 shelf_disabling_extensions_.find(extension); 1902 shelf_disabling_extensions_.find(extension);
1900 if (iter != shelf_disabling_extensions_.end()) 1903 if (iter != shelf_disabling_extensions_.end())
1901 shelf_disabling_extensions_.erase(iter); 1904 shelf_disabling_extensions_.erase(iter);
1902 } 1905 }
1906
1907 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698