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

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

Issue 2361513003: MD History: Update sign in state in data source (Closed)
Patch Set: move 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..9994327ed0ee78631f078d7d6f85cef652a48551 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::CreateDataSource, base::Unretained(this))));
}
- 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,17 @@ void MdHistoryUI::RegisterProfilePrefs(
user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
}
+// TODO(lshang): Change to not re-create data source every time after we use
+// unique_ptr instead of raw pointers for data source.
+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();
}
« 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