| 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 c25e6ec67b08192e4ffe4a074862bdce6e5d296c..625ab096ffd76c0cbf09eb6573a67513787e4193 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,21 @@ bool DefaultSearchProviderIsGoogle(Profile* profile) {
|
| SEARCH_ENGINE_GOOGLE);
|
| }
|
|
|
| +// Returns whether we are in the Fast NTP experiment or not.
|
| +bool IsLocalNTPFastEnabled() {
|
| + return StartsWithASCII(base::FieldTrialList::FindFullName("LocalNTPFast"),
|
| + "Enabled", true);
|
| +}
|
| +
|
| +// Serves a particular resource.
|
| +// Used for bypassing the default resources when we are in an experiment.
|
| +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 +181,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(
|
| @@ -184,12 +209,9 @@ void LocalNtpSource::StartDataRequest(
|
|
|
| std::string LocalNtpSource::GetMimeType(
|
| const std::string& path) const {
|
| - const std::string& stripped_path = StripParameters(path);
|
| - std::string filename;
|
| - webui::ParsePathAndScale(GURL(GetLocalNtpPath() + stripped_path), &filename,
|
| - NULL);
|
| + const std::string stripped_path = StripParameters(path);
|
| for (size_t i = 0; i < arraysize(kResources); ++i) {
|
| - if (filename == kResources[i].filename)
|
| + if (stripped_path == kResources[i].filename)
|
| return kResources[i].mime_type;
|
| }
|
| return std::string();
|
|
|