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

Side by Side Diff: chrome/browser/resources/chromeos/arc_support/background.js

Issue 2104893003: Adds a new checkbox for backup and restore in opt-in flow. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Adds a new checkbox for backup and restore in opt-in flow. Created 4 years, 5 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
OLDNEW
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 * UI Pages. Note the order must be in sync with the ArcAuthService::UIPage 6 * UI Pages. Note the order must be in sync with the ArcAuthService::UIPage
7 * enum. 7 * enum.
8 * @type {Array<string>} 8 * @type {Array<string>}
9 */ 9 */
10 var UI_PAGES = ['none', 10 var UI_PAGES = ['none',
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 * @param {!Object} data Localized strings and relevant information. 83 * @param {!Object} data Localized strings and relevant information.
84 * @param {string} deviceId Current device id. 84 * @param {string} deviceId Current device id.
85 */ 85 */
86 function initialize(data, deviceId) { 86 function initialize(data, deviceId) {
87 currentDeviceId = deviceId; 87 currentDeviceId = deviceId;
88 var doc = appWindow.contentWindow.document; 88 var doc = appWindow.contentWindow.document;
89 var loadTimeData = appWindow.contentWindow.loadTimeData; 89 var loadTimeData = appWindow.contentWindow.loadTimeData;
90 loadTimeData.data = data; 90 loadTimeData.data = data;
91 appWindow.contentWindow.i18nTemplate.process(doc, loadTimeData); 91 appWindow.contentWindow.i18nTemplate.process(doc, loadTimeData);
92 var countryCode = data.countryCode.toLowerCase(); 92 var countryCode = data.countryCode.toLowerCase();
93 setBackupRestoreMode(data.textBackupRestore, true);
khmel 2016/06/28 23:09:54 Remove true? Ideally we should register listener o
malaykeshav 2016/06/29 01:29:06 Done. Not sure what you mean by UMA impl. I have u
xiyuan 2016/06/29 21:36:38 khmel@ means is to observe the pref change: https:
93 94
94 var scriptSetCountryCode = 'document.countryCode = \'' + countryCode + '\';'; 95 var scriptSetCountryCode = 'document.countryCode = \'' + countryCode + '\';';
95 termsView.addContentScripts([ 96 termsView.addContentScripts([
96 { name: 'preProcess', 97 { name: 'preProcess',
97 matches: ['https://play.google.com/*'], 98 matches: ['https://play.google.com/*'],
98 js: { code: scriptSetCountryCode }, 99 js: { code: scriptSetCountryCode },
99 run_at: 'document_start' 100 run_at: 'document_start'
100 }, 101 },
101 { name: 'postProcess', 102 { name: 'postProcess',
102 matches: ['https://play.google.com/*'], 103 matches: ['https://play.google.com/*'],
103 css: { files: ['playstore.css'] }, 104 css: { files: ['playstore.css'] },
104 js: { files: ['playstore.js'] }, 105 js: { files: ['playstore.js'] },
105 run_at: 'document_end' 106 run_at: 'document_end'
106 }]); 107 }]);
107 108
108 // Applying localization changes page layout, update terms height. 109 // Applying localization changes page layout, update terms height.
109 updateTermsHeight(); 110 updateTermsHeight();
110 } 111 }
111 112
112 /** 113 /**
114 * Handles the event when the user clicks on a learn more link. Opens the
115 * support page for the user.
116 * @param {Event} event
117 */
118 var onLearnMore = function(event) {
119 var url = 'https://support.google.com/chromebook?p=playapps';
khmel 2016/06/28 23:09:54 Do we want the same help for both?
malaykeshav 2016/06/29 01:29:06 Yes. https://b.corp.google.com/u/0/issues/28704780
120 chrome.browser.openTab({'url': url}, function() {});
121 event.preventDefault();
122 };
123
124 /**
113 * Sets current metrics mode. 125 * Sets current metrics mode.
114 * @param {string} text Describes current metrics state. 126 * @param {string} text Describes current metrics state.
115 * @param {boolean} canEnable Defines if user is allowed to change this metrics 127 * @param {boolean} canEnable Defines if user is allowed to change this metrics
116 * option. 128 * option.
117 * @param {boolean} on Defines if metrics are active currently. 129 * @param {boolean} on Defines if metrics are active currently.
118 */ 130 */
119 function setMetricsMode(text, canEnable, on) { 131 function setMetricsMode(text, canEnable, on) {
120 var doc = appWindow.contentWindow.document; 132 var doc = appWindow.contentWindow.document;
121 var enableMetrics = doc.getElementById('enable-metrics'); 133 var enableMetrics = doc.getElementById('enable-metrics');
122 enableMetrics.hidden = !canEnable; 134 enableMetrics.hidden = !canEnable;
123 enableMetrics.checked = on; 135 enableMetrics.checked = on;
124 136
125 var onSettings = function(event) { 137 var onSettings = function(event) {
126 chrome.browser.openTab({'url': 'chrome://settings'}, function() {}); 138 chrome.browser.openTab({'url': 'chrome://settings'}, function() {});
127 event.preventDefault(); 139 event.preventDefault();
128 }; 140 };
129 141
130 var onLearnMore = function(event) {
131 var url = 'https://support.google.com/chromebook?p=playapps';
132 chrome.browser.openTab({'url': url}, function() {});
133 event.preventDefault();
134 };
135
136 doc.getElementById('text-metrics').innerHTML = text; 142 doc.getElementById('text-metrics').innerHTML = text;
137 doc.getElementById('settings-link').addEventListener('click', onSettings); 143 doc.getElementById('settings-link').addEventListener('click', onSettings);
138 doc.getElementById('learn-more-link').addEventListener('click', onLearnMore); 144 doc.getElementById('learn-more-link-metrics').addEventListener('click',
145 onLearnMore);
139 146
140 // Applying metrics mode changes page layout, update terms height. 147 // Applying metrics mode changes page layout, update terms height.
141 updateTermsHeight(); 148 updateTermsHeight();
142 } 149 }
143 150
144 /** 151 /**
152 * Sets current metrics mode.
153 * @param {string} text String used to display next to checkbox.
154 * @param {boolean=} isChecked Defines if backup and restore option is active
khmel 2016/06/28 23:09:54 Not sure if '=' is needed.
malaykeshav 2016/06/29 01:29:06 No longer required.
155 * currently. By default the checkbox should be checked.
156 */
157 function setBackupRestoreMode(text, isChecked) {
158 var doc = appWindow.contentWindow.document;
159 var enableBackupRestoreEl = doc.getElementById('enable-backup-restore');
160 enableBackupRestoreEl.checked = isChecked;
161 enableBackupRestoreEl.hidden = false;
khmel 2016/06/28 23:09:54 You always set it visible. I think this is not req
malaykeshav 2016/06/29 01:29:06 Done
162
163 doc.getElementById('text-backup-restore').innerHTML = text;
164 doc.getElementById('learn-more-link-backup-restore').addEventListener('click',
165 onLearnMore);
166 }
167
168 /**
145 * Updates terms view height manually because webview is not automatically 169 * Updates terms view height manually because webview is not automatically
146 * resized in case parent div element gets resized. 170 * resized in case parent div element gets resized.
147 */ 171 */
148 function updateTermsHeight() { 172 function updateTermsHeight() {
149 var setTermsHeight = function() { 173 var setTermsHeight = function() {
150 var doc = appWindow.contentWindow.document; 174 var doc = appWindow.contentWindow.document;
151 var termsContainer = doc.getElementById('terms-container'); 175 var termsContainer = doc.getElementById('terms-container');
152 var style = window.getComputedStyle(termsContainer, null); 176 var style = window.getComputedStyle(termsContainer, null);
153 var height = style.getPropertyValue('height'); 177 var height = style.getPropertyValue('height');
154 termsView.style.height = height; 178 termsView.style.height = height;
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 termsView.addEventListener('newwindow', function(event) { 376 termsView.addEventListener('newwindow', function(event) {
353 event.preventDefault(); 377 event.preventDefault();
354 chrome.browser.openTab({'url': event.targetUrl}, function() {}); 378 chrome.browser.openTab({'url': event.targetUrl}, function() {});
355 }); 379 });
356 380
357 var onAgree = function() { 381 var onAgree = function() {
358 var enableMetrics = doc.getElementById('enable-metrics'); 382 var enableMetrics = doc.getElementById('enable-metrics');
359 if (!enableMetrics.hidden && enableMetrics.checked) { 383 if (!enableMetrics.hidden && enableMetrics.checked) {
360 sendNativeMessage('enableMetrics'); 384 sendNativeMessage('enableMetrics');
361 } 385 }
386
387 var enableBackupRestore = doc.getElementById('enable-backup-restore');
388 if (enableBackupRestore.checked) {
389 sendNativeMessage('enableBackupRestore');
390 }
391
362 sendNativeMessage('startLso'); 392 sendNativeMessage('startLso');
363 }; 393 };
364 394
365 var onCancel = function() { 395 var onCancel = function() {
366 if (appWindow) { 396 if (appWindow) {
367 windowClosedInternally = false; 397 windowClosedInternally = false;
368 appWindow.close(); 398 appWindow.close();
369 appWindow = null; 399 appWindow = null;
370 } 400 }
371 }; 401 };
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 type: 'chrome', 444 type: 'chrome',
415 color: '#ffffff' 445 color: '#ffffff'
416 }, 446 },
417 'innerBounds': { 447 'innerBounds': {
418 'width': 960, 448 'width': 960,
419 'height': 688 449 'height': 688
420 } 450 }
421 }; 451 };
422 chrome.app.window.create('main.html', options, onWindowCreated); 452 chrome.app.window.create('main.html', options, onWindowCreated);
423 }); 453 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698