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

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: remove unused forward declare 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 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 source->SetJsonPath("strings.js"); 209 source->SetJsonPath("strings.js");
210 210
211 return source; 211 return source;
212 } 212 }
213 213
214 } // namespace 214 } // namespace
215 215
216 bool MdHistoryUI::use_test_title_ = false; 216 bool MdHistoryUI::use_test_title_ = false;
217 217
218 MdHistoryUI::MdHistoryUI(content::WebUI* web_ui) : WebUIController(web_ui) { 218 MdHistoryUI::MdHistoryUI(content::WebUI* web_ui) : WebUIController(web_ui) {
219 Profile* profile = Profile::FromWebUI(web_ui);
220 web_ui->AddMessageHandler(new BrowsingHistoryHandler()); 219 web_ui->AddMessageHandler(new BrowsingHistoryHandler());
221 web_ui->AddMessageHandler(new MetricsHandler()); 220 web_ui->AddMessageHandler(new MetricsHandler());
222 221
223 if (search::IsInstantExtendedAPIEnabled()) { 222 if (search::IsInstantExtendedAPIEnabled()) {
224 web_ui->AddMessageHandler(new browser_sync::ForeignSessionHandler()); 223 web_ui->AddMessageHandler(new browser_sync::ForeignSessionHandler());
225 web_ui->AddMessageHandler(new HistoryLoginHandler()); 224 web_ui->AddMessageHandler(new HistoryLoginHandler(
225 base::Bind(&MdHistoryUI::SignInChanged, base::Unretained(this))));
Dan Beam 2016/09/30 02:55:40 same
lshang 2016/09/30 03:21:13 Done.
226 } 226 }
227 227
228 data_source_ = CreateMdHistoryUIHTMLSource(profile, use_test_title_); 228 CreateDataSource();
229 content::WebUIDataSource::Add(profile, data_source_);
230 229
231 web_ui->RegisterMessageCallback("menuPromoShown", 230 web_ui->RegisterMessageCallback("menuPromoShown",
232 base::Bind(&MdHistoryUI::HandleMenuPromoShown, base::Unretained(this))); 231 base::Bind(&MdHistoryUI::HandleMenuPromoShown, base::Unretained(this)));
233 } 232 }
234 233
235 MdHistoryUI::~MdHistoryUI() {} 234 MdHistoryUI::~MdHistoryUI() {}
236 235
237 // static 236 // static
238 bool MdHistoryUI::IsEnabled(Profile* profile) { 237 bool MdHistoryUI::IsEnabled(Profile* profile) {
239 return base::FeatureList::IsEnabled(features::kMaterialDesignHistory) && 238 return base::FeatureList::IsEnabled(features::kMaterialDesignHistory) &&
(...skipping 19 matching lines...) Expand all
259 return ResourceBundle::GetSharedInstance().LoadDataResourceBytesForScale( 258 return ResourceBundle::GetSharedInstance().LoadDataResourceBytesForScale(
260 IDR_HISTORY_FAVICON, scale_factor); 259 IDR_HISTORY_FAVICON, scale_factor);
261 } 260 }
262 261
263 void MdHistoryUI::RegisterProfilePrefs( 262 void MdHistoryUI::RegisterProfilePrefs(
264 user_prefs::PrefRegistrySyncable* registry) { 263 user_prefs::PrefRegistrySyncable* registry) {
265 registry->RegisterBooleanPref(prefs::kMdHistoryMenuPromoShown, false, 264 registry->RegisterBooleanPref(prefs::kMdHistoryMenuPromoShown, false,
266 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); 265 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
267 } 266 }
268 267
268 void MdHistoryUI::CreateDataSource() {
269 Profile* profile = Profile::FromWebUI(web_ui());
270 content::WebUIDataSource* data_source =
271 CreateMdHistoryUIHTMLSource(profile, use_test_title_);
272 content::WebUIDataSource::Add(profile, data_source);
273 }
274
269 void MdHistoryUI::HandleMenuPromoShown(const base::ListValue* args) { 275 void MdHistoryUI::HandleMenuPromoShown(const base::ListValue* args) {
270 Profile::FromWebUI(web_ui())->GetPrefs()->SetBoolean( 276 Profile::FromWebUI(web_ui())->GetPrefs()->SetBoolean(
271 prefs::kMdHistoryMenuPromoShown, true); 277 prefs::kMdHistoryMenuPromoShown, true);
272 data_source_->AddBoolean(kShowMenuPromoKey, false); 278 CreateDataSource();
273 } 279 }
280
281 void MdHistoryUI::SignInChanged() {
282 // Recreate the data source so sign in state get updated in there.
283 CreateDataSource();
284 }
OLDNEW
« chrome/browser/ui/webui/history_ui.cc ('K') | « chrome/browser/ui/webui/md_history_ui.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698