| OLD | NEW |
| 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/import_data_handler.h" | 5 #include "chrome/browser/ui/webui/options/import_data_handler.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 105 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 106 | 106 |
| 107 if (!imported_items) | 107 if (!imported_items) |
| 108 return; | 108 return; |
| 109 | 109 |
| 110 // If another import is already ongoing, let it finish silently. | 110 // If another import is already ongoing, let it finish silently. |
| 111 if (importer_host_) | 111 if (importer_host_) |
| 112 importer_host_->set_observer(NULL); | 112 importer_host_->set_observer(NULL); |
| 113 | 113 |
| 114 base::FundamentalValue importing(true); | 114 base::FundamentalValue importing(true); |
| 115 web_ui()->CallJavascriptFunction("ImportDataOverlay.setImportingState", | 115 web_ui()->CallJavascriptFunctionUnsafe("ImportDataOverlay.setImportingState", |
| 116 importing); | 116 importing); |
| 117 import_did_succeed_ = false; | 117 import_did_succeed_ = false; |
| 118 | 118 |
| 119 importer_host_ = new ExternalProcessImporterHost(); | 119 importer_host_ = new ExternalProcessImporterHost(); |
| 120 importer_host_->set_observer(this); | 120 importer_host_->set_observer(this); |
| 121 Profile* profile = Profile::FromWebUI(web_ui()); | 121 Profile* profile = Profile::FromWebUI(web_ui()); |
| 122 importer_host_->StartImportSettings(source_profile, profile, | 122 importer_host_->StartImportSettings(source_profile, profile, |
| 123 imported_items, | 123 imported_items, |
| 124 new ProfileWriter(profile)); | 124 new ProfileWriter(profile)); |
| 125 | 125 |
| 126 importer::LogImporterUseToMetrics("ImportDataHandler", | 126 importer::LogImporterUseToMetrics("ImportDataHandler", |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 browser_profile->SetBoolean("passwords", | 188 browser_profile->SetBoolean("passwords", |
| 189 (browser_services & importer::PASSWORDS) != 0); | 189 (browser_services & importer::PASSWORDS) != 0); |
| 190 browser_profile->SetBoolean("search", | 190 browser_profile->SetBoolean("search", |
| 191 (browser_services & importer::SEARCH_ENGINES) != 0); | 191 (browser_services & importer::SEARCH_ENGINES) != 0); |
| 192 browser_profile->SetBoolean("autofill-form-data", | 192 browser_profile->SetBoolean("autofill-form-data", |
| 193 (browser_services & importer::AUTOFILL_FORM_DATA) != 0); | 193 (browser_services & importer::AUTOFILL_FORM_DATA) != 0); |
| 194 | 194 |
| 195 browser_profiles.Append(browser_profile); | 195 browser_profiles.Append(browser_profile); |
| 196 } | 196 } |
| 197 | 197 |
| 198 web_ui()->CallJavascriptFunction("ImportDataOverlay.updateSupportedBrowsers", | 198 web_ui()->CallJavascriptFunctionUnsafe( |
| 199 browser_profiles); | 199 "ImportDataOverlay.updateSupportedBrowsers", browser_profiles); |
| 200 } | 200 } |
| 201 | 201 |
| 202 void ImportDataHandler::ImportStarted() { | 202 void ImportDataHandler::ImportStarted() { |
| 203 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 203 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 204 } | 204 } |
| 205 | 205 |
| 206 void ImportDataHandler::ImportItemStarted(importer::ImportItem item) { | 206 void ImportDataHandler::ImportItemStarted(importer::ImportItem item) { |
| 207 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 207 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 208 | 208 |
| 209 // TODO(csilv): show progress detail in the web view. | 209 // TODO(csilv): show progress detail in the web view. |
| 210 } | 210 } |
| 211 | 211 |
| 212 void ImportDataHandler::ImportItemEnded(importer::ImportItem item) { | 212 void ImportDataHandler::ImportItemEnded(importer::ImportItem item) { |
| 213 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 213 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 214 | 214 |
| 215 // TODO(csilv): show progress detail in the web view. | 215 // TODO(csilv): show progress detail in the web view. |
| 216 import_did_succeed_ = true; | 216 import_did_succeed_ = true; |
| 217 } | 217 } |
| 218 | 218 |
| 219 void ImportDataHandler::ImportEnded() { | 219 void ImportDataHandler::ImportEnded() { |
| 220 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 220 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 221 | 221 |
| 222 importer_host_->set_observer(NULL); | 222 importer_host_->set_observer(NULL); |
| 223 importer_host_ = NULL; | 223 importer_host_ = NULL; |
| 224 | 224 |
| 225 if (import_did_succeed_) { | 225 if (import_did_succeed_) { |
| 226 web_ui()->CallJavascriptFunction("ImportDataOverlay.confirmSuccess"); | 226 web_ui()->CallJavascriptFunctionUnsafe("ImportDataOverlay.confirmSuccess"); |
| 227 } else { | 227 } else { |
| 228 base::FundamentalValue state(false); | 228 base::FundamentalValue state(false); |
| 229 web_ui()->CallJavascriptFunction("ImportDataOverlay.setImportingState", | 229 web_ui()->CallJavascriptFunctionUnsafe( |
| 230 state); | 230 "ImportDataOverlay.setImportingState", state); |
| 231 web_ui()->CallJavascriptFunction("ImportDataOverlay.dismiss"); | 231 web_ui()->CallJavascriptFunctionUnsafe("ImportDataOverlay.dismiss"); |
| 232 } | 232 } |
| 233 } | 233 } |
| 234 | 234 |
| 235 void ImportDataHandler::FileSelected(const base::FilePath& path, | 235 void ImportDataHandler::FileSelected(const base::FilePath& path, |
| 236 int /*index*/, | 236 int /*index*/, |
| 237 void* /*params*/) { | 237 void* /*params*/) { |
| 238 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 238 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 239 | 239 |
| 240 importer::SourceProfile source_profile; | 240 importer::SourceProfile source_profile; |
| 241 source_profile.importer_type = importer::TYPE_BOOKMARKS_FILE; | 241 source_profile.importer_type = importer::TYPE_BOOKMARKS_FILE; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 262 base::string16(), | 262 base::string16(), |
| 263 base::FilePath(), | 263 base::FilePath(), |
| 264 &file_type_info, | 264 &file_type_info, |
| 265 0, | 265 0, |
| 266 base::FilePath::StringType(), | 266 base::FilePath::StringType(), |
| 267 browser->window()->GetNativeWindow(), | 267 browser->window()->GetNativeWindow(), |
| 268 NULL); | 268 NULL); |
| 269 } | 269 } |
| 270 | 270 |
| 271 } // namespace options | 271 } // namespace options |
| OLD | NEW |