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

Side by Side Diff: chrome/browser/ui/webui/options2/search_engine_manager_handler2.cc

Issue 9994005: Separate handler initialization from page initialization (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: move anything that indirectly calls JS to InitializePage Created 8 years, 8 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 | Annotate | Revision Log
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/options2/search_engine_manager_handler2.h" 5 #include "chrome/browser/ui/webui/options2/search_engine_manager_handler2.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/string_number_conversions.h" 8 #include "base/string_number_conversions.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "base/values.h" 10 #include "base/values.h"
(...skipping 26 matching lines...) Expand all
37 } 37 }
38 38
39 SearchEngineManagerHandler::~SearchEngineManagerHandler() { 39 SearchEngineManagerHandler::~SearchEngineManagerHandler() {
40 if (list_controller_.get() && list_controller_->table_model()) 40 if (list_controller_.get() && list_controller_->table_model())
41 list_controller_->table_model()->SetObserver(NULL); 41 list_controller_->table_model()->SetObserver(NULL);
42 } 42 }
43 43
44 void SearchEngineManagerHandler::InitializeHandler() { 44 void SearchEngineManagerHandler::InitializeHandler() {
45 list_controller_.reset( 45 list_controller_.reset(
46 new KeywordEditorController(Profile::FromWebUI(web_ui()))); 46 new KeywordEditorController(Profile::FromWebUI(web_ui())));
47 DCHECK(list_controller_.get());
48 list_controller_->table_model()->SetObserver(this);
49 } 47 }
50 48
51 void SearchEngineManagerHandler::InitializePage() { 49 void SearchEngineManagerHandler::InitializePage() {
50 list_controller_->table_model()->SetObserver(this);
52 OnModelChanged(); 51 OnModelChanged();
53 } 52 }
54 53
55 void SearchEngineManagerHandler::GetLocalizedValues( 54 void SearchEngineManagerHandler::GetLocalizedValues(
56 base::DictionaryValue* localized_strings) { 55 base::DictionaryValue* localized_strings) {
57 DCHECK(localized_strings); 56 DCHECK(localized_strings);
58 57
59 RegisterTitle(localized_strings, "searchEngineManagerPage", 58 RegisterTitle(localized_strings, "searchEngineManagerPage",
60 IDS_SEARCH_ENGINES_EDITOR_WINDOW_TITLE); 59 IDS_SEARCH_ENGINES_EDITOR_WINDOW_TITLE);
61 localized_strings->SetString("defaultSearchEngineListTitle", 60 localized_strings->SetString("defaultSearchEngineListTitle",
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 list_controller_->RemoveTemplateURL(index); 239 list_controller_->RemoveTemplateURL(index);
241 } 240 }
242 241
243 void SearchEngineManagerHandler::EditSearchEngine(const ListValue* args) { 242 void SearchEngineManagerHandler::EditSearchEngine(const ListValue* args) {
244 int index; 243 int index;
245 if (!ExtractIntegerValue(args, &index)) { 244 if (!ExtractIntegerValue(args, &index)) {
246 NOTREACHED(); 245 NOTREACHED();
247 return; 246 return;
248 } 247 }
249 248
250 // CHECK()s to track down the cause of crbug.com/121741.
251 CHECK(list_controller_.get());
252 CHECK(list_controller_->table_model());
253
254 // Allow -1, which means we are adding a new engine. 249 // Allow -1, which means we are adding a new engine.
255 if (index < -1 || index >= list_controller_->table_model()->RowCount()) 250 if (index < -1 || index >= list_controller_->table_model()->RowCount())
256 return; 251 return;
257 252
258 edit_controller_.reset(new EditSearchEngineController( 253 edit_controller_.reset(new EditSearchEngineController(
259 (index == -1) ? NULL : list_controller_->GetTemplateURL(index), this, 254 (index == -1) ? NULL : list_controller_->GetTemplateURL(index), this,
260 Profile::FromWebUI(web_ui()))); 255 Profile::FromWebUI(web_ui())));
261 } 256 }
262 257
263 void SearchEngineManagerHandler::OnEditedKeyword( 258 void SearchEngineManagerHandler::OnEditedKeyword(
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 if (!args->GetString(ENGINE_NAME, &name) || 310 if (!args->GetString(ENGINE_NAME, &name) ||
316 !args->GetString(ENGINE_KEYWORD, &keyword) || 311 !args->GetString(ENGINE_KEYWORD, &keyword) ||
317 !args->GetString(ENGINE_URL, &url)) { 312 !args->GetString(ENGINE_URL, &url)) {
318 NOTREACHED(); 313 NOTREACHED();
319 return; 314 return;
320 } 315 }
321 edit_controller_->AcceptAddOrEdit(name, keyword, url); 316 edit_controller_->AcceptAddOrEdit(name, keyword, url);
322 } 317 }
323 318
324 } // namespace options2 319 } // namespace options2
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698