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

Side by Side Diff: chrome/browser/ui/webui/md_history_ui.cc

Issue 2511993002: Migrate md history test code to ScopedFeatureList. (Closed)
Patch Set: rebase Created 4 years, 1 month 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 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/ui/webui/md_history_ui.h" 5 #include "chrome/browser/ui/webui/md_history_ui.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "build/build_config.h" 10 #include "build/build_config.h"
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 233
234 // static 234 // static
235 bool MdHistoryUI::IsEnabled(Profile* profile) { 235 bool MdHistoryUI::IsEnabled(Profile* profile) {
236 return base::FeatureList::IsEnabled(features::kMaterialDesignHistory) && 236 return base::FeatureList::IsEnabled(features::kMaterialDesignHistory) &&
237 !base::CommandLine::ForCurrentProcess()->HasSwitch( 237 !base::CommandLine::ForCurrentProcess()->HasSwitch(
238 switches::kHistoryEnableGroupByDomain) && 238 switches::kHistoryEnableGroupByDomain) &&
239 !profile->IsSupervised(); 239 !profile->IsSupervised();
240 } 240 }
241 241
242 // static 242 // static
243 void MdHistoryUI::SetEnabledForTesting(bool enabled) {
244 std::unique_ptr<base::FeatureList> feature_list(new base::FeatureList);
245
246 const std::string& name = features::kMaterialDesignHistory.name;
247 feature_list->InitializeFromCommandLine(enabled ? name : "",
248 enabled ? "" : name);
249 base::FeatureList::ClearInstanceForTesting();
250 base::FeatureList::SetInstance(std::move(feature_list));
251 }
252
253 // static
254 base::RefCountedMemory* MdHistoryUI::GetFaviconResourceBytes( 243 base::RefCountedMemory* MdHistoryUI::GetFaviconResourceBytes(
255 ui::ScaleFactor scale_factor) { 244 ui::ScaleFactor scale_factor) {
256 return ResourceBundle::GetSharedInstance().LoadDataResourceBytesForScale( 245 return ResourceBundle::GetSharedInstance().LoadDataResourceBytesForScale(
257 IDR_HISTORY_FAVICON, scale_factor); 246 IDR_HISTORY_FAVICON, scale_factor);
258 } 247 }
259 248
260 void MdHistoryUI::RegisterProfilePrefs( 249 void MdHistoryUI::RegisterProfilePrefs(
261 user_prefs::PrefRegistrySyncable* registry) { 250 user_prefs::PrefRegistrySyncable* registry) {
262 registry->RegisterBooleanPref(prefs::kMdHistoryMenuPromoShown, false, 251 registry->RegisterBooleanPref(prefs::kMdHistoryMenuPromoShown, false,
263 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); 252 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
264 } 253 }
265 254
266 // TODO(lshang): Change to not re-create data source every time after we use 255 // TODO(lshang): Change to not re-create data source every time after we use
267 // unique_ptr instead of raw pointers for data source. 256 // unique_ptr instead of raw pointers for data source.
268 void MdHistoryUI::CreateDataSource() { 257 void MdHistoryUI::CreateDataSource() {
269 Profile* profile = Profile::FromWebUI(web_ui()); 258 Profile* profile = Profile::FromWebUI(web_ui());
270 content::WebUIDataSource* data_source = 259 content::WebUIDataSource* data_source =
271 CreateMdHistoryUIHTMLSource(profile, use_test_title_); 260 CreateMdHistoryUIHTMLSource(profile, use_test_title_);
272 content::WebUIDataSource::Add(profile, data_source); 261 content::WebUIDataSource::Add(profile, data_source);
273 } 262 }
274 263
275 void MdHistoryUI::HandleMenuPromoShown(const base::ListValue* args) { 264 void MdHistoryUI::HandleMenuPromoShown(const base::ListValue* args) {
276 Profile::FromWebUI(web_ui())->GetPrefs()->SetBoolean( 265 Profile::FromWebUI(web_ui())->GetPrefs()->SetBoolean(
277 prefs::kMdHistoryMenuPromoShown, true); 266 prefs::kMdHistoryMenuPromoShown, true);
278 CreateDataSource(); 267 CreateDataSource();
279 } 268 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/md_history_ui.h ('k') | chrome/browser/ui/webui/uber/uber_ui_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698