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

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

Issue 2361513003: MD History: Update sign in state in data source (Closed)
Patch Set: fix promo crash 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
« no previous file with comments | « chrome/browser/ui/webui/md_history_ui.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.
+}
« no previous file with comments | « 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