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

Side by Side Diff: chrome/browser/resources/hotword_helper/manager.js

Issue 212253003: [Hotword] Update helper extension to listen for change to audio logging preference. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix typo, cleanup Created 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/resources/hotword_helper/optin_client.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2014 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 'use strict'; 5 'use strict';
6 6
7 /** 7 /**
8 * @fileoverview This extension manages communications between Chrome, 8 * @fileoverview This extension manages communications between Chrome,
9 * Google.com pages and the Chrome Hotword extension. 9 * Google.com pages and the Chrome Hotword extension.
10 * 10 *
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 42
43 43
44 /** 44 /**
45 * Commands sent from the page to this content script. 45 * Commands sent from the page to this content script.
46 * @enum {string} 46 * @enum {string}
47 */ 47 */
48 OptInManager.CommandFromPage = { 48 OptInManager.CommandFromPage = {
49 // User has explicitly clicked 'no'. 49 // User has explicitly clicked 'no'.
50 CLICKED_NO_OPTIN: 'hcno', 50 CLICKED_NO_OPTIN: 'hcno',
51 // User has opted in. 51 // User has opted in.
52 CLICKED_OPTIN: 'hco' 52 CLICKED_OPTIN: 'hco',
53 // Audio logging is opted in.
54 AUDIO_LOGGING_ON: 'alon',
55 // Audio logging is opted out.
56 AUDIO_LOGGING_OFF: 'aloff',
53 }; 57 };
54 58
55 59
56 /** 60 /**
57 * Handles a tab being activated / focused on. 61 * Handles a tab being activated / focused on.
58 * @param {{tabId: number}} info Information about the activated tab. 62 * @param {{tabId: number}} info Information about the activated tab.
59 * @private 63 * @private
60 */ 64 */
61 OptInManager.prototype.handleActivatedTab_ = function(info) { 65 OptInManager.prototype.handleActivatedTab_ = function(info) {
62 chrome.tabs.get(info.tabId, this.preInjectTab_.bind(this)); 66 chrome.tabs.get(info.tabId, this.preInjectTab_.bind(this));
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 chrome.hotwordPrivate.setEnabled(true); 154 chrome.hotwordPrivate.setEnabled(true);
151 this.preInjectTab_(sender.tab); 155 this.preInjectTab_(sender.tab);
152 } 156 }
153 } 157 }
154 // User has explicitly clicked 'no thanks'. 158 // User has explicitly clicked 'no thanks'.
155 if (request.type === OptInManager.CommandFromPage.CLICKED_NO_OPTIN) { 159 if (request.type === OptInManager.CommandFromPage.CLICKED_NO_OPTIN) {
156 if (chrome.hotwordPrivate && chrome.hotwordPrivate.setEnabled) { 160 if (chrome.hotwordPrivate && chrome.hotwordPrivate.setEnabled) {
157 chrome.hotwordPrivate.setEnabled(false); 161 chrome.hotwordPrivate.setEnabled(false);
158 } 162 }
159 } 163 }
164 // Information regarding the audio logging preference was sent.
165 if (request.type === OptInManager.CommandFromPage.AUDIO_LOGGING_ON) {
166 if (chrome.hotwordPrivate &&
167 chrome.hotwordPrivate.setAudioLoggingEnabled) {
168 chrome.hotwordPrivate.setAudioLoggingEnabled(true);
169 chrome.runtime.sendMessage(
170 OptInManager.HOTWORD_EXTENSION_ID_,
171 {'cmd': OptInManager.CommandFromHelper.AUDIO_LOGGING_ON});
172 }
173 }
174 if (request.type === OptInManager.CommandFromPage.AUDIO_LOGGING_OFF) {
175 if (chrome.hotwordPrivate &&
176 chrome.hotwordPrivate.setAudioLoggingEnabled) {
177 chrome.hotwordPrivate.setAudioLoggingEnabled(false);
178 chrome.runtime.sendMessage(
179 OptInManager.HOTWORD_EXTENSION_ID_,
180 {'cmd': OptInManager.CommandFromHelper.AUDIO_LOGGING_OFF});
181 }
182 }
160 } 183 }
161 }; 184 };
162 185
163 186
164 /** 187 /**
165 * Determines if a URL is eligible for hotwording. For now, the 188 * Determines if a URL is eligible for hotwording. For now, the
166 * valid pages are the Google HP and SERP (this will include the NTP). 189 * valid pages are the Google HP and SERP (this will include the NTP).
167 * @param {string} url Url to check. 190 * @param {string} url Url to check.
168 * @return {boolean} True if url is eligible hotword url. 191 * @return {boolean} True if url is eligible hotword url.
169 */ 192 */
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 chrome.runtime.onMessage.addListener(this.handleMessage_.bind(this)); 225 chrome.runtime.onMessage.addListener(this.handleMessage_.bind(this));
203 226
204 if (chrome.hotwordPrivate && chrome.hotwordPrivate.onEnabledChanged) { 227 if (chrome.hotwordPrivate && chrome.hotwordPrivate.onEnabledChanged) {
205 chrome.hotwordPrivate.onEnabledChanged.addListener( 228 chrome.hotwordPrivate.onEnabledChanged.addListener(
206 this.handleEnabledChange_.bind(this)); 229 this.handleEnabledChange_.bind(this));
207 } 230 }
208 }; 231 };
209 232
210 233
211 new OptInManager().initialize(); 234 new OptInManager().initialize();
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/resources/hotword_helper/optin_client.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698