OLD | NEW |
1 /** | 1 /** |
2 * Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 * Copyright (c) 2012 The Chromium Authors. All rights reserved. |
3 * Use of this source code is governed by a BSD-style license that can be | 3 * Use of this source code is governed by a BSD-style license that can be |
4 * found in the LICENSE file. | 4 * found in the LICENSE file. |
5 **/ | 5 **/ |
6 | 6 |
7 // Checking for "chrome.app.runtime" availability allows this Chrome app code to | 7 // Checking for "chrome.app.runtime" availability allows this Chrome app code to |
8 // be tested in a regular web page (like tests/manual.html). Checking for | 8 // be tested in a regular web page (like tests/manual.html). Checking for |
9 // "chrome" and "chrome.app" availability further allows this code to be tested | 9 // "chrome" and "chrome.app" availability further allows this code to be tested |
10 // in non-Chrome browsers, which is useful for example to test touch support | 10 // in non-Chrome browsers, which is useful for example to test touch support |
11 // with a non-Chrome touch device. | 11 // with a non-Chrome touch device. |
12 if (typeof chrome !== 'undefined' && chrome.app && chrome.app.runtime) { | 12 if (typeof chrome !== 'undefined' && chrome.app && chrome.app.runtime) { |
| 13 // Compatibility for running under app_shell, which does not have app.window. |
| 14 var createWindow = |
| 15 chrome.shell ? chrome.shell.createWindow : chrome.app.window.create; |
| 16 |
13 var showCalculatorWindow = function () { | 17 var showCalculatorWindow = function () { |
14 chrome.app.window.create('calculator.html', { | 18 createWindow('calculator.html', { |
15 innerBounds: { | 19 innerBounds: { |
16 width: 243, minWidth: 243, maxWidth: 243, | 20 width: 243, minWidth: 243, maxWidth: 243, |
17 height: 380, minHeight: 380, maxHeight: 380 | 21 height: 380, minHeight: 380, maxHeight: 380 |
18 }, | 22 }, |
19 id: 'calculator' | 23 id: 'calculator' |
20 }, function(appWindow) { | 24 }, function(appWindow) { |
21 appWindow.contentWindow.onload = function() { | 25 appWindow.contentWindow.onload = function() { |
22 new Controller(new Model(9), new View(appWindow.contentWindow)); | 26 new Controller(new Model(9), new View(appWindow.contentWindow)); |
23 }; | 27 }; |
24 }); | 28 }); |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 operand: this.getUpdatedValue_(before, after, 'operand', !before.operator) | 101 operand: this.getUpdatedValue_(before, after, 'operand', !before.operator) |
98 }); | 102 }); |
99 return !before.accumulator; | 103 return !before.accumulator; |
100 } | 104 } |
101 | 105 |
102 /** @private */ | 106 /** @private */ |
103 Controller.prototype.getUpdatedValue_ = function(before, after, key, zero) { | 107 Controller.prototype.getUpdatedValue_ = function(before, after, key, zero) { |
104 var value = (typeof after[key] !== 'undefined') ? after[key] : before[key]; | 108 var value = (typeof after[key] !== 'undefined') ? after[key] : before[key]; |
105 return zero ? (value || '0') : value; | 109 return zero ? (value || '0') : value; |
106 } | 110 } |
OLD | NEW |