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

Side by Side Diff: chrome/browser/search/local_ntp_source.cc

Issue 2877483002: Add about:flags entries for UseGoogleLocalNtp and OneGoogleBarOnLocalNtp (Closed)
Patch Set: Created 3 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/search/local_ntp_source.h" 5 #include "chrome/browser/search/local_ntp_source.h"
6 6
7 #include "base/base64.h" 7 #include "base/base64.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/feature_list.h" 9 #include "base/feature_list.h"
10 #include "base/json/json_string_value_serializer.h" 10 #include "base/json/json_string_value_serializer.h"
11 #include "base/json/json_writer.h" 11 #include "base/json/json_writer.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/memory/ptr_util.h" 13 #include "base/memory/ptr_util.h"
14 #include "base/memory/ref_counted_memory.h" 14 #include "base/memory/ref_counted_memory.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/values.h" 17 #include "base/values.h"
18 #include "build/build_config.h" 18 #include "build/build_config.h"
19 #include "chrome/browser/profiles/profile.h" 19 #include "chrome/browser/profiles/profile.h"
20 #include "chrome/browser/search/instant_io_context.h" 20 #include "chrome/browser/search/instant_io_context.h"
21 #include "chrome/browser/search/local_files_ntp_source.h" 21 #include "chrome/browser/search/local_files_ntp_source.h"
22 #include "chrome/browser/search/one_google_bar/one_google_bar_data.h" 22 #include "chrome/browser/search/one_google_bar/one_google_bar_data.h"
23 #include "chrome/browser/search/one_google_bar/one_google_bar_service.h" 23 #include "chrome/browser/search/one_google_bar/one_google_bar_service.h"
24 #include "chrome/browser/search/one_google_bar/one_google_bar_service_factory.h" 24 #include "chrome/browser/search/one_google_bar/one_google_bar_service_factory.h"
25 #include "chrome/browser/search_engines/template_url_service_factory.h" 25 #include "chrome/browser/search_engines/template_url_service_factory.h"
26 #include "chrome/browser/themes/theme_properties.h" 26 #include "chrome/browser/themes/theme_properties.h"
27 #include "chrome/browser/themes/theme_service.h" 27 #include "chrome/browser/themes/theme_service.h"
28 #include "chrome/browser/themes/theme_service_factory.h" 28 #include "chrome/browser/themes/theme_service_factory.h"
29 #include "chrome/common/chrome_features.h"
29 #include "chrome/common/chrome_switches.h" 30 #include "chrome/common/chrome_switches.h"
30 #include "chrome/common/url_constants.h" 31 #include "chrome/common/url_constants.h"
31 #include "chrome/grit/browser_resources.h" 32 #include "chrome/grit/browser_resources.h"
32 #include "chrome/grit/generated_resources.h" 33 #include "chrome/grit/generated_resources.h"
33 #include "chrome/grit/theme_resources.h" 34 #include "chrome/grit/theme_resources.h"
34 #include "components/search_engines/template_url_service.h" 35 #include "components/search_engines/template_url_service.h"
35 #include "components/search_engines/template_url_service_observer.h" 36 #include "components/search_engines/template_url_service_observer.h"
36 #include "components/strings/grit/components_strings.h" 37 #include "components/strings/grit/components_strings.h"
37 #include "content/public/browser/browser_thread.h" 38 #include "content/public/browser/browser_thread.h"
38 #include "crypto/secure_hash.h" 39 #include "crypto/secure_hash.h"
39 #include "net/base/hash_value.h" 40 #include "net/base/hash_value.h"
40 #include "net/url_request/url_request.h" 41 #include "net/url_request/url_request.h"
41 #include "third_party/skia/include/core/SkColor.h" 42 #include "third_party/skia/include/core/SkColor.h"
42 #include "ui/base/l10n/l10n_util.h" 43 #include "ui/base/l10n/l10n_util.h"
43 #include "ui/base/resource/resource_bundle.h" 44 #include "ui/base/resource/resource_bundle.h"
44 #include "ui/base/webui/web_ui_util.h" 45 #include "ui/base/webui/web_ui_util.h"
45 #include "ui/resources/grit/ui_resources.h" 46 #include "ui/resources/grit/ui_resources.h"
46 #include "url/gurl.h" 47 #include "url/gurl.h"
47 48
48 namespace { 49 namespace {
49 50
50 base::Feature kOneGoogleBarOnLocalNtpFeature{"OneGoogleBarOnLocalNtp",
51 base::FEATURE_DISABLED_BY_DEFAULT};
52
53 // Signifies a locally constructed resource, i.e. not from grit/. 51 // Signifies a locally constructed resource, i.e. not from grit/.
54 const int kLocalResource = -1; 52 const int kLocalResource = -1;
55 53
56 const char kConfigDataFilename[] = "config.js"; 54 const char kConfigDataFilename[] = "config.js";
57 const char kThemeCSSFilename[] = "theme.css"; 55 const char kThemeCSSFilename[] = "theme.css";
58 const char kMainHtmlFilename[] = "local-ntp.html"; 56 const char kMainHtmlFilename[] = "local-ntp.html";
59 const char kOneGoogleBarScriptFilename[] = "one-google.js"; 57 const char kOneGoogleBarScriptFilename[] = "one-google.js";
60 const char kOneGoogleBarInHeadStyleFilename[] = "one-google/in-head.css"; 58 const char kOneGoogleBarInHeadStyleFilename[] = "one-google/in-head.css";
61 const char kOneGoogleBarInHeadScriptFilename[] = "one-google/in-head.js"; 59 const char kOneGoogleBarInHeadScriptFilename[] = "one-google/in-head.js";
62 const char kOneGoogleBarAfterBarScriptFilename[] = "one-google/after-bar.js"; 60 const char kOneGoogleBarAfterBarScriptFilename[] = "one-google/after-bar.js";
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 230
233 LocalNtpSource::LocalNtpSource(Profile* profile) 231 LocalNtpSource::LocalNtpSource(Profile* profile)
234 : profile_(profile), 232 : profile_(profile),
235 one_google_bar_service_(nullptr), 233 one_google_bar_service_(nullptr),
236 one_google_bar_service_observer_(this), 234 one_google_bar_service_observer_(this),
237 default_search_provider_is_google_(false), 235 default_search_provider_is_google_(false),
238 default_search_provider_is_google_io_thread_(false), 236 default_search_provider_is_google_io_thread_(false),
239 weak_ptr_factory_(this) { 237 weak_ptr_factory_(this) {
240 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 238 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
241 239
242 if (base::FeatureList::IsEnabled(kOneGoogleBarOnLocalNtpFeature)) { 240 if (base::FeatureList::IsEnabled(features::kOneGoogleBarOnLocalNtp)) {
243 one_google_bar_service_ = 241 one_google_bar_service_ =
244 OneGoogleBarServiceFactory::GetForProfile(profile_); 242 OneGoogleBarServiceFactory::GetForProfile(profile_);
245 } 243 }
246 244
247 // |one_google_bar_service_| is null in incognito, or when the feature is 245 // |one_google_bar_service_| is null in incognito, or when the feature is
248 // disabled. 246 // disabled.
249 if (one_google_bar_service_) 247 if (one_google_bar_service_)
250 one_google_bar_service_observer_.Add(one_google_bar_service_); 248 one_google_bar_service_observer_.Add(one_google_bar_service_);
251 249
252 TemplateURLService* template_url_service = 250 TemplateURLService* template_url_service =
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
491 base::Bind(&LocalNtpSource::SetDefaultSearchProviderIsGoogleOnIOThread, 489 base::Bind(&LocalNtpSource::SetDefaultSearchProviderIsGoogleOnIOThread,
492 weak_ptr_factory_.GetWeakPtr(), is_google)); 490 weak_ptr_factory_.GetWeakPtr(), is_google));
493 } 491 }
494 492
495 void LocalNtpSource::SetDefaultSearchProviderIsGoogleOnIOThread( 493 void LocalNtpSource::SetDefaultSearchProviderIsGoogleOnIOThread(
496 bool is_google) { 494 bool is_google) {
497 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); 495 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
498 496
499 default_search_provider_is_google_io_thread_ = is_google; 497 default_search_provider_is_google_io_thread_ = is_google;
500 } 498 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698