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

Side by Side Diff: chrome/browser/resources/welcome/win10/sectioned.js

Issue 2449853008: Determine the Win10-specific Welcome page variant to display (Closed)
Patch Set: Comments Created 4 years, 1 month 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 cr.define('sectioned', function() { 5 cr.define('sectioned', function() {
6 'use strict'; 6 'use strict';
7 7
8 function computeClasses(isCombined) {
9 if (isCombined)
10 return 'section expandable expanded';
11 return 'section';
12 }
13
8 function onContinue() { 14 function onContinue() {
9 chrome.send('handleContinue'); 15 chrome.send('handleContinue');
10 } 16 }
11 17
12 function onOpenSettings() { 18 function onOpenSettings() {
13 chrome.send('handleSetDefaultBrowser'); 19 chrome.send('handleSetDefaultBrowser');
14 } 20 }
15 21
16 function onToggle(app) { 22 function onToggle(app) {
17 if (app.isCombined) { 23 if (app.isCombined) {
18 // Toggle sections. 24 // Toggle sections.
19 var sections = document.querySelectorAll('.section.expandable'); 25 var sections = document.querySelectorAll('.section.expandable');
20 sections.forEach(function(section) { 26 sections.forEach(function(section) {
21 section.classList.toggle('expanded'); 27 section.classList.toggle('expanded');
22 }); 28 });
23 // Toggle screenshots. 29 // Toggle screenshots.
24 var screenshots = document.querySelectorAll('.screenshot-image'); 30 var screenshots = document.querySelectorAll('.screenshot-image');
25 screenshots.forEach(function(screenshot) { 31 screenshots.forEach(function(screenshot) {
26 screenshot.classList.toggle('hidden'); 32 screenshot.classList.toggle('hidden');
27 }); 33 });
28 } 34 }
29 } 35 }
30 36
31 function computeClasses(isCombined) {
32 if (isCombined)
33 return 'section expandable expanded';
34 return 'section';
35 }
36
37 function initialize() { 37 function initialize() {
38 var app = $('sectioned-app'); 38 var app = $('sectioned-app');
39 39
40 app.isCombined = window.location.href.includes('variant=combined'); 40 // Set variables.
41 // Determines if the combined variant should be displayed. The combined
42 // variant includes instructions on how to pin Chrome to the taskbar.
43 app.isCombined = false;
41 44
42 // Set handlers. 45 // Set handlers.
43 app.computeClasses = computeClasses; 46 app.computeClasses = computeClasses;
44 app.onContinue = onContinue; 47 app.onContinue = onContinue;
45 app.onOpenSettings = onOpenSettings; 48 app.onOpenSettings = onOpenSettings;
46 app.onToggle = onToggle.bind(this, app); 49 app.onToggle = onToggle.bind(this, app);
50
51
52 // Asynchronously check if Chrome is pinned to the taskbar.
53 cr.sendWithPromise('getPinnedToTaskbarState').then(
54 function(isPinnedToTaskbar) {
55 // Allow overriding of the result via a query parameter.
56 // TODO(pmonette): Remove these checks when they are no longer needed.
57 var params = new URLSearchParams(location.search.slice(1));
58 if (params.has('variant')) {
59 if (params.get('variant') === 'defaultonly')
60 app.isCombined = false;
61 if (params.get('variant') === 'combined')
michaelpg 2016/11/04 23:59:24 (same)
62 app.isCombined = true;
63 } else {
64 app.isCombined = !isPinnedToTaskbar;
65 }
66 });
47 } 67 }
48 68
49 return { 69 return {
50 initialize: initialize 70 initialize: initialize
51 }; 71 };
52 }); 72 });
53 73
54 document.addEventListener('DOMContentLoaded', sectioned.initialize); 74 document.addEventListener('DOMContentLoaded', sectioned.initialize);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698