Chromium Code Reviews| Index: chrome/browser/resources/settings/people_page/import_data_browser_proxy.js |
| diff --git a/chrome/browser/resources/settings/people_page/import_data_browser_proxy.js b/chrome/browser/resources/settings/people_page/import_data_browser_proxy.js |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..57da444221db7cbceaac733e54af6e74eef8414f |
| --- /dev/null |
| +++ b/chrome/browser/resources/settings/people_page/import_data_browser_proxy.js |
| @@ -0,0 +1,90 @@ |
| +// 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. |
| + |
| +/** |
| + * @fileoverview A helper object used from the the Import Data dialog to allow |
| + * users to import data (like bookmarks) from other web browsers. |
| + */ |
| +cr.exportPath('settings'); |
| + |
| +/** |
| + * An object describing a source browser profile that may be imported. |
| + * The structure of this data should be kept in sync with C++ ImportDataHandler. |
| + * @typedef {{ |
| + * name: string, |
| + * index: number, |
| + * history: boolean, |
| + * favorites: boolean, |
| + * passwords: boolean, |
| + * search: boolean, |
| + * autofillFormData: boolean, |
| + * }} |
| + */ |
| +settings.BrowserProfile; |
| + |
| +/** |
| + * @enum {string} |
| + */ |
| +settings.ImportDataStatus = { |
| + INITIAL: 'initial', |
| + 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.
|
| + SUCCEEDED: 'succeeded', |
| + FAILED: 'failed', |
| +}; |
| + |
| +cr.define('settings', function() { |
| + /** @interface */ |
| + function ImportDataBrowserProxy() {} |
| + |
| + ImportDataBrowserProxy.prototype = { |
| + /** |
| + * 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.
|
| + * @return {!Promise<!Array<!settings.BrowserProfile>>} |
| + */ |
| + initializeImportDialog: function() {}, |
| + |
| + /** |
| + * Starts importing data for the specificed source browser profile. The C++ |
| + * responds with the 'import-data-status-changed' WebUIListener event. |
| + * @param {number} sourceBrowserProfileIndex |
| + */ |
| + importData: function(sourceBrowserProfileIndex) {}, |
| + |
| + /** |
| + * Prompts the user to choose a bookmarks file to import bookmarks from. |
| + */ |
| + importFromBookmarksFile: function() {}, |
| + }; |
| + |
| + /** |
| + * @constructor |
| + * @implements {settings.ImportDataBrowserProxy} |
| + */ |
| + function ImportDataBrowserProxyImpl() {} |
| + // The singleton instance_ is replaced with a test version of this wrapper |
| + // during testing. |
| + cr.addSingletonGetter(ImportDataBrowserProxyImpl); |
| + |
| + ImportDataBrowserProxyImpl.prototype = { |
| + /** @override */ |
| + initializeImportDialog: function() { |
| + return cr.sendWithPromise('initializeImportDialog'); |
| + }, |
| + |
| + /** @override */ |
| + importData: function(sourceBrowserProfileIndex) { |
| + chrome.send('importData', [sourceBrowserProfileIndex]); |
| + }, |
| + |
| + /** @override */ |
| + importFromBookmarksFile: function() { |
| + chrome.send('importFromBookmarksFile'); |
| + }, |
| + }; |
| + |
| + return { |
| + ImportDataBrowserProxy: ImportDataBrowserProxy, |
| + ImportDataBrowserProxyImpl: ImportDataBrowserProxyImpl, |
| + }; |
| +}); |