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

Side by Side Diff: chrome/browser/ui/webui/options2/import_data_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/import_data_handler2.h" 5 #include "chrome/browser/ui/webui/options2/import_data_handler2.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 }; 57 };
58 58
59 RegisterStrings(localized_strings, resources, arraysize(resources)); 59 RegisterStrings(localized_strings, resources, arraysize(resources));
60 RegisterTitle(localized_strings, "importDataOverlay", 60 RegisterTitle(localized_strings, "importDataOverlay",
61 IDS_IMPORT_SETTINGS_TITLE); 61 IDS_IMPORT_SETTINGS_TITLE);
62 } 62 }
63 63
64 void ImportDataHandler::InitializeHandler() { 64 void ImportDataHandler::InitializeHandler() {
65 Profile* profile = Profile::FromWebUI(web_ui()); 65 Profile* profile = Profile::FromWebUI(web_ui());
66 importer_list_ = new ImporterList(profile->GetRequestContext()); 66 importer_list_ = new ImporterList(profile->GetRequestContext());
67 }
68
69 void ImportDataHandler::InitializePage() {
67 importer_list_->DetectSourceProfiles(this); 70 importer_list_->DetectSourceProfiles(this);
68 } 71 }
69 72
70 void ImportDataHandler::RegisterMessages() { 73 void ImportDataHandler::RegisterMessages() {
71 web_ui()->RegisterMessageCallback("importData", 74 web_ui()->RegisterMessageCallback("importData",
72 base::Bind(&ImportDataHandler::ImportData, base::Unretained(this))); 75 base::Bind(&ImportDataHandler::ImportData, base::Unretained(this)));
73 } 76 }
74 77
75 void ImportDataHandler::ImportData(const ListValue* args) { 78 void ImportDataHandler::ImportData(const ListValue* args) {
76 std::string string_value; 79 std::string string_value;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 importer_host_->StartImportSettings(source_profile, profile, 124 importer_host_->StartImportSettings(source_profile, profile,
122 import_services, 125 import_services,
123 new ProfileWriter(profile), false); 126 new ProfileWriter(profile), false);
124 } else { 127 } else {
125 LOG(WARNING) << "There were no settings to import from '" 128 LOG(WARNING) << "There were no settings to import from '"
126 << source_profile.importer_name << "'."; 129 << source_profile.importer_name << "'.";
127 } 130 }
128 } 131 }
129 132
130 void ImportDataHandler::OnSourceProfilesLoaded() { 133 void ImportDataHandler::OnSourceProfilesLoaded() {
131 InitializePage(); 134 UpdateSupportedBrowsers();
132 } 135 }
133 136
134 void ImportDataHandler::InitializePage() { 137 void ImportDataHandler::UpdateSupportedBrowsers() {
135 if (!importer_list_->source_profiles_loaded()) 138 if (!importer_list_->source_profiles_loaded())
136 return; 139 return;
137 140
138 ListValue browser_profiles; 141 ListValue browser_profiles;
139 for (size_t i = 0; i < importer_list_->count(); ++i) { 142 for (size_t i = 0; i < importer_list_->count(); ++i) {
140 const importer::SourceProfile& source_profile = 143 const importer::SourceProfile& source_profile =
141 importer_list_->GetSourceProfileAt(i); 144 importer_list_->GetSourceProfileAt(i);
142 uint16 browser_services = source_profile.services_supported; 145 uint16 browser_services = source_profile.services_supported;
143 146
144 DictionaryValue* browser_profile = new DictionaryValue(); 147 DictionaryValue* browser_profile = new DictionaryValue();
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 web_ui()->CallJavascriptFunction("ImportDataOverlay.confirmSuccess"); 183 web_ui()->CallJavascriptFunction("ImportDataOverlay.confirmSuccess");
181 } else { 184 } else {
182 base::FundamentalValue state(false); 185 base::FundamentalValue state(false);
183 web_ui()->CallJavascriptFunction("ImportDataOverlay.setImportingState", 186 web_ui()->CallJavascriptFunction("ImportDataOverlay.setImportingState",
184 state); 187 state);
185 web_ui()->CallJavascriptFunction("ImportDataOverlay.dismiss"); 188 web_ui()->CallJavascriptFunction("ImportDataOverlay.dismiss");
186 } 189 }
187 } 190 }
188 191
189 } // namespace options2 192 } // namespace options2
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698