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

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

Issue 12607011: Fix a crashing call to GURL::spec() in downloads_api.cc:DownloadItemToJSON() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: @r188114 Created 7 years, 9 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
« no previous file with comments | « no previous file | content/browser/download/download_item_impl.cc » ('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) 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 <algorithm> 7 #include <algorithm>
8 #include <cctype> 8 #include <cctype>
9 #include <iterator> 9 #include <iterator>
10 #include <set> 10 #include <set>
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 exploded.day_of_month, exploded.hour, exploded.minute, exploded.second, 210 exploded.day_of_month, exploded.hour, exploded.minute, exploded.second,
211 exploded.millisecond); 211 exploded.millisecond);
212 } 212 }
213 213
214 scoped_ptr<base::DictionaryValue> DownloadItemToJSON( 214 scoped_ptr<base::DictionaryValue> DownloadItemToJSON(
215 DownloadItem* download_item, 215 DownloadItem* download_item,
216 bool incognito) { 216 bool incognito) {
217 base::DictionaryValue* json = new base::DictionaryValue(); 217 base::DictionaryValue* json = new base::DictionaryValue();
218 json->SetBoolean(kExistsKey, !download_item->GetFileExternallyRemoved()); 218 json->SetBoolean(kExistsKey, !download_item->GetFileExternallyRemoved());
219 json->SetInteger(kIdKey, download_item->GetId()); 219 json->SetInteger(kIdKey, download_item->GetId());
220 json->SetString(kUrlKey, download_item->GetOriginalUrl().spec()); 220 const GURL& url = download_item->GetOriginalUrl();
221 json->SetString(kUrlKey, (url.is_valid() ? url.spec() : ""));
221 json->SetString( 222 json->SetString(
222 kFilenameKey, download_item->GetFullPath().LossyDisplayName()); 223 kFilenameKey, download_item->GetFullPath().LossyDisplayName());
223 json->SetString(kDangerKey, DangerString(download_item->GetDangerType())); 224 json->SetString(kDangerKey, DangerString(download_item->GetDangerType()));
224 if (download_item->GetDangerType() != 225 if (download_item->GetDangerType() !=
225 content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS) 226 content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS)
226 json->SetBoolean(kDangerAcceptedKey, 227 json->SetBoolean(kDangerAcceptedKey,
227 download_item->GetDangerType() == 228 download_item->GetDangerType() ==
228 content::DOWNLOAD_DANGER_TYPE_USER_VALIDATED); 229 content::DOWNLOAD_DANGER_TYPE_USER_VALIDATED);
229 json->SetString(kStateKey, StateString(download_item->GetState())); 230 json->SetString(kStateKey, StateString(download_item->GetState()));
230 json->SetBoolean(kPausedKey, download_item->IsPaused()); 231 json->SetBoolean(kPausedKey, download_item->IsPaused());
(...skipping 1212 matching lines...) Expand 10 before | Expand all | Expand 10 after
1443 DownloadsNotificationSource notification_source; 1444 DownloadsNotificationSource notification_source;
1444 notification_source.event_name = event_name; 1445 notification_source.event_name = event_name;
1445 notification_source.profile = profile_; 1446 notification_source.profile = profile_;
1446 content::Source<DownloadsNotificationSource> content_source( 1447 content::Source<DownloadsNotificationSource> content_source(
1447 &notification_source); 1448 &notification_source);
1448 content::NotificationService::current()->Notify( 1449 content::NotificationService::current()->Notify(
1449 chrome::NOTIFICATION_EXTENSION_DOWNLOADS_EVENT, 1450 chrome::NOTIFICATION_EXTENSION_DOWNLOADS_EVENT,
1450 content_source, 1451 content_source,
1451 content::Details<std::string>(&json_args)); 1452 content::Details<std::string>(&json_args));
1452 } 1453 }
OLDNEW
« no previous file with comments | « no previous file | content/browser/download/download_item_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698