Chromium Code Reviews| 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 should 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 */ | |
| 29 settings.ImportDataStatus = { | |
| 30 INITIAL: 'initial', | |
| 31 IN_PROGRESS: 'inProgress', | |
|
dpapad
2016/11/03 23:40:43
Should these literals match the C++. If so let's a
tommycli
2016/11/03 23:46:45
Done.
| |
| 32 SUCCEEDED: 'succeeded', | |
| 33 FAILED: 'failed', | |
| 34 }; | |
| 35 | |
| 36 cr.define('settings', function() { | |
| 37 /** @interface */ | |
| 38 function ImportDataBrowserProxy() {} | |
| 39 | |
| 40 ImportDataBrowserProxy.prototype = { | |
| 41 /** | |
| 42 * Returns a true promise if Easy Unlock is already enabled on the device. | |
|
dpapad
2016/11/03 23:40:43
What's a true promise? Should it be Promise<boolea
tommycli
2016/11/03 23:46:45
Done. Oops, I just needed to update the comment.
| |
| 43 * @return {!Promise<!Array<!settings.BrowserProfile>>} | |
| 44 */ | |
| 45 initializeImportDialog: function() {}, | |
| 46 | |
| 47 /** | |
| 48 * Starts importing data for the specificed source browser profile. The C++ | |
| 49 * responds with the 'import-data-status-changed' WebUIListener event. | |
| 50 * @param {number} sourceBrowserProfileIndex | |
| 51 */ | |
| 52 importData: function(sourceBrowserProfileIndex) {}, | |
| 53 | |
| 54 /** | |
| 55 * Prompts the user to choose a bookmarks file to import bookmarks from. | |
| 56 */ | |
| 57 importFromBookmarksFile: function() {}, | |
| 58 }; | |
| 59 | |
| 60 /** | |
| 61 * @constructor | |
| 62 * @implements {settings.ImportDataBrowserProxy} | |
| 63 */ | |
| 64 function ImportDataBrowserProxyImpl() {} | |
| 65 // The singleton instance_ is replaced with a test version of this wrapper | |
| 66 // during testing. | |
| 67 cr.addSingletonGetter(ImportDataBrowserProxyImpl); | |
| 68 | |
| 69 ImportDataBrowserProxyImpl.prototype = { | |
| 70 /** @override */ | |
| 71 initializeImportDialog: function() { | |
| 72 return cr.sendWithPromise('initializeImportDialog'); | |
| 73 }, | |
| 74 | |
| 75 /** @override */ | |
| 76 importData: function(sourceBrowserProfileIndex) { | |
| 77 chrome.send('importData', [sourceBrowserProfileIndex]); | |
| 78 }, | |
| 79 | |
| 80 /** @override */ | |
| 81 importFromBookmarksFile: function() { | |
| 82 chrome.send('importFromBookmarksFile'); | |
| 83 }, | |
| 84 }; | |
| 85 | |
| 86 return { | |
| 87 ImportDataBrowserProxy: ImportDataBrowserProxy, | |
| 88 ImportDataBrowserProxyImpl: ImportDataBrowserProxyImpl, | |
| 89 }; | |
| 90 }); | |
| OLD | NEW |