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

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

Issue 10802056: Switch default filename retrieval to use GetFielNameToReportUser, which is more authoritative. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 5 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 | no next file » | 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/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 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 item->GetFullPath(), 377 item->GetFullPath(),
378 item->GetReceivedBytes()); 378 item->GetReceivedBytes());
379 379
380 // RCH specifies that the receiver gets the url, but with Web Intents 380 // RCH specifies that the receiver gets the url, but with Web Intents
381 // it isn't really needed. 381 // it isn't really needed.
382 intent_data.extra_data.insert(make_pair( 382 intent_data.extra_data.insert(make_pair(
383 ASCIIToUTF16("url"), ASCIIToUTF16(item->GetURL().spec()))); 383 ASCIIToUTF16("url"), ASCIIToUTF16(item->GetURL().spec())));
384 384
385 // The SuggestedFilename is not always filled in in the DownloadItem. 385 // The SuggestedFilename is not always filled in in the DownloadItem.
386 // When it is, it comes from the purpose-built HTML algorithm, but 386 // When it is, it comes from the purpose-built HTML algorithm, but
387 // in practice it is frequently just inferred. 387 // in practice it is frequently just inferred. GetFileNameToReportUser
388 string16 filename = UTF8ToUTF16(item->GetSuggestedFilename()); 388 // is more authoritative.
389 string16 filename = item->GetFileNameToReportUser().LossyDisplayName();
Greg Billock 2012/07/23 21:42:22 So this looks right, then, and is what we decided
asanka 2012/07/23 21:45:43 Yes. GetFileNameToReportUser() is what we decided
Greg Billock 2012/07/24 20:09:47 Done.
389 if (filename.empty()) 390 if (filename.empty())
390 filename = item->GetFileNameToReportUser().LossyDisplayName(); 391 filename = UTF8ToUTF16(item->GetSuggestedFilename());
391 intent_data.extra_data.insert(make_pair(ASCIIToUTF16("filename"), filename)); 392 intent_data.extra_data.insert(make_pair(ASCIIToUTF16("filename"), filename));
392 393
393 content::WebIntentsDispatcher* dispatcher = 394 content::WebIntentsDispatcher* dispatcher =
394 content::WebIntentsDispatcher::Create(intent_data); 395 content::WebIntentsDispatcher::Create(intent_data);
395 // TODO(gbillock): try to get this to be able to delegate to the Browser 396 // TODO(gbillock): try to get this to be able to delegate to the Browser
396 // object directly, passing a NULL WebContents? 397 // object directly, passing a NULL WebContents?
397 item->GetWebContents()->GetDelegate()->WebIntentDispatch( 398 item->GetWebContents()->GetDelegate()->WebIntentDispatch(
398 item->GetWebContents(), dispatcher); 399 item->GetWebContents(), dispatcher);
399 } 400 }
400 401
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
758 int32 download_id, int64 db_handle) { 759 int32 download_id, int64 db_handle) {
759 // It's not immediately obvious, but HistoryBackend::CreateDownload() can 760 // It's not immediately obvious, but HistoryBackend::CreateDownload() can
760 // call this function with an invalid |db_handle|. For instance, this can 761 // call this function with an invalid |db_handle|. For instance, this can
761 // happen when the history database is offline. We cannot have multiple 762 // happen when the history database is offline. We cannot have multiple
762 // DownloadItems with the same invalid db_handle, so we need to assign a 763 // DownloadItems with the same invalid db_handle, so we need to assign a
763 // unique |db_handle| here. 764 // unique |db_handle| here.
764 if (db_handle == DownloadItem::kUninitializedHandle) 765 if (db_handle == DownloadItem::kUninitializedHandle)
765 db_handle = download_history_->GetNextFakeDbHandle(); 766 db_handle = download_history_->GetNextFakeDbHandle();
766 download_manager_->OnItemAddedToPersistentStore(download_id, db_handle); 767 download_manager_->OnItemAddedToPersistentStore(download_id, db_handle);
767 } 768 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698