| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 /** |
| 6 * @fileoverview A helper object used from the the Import Data dialog to allow |
| 7 * users to import data (like bookmarks) from other web browsers. |
| 8 */ |
| 9 cr.exportPath('settings'); |
| 10 |
| 11 /** |
| 12 * An object describing a source browser profile that may be imported. |
| 13 * The structure of this data must be kept in sync with C++ ImportDataHandler. |
| 14 * @typedef {{ |
| 15 * name: string, |
| 16 * index: number, |
| 17 * history: boolean, |
| 18 * favorites: boolean, |
| 19 * passwords: boolean, |
| 20 * search: boolean, |
| 21 * autofillFormData: boolean, |
| 22 * }} |
| 23 */ |
| 24 settings.BrowserProfile; |
| 25 |
| 26 /** |
| 27 * @enum {string} |
| 28 * These string values must be kept in sync with the C++ ImportDataHandler. |
| 29 */ |
| 30 settings.ImportDataStatus = { |
| 31 INITIAL: 'initial', |
| 32 IN_PROGRESS: 'inProgress', |
| 33 SUCCEEDED: 'succeeded', |
| 34 FAILED: 'failed', |
| 35 }; |
| 36 |
| 37 cr.define('settings', function() { |
| 38 /** @interface */ |
| 39 function ImportDataBrowserProxy() {} |
| 40 |
| 41 ImportDataBrowserProxy.prototype = { |
| 42 /** |
| 43 * Returns the source profiles available for importing from other browsers. |
| 44 * @return {!Promise<!Array<!settings.BrowserProfile>>} |
| 45 */ |
| 46 initializeImportDialog: function() {}, |
| 47 |
| 48 /** |
| 49 * Starts importing data for the specificed source browser profile. The C++ |
| 50 * responds with the 'import-data-status-changed' WebUIListener event. |
| 51 * @param {number} sourceBrowserProfileIndex |
| 52 */ |
| 53 importData: function(sourceBrowserProfileIndex) {}, |
| 54 |
| 55 /** |
| 56 * Prompts the user to choose a bookmarks file to import bookmarks from. |
| 57 */ |
| 58 importFromBookmarksFile: function() {}, |
| 59 }; |
| 60 |
| 61 /** |
| 62 * @constructor |
| 63 * @implements {settings.ImportDataBrowserProxy} |
| 64 */ |
| 65 function ImportDataBrowserProxyImpl() {} |
| 66 // The singleton instance_ is replaced with a test version of this wrapper |
| 67 // during testing. |
| 68 cr.addSingletonGetter(ImportDataBrowserProxyImpl); |
| 69 |
| 70 ImportDataBrowserProxyImpl.prototype = { |
| 71 /** @override */ |
| 72 initializeImportDialog: function() { |
| 73 return cr.sendWithPromise('initializeImportDialog'); |
| 74 }, |
| 75 |
| 76 /** @override */ |
| 77 importData: function(sourceBrowserProfileIndex) { |
| 78 chrome.send('importData', [sourceBrowserProfileIndex]); |
| 79 }, |
| 80 |
| 81 /** @override */ |
| 82 importFromBookmarksFile: function() { |
| 83 chrome.send('importFromBookmarksFile'); |
| 84 }, |
| 85 }; |
| 86 |
| 87 return { |
| 88 ImportDataBrowserProxy: ImportDataBrowserProxy, |
| 89 ImportDataBrowserProxyImpl: ImportDataBrowserProxyImpl, |
| 90 }; |
| 91 }); |
| OLD | NEW |