| OLD | NEW |
| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 | 10 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 #include "chrome/browser/search/instant_io_context.h" | 22 #include "chrome/browser/search/instant_io_context.h" |
| 23 #include "chrome/browser/search/local_files_ntp_source.h" | 23 #include "chrome/browser/search/local_files_ntp_source.h" |
| 24 #include "chrome/browser/search/search.h" | 24 #include "chrome/browser/search/search.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_switches.h" | 29 #include "chrome/common/chrome_switches.h" |
| 30 #include "chrome/common/url_constants.h" | 30 #include "chrome/common/url_constants.h" |
| 31 #include "chrome/grit/generated_resources.h" | 31 #include "chrome/grit/generated_resources.h" |
| 32 #include "components/search_engines/template_url_prepopulate_data.h" | |
| 33 #include "components/search_engines/template_url_service.h" | 32 #include "components/search_engines/template_url_service.h" |
| 34 #include "components/strings/grit/components_strings.h" | 33 #include "components/strings/grit/components_strings.h" |
| 35 #include "grit/browser_resources.h" | 34 #include "grit/browser_resources.h" |
| 36 #include "grit/theme_resources.h" | 35 #include "grit/theme_resources.h" |
| 37 #include "net/url_request/url_request.h" | 36 #include "net/url_request/url_request.h" |
| 38 #include "third_party/skia/include/core/SkColor.h" | 37 #include "third_party/skia/include/core/SkColor.h" |
| 39 #include "ui/base/l10n/l10n_util.h" | 38 #include "ui/base/l10n/l10n_util.h" |
| 40 #include "ui/base/resource/resource_bundle.h" | 39 #include "ui/base/resource/resource_bundle.h" |
| 41 #include "ui/base/ui_base_switches.h" | 40 #include "ui/base/ui_base_switches.h" |
| 42 #include "ui/base/webui/jstemplate_builder.h" | 41 #include "ui/base/webui/jstemplate_builder.h" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 return false; | 80 return false; |
| 82 | 81 |
| 83 TemplateURLService* template_url_service = | 82 TemplateURLService* template_url_service = |
| 84 TemplateURLServiceFactory::GetForProfile(profile); | 83 TemplateURLServiceFactory::GetForProfile(profile); |
| 85 if (!template_url_service) | 84 if (!template_url_service) |
| 86 return false; | 85 return false; |
| 87 | 86 |
| 88 const TemplateURL* default_provider = | 87 const TemplateURL* default_provider = |
| 89 template_url_service->GetDefaultSearchProvider(); | 88 template_url_service->GetDefaultSearchProvider(); |
| 90 return default_provider && | 89 return default_provider && |
| 91 (TemplateURLPrepopulateData::GetEngineType( | 90 (default_provider->GetEngineType( |
| 92 *default_provider, template_url_service->search_terms_data()) == | 91 template_url_service->search_terms_data()) == |
| 93 SEARCH_ENGINE_GOOGLE); | 92 SEARCH_ENGINE_GOOGLE); |
| 94 } | 93 } |
| 95 | 94 |
| 96 // Returns whether icon NTP is enabled by experiment. | 95 // Returns whether icon NTP is enabled by experiment. |
| 97 // TODO(huangs): Remove all 3 copies of this routine once Icon NTP launches. | 96 // TODO(huangs): Remove all 3 copies of this routine once Icon NTP launches. |
| 98 bool IsIconNTPEnabled() { | 97 bool IsIconNTPEnabled() { |
| 99 // Note: It's important to query the field trial state first, to ensure that | 98 // Note: It's important to query the field trial state first, to ensure that |
| 100 // UMA reports the correct group. | 99 // UMA reports the correct group. |
| 101 const std::string group_name = base::FieldTrialList::FindFullName("IconNTP"); | 100 const std::string group_name = base::FieldTrialList::FindFullName("IconNTP"); |
| 102 using base::CommandLine; | 101 using base::CommandLine; |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 } | 267 } |
| 269 } | 268 } |
| 270 return false; | 269 return false; |
| 271 } | 270 } |
| 272 | 271 |
| 273 std::string LocalNtpSource::GetContentSecurityPolicyChildSrc() const { | 272 std::string LocalNtpSource::GetContentSecurityPolicyChildSrc() const { |
| 274 // Allow embedding of most visited iframes. | 273 // Allow embedding of most visited iframes. |
| 275 return base::StringPrintf("child-src %s;", | 274 return base::StringPrintf("child-src %s;", |
| 276 chrome::kChromeSearchMostVisitedUrl); | 275 chrome::kChromeSearchMostVisitedUrl); |
| 277 } | 276 } |
| OLD | NEW |