| OLD | NEW |
| 1 // Copyright 2016 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 /** | 5 /** |
| 6 * @fileoverview A helper object used from the "Manage search engines" section | 6 * @fileoverview A helper object used from the "Manage search engines" section |
| 7 * to interact with the browser. | 7 * to interact with the browser. |
| 8 */ | 8 */ |
| 9 | 9 |
| 10 /** | 10 /** |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 /** | 28 /** |
| 29 * @typedef {{ | 29 * @typedef {{ |
| 30 * defaults: !Array<!SearchEngine>, | 30 * defaults: !Array<!SearchEngine>, |
| 31 * others: !Array<!SearchEngine>, | 31 * others: !Array<!SearchEngine>, |
| 32 * extensions: !Array<!SearchEngine> | 32 * extensions: !Array<!SearchEngine> |
| 33 * }} | 33 * }} |
| 34 */ | 34 */ |
| 35 var SearchEnginesInfo; | 35 var SearchEnginesInfo; |
| 36 | 36 |
| 37 cr.define('settings', function() { | 37 cr.define('settings', function() { |
| 38 /** @constructor */ | 38 /** @interface */ |
| 39 function SearchEnginesBrowserProxy() {}; | 39 function SearchEnginesBrowserProxy() {} |
| 40 | |
| 41 // The singleton instance_ is replaced with a test version of this wrapper | |
| 42 // during testing. | |
| 43 cr.addSingletonGetter(SearchEnginesBrowserProxy); | |
| 44 | 40 |
| 45 SearchEnginesBrowserProxy.prototype = { | 41 SearchEnginesBrowserProxy.prototype = { |
| 46 /** @param {number} modelIndex */ | 42 /** @param {number} modelIndex */ |
| 47 setDefaultSearchEngine: function(modelIndex) { | 43 setDefaultSearchEngine: function(modelIndex) {}, |
| 48 chrome.send('setDefaultSearchEngine', [modelIndex]); | |
| 49 }, | |
| 50 | 44 |
| 51 /** @param {number} modelIndex */ | 45 /** @param {number} modelIndex */ |
| 52 removeSearchEngine: function(modelIndex) { | 46 removeSearchEngine: function(modelIndex) {}, |
| 53 chrome.send('removeSearchEngine', [modelIndex]); | |
| 54 }, | |
| 55 | 47 |
| 56 /** @param {number} modelIndex */ | 48 /** @param {number} modelIndex */ |
| 57 searchEngineEditStarted: function(modelIndex) { | 49 searchEngineEditStarted: function(modelIndex) {}, |
| 58 chrome.send('searchEngineEditStarted', [modelIndex]); | |
| 59 }, | |
| 60 | 50 |
| 61 searchEngineEditCancelled: function() { | 51 searchEngineEditCancelled: function() {}, |
| 62 chrome.send('searchEngineEditCancelled'); | |
| 63 }, | |
| 64 | 52 |
| 65 /** | 53 /** |
| 66 * @param {string} searchEngine | 54 * @param {string} searchEngine |
| 67 * @param {string} keyword | 55 * @param {string} keyword |
| 68 * @param {string} queryUrl | 56 * @param {string} queryUrl |
| 69 */ | 57 */ |
| 58 searchEngineEditCompleted: function(searchEngine, keyword, queryUrl) {}, |
| 59 |
| 60 /** |
| 61 * @return {!Promise<!SearchEnginesInfo>} |
| 62 */ |
| 63 getSearchEnginesList: function() {}, |
| 64 |
| 65 /** |
| 66 * @param {string} fieldName |
| 67 * @param {string} fieldValue |
| 68 * @return {!Promise<boolean>} |
| 69 */ |
| 70 validateSearchEngineInput: function(fieldName, fieldValue) {}, |
| 71 }; |
| 72 |
| 73 /** |
| 74 * @constructor |
| 75 * @implements {settings.SearchEnginesBrowserProxy} |
| 76 */ |
| 77 function SearchEnginesBrowserProxyImpl() {} |
| 78 // The singleton instance_ is replaced with a test version of this wrapper |
| 79 // during testing. |
| 80 cr.addSingletonGetter(SearchEnginesBrowserProxyImpl); |
| 81 |
| 82 SearchEnginesBrowserProxyImpl.prototype = { |
| 83 /** @override */ |
| 84 setDefaultSearchEngine: function(modelIndex) { |
| 85 chrome.send('setDefaultSearchEngine', [modelIndex]); |
| 86 }, |
| 87 |
| 88 /** @override */ |
| 89 removeSearchEngine: function(modelIndex) { |
| 90 chrome.send('removeSearchEngine', [modelIndex]); |
| 91 }, |
| 92 |
| 93 /** @override */ |
| 94 searchEngineEditStarted: function(modelIndex) { |
| 95 chrome.send('searchEngineEditStarted', [modelIndex]); |
| 96 }, |
| 97 |
| 98 /** @override */ |
| 99 searchEngineEditCancelled: function() { |
| 100 chrome.send('searchEngineEditCancelled'); |
| 101 }, |
| 102 |
| 103 /** @override */ |
| 70 searchEngineEditCompleted: function(searchEngine, keyword, queryUrl) { | 104 searchEngineEditCompleted: function(searchEngine, keyword, queryUrl) { |
| 71 chrome.send('searchEngineEditCompleted', [ | 105 chrome.send('searchEngineEditCompleted', [ |
| 72 searchEngine, keyword, queryUrl, | 106 searchEngine, keyword, queryUrl, |
| 73 ]); | 107 ]); |
| 74 }, | 108 }, |
| 75 | 109 |
| 76 /** | 110 /** @override */ |
| 77 * @return {!Promise<!SearchEnginesInfo>} | |
| 78 */ | |
| 79 getSearchEnginesList: function() { | 111 getSearchEnginesList: function() { |
| 80 return cr.sendWithPromise('getSearchEnginesList'); | 112 return cr.sendWithPromise('getSearchEnginesList'); |
| 81 }, | 113 }, |
| 82 | 114 |
| 83 /** | 115 /** @override */ |
| 84 * @param {string} fieldName | |
| 85 * @param {string} fieldValue | |
| 86 * @return {!Promise<boolean>} | |
| 87 */ | |
| 88 validateSearchEngineInput: function(fieldName, fieldValue) { | 116 validateSearchEngineInput: function(fieldName, fieldValue) { |
| 89 return cr.sendWithPromise( | 117 return cr.sendWithPromise( |
| 90 'validateSearchEngineInput', fieldName, fieldValue); | 118 'validateSearchEngineInput', fieldName, fieldValue); |
| 91 }, | 119 }, |
| 92 }; | 120 }; |
| 93 | 121 |
| 94 return { | 122 return { |
| 95 SearchEnginesBrowserProxy: SearchEnginesBrowserProxy, | 123 SearchEnginesBrowserProxyImpl: SearchEnginesBrowserProxyImpl, |
| 96 }; | 124 }; |
| 97 }); | 125 }); |
| OLD | NEW |