OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 /** | 5 /** |
6 * The base class that should be extended by all HTML applications. | 6 * The base class that should be extended by all HTML applications. |
7 * | 7 * |
8 * It should both be easy to use for users coming over from JavaScript, but | 8 * It should both be easy to use for users coming over from JavaScript, but |
9 * also offer a clear notion of OO encapsulation. | 9 * also offer a clear notion of OO encapsulation. |
10 * | 10 * |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 } | 80 } |
81 | 81 |
82 print('App cache update ready, now swapping...'); | 82 print('App cache update ready, now swapping...'); |
83 window.applicationCache.swapCache(); | 83 window.applicationCache.swapCache(); |
84 print('App cache swapped, now reloading page...'); | 84 print('App cache swapped, now reloading page...'); |
85 window.location.reload(); | 85 window.location.reload(); |
86 return true; | 86 return true; |
87 } | 87 } |
88 | 88 |
89 /** Returns true if we are running as a packaged application. */ | 89 /** Returns true if we are running as a packaged application. */ |
90 static bool get isPackaged() { | 90 static bool get isPackaged { |
91 return window.location.protocol == 'chrome-extension:'; | 91 return window.location.protocol == 'chrome-extension:'; |
92 } | 92 } |
93 | 93 |
94 /** | 94 /** |
95 * Gets the server URL. This is needed when we are loaded from a packaged | 95 * Gets the server URL. This is needed when we are loaded from a packaged |
96 * Chrome app. | 96 * Chrome app. |
97 */ | 97 */ |
98 static String serverUrl(String url) { | 98 static String serverUrl(String url) { |
99 if (isPackaged) { | 99 if (isPackaged) { |
100 // TODO(jmesserly): Several problems with this: | 100 // TODO(jmesserly): Several problems with this: |
101 // * How do we authenticate against the server? | 101 // * How do we authenticate against the server? |
102 // * How do we talk to a server other than thump? | 102 // * How do we talk to a server other than thump? |
103 assert(url.startsWith('/')); | 103 assert(url.startsWith('/')); |
104 return 'http://thump.googleplex.com$url'; | 104 return 'http://thump.googleplex.com$url'; |
105 } else { | 105 } else { |
106 return url; | 106 return url; |
107 } | 107 } |
108 } | 108 } |
109 } | 109 } |
OLD | NEW |