Chromium Code Reviews| 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..58b541235aa33e08be630ee3a504f579ca7b7308 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)))); |
|
Dan Beam
2016/09/30 02:55:40
same
lshang
2016/09/30 03:21:13
Done.
|
| } |
| - data_source_ = CreateMdHistoryUIHTMLSource(profile, use_test_title_); |
| - content::WebUIDataSource::Add(profile, data_source_); |
| + CreateDataSource(); |
| web_ui->RegisterMessageCallback("menuPromoShown", |
| base::Bind(&MdHistoryUI::HandleMenuPromoShown, base::Unretained(this))); |
| @@ -266,8 +265,20 @@ void MdHistoryUI::RegisterProfilePrefs( |
| user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); |
| } |
| +void MdHistoryUI::CreateDataSource() { |
| + Profile* profile = Profile::FromWebUI(web_ui()); |
| + content::WebUIDataSource* data_source = |
| + CreateMdHistoryUIHTMLSource(profile, use_test_title_); |
| + content::WebUIDataSource::Add(profile, data_source); |
| +} |
| + |
| void MdHistoryUI::HandleMenuPromoShown(const base::ListValue* args) { |
| Profile::FromWebUI(web_ui())->GetPrefs()->SetBoolean( |
| prefs::kMdHistoryMenuPromoShown, true); |
| - data_source_->AddBoolean(kShowMenuPromoKey, false); |
| + CreateDataSource(); |
| +} |
| + |
| +void MdHistoryUI::SignInChanged() { |
| + // Recreate the data source so sign in state get updated in there. |
| + CreateDataSource(); |
| } |