Chromium Code Reviews| OLD | NEW |
|---|---|
| 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('inline', function() { | 5 cr.define('inline', 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 var sections = document.querySelectorAll('.section.expandable'); | 24 var sections = document.querySelectorAll('.section.expandable'); |
| 19 sections.forEach(function(section) { | 25 sections.forEach(function(section) { |
| 20 section.classList.toggle('expanded'); | 26 section.classList.toggle('expanded'); |
| 21 }); | 27 }); |
| 22 } | 28 } |
| 23 } | 29 } |
| 24 | 30 |
| 25 function computeClasses(isCombined) { | |
| 26 if (isCombined) | |
| 27 return 'section expandable expanded'; | |
| 28 return 'section'; | |
| 29 } | |
| 30 | |
| 31 function initialize() { | 31 function initialize() { |
| 32 var app = $('inline-app'); | 32 var app = $('inline-app'); |
| 33 | 33 |
| 34 app.isCombined = window.location.href.includes('variant=combined'); | 34 // Set variables. |
| 35 app.isCombined = false; | |
| 35 | 36 |
| 36 // Set handlers. | 37 // Set handlers. |
| 37 app.computeClasses = computeClasses; | 38 app.computeClasses = computeClasses; |
| 38 app.onContinue = onContinue; | 39 app.onContinue = onContinue; |
| 39 app.onOpenSettings = onOpenSettings; | 40 app.onOpenSettings = onOpenSettings; |
| 40 app.onToggle = onToggle.bind(this, app); | 41 app.onToggle = onToggle.bind(this, app); |
| 42 | |
| 43 // Asynchronously check if Chrome is pinned to the taskbar. | |
| 44 cr.sendWithPromise('handleIsPinnedToTaskbar').then( | |
| 45 function(isPinnedToTaskbar) { | |
| 46 // Show the combined variant if Chrome is not pinned. | |
|
tmartino
2016/10/28 15:18:04
Can we document this in the first place the variab
Patrick Monette
2016/10/28 21:21:37
Done.
| |
| 47 app.isCombined = !isPinnedToTaskbar; | |
| 48 }); | |
| 41 } | 49 } |
| 42 | 50 |
| 43 return { | 51 return { |
| 44 initialize: initialize | 52 initialize: initialize |
| 45 }; | 53 }; |
| 46 }); | 54 }); |
| 47 | 55 |
| 48 document.addEventListener('DOMContentLoaded', inline.initialize); | 56 document.addEventListener('DOMContentLoaded', inline.initialize); |
| OLD | NEW |