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

Unified Diff: chrome/browser/ui/webui/md_history_ui.cc

Issue 2361513003: MD History: Update sign in state in data source (Closed)
Patch Set: add get method Created 4 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/webui/md_history_ui.cc
diff --git a/chrome/browser/ui/webui/md_history_ui.cc b/chrome/browser/ui/webui/md_history_ui.cc
index 56bbf9b69003e58ce5d8a0fa4a19f3f7d834920a..5dd1248579891b478f8f48bb8715e8eed3b502fe 100644
--- a/chrome/browser/ui/webui/md_history_ui.cc
+++ b/chrome/browser/ui/webui/md_history_ui.cc
@@ -216,17 +216,16 @@ content::WebUIDataSource* CreateMdHistoryUIHTMLSource(Profile* profile,
bool MdHistoryUI::use_test_title_ = false;
MdHistoryUI::MdHistoryUI(content::WebUI* web_ui) : WebUIController(web_ui) {
- Profile* profile = Profile::FromWebUI(web_ui);
web_ui->AddMessageHandler(new BrowsingHistoryHandler());
web_ui->AddMessageHandler(new MetricsHandler());
if (search::IsInstantExtendedAPIEnabled()) {
web_ui->AddMessageHandler(new browser_sync::ForeignSessionHandler());
- web_ui->AddMessageHandler(new HistoryLoginHandler());
+ web_ui->AddMessageHandler(new HistoryLoginHandler(
+ base::Bind(&MdHistoryUI::SignInChanged, base::Unretained(this))));
}
- data_source_ = CreateMdHistoryUIHTMLSource(profile, use_test_title_);
- content::WebUIDataSource::Add(profile, data_source_);
+ CreateAndGetDataSource();
web_ui->RegisterMessageCallback("menuPromoShown",
base::Bind(&MdHistoryUI::HandleMenuPromoShown, base::Unretained(this)));
@@ -266,8 +265,21 @@ void MdHistoryUI::RegisterProfilePrefs(
user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
}
+content::WebUIDataSource* MdHistoryUI::CreateAndGetDataSource() {
+ Profile* profile = Profile::FromWebUI(web_ui());
+ content::WebUIDataSource* data_source =
+ CreateMdHistoryUIHTMLSource(profile, use_test_title_);
+ content::WebUIDataSource::Add(profile, data_source);
+ return data_source;
+}
+
void MdHistoryUI::HandleMenuPromoShown(const base::ListValue* args) {
Profile::FromWebUI(web_ui())->GetPrefs()->SetBoolean(
prefs::kMdHistoryMenuPromoShown, true);
- data_source_->AddBoolean(kShowMenuPromoKey, false);
+ CreateAndGetDataSource()->AddBoolean(kShowMenuPromoKey, false);
Dan Beam 2016/09/30 00:47:43 I think you can just name this CreateDataSource()
lshang 2016/09/30 01:31:08 Yeah you're right. Done!
+}
+
+void MdHistoryUI::SignInChanged(bool signed_in) {
+ // Recreate the data source so sign in state get updated in there.
+ CreateAndGetDataSource();
}
« 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