| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #ifndef CHROME_BROWSER_UI_WEBUI_OPTIONS_IMPORT_DATA_HANDLER_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_SETTINGS_SETTINGS_IMPORT_DATA_HANDLER_H_ |
| 6 #define CHROME_BROWSER_UI_WEBUI_OPTIONS_IMPORT_DATA_HANDLER_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_SETTINGS_SETTINGS_IMPORT_DATA_HANDLER_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| 11 | 11 |
| 12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "chrome/browser/importer/importer_progress_observer.h" | 14 #include "chrome/browser/importer/importer_progress_observer.h" |
| 15 #include "chrome/browser/ui/webui/options/options_ui.h" | 15 #include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h" |
| 16 #include "chrome/common/importer/importer_data_types.h" | 16 #include "chrome/common/importer/importer_data_types.h" |
| 17 #include "ui/shell_dialogs/select_file_dialog.h" | 17 #include "ui/shell_dialogs/select_file_dialog.h" |
| 18 | 18 |
| 19 class ExternalProcessImporterHost; | 19 class ExternalProcessImporterHost; |
| 20 class ImporterList; | 20 class ImporterList; |
| 21 | 21 |
| 22 namespace options { | 22 namespace settings { |
| 23 | 23 |
| 24 // Chrome personal stuff import data overlay UI handler. | 24 // Chrome personal stuff import data overlay UI handler. |
| 25 class ImportDataHandler : public OptionsPageUIHandler, | 25 class ImportDataHandler : public SettingsPageUIHandler, |
| 26 public importer::ImporterProgressObserver, | 26 public importer::ImporterProgressObserver, |
| 27 public ui::SelectFileDialog::Listener { | 27 public ui::SelectFileDialog::Listener { |
| 28 public: | 28 public: |
| 29 ImportDataHandler(); | 29 ImportDataHandler(); |
| 30 ~ImportDataHandler() override; | 30 ~ImportDataHandler() override; |
| 31 | 31 |
| 32 // OptionsPageUIHandler: | 32 // SettingsPageUIHandler |
| 33 void GetLocalizedValues(base::DictionaryValue* localized_strings) override; | |
| 34 void InitializeHandler() override; | |
| 35 void InitializePage() override; | |
| 36 | |
| 37 // content::WebUIMessageHandler: | |
| 38 void RegisterMessages() override; | 33 void RegisterMessages() override; |
| 34 void OnJavascriptAllowed() override {} |
| 35 void OnJavascriptDisallowed() override; |
| 39 | 36 |
| 40 private: | 37 private: |
| 41 void StartImport(const importer::SourceProfile& source_profile, | 38 void StartImport(const importer::SourceProfile& source_profile, |
| 42 uint16_t imported_items); | 39 uint16_t imported_items); |
| 43 | 40 |
| 44 void ImportData(const base::ListValue* args); | 41 void ImportData(const base::ListValue* args); |
| 45 | 42 |
| 43 void InitializeDialog(const base::ListValue* args); |
| 44 void SendBrowserProfileData(); |
| 45 |
| 46 // importer::ImporterProgressObserver: | 46 // importer::ImporterProgressObserver: |
| 47 void ImportStarted() override; | 47 void ImportStarted() override; |
| 48 void ImportItemStarted(importer::ImportItem item) override; | 48 void ImportItemStarted(importer::ImportItem item) override; |
| 49 void ImportItemEnded(importer::ImportItem item) override; | 49 void ImportItemEnded(importer::ImportItem item) override; |
| 50 void ImportEnded() override; | 50 void ImportEnded() override; |
| 51 | 51 |
| 52 // ui::SelectFileDialog::Listener: | 52 // ui::SelectFileDialog::Listener: |
| 53 void FileSelected(const base::FilePath& path, | 53 void FileSelected(const base::FilePath& path, |
| 54 int index, | 54 int index, |
| 55 void* params) override; | 55 void* params) override; |
| 56 | 56 |
| 57 // Opens a file selection dialog to choose the bookmarks HTML file. | 57 // Opens a file selection dialog to choose the bookmarks HTML file. |
| 58 void HandleChooseBookmarksFile(const base::ListValue* args); | 58 void HandleChooseBookmarksFile(const base::ListValue* args); |
| 59 | 59 |
| 60 std::unique_ptr<ImporterList> importer_list_; | 60 std::unique_ptr<ImporterList> importer_list_; |
| 61 | 61 |
| 62 // If non-null it means importing is in progress. ImporterHost takes care | 62 // If non-null it means importing is in progress. ImporterHost takes care |
| 63 // of deleting itself when import is complete. | 63 // of deleting itself when import is complete. |
| 64 ExternalProcessImporterHost* importer_host_; // weak | 64 ExternalProcessImporterHost* importer_host_; // weak |
| 65 | 65 |
| 66 bool import_did_succeed_; | 66 bool import_did_succeed_; |
| 67 | 67 |
| 68 scoped_refptr<ui::SelectFileDialog> select_file_dialog_; | 68 scoped_refptr<ui::SelectFileDialog> select_file_dialog_; |
| 69 | 69 |
| 70 DISALLOW_COPY_AND_ASSIGN(ImportDataHandler); | 70 DISALLOW_COPY_AND_ASSIGN(ImportDataHandler); |
| 71 }; | 71 }; |
| 72 | 72 |
| 73 } // namespace options | 73 } // namespace settings |
| 74 | 74 |
| 75 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS_IMPORT_DATA_HANDLER_H_ | 75 #endif // CHROME_BROWSER_UI_WEBUI_SETTINGS_SETTINGS_IMPORT_DATA_HANDLER_H_ |
| OLD | NEW |