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..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(); |
| } |