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

Side by Side Diff: chrome/browser/android/ntp/popular_sites.cc

Issue 1928913002: Create //components/ntp_tiles. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
« no previous file with comments | « chrome/browser/android/ntp/most_visited_sites.cc ('k') | chrome/chrome_browser.gypi » ('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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/android/ntp/popular_sites.h" 5 #include "chrome/browser/android/ntp/popular_sites.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/files/file_path.h" 11 #include "base/files/file_path.h"
12 #include "base/files/file_util.h" 12 #include "base/files/file_util.h"
13 #include "base/json/json_reader.h" 13 #include "base/json/json_reader.h"
14 #include "base/path_service.h" 14 #include "base/path_service.h"
15 #include "base/strings/string_util.h" 15 #include "base/strings/string_util.h"
16 #include "base/strings/stringprintf.h" 16 #include "base/strings/stringprintf.h"
17 #include "base/task_runner_util.h" 17 #include "base/task_runner_util.h"
18 #include "base/time/time.h" 18 #include "base/time/time.h"
19 #include "base/values.h" 19 #include "base/values.h"
20 #include "chrome/browser/browser_process.h" 20 #include "chrome/browser/browser_process.h"
21 #include "chrome/common/chrome_paths.h" 21 #include "chrome/common/chrome_paths.h"
22 #include "chrome/common/chrome_switches.h"
23 #include "components/google/core/browser/google_util.h" 22 #include "components/google/core/browser/google_util.h"
23 #include "components/ntp_tiles/switches.h"
24 #include "components/pref_registry/pref_registry_syncable.h" 24 #include "components/pref_registry/pref_registry_syncable.h"
25 #include "components/prefs/pref_service.h" 25 #include "components/prefs/pref_service.h"
26 #include "components/search_engines/search_engine_type.h" 26 #include "components/search_engines/search_engine_type.h"
27 #include "components/search_engines/template_url_prepopulate_data.h" 27 #include "components/search_engines/template_url_prepopulate_data.h"
28 #include "components/search_engines/template_url_service.h" 28 #include "components/search_engines/template_url_service.h"
29 #include "components/variations/service/variations_service.h" 29 #include "components/variations/service/variations_service.h"
30 #include "content/public/browser/browser_thread.h" 30 #include "content/public/browser/browser_thread.h"
31 31
32 using content::BrowserThread; 32 using content::BrowserThread;
33 33
(...skipping 10 matching lines...) Expand all
44 const char kPopularSitesCountryPref[] = "popular_sites_country"; 44 const char kPopularSitesCountryPref[] = "popular_sites_country";
45 const char kPopularSitesVersionPref[] = "popular_sites_version"; 45 const char kPopularSitesVersionPref[] = "popular_sites_version";
46 46
47 // Extract the country from the default search engine if the default search 47 // Extract the country from the default search engine if the default search
48 // engine is Google. 48 // engine is Google.
49 std::string GetDefaultSearchEngineCountryCode( 49 std::string GetDefaultSearchEngineCountryCode(
50 const TemplateURLService* template_url_service) { 50 const TemplateURLService* template_url_service) {
51 DCHECK(template_url_service); 51 DCHECK(template_url_service);
52 52
53 base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); 53 base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess();
54 if (!cmd_line->HasSwitch(switches::kEnableNTPSearchEngineCountryDetection)) 54 if (!cmd_line->HasSwitch(
55 ntp_tiles::switches::kEnableNTPSearchEngineCountryDetection))
55 return std::string(); 56 return std::string();
56 57
57 const TemplateURL* default_provider = 58 const TemplateURL* default_provider =
58 template_url_service->GetDefaultSearchProvider(); 59 template_url_service->GetDefaultSearchProvider();
59 // It's possible to not have a default provider in the case that the default 60 // It's possible to not have a default provider in the case that the default
60 // search engine is defined by policy. 61 // search engine is defined by policy.
61 if (default_provider) { 62 if (default_provider) {
62 bool is_google_search_engine = 63 bool is_google_search_engine =
63 TemplateURLPrepopulateData::GetEngineType( 64 TemplateURLPrepopulateData::GetEngineType(
64 *default_provider, template_url_service->search_terms_data()) == 65 *default_provider, template_url_service->search_terms_data()) ==
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 base::Bind(&PopularSites::OnJsonParsed, weak_ptr_factory_.GetWeakPtr())); 315 base::Bind(&PopularSites::OnJsonParsed, weak_ptr_factory_.GetWeakPtr()));
315 } 316 }
316 317
317 void PopularSites::OnJsonParsed(std::unique_ptr<std::vector<Site>> sites) { 318 void PopularSites::OnJsonParsed(std::unique_ptr<std::vector<Site>> sites) {
318 if (sites) 319 if (sites)
319 sites_.swap(*sites); 320 sites_.swap(*sites);
320 else 321 else
321 sites_.clear(); 322 sites_.clear();
322 callback_.Run(!!sites); 323 callback_.Run(!!sites);
323 } 324 }
OLDNEW
« no previous file with comments | « chrome/browser/android/ntp/most_visited_sites.cc ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698