| OLD | NEW |
| 1 // Copyright (c) 2011 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" |
| 11 #include "base/bind_helpers.h" | 11 #include "base/bind_helpers.h" |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 { "noProfileFound", IDS_IMPORT_NO_PROFILE_FOUND }, | 54 { "noProfileFound", IDS_IMPORT_NO_PROFILE_FOUND }, |
| 55 { "importSucceeded", IDS_IMPORT_SUCCEEDED }, | 55 { "importSucceeded", IDS_IMPORT_SUCCEEDED }, |
| 56 { "findYourImportedBookmarks", IDS_IMPORT_FIND_YOUR_BOOKMARKS }, | 56 { "findYourImportedBookmarks", IDS_IMPORT_FIND_YOUR_BOOKMARKS }, |
| 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::Initialize() { | 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 importer_list_->DetectSourceProfiles(this); | 67 importer_list_->DetectSourceProfiles(this); |
| 68 } | 68 } |
| 69 | 69 |
| 70 void ImportDataHandler::RegisterMessages() { | 70 void ImportDataHandler::RegisterMessages() { |
| 71 web_ui()->RegisterMessageCallback("importData", | 71 web_ui()->RegisterMessageCallback("importData", |
| 72 base::Bind(&ImportDataHandler::ImportData, base::Unretained(this))); | 72 base::Bind(&ImportDataHandler::ImportData, base::Unretained(this))); |
| 73 } | 73 } |
| 74 | 74 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 importer_host_->StartImportSettings(source_profile, profile, | 121 importer_host_->StartImportSettings(source_profile, profile, |
| 122 import_services, | 122 import_services, |
| 123 new ProfileWriter(profile), false); | 123 new ProfileWriter(profile), false); |
| 124 } else { | 124 } else { |
| 125 LOG(WARNING) << "There were no settings to import from '" | 125 LOG(WARNING) << "There were no settings to import from '" |
| 126 << source_profile.importer_name << "'."; | 126 << source_profile.importer_name << "'."; |
| 127 } | 127 } |
| 128 } | 128 } |
| 129 | 129 |
| 130 void ImportDataHandler::OnSourceProfilesLoaded() { | 130 void ImportDataHandler::OnSourceProfilesLoaded() { |
| 131 InitializePage(); |
| 132 } |
| 133 |
| 134 void ImportDataHandler::InitializePage() { |
| 135 if (!importer_list_->source_profiles_loaded()) |
| 136 return; |
| 137 |
| 131 ListValue browser_profiles; | 138 ListValue browser_profiles; |
| 132 for (size_t i = 0; i < importer_list_->count(); ++i) { | 139 for (size_t i = 0; i < importer_list_->count(); ++i) { |
| 133 const importer::SourceProfile& source_profile = | 140 const importer::SourceProfile& source_profile = |
| 134 importer_list_->GetSourceProfileAt(i); | 141 importer_list_->GetSourceProfileAt(i); |
| 135 uint16 browser_services = source_profile.services_supported; | 142 uint16 browser_services = source_profile.services_supported; |
| 136 | 143 |
| 137 DictionaryValue* browser_profile = new DictionaryValue(); | 144 DictionaryValue* browser_profile = new DictionaryValue(); |
| 138 browser_profile->SetString("name", source_profile.importer_name); | 145 browser_profile->SetString("name", source_profile.importer_name); |
| 139 browser_profile->SetInteger("index", i); | 146 browser_profile->SetInteger("index", i); |
| 140 browser_profile->SetBoolean("history", | 147 browser_profile->SetBoolean("history", |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 web_ui()->CallJavascriptFunction("ImportDataOverlay.confirmSuccess"); | 180 web_ui()->CallJavascriptFunction("ImportDataOverlay.confirmSuccess"); |
| 174 } else { | 181 } else { |
| 175 base::FundamentalValue state(false); | 182 base::FundamentalValue state(false); |
| 176 web_ui()->CallJavascriptFunction("ImportDataOverlay.setImportingState", | 183 web_ui()->CallJavascriptFunction("ImportDataOverlay.setImportingState", |
| 177 state); | 184 state); |
| 178 web_ui()->CallJavascriptFunction("ImportDataOverlay.dismiss"); | 185 web_ui()->CallJavascriptFunction("ImportDataOverlay.dismiss"); |
| 179 } | 186 } |
| 180 } | 187 } |
| 181 | 188 |
| 182 } // namespace options2 | 189 } // namespace options2 |
| OLD | NEW |