Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2270)

Unified Diff: chrome/browser/resources/settings/search_page/search_page.js

Issue 1096143003: Add chrome.searchEnginesPrivate API and Search Settings page. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update OWNERS Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/settings/search_page/search_page.js
diff --git a/chrome/browser/resources/settings/search_page/search_page.js b/chrome/browser/resources/settings/search_page/search_page.js
new file mode 100644
index 0000000000000000000000000000000000000000..22deceb4311ab21aba8574a6595dd32f8bc8d145
--- /dev/null
+++ b/chrome/browser/resources/settings/search_page/search_page.js
@@ -0,0 +1,119 @@
+// Copyright 2015 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
+ * 'cr-settings-search-page' is the settings page containing search settings.
+ *
+ * Example:
+ *
+ * <core-animated-pages>
+ * <cr-settings-search-page prefs="{{prefs}}"></cr-settings-search-page>
+ * ... other pages ...
+ * </core-animated-pages>
+ *
+ * @group Chrome Settings Elements
+ * @element cr-settings-search-page
+ */
+Polymer('cr-settings-search-page', {
+ publish: {
+ /**
+ * Preferences state.
+ *
+ * @attribute prefs
+ * @type {CrSettingsPrefsElement}
+ * @default null
+ */
+ prefs: null,
+
+ /**
+ * Whether the page is a subpage.
+ *
+ * @attribute subpage
+ * @type {boolean}
+ * @default false
+ */
+ subpage: false,
+
+ /**
+ * ID of the page.
+ *
+ * @attribute PAGE_ID
+ * @const {string}
+ * @default 'search'
+ */
+ PAGE_ID: 'search',
+
+ /**
+ * Title for the page header and navigation menu.
+ *
+ * @attribute pageTitle
+ * @type {string}
+ */
+ pageTitle: loadTimeData.getString('searchPageTitle'),
+
+ /**
+ * Name of the 'core-icon' to be shown in the settings-page-header.
+ *
+ * @attribute icon
+ * @type {string}
+ * @default 'search'
+ */
+ icon: 'search',
+
+ /**
+ * List of default search engines available.
+ *
+ * @attribute searchEngines
+ * @type {Array<!SearchEngine}
+ * @default null
+ */
+ searchEngines: null,
+
+ /**
+ * GUID of the currently selected default search engine.
+ *
+ * @attribute defaultEngineGuid
+ * @type {string}
+ * @default ''
+ */
+ defaultEngineGuid: '',
+ },
+
+ /** @override */
+ created: function() {
+ this.searchEngines = [];
+ },
+
+ /** @override */
+ domReady: function() {
+ chrome.searchEnginesPrivate.onDefaultSearchEnginesChanged.addListener(
+ this.updateSearchEngines_.bind(this));
+ chrome.searchEnginesPrivate.getDefaultSearchEngines(
+ this.updateSearchEngines_.bind(this));
+ },
+
+ /**
+ * Persists the new default search engine back to Chrome. Called when the
+ * user selects a new default in the search engines dropdown.
+ */
+ defaultEngineGuidChanged: function() {
+ chrome.searchEnginesPrivate.setSelectedSearchEngine(this.defaultEngineGuid);
+ },
+
+
+ /**
+ * Updates the list of search engines with the given |engines|.
+ * @param {!Array<!SearchEngine>} engines
+ * @private
+ */
+ updateSearchEngines_: function(engines) {
+ this.searchEngines = engines;
+ for (var i = 0; i < engines.length; i++) {
+ if (engines[i].isSelected) {
+ this.defaultEngineGuid = engines[i].guid;
+ }
+ }
+ }
+});

Powered by Google App Engine
This is Rietveld 408576698