| Index: chrome/browser/ui/webui/settings/settings_import_data_handler.cc
|
| diff --git a/chrome/browser/ui/webui/options/import_data_handler.cc b/chrome/browser/ui/webui/settings/settings_import_data_handler.cc
|
| similarity index 83%
|
| copy from chrome/browser/ui/webui/options/import_data_handler.cc
|
| copy to chrome/browser/ui/webui/settings/settings_import_data_handler.cc
|
| index bef03700bb5ce0b2c705599def10f1956f930782..07ff62526b0042e1f333e5d903cb7c3521c7afc4 100644
|
| --- a/chrome/browser/ui/webui/options/import_data_handler.cc
|
| +++ b/chrome/browser/ui/webui/settings/settings_import_data_handler.cc
|
| @@ -1,8 +1,8 @@
|
| -// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
| +// Copyright 2016 The Chromium Authors. All rights reserved.
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#include "chrome/browser/ui/webui/options/import_data_handler.h"
|
| +#include "chrome/browser/ui/webui/settings/settings_import_data_handler.h"
|
|
|
| #include <stddef.h>
|
|
|
| @@ -33,11 +33,10 @@
|
|
|
| using content::BrowserThread;
|
|
|
| -namespace options {
|
| +namespace settings {
|
|
|
| ImportDataHandler::ImportDataHandler()
|
| - : importer_host_(NULL),
|
| - import_did_succeed_(false) {
|
| + : importer_host_(NULL), import_did_succeed_(false) {
|
| DCHECK_CURRENTLY_ON(BrowserThread::UI);
|
| }
|
|
|
| @@ -51,46 +50,24 @@ ImportDataHandler::~ImportDataHandler() {
|
| select_file_dialog_->ListenerDestroyed();
|
| }
|
|
|
| -void ImportDataHandler::GetLocalizedValues(
|
| - base::DictionaryValue* localized_strings) {
|
| - DCHECK_CURRENTLY_ON(BrowserThread::UI);
|
| - DCHECK(localized_strings);
|
| -
|
| - static OptionsStringResource resources[] = {
|
| - {"importFromLabel", IDS_IMPORT_FROM_LABEL},
|
| - {"importLoading", IDS_IMPORT_LOADING_PROFILES},
|
| - {"importDescription", IDS_IMPORT_ITEMS_LABEL},
|
| - {"importHistory", IDS_IMPORT_HISTORY_CHKBOX},
|
| - {"importFavorites", IDS_IMPORT_FAVORITES_CHKBOX},
|
| - {"importSearch", IDS_IMPORT_SEARCH_ENGINES_CHKBOX},
|
| - {"importPasswords", IDS_IMPORT_PASSWORDS_CHKBOX},
|
| - {"importAutofillFormData", IDS_IMPORT_AUTOFILL_FORM_DATA_CHKBOX},
|
| - {"importChooseFile", IDS_IMPORT_CHOOSE_FILE},
|
| - {"importCommit", IDS_IMPORT_COMMIT},
|
| - {"noProfileFound", IDS_IMPORT_NO_PROFILE_FOUND},
|
| - {"importSucceeded", IDS_IMPORT_SUCCEEDED},
|
| - {"findYourImportedBookmarks", IDS_IMPORT_FIND_YOUR_BOOKMARKS},
|
| - };
|
| -
|
| - RegisterStrings(localized_strings, resources, arraysize(resources));
|
| - RegisterTitle(localized_strings, "importDataOverlay",
|
| - IDS_IMPORT_SETTINGS_TITLE);
|
| -}
|
| -
|
| -void ImportDataHandler::InitializeHandler() {
|
| - DCHECK_CURRENTLY_ON(BrowserThread::UI);
|
| +void ImportDataHandler::InitializeDialog(const base::ListValue* args) {
|
| + AllowJavascript();
|
|
|
| importer_list_.reset(new ImporterList());
|
| importer_list_->DetectSourceProfiles(
|
| g_browser_process->GetApplicationLocale(),
|
| true, // include_interactive_profiles?
|
| - base::Bind(&ImportDataHandler::InitializePage, base::Unretained(this)));
|
| + base::Bind(&ImportDataHandler::SendBrowserProfileData,
|
| + base::Unretained(this)));
|
| }
|
|
|
| void ImportDataHandler::RegisterMessages() {
|
| DCHECK_CURRENTLY_ON(BrowserThread::UI);
|
|
|
| web_ui()->RegisterMessageCallback(
|
| + "initializeImportDialog",
|
| + base::Bind(&ImportDataHandler::InitializeDialog, base::Unretained(this)));
|
| + web_ui()->RegisterMessageCallback(
|
| "importData",
|
| base::Bind(&ImportDataHandler::ImportData, base::Unretained(this)));
|
| web_ui()->RegisterMessageCallback(
|
| @@ -99,6 +76,15 @@ void ImportDataHandler::RegisterMessages() {
|
| base::Unretained(this)));
|
| }
|
|
|
| +void ImportDataHandler::OnJavascriptDisallowed() {
|
| + // Cancels outstanding profile list detections.
|
| + importer_list_.reset();
|
| +
|
| + // Stops listening to updates from any ongoing imports.
|
| + if (importer_host_)
|
| + importer_host_->set_observer(NULL);
|
| +}
|
| +
|
| void ImportDataHandler::StartImport(
|
| const importer::SourceProfile& source_profile,
|
| uint16_t imported_items) {
|
| @@ -169,7 +155,7 @@ void ImportDataHandler::ImportData(const base::ListValue* args) {
|
| }
|
| }
|
|
|
| -void ImportDataHandler::InitializePage() {
|
| +void ImportDataHandler::SendBrowserProfileData() {
|
| DCHECK_CURRENTLY_ON(BrowserThread::UI);
|
|
|
| base::ListValue browser_profiles;
|
| @@ -269,4 +255,4 @@ void ImportDataHandler::HandleChooseBookmarksFile(const base::ListValue* args) {
|
| NULL);
|
| }
|
|
|
| -} // namespace options
|
| +} // namespace settings
|
|
|