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

Side by Side Diff: chrome/browser/ui/webui/options/startup_pages_handler.cc

Issue 11421029: Remove PrefObserver usages, batch 13. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix - rebase Created 8 years 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/webui/options/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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/options/startup_pages_handler.h" 5 #include "chrome/browser/ui/webui/options/startup_pages_handler.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/string_number_conversions.h" 9 #include "base/string_number_conversions.h"
10 #include "chrome/browser/autocomplete/autocomplete_classifier.h" 10 #include "chrome/browser/autocomplete/autocomplete_classifier.h"
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 } 83 }
84 84
85 void StartupPagesHandler::InitializeHandler() { 85 void StartupPagesHandler::InitializeHandler() {
86 Profile* profile = Profile::FromWebUI(web_ui()); 86 Profile* profile = Profile::FromWebUI(web_ui());
87 87
88 startup_custom_pages_table_model_.reset( 88 startup_custom_pages_table_model_.reset(
89 new CustomHomePagesTableModel(profile)); 89 new CustomHomePagesTableModel(profile));
90 startup_custom_pages_table_model_->SetObserver(this); 90 startup_custom_pages_table_model_->SetObserver(this);
91 91
92 pref_change_registrar_.Init(profile->GetPrefs()); 92 pref_change_registrar_.Init(profile->GetPrefs());
93 pref_change_registrar_.Add(prefs::kURLsToRestoreOnStartup, this); 93 pref_change_registrar_.Add(
94 prefs::kURLsToRestoreOnStartup,
95 base::Bind(&StartupPagesHandler::UpdateStartupPages,
96 base::Unretained(this)));
94 97
95 autocomplete_controller_.reset(new AutocompleteController(profile, this, 98 autocomplete_controller_.reset(new AutocompleteController(profile, this,
96 AutocompleteClassifier::kDefaultOmniboxProviders)); 99 AutocompleteClassifier::kDefaultOmniboxProviders));
97 } 100 }
98 101
99 void StartupPagesHandler::InitializePage() { 102 void StartupPagesHandler::InitializePage() {
100 UpdateStartupPages(); 103 UpdateStartupPages();
101 } 104 }
102 105
103 void StartupPagesHandler::OnModelChanged() { 106 void StartupPagesHandler::OnModelChanged() {
(...skipping 19 matching lines...) Expand all
123 } 126 }
124 127
125 void StartupPagesHandler::OnItemsAdded(int start, int length) { 128 void StartupPagesHandler::OnItemsAdded(int start, int length) {
126 OnModelChanged(); 129 OnModelChanged();
127 } 130 }
128 131
129 void StartupPagesHandler::OnItemsRemoved(int start, int length) { 132 void StartupPagesHandler::OnItemsRemoved(int start, int length) {
130 OnModelChanged(); 133 OnModelChanged();
131 } 134 }
132 135
133 void StartupPagesHandler::OnPreferenceChanged(PrefServiceBase* service,
134 const std::string& pref_name) {
135 if (pref_name == prefs::kURLsToRestoreOnStartup) {
136 UpdateStartupPages();
137 } else {
138 NOTREACHED();
139 }
140 }
141
142 void StartupPagesHandler::SetStartupPagesToCurrentPages( 136 void StartupPagesHandler::SetStartupPagesToCurrentPages(
143 const ListValue* args) { 137 const ListValue* args) {
144 startup_custom_pages_table_model_->SetToCurrentlyOpenPages(); 138 startup_custom_pages_table_model_->SetToCurrentlyOpenPages();
145 } 139 }
146 140
147 void StartupPagesHandler::RemoveStartupPages(const ListValue* args) { 141 void StartupPagesHandler::RemoveStartupPages(const ListValue* args) {
148 for (int i = args->GetSize() - 1; i >= 0; --i) { 142 for (int i = args->GetSize() - 1; i >= 0; --i) {
149 std::string string_value; 143 std::string string_value;
150 CHECK(args->GetString(i, &string_value)); 144 CHECK(args->GetString(i, &string_value));
151 145
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 246
253 void StartupPagesHandler::OnResultChanged(bool default_match_changed) { 247 void StartupPagesHandler::OnResultChanged(bool default_match_changed) {
254 const AutocompleteResult& result = autocomplete_controller_->result(); 248 const AutocompleteResult& result = autocomplete_controller_->result();
255 ListValue suggestions; 249 ListValue suggestions;
256 OptionsUI::ProcessAutocompleteSuggestions(result, &suggestions); 250 OptionsUI::ProcessAutocompleteSuggestions(result, &suggestions);
257 web_ui()->CallJavascriptFunction( 251 web_ui()->CallJavascriptFunction(
258 "StartupOverlay.updateAutocompleteSuggestions", suggestions); 252 "StartupOverlay.updateAutocompleteSuggestions", suggestions);
259 } 253 }
260 254
261 } // namespace options 255 } // namespace options
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/options/startup_pages_handler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698