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

Side by Side Diff: chrome/browser/resources/hotword_helper/optin_client.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 | « chrome/browser/resources/hotword_helper/manager.js ('k') | no next file » | 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 is the content script injected by the opt in helper. 8 * @fileoverview This is the content script injected by the opt in helper.
9 * It is injected into the newtab page and also google.com and notifies the 9 * It is injected into the newtab page and also google.com and notifies the
10 * page to show an opt-in message for the user to enable the built-in hotword 10 * page to show an opt-in message for the user to enable the built-in hotword
(...skipping 17 matching lines...) Expand all
28 28
29 29
30 /** 30 /**
31 * Commands sent from the page to this content script. 31 * Commands sent from the page to this content script.
32 * @enum {string} 32 * @enum {string}
33 */ 33 */
34 OptInClient.CommandFromPage = { 34 OptInClient.CommandFromPage = {
35 // User has explicitly clicked 'no'. 35 // User has explicitly clicked 'no'.
36 CLICKED_NO_OPTIN: 'hcno', 36 CLICKED_NO_OPTIN: 'hcno',
37 // User has opted in. 37 // User has opted in.
38 CLICKED_OPTIN: 'hco' 38 CLICKED_OPTIN: 'hco',
39 // Audio logging is opted in.
40 AUDIO_LOGGING_ON: 'alon',
41 // Audio logging is opted out.
42 AUDIO_LOGGING_OFF: 'aloff',
39 }; 43 };
40 44
41 45
42 /** 46 /**
43 * Used to determine if this content script has already been injected. 47 * Used to determine if this content script has already been injected.
44 * @const {string} 48 * @const {string}
45 * @private 49 * @private
46 */ 50 */
47 OptInClient.EXISTS_ = 'chwoihe'; 51 OptInClient.EXISTS_ = 'chwoihe';
48 52
49 53
50 /** 54 /**
51 * Handles the messages posted to the window, mainly listening for 55 * Handles the messages posted to the window, mainly listening for
52 * the optin and no optin clicks. 56 * the optin and no optin clicks. Also listening for preference on
57 * audio logging.
53 * @param {!MessageEvent} messageEvent Message event from the window. 58 * @param {!MessageEvent} messageEvent Message event from the window.
54 * @private 59 * @private
55 */ 60 */
56 OptInClient.prototype.handleCommandFromPage_ = function(messageEvent) { 61 OptInClient.prototype.handleCommandFromPage_ = function(messageEvent) {
57 if (messageEvent.source === window && messageEvent.data.type) { 62 if (messageEvent.source === window && messageEvent.data.type) {
58 var command = messageEvent.data.type; 63 var command = messageEvent.data.type;
59 switch (command) { 64 chrome.runtime.sendMessage({'type': command});
60 case OptInClient.CommandFromPage.CLICKED_OPTIN:
61 chrome.runtime.sendMessage(
62 {'type': command});
63 break;
64 case OptInClient.CommandFromPage.CLICKED_NO_OPTIN:
65 chrome.runtime.sendMessage(
66 {'type': command});
67 break;
68 }
69 } 65 }
70 }; 66 };
71 67
72 68
73 /** 69 /**
74 * Sends a command to the page allowing it to display the hotword opt-in 70 * Sends a command to the page allowing it to display the hotword opt-in
75 * message. It is up to the page whether it is actually displayed. 71 * message. It is up to the page whether it is actually displayed.
76 * @private 72 * @private
77 */ 73 */
78 OptInClient.prototype.notifyPageAllowOptIn_ = function() { 74 OptInClient.prototype.notifyPageAllowOptIn_ = function() {
(...skipping 15 matching lines...) Expand all
94 'message', this.handleCommandFromPage_.bind(this), false); 90 'message', this.handleCommandFromPage_.bind(this), false);
95 91
96 if (document.readyState === 'complete') 92 if (document.readyState === 'complete')
97 this.notifyPageAllowOptIn_(); 93 this.notifyPageAllowOptIn_();
98 else 94 else
99 document.onreadystatechange = this.notifyPageAllowOptIn_; 95 document.onreadystatechange = this.notifyPageAllowOptIn_;
100 }; 96 };
101 97
102 98
103 new OptInClient().initialize(); 99 new OptInClient().initialize();
OLDNEW
« no previous file with comments | « chrome/browser/resources/hotword_helper/manager.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698