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

Side by Side Diff: content/browser/download/download_item.cc

Issue 8475024: Changed argument to GetAcceptLangs() to a BrowserContext. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merged to LKGR. Created 9 years, 1 month 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "content/browser/download/download_item.h" 5 #include "content/browser/download/download_item.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/basictypes.h"
9 #include "base/bind.h" 10 #include "base/bind.h"
10 #include "base/basictypes.h"
11 #include "base/file_util.h" 11 #include "base/file_util.h"
12 #include "base/format_macros.h" 12 #include "base/format_macros.h"
13 #include "base/i18n/case_conversion.h" 13 #include "base/i18n/case_conversion.h"
14 #include "base/i18n/string_search.h" 14 #include "base/i18n/string_search.h"
15 #include "base/logging.h" 15 #include "base/logging.h"
16 #include "base/metrics/histogram.h" 16 #include "base/metrics/histogram.h"
17 #include "base/stringprintf.h" 17 #include "base/stringprintf.h"
18 #include "base/utf_string_conversions.h" 18 #include "base/utf_string_conversions.h"
19 #include "content/browser/download/download_create_info.h" 19 #include "content/browser/download/download_create_info.h"
20 #include "content/browser/download/download_file.h" 20 #include "content/browser/download/download_file.h"
21 #include "content/browser/download/download_file_manager.h" 21 #include "content/browser/download/download_file_manager.h"
22 #include "content/browser/download/download_id.h" 22 #include "content/browser/download/download_id.h"
23 #include "content/browser/download/download_manager.h" 23 #include "content/browser/download/download_manager.h"
24 #include "content/browser/download/download_persistent_store_info.h" 24 #include "content/browser/download/download_persistent_store_info.h"
25 #include "content/browser/download/download_request_handle.h" 25 #include "content/browser/download/download_request_handle.h"
26 #include "content/browser/download/download_stats.h" 26 #include "content/browser/download/download_stats.h"
27 #include "content/browser/download/interrupt_reasons.h" 27 #include "content/browser/download/interrupt_reasons.h"
28 #include "content/browser/tab_contents/tab_contents.h"
28 #include "content/public/browser/browser_thread.h" 29 #include "content/public/browser/browser_thread.h"
29 #include "content/public/browser/content_browser_client.h" 30 #include "content/public/browser/content_browser_client.h"
30 #include "content/public/browser/download_manager_delegate.h" 31 #include "content/public/browser/download_manager_delegate.h"
31 #include "net/base/net_util.h" 32 #include "net/base/net_util.h"
32 33
33 using content::BrowserThread; 34 using content::BrowserThread;
34 35
35 // A DownloadItem normally goes through the following states: 36 // A DownloadItem normally goes through the following states:
36 // * Created (when download starts) 37 // * Created (when download starts)
37 // * Made visible to consumers (e.g. Javascript) after the 38 // * Made visible to consumers (e.g. Javascript) after the
(...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after
617 if (base::i18n::StringSearchIgnoringCaseAndAccents(query, url_raw)) 618 if (base::i18n::StringSearchIgnoringCaseAndAccents(query, url_raw))
618 return true; 619 return true;
619 620
620 // TODO(phajdan.jr): write a test case for the following code. 621 // TODO(phajdan.jr): write a test case for the following code.
621 // A good test case would be: 622 // A good test case would be:
622 // "/\xe4\xbd\xa0\xe5\xa5\xbd\xe4\xbd\xa0\xe5\xa5\xbd", 623 // "/\xe4\xbd\xa0\xe5\xa5\xbd\xe4\xbd\xa0\xe5\xa5\xbd",
623 // L"/\x4f60\x597d\x4f60\x597d", 624 // L"/\x4f60\x597d\x4f60\x597d",
624 // "/%E4%BD%A0%E5%A5%BD%E4%BD%A0%E5%A5%BD" 625 // "/%E4%BD%A0%E5%A5%BD%E4%BD%A0%E5%A5%BD"
625 std::string languages; 626 std::string languages;
626 TabContents* tab = GetTabContents(); 627 TabContents* tab = GetTabContents();
627 if (tab) 628 if (tab) {
628 languages = content::GetContentClient()->browser()->GetAcceptLangs(tab); 629 languages = content::GetContentClient()->browser()->GetAcceptLangs(
630 tab->browser_context());
631 }
629 string16 url_formatted(net::FormatUrl(GetURL(), languages)); 632 string16 url_formatted(net::FormatUrl(GetURL(), languages));
630 if (base::i18n::StringSearchIgnoringCaseAndAccents(query, url_formatted)) 633 if (base::i18n::StringSearchIgnoringCaseAndAccents(query, url_formatted))
631 return true; 634 return true;
632 635
633 string16 path(full_path().LossyDisplayName()); 636 string16 path(full_path().LossyDisplayName());
634 return base::i18n::StringSearchIgnoringCaseAndAccents(query, path); 637 return base::i18n::StringSearchIgnoringCaseAndAccents(query, path);
635 } 638 }
636 639
637 void DownloadItem::SetFileCheckResults(const DownloadStateInfo& state) { 640 void DownloadItem::SetFileCheckResults(const DownloadStateInfo& state) {
638 // TODO(rdsmith): Change to DCHECK after http://crbug.com/85408 resolved. 641 // TODO(rdsmith): Change to DCHECK after http://crbug.com/85408 resolved.
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
797 state_info_.target_name.value().c_str(), 800 state_info_.target_name.value().c_str(),
798 full_path().value().c_str()); 801 full_path().value().c_str());
799 } else { 802 } else {
800 description += base::StringPrintf(" url = \"%s\"", url_list.c_str()); 803 description += base::StringPrintf(" url = \"%s\"", url_list.c_str());
801 } 804 }
802 805
803 description += " }"; 806 description += " }";
804 807
805 return description; 808 return description;
806 } 809 }
OLDNEW
« no previous file with comments | « chrome/browser/chrome_content_browser_client.cc ('k') | content/browser/download/save_package.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698