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

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

Issue 2361513003: MD History: Update sign in state in data source (Closed)
Patch Set: try another approach Created 4 years, 2 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 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 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 211
212 } // namespace 212 } // namespace
213 213
214 bool MdHistoryUI::use_test_title_ = false; 214 bool MdHistoryUI::use_test_title_ = false;
215 215
216 MdHistoryUI::MdHistoryUI(content::WebUI* web_ui) : WebUIController(web_ui) { 216 MdHistoryUI::MdHistoryUI(content::WebUI* web_ui) : WebUIController(web_ui) {
217 Profile* profile = Profile::FromWebUI(web_ui); 217 Profile* profile = Profile::FromWebUI(web_ui);
218 web_ui->AddMessageHandler(new BrowsingHistoryHandler()); 218 web_ui->AddMessageHandler(new BrowsingHistoryHandler());
219 web_ui->AddMessageHandler(new MetricsHandler()); 219 web_ui->AddMessageHandler(new MetricsHandler());
220 220
221 if (search::IsInstantExtendedAPIEnabled()) {
222 web_ui->AddMessageHandler(new browser_sync::ForeignSessionHandler());
223 web_ui->AddMessageHandler(new HistoryLoginHandler());
224 }
225
226 data_source_ = CreateMdHistoryUIHTMLSource(profile, use_test_title_); 221 data_source_ = CreateMdHistoryUIHTMLSource(profile, use_test_title_);
227 content::WebUIDataSource::Add(profile, data_source_); 222 content::WebUIDataSource::Add(profile, data_source_);
228 223
224 if (search::IsInstantExtendedAPIEnabled()) {
225 web_ui->AddMessageHandler(new browser_sync::ForeignSessionHandler());
226 web_ui->AddMessageHandler(new HistoryLoginHandler(data_source_));
227 }
228
229 web_ui->RegisterMessageCallback("menuPromoShown", 229 web_ui->RegisterMessageCallback("menuPromoShown",
230 base::Bind(&MdHistoryUI::HandleMenuPromoShown, base::Unretained(this))); 230 base::Bind(&MdHistoryUI::HandleMenuPromoShown, base::Unretained(this)));
231 } 231 }
232 232
233 MdHistoryUI::~MdHistoryUI() {} 233 MdHistoryUI::~MdHistoryUI() {}
234 234
235 // static 235 // static
236 bool MdHistoryUI::IsEnabled(Profile* profile) { 236 bool MdHistoryUI::IsEnabled(Profile* profile) {
237 return base::FeatureList::IsEnabled(features::kMaterialDesignHistory) && 237 return base::FeatureList::IsEnabled(features::kMaterialDesignHistory) &&
238 !base::CommandLine::ForCurrentProcess()->HasSwitch( 238 !base::CommandLine::ForCurrentProcess()->HasSwitch(
(...skipping 23 matching lines...) Expand all
262 user_prefs::PrefRegistrySyncable* registry) { 262 user_prefs::PrefRegistrySyncable* registry) {
263 registry->RegisterBooleanPref(prefs::kMdHistoryMenuPromoShown, false, 263 registry->RegisterBooleanPref(prefs::kMdHistoryMenuPromoShown, false,
264 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); 264 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
265 } 265 }
266 266
267 void MdHistoryUI::HandleMenuPromoShown(const base::ListValue* args) { 267 void MdHistoryUI::HandleMenuPromoShown(const base::ListValue* args) {
268 Profile::FromWebUI(web_ui())->GetPrefs()->SetBoolean( 268 Profile::FromWebUI(web_ui())->GetPrefs()->SetBoolean(
269 prefs::kMdHistoryMenuPromoShown, true); 269 prefs::kMdHistoryMenuPromoShown, true);
270 data_source_->AddBoolean("showMenuPromo", false); 270 data_source_->AddBoolean("showMenuPromo", false);
271 } 271 }
OLDNEW
« chrome/browser/ui/webui/history_login_handler.cc ('K') | « chrome/browser/ui/webui/history_ui.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698