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

Side by Side Diff: chrome/browser/ui/webui/settings/settings_startup_pages_handler.cc

Issue 1776393003: MD Settings: avoid double pref observation on Startup Pages (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: doc comment Created 4 years, 9 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 unified diff | Download patch
« no previous file with comments | « chrome/browser/ui/webui/settings/settings_startup_pages_handler.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/webui/settings/settings_startup_pages_handler.h" 5 #include "chrome/browser/ui/webui/settings/settings_startup_pages_handler.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "chrome/browser/prefs/session_startup_pref.h" 10 #include "chrome/browser/prefs/session_startup_pref.h"
(...skipping 22 matching lines...) Expand all
33 base::Bind(&StartupPagesHandler::OnStartupPrefsPageLoad, 33 base::Bind(&StartupPagesHandler::OnStartupPrefsPageLoad,
34 base::Unretained(this))); 34 base::Unretained(this)));
35 web_ui()->RegisterMessageCallback("removeStartupPage", 35 web_ui()->RegisterMessageCallback("removeStartupPage",
36 base::Bind(&StartupPagesHandler::RemoveStartupPage, 36 base::Bind(&StartupPagesHandler::RemoveStartupPage,
37 base::Unretained(this))); 37 base::Unretained(this)));
38 web_ui()->RegisterMessageCallback("setStartupPagesToCurrentPages", 38 web_ui()->RegisterMessageCallback("setStartupPagesToCurrentPages",
39 base::Bind(&StartupPagesHandler::SetStartupPagesToCurrentPages, 39 base::Bind(&StartupPagesHandler::SetStartupPagesToCurrentPages,
40 base::Unretained(this))); 40 base::Unretained(this)));
41 } 41 }
42 42
43 void StartupPagesHandler::RenderViewReused() {
44 startup_custom_pages_table_model_.SetObserver(nullptr);
45 pref_change_registrar_.RemoveAll();
46 }
47
43 void StartupPagesHandler::OnModelChanged() { 48 void StartupPagesHandler::OnModelChanged() {
44 base::ListValue startup_pages; 49 base::ListValue startup_pages;
45 int page_count = startup_custom_pages_table_model_.RowCount(); 50 int page_count = startup_custom_pages_table_model_.RowCount();
46 std::vector<GURL> urls = startup_custom_pages_table_model_.GetURLs(); 51 std::vector<GURL> urls = startup_custom_pages_table_model_.GetURLs();
47 for (int i = 0; i < page_count; ++i) { 52 for (int i = 0; i < page_count; ++i) {
48 scoped_ptr<base::DictionaryValue> entry(new base::DictionaryValue()); 53 scoped_ptr<base::DictionaryValue> entry(new base::DictionaryValue());
49 entry->SetString("title", startup_custom_pages_table_model_.GetText(i, 0)); 54 entry->SetString("title", startup_custom_pages_table_model_.GetText(i, 0));
50 entry->SetString("url", urls[i].spec()); 55 entry->SetString("url", urls[i].spec());
51 entry->SetString("tooltip", 56 entry->SetString("tooltip",
52 startup_custom_pages_table_model_.GetTooltip(i)); 57 startup_custom_pages_table_model_.GetTooltip(i));
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 156
152 void StartupPagesHandler::UpdateStartupPages() { 157 void StartupPagesHandler::UpdateStartupPages() {
153 const SessionStartupPref startup_pref = SessionStartupPref::GetStartupPref( 158 const SessionStartupPref startup_pref = SessionStartupPref::GetStartupPref(
154 Profile::FromWebUI(web_ui())->GetPrefs()); 159 Profile::FromWebUI(web_ui())->GetPrefs());
155 startup_custom_pages_table_model_.SetURLs(startup_pref.urls); 160 startup_custom_pages_table_model_.SetURLs(startup_pref.urls);
156 // The change will go to the JS code in the 161 // The change will go to the JS code in the
157 // StartupPagesHandler::OnModelChanged() method. 162 // StartupPagesHandler::OnModelChanged() method.
158 } 163 }
159 164
160 } // namespace settings 165 } // namespace settings
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/settings/settings_startup_pages_handler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698