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..b15b4ed2bfdd9a221ffea2baac2018716b2e0f75 100644 |
| --- a/chrome/browser/ui/webui/md_history_ui.cc |
| +++ b/chrome/browser/ui/webui/md_history_ui.cc |
| @@ -215,14 +215,16 @@ content::WebUIDataSource* CreateMdHistoryUIHTMLSource(Profile* profile, |
| bool MdHistoryUI::use_test_title_ = false; |
| -MdHistoryUI::MdHistoryUI(content::WebUI* web_ui) : WebUIController(web_ui) { |
| +MdHistoryUI::MdHistoryUI(content::WebUI* web_ui) |
| + : WebUIController(web_ui), weak_ptr_factory_(this) { |
| 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, weak_ptr_factory_.GetWeakPtr()))); |
|
Dan Beam
2016/09/29 18:13:33
you can use weakptr, but now that we're not depend
lshang
2016/09/30 00:33:19
Done.
|
| } |
| data_source_ = CreateMdHistoryUIHTMLSource(profile, use_test_title_); |
|
Dan Beam
2016/09/29 18:13:33
don't keep this pointer around, as it's potentiall
lshang
2016/09/30 00:33:19
Done. Added a Get() method to create the data sour
|
| @@ -269,5 +271,15 @@ void MdHistoryUI::RegisterProfilePrefs( |
| void MdHistoryUI::HandleMenuPromoShown(const base::ListValue* args) { |
| Profile::FromWebUI(web_ui())->GetPrefs()->SetBoolean( |
| prefs::kMdHistoryMenuPromoShown, true); |
| + Profile* profile = Profile::FromWebUI(web_ui()); |
| + data_source_ = CreateMdHistoryUIHTMLSource(profile, use_test_title_); |
| + content::WebUIDataSource::Add(profile, data_source_); |
|
lshang
2016/09/29 08:06:48
I also modified here due to the same reason as bel
|
| data_source_->AddBoolean(kShowMenuPromoKey, false); |
| } |
| + |
| +void MdHistoryUI::SignInChanged(bool signed_in) { |
| + // Recreate the data source so sign in state get updated in there. |
| + Profile* profile = Profile::FromWebUI(web_ui()); |
| + data_source_ = CreateMdHistoryUIHTMLSource(profile, use_test_title_); |
| + content::WebUIDataSource::Add(profile, data_source_); |
|
lshang
2016/09/29 08:06:48
I found that purely AddBoolean() here will cause b
Dan Beam
2016/09/29 18:13:33
wow, that's crazy sauce. we should just make hand
lshang
2016/09/30 00:33:19
Done.
|
| +} |