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

Side by Side Diff: chrome/common/extensions/docs/examples/apps/calculator/app/controller.js

Issue 254473011: Introduce chrome.shell.createWindow stub API for app_shell (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix deps (shell-api) Created 6 years, 7 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
OLDNEW
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
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 }
OLDNEW
« no previous file with comments | « chrome/common/extensions/api/_api_features.json ('k') | chrome/renderer/chrome_content_renderer_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698