Chromium Code Reviews| Index: chrome/browser/search/local_ntp_source.cc |
| diff --git a/chrome/browser/search/local_ntp_source.cc b/chrome/browser/search/local_ntp_source.cc |
| index b4b4d7db944f5f21fe759cdeb8f350148e2e2164..b3eb45673e81ef420c8ef83a3720a98371bd84d3 100644 |
| --- a/chrome/browser/search/local_ntp_source.cc |
| +++ b/chrome/browser/search/local_ntp_source.cc |
| @@ -8,6 +8,7 @@ |
| #include "base/logging.h" |
| #include "base/memory/ref_counted_memory.h" |
| #include "base/memory/scoped_ptr.h" |
| +#include "base/metrics/field_trial.h" |
| #include "base/strings/string_util.h" |
| #include "base/strings/stringprintf.h" |
| #include "base/strings/utf_string_conversions.h" |
| @@ -78,6 +79,18 @@ bool DefaultSearchProviderIsGoogle(Profile* profile) { |
| SEARCH_ENGINE_GOOGLE); |
| } |
| +bool IsLocalNTPFastEnabled() { |
|
Mathieu
2015/03/14 19:58:27
Can you 1-line comment these functions?
fserb
2015/03/16 19:52:27
Done.
|
| + return StartsWithASCII(base::FieldTrialList::FindFullName("LocalNTPFast"), |
| + "Enabled", true); |
| +} |
| + |
| +void SendResource(int resource_id, |
| + const content::URLDataSource::GotDataCallback& callback) { |
| + scoped_refptr<base::RefCountedStaticMemory> response( |
| + ResourceBundle::GetSharedInstance().LoadDataResourceBytes(resource_id)); |
| + callback.Run(response.get()); |
| +} |
| + |
| // Adds a localized string keyed by resource id to the dictionary. |
| void AddString(base::DictionaryValue* dictionary, |
| const std::string& key, |
| @@ -165,6 +178,15 @@ void LocalNtpSource::StartDataRequest( |
| callback.Run(base::RefCountedString::TakeString(&config_data_js)); |
| return; |
| } |
| + if (IsLocalNTPFastEnabled()) { |
| + if (stripped_path == "local-ntp.html") { |
| + return SendResource(IDR_LOCAL_NTP_FAST_HTML, callback); |
| + } else if (stripped_path == "local-ntp.js") { |
| + return SendResource(IDR_LOCAL_NTP_FAST_JS, callback); |
| + } else if (stripped_path == "local-ntp.css") { |
| + return SendResource(IDR_LOCAL_NTP_FAST_CSS, callback); |
| + } |
| + } |
| float scale = 1.0f; |
| std::string filename; |
| webui::ParsePathAndScale( |