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

Side by Side Diff: chrome/browser/resources/chromeos/login/screen_offline_message.js

Issue 8043024: [cros,webui] Captive portal on login screen proper handling. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: nits2 Created 9 years, 2 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 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 /** 5 /**
6 * @fileoverview Offline message screen implementation. 6 * @fileoverview Offline message screen implementation.
7 */ 7 */
8 8
9 cr.define('login', function() { 9 cr.define('login', function() {
10 // Screens that should have offline message overlay. 10 // Screens that should have offline message overlay.
(...skipping 15 matching lines...) Expand all
26 26
27 // Note that OfflineMessageScreen is not registered with Oobe because 27 // Note that OfflineMessageScreen is not registered with Oobe because
28 // it is shown on top of sign-in screen instead of as an independent screen. 28 // it is shown on top of sign-in screen instead of as an independent screen.
29 }; 29 };
30 30
31 OfflineMessageScreen.prototype = { 31 OfflineMessageScreen.prototype = {
32 __proto__: HTMLDivElement.prototype, 32 __proto__: HTMLDivElement.prototype,
33 33
34 /** @inheritDoc */ 34 /** @inheritDoc */
35 decorate: function() { 35 decorate: function() {
36 window.addEventListener('online', 36 chrome.send('loginAddNetworkStateObserver',
37 this.handleNetworkStateChange_.bind(this)); 37 ['login.OfflineMessageScreen.updateState']);
38 window.addEventListener('offline', 38
39 this.handleNetworkStateChange_.bind(this));
40 cr.ui.DropDown.decorate($('offline-networks-list')); 39 cr.ui.DropDown.decorate($('offline-networks-list'));
41 }, 40 },
42 41
43 onBeforeShow: function() { 42 onBeforeShow: function() {
44 cr.ui.DropDown.setActive('offline-networks-list', true); 43 cr.ui.DropDown.setActive('offline-networks-list', true);
45 }, 44 },
46 45
47 onBeforeHide: function() { 46 onBeforeHide: function() {
48 cr.ui.DropDown.setActive('offline-networks-list', false); 47 cr.ui.DropDown.setActive('offline-networks-list', false);
49 }, 48 },
50 49
50 update: function() {
51 chrome.send('loginRequestNetworkState',
52 ['login.OfflineMessageScreen.updateState']);
53 },
54
51 /** 55 /**
52 * Shows or hides offline message based on network on/offline state. 56 * Shows or hides offline message based on network on/offline state.
53 */ 57 */
54 update: function() { 58 updateState: function(state) {
55 var currentScreen = Oobe.getInstance().currentScreen; 59 var currentScreen = Oobe.getInstance().currentScreen;
56 var offlineMessage = this; 60 var offlineMessage = this;
57 var isOffline = !window.navigator.onLine; 61 var isOnline = state == 1;
62 var isUnderCaptivePortal = state == 2;
58 var shouldOverlay = MANAGED_SCREENS.indexOf(currentScreen.id) != -1; 63 var shouldOverlay = MANAGED_SCREENS.indexOf(currentScreen.id) != -1;
59 64
60 if (isOffline && shouldOverlay) { 65 if (!isOnline && shouldOverlay) {
61 offlineMessage.onBeforeShow(); 66 offlineMessage.onBeforeShow();
62 67
63 $('offline-message-text').hidden = false; 68 $('offline-message-text').hidden = isUnderCaptivePortal;
64 $('captive-portal-message-text').hidden = true; 69 $('captive-portal-message-text').hidden = !isUnderCaptivePortal;
65 70
66 offlineMessage.classList.remove('hidden'); 71 offlineMessage.classList.remove('hidden');
67 offlineMessage.classList.remove('faded'); 72 offlineMessage.classList.remove('faded');
68 73
69 if (!currentScreen.classList.contains('faded')) { 74 if (!currentScreen.classList.contains('faded')) {
70 currentScreen.classList.add('faded'); 75 currentScreen.classList.add('faded');
71 currentScreen.addEventListener('webkitTransitionEnd', 76 currentScreen.addEventListener('webkitTransitionEnd',
72 function f(e) { 77 function f(e) {
73 currentScreen.removeEventListener('webkitTransitionEnd', f); 78 currentScreen.removeEventListener('webkitTransitionEnd', f);
74 if (currentScreen.classList.contains('faded')) 79 if (currentScreen.classList.contains('faded'))
(...skipping 10 matching lines...) Expand all
85 offlineMessage.removeEventListener('webkitTransitionEnd', f); 90 offlineMessage.removeEventListener('webkitTransitionEnd', f);
86 if (offlineMessage.classList.contains('faded')) 91 if (offlineMessage.classList.contains('faded'))
87 offlineMessage.classList.add('hidden'); 92 offlineMessage.classList.add('hidden');
88 }); 93 });
89 94
90 currentScreen.classList.remove('hidden'); 95 currentScreen.classList.remove('hidden');
91 currentScreen.classList.remove('faded'); 96 currentScreen.classList.remove('faded');
92 } 97 }
93 } 98 }
94 }, 99 },
95
96 /**
97 * Handler of online/offline event.
98 */
99 handleNetworkStateChange_: function() {
100 this.update();
101 }
102 }; 100 };
103 101
104 /** 102 /**
103 * Network state changed callback.
104 * @param {Integer} state Current state of the network: 0 - offline;
105 * 1 - online; 2 - under the captive portal.
106 */
107 OfflineMessageScreen.updateState = function(state) {
108 $('offline-message').updateState(state);
109 };
110
111 /**
105 * Handler for iframe's error notification coming from the outside. 112 * Handler for iframe's error notification coming from the outside.
106 * For more info see C++ class 'SnifferObserver' which calls this method. 113 * For more info see C++ class 'SnifferObserver' which calls this method.
107 * @param {number} error Error code. 114 * @param {number} error Error code.
108 */ 115 */
109 OfflineMessageScreen.onFrameError = function(error) { 116 OfflineMessageScreen.onFrameError = function(error) {
110 var currentScreen = Oobe.getInstance().currentScreen; 117 var currentScreen = Oobe.getInstance().currentScreen;
111 var offlineMessage = $('offline-message'); 118 var offlineMessage = $('offline-message');
112 var isOffline = !window.navigator.onLine; 119 var isOffline = !window.navigator.onLine;
113 var shouldOverlay = MANAGED_SCREENS.indexOf(currentScreen.id) != -1; 120 var shouldOverlay = MANAGED_SCREENS.indexOf(currentScreen.id) != -1;
114 121
(...skipping 18 matching lines...) Expand all
133 if (currentScreen.classList.contains('faded')) 140 if (currentScreen.classList.contains('faded'))
134 currentScreen.classList.add('hidden'); 141 currentScreen.classList.add('hidden');
135 }); 142 });
136 } 143 }
137 }; 144 };
138 145
139 return { 146 return {
140 OfflineMessageScreen: OfflineMessageScreen 147 OfflineMessageScreen: OfflineMessageScreen
141 }; 148 };
142 }); 149 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698