OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "chrome/browser/chromeos/login/screens/update_screen.h" | 5 #include "chrome/browser/chromeos/login/screens/update_screen.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
11 #include "base/file_util.h" | 11 #include "base/file_util.h" |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/message_loop.h" | 13 #include "base/message_loop.h" |
14 #include "base/threading/thread_restrictions.h" | 14 #include "base/threading/thread_restrictions.h" |
15 #include "chrome/browser/chromeos/cros/cros_library.h" | |
16 #include "chrome/browser/chromeos/cros/network_library.h" | |
17 #include "chrome/browser/chromeos/login/screens/error_screen.h" | 15 #include "chrome/browser/chromeos/login/screens/error_screen.h" |
18 #include "chrome/browser/chromeos/login/screens/screen_observer.h" | 16 #include "chrome/browser/chromeos/login/screens/screen_observer.h" |
19 #include "chrome/browser/chromeos/login/screens/update_screen_actor.h" | 17 #include "chrome/browser/chromeos/login/screens/update_screen_actor.h" |
20 #include "chrome/browser/chromeos/login/startup_utils.h" | 18 #include "chrome/browser/chromeos/login/startup_utils.h" |
21 #include "chrome/browser/chromeos/login/wizard_controller.h" | 19 #include "chrome/browser/chromeos/login/wizard_controller.h" |
22 #include "chromeos/chromeos_switches.h" | 20 #include "chromeos/chromeos_switches.h" |
23 #include "chromeos/dbus/dbus_thread_manager.h" | 21 #include "chromeos/dbus/dbus_thread_manager.h" |
| 22 #include "chromeos/network/network_state.h" |
24 #include "content/public/browser/browser_thread.h" | 23 #include "content/public/browser/browser_thread.h" |
25 | 24 |
26 using content::BrowserThread; | 25 using content::BrowserThread; |
27 | 26 |
28 namespace chromeos { | 27 namespace chromeos { |
29 | 28 |
30 namespace { | 29 namespace { |
31 | 30 |
32 // Progress bar stages. Each represents progress bar value | 31 // Progress bar stages. Each represents progress bar value |
33 // at the beginning of each stage. | 32 // at the beginning of each stage. |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 screen->ExitUpdate(UpdateScreen::REASON_UPDATE_INIT_FAILED); | 76 screen->ExitUpdate(UpdateScreen::REASON_UPDATE_INIT_FAILED); |
78 } | 77 } |
79 } | 78 } |
80 | 79 |
81 // Returns true if blocking AU is enabled in command line. | 80 // Returns true if blocking AU is enabled in command line. |
82 bool IsBlockingUpdateEnabledInCommandLine() { | 81 bool IsBlockingUpdateEnabledInCommandLine() { |
83 return !CommandLine::ForCurrentProcess()->HasSwitch( | 82 return !CommandLine::ForCurrentProcess()->HasSwitch( |
84 chromeos::switches::kDisableOOBEBlockingUpdate); | 83 chromeos::switches::kDisableOOBEBlockingUpdate); |
85 } | 84 } |
86 | 85 |
87 // TODO (ygorshenin@): switch over to use NetworkStateHandler. | |
88 const Network* GetDefaultNetwork() { | |
89 CrosLibrary* cros = CrosLibrary::Get(); | |
90 if (!cros) | |
91 return NULL; | |
92 NetworkLibrary* network_library = cros->GetNetworkLibrary(); | |
93 if (!network_library) | |
94 return NULL; | |
95 return network_library->active_network(); | |
96 } | |
97 | |
98 } // anonymous namespace | 86 } // anonymous namespace |
99 | 87 |
100 // static | 88 // static |
101 UpdateScreen::InstanceSet& UpdateScreen::GetInstanceSet() { | 89 UpdateScreen::InstanceSet& UpdateScreen::GetInstanceSet() { |
102 CR_DEFINE_STATIC_LOCAL(std::set<UpdateScreen*>, instance_set, ()); | 90 CR_DEFINE_STATIC_LOCAL(std::set<UpdateScreen*>, instance_set, ()); |
103 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); // not threadsafe. | 91 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); // not threadsafe. |
104 return instance_set; | 92 return instance_set; |
105 } | 93 } |
106 | 94 |
107 // static | 95 // static |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 case UpdateEngineClient::UPDATE_STATUS_REPORTING_ERROR_EVENT: | 233 case UpdateEngineClient::UPDATE_STATUS_REPORTING_ERROR_EVENT: |
246 ExitUpdate(REASON_UPDATE_ENDED); | 234 ExitUpdate(REASON_UPDATE_ENDED); |
247 break; | 235 break; |
248 default: | 236 default: |
249 NOTREACHED(); | 237 NOTREACHED(); |
250 break; | 238 break; |
251 } | 239 } |
252 } | 240 } |
253 | 241 |
254 void UpdateScreen::OnPortalDetectionCompleted( | 242 void UpdateScreen::OnPortalDetectionCompleted( |
255 const Network* network, | 243 const NetworkState* network, |
256 const NetworkPortalDetector::CaptivePortalState& state) { | 244 const NetworkPortalDetector::CaptivePortalState& state) { |
257 LOG(WARNING) << "UpdateScreen::PortalDetectionCompleted(): " | 245 LOG(WARNING) << "UpdateScreen::PortalDetectionCompleted(): " |
258 << "network=" << (network ? network->service_path() : "") << ", " | 246 << "network=" << (network ? network->path() : "") << ", " |
259 << "state.status=" << state.status << ", " | 247 << "state.status=" << state.status << ", " |
260 << "state.response_code=" << state.response_code; | 248 << "state.response_code=" << state.response_code; |
261 | 249 |
262 // Wait for the sane detection results. | 250 // Wait for the sane detection results. |
263 if (network && | 251 if (network && |
264 state.status == NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_UNKNOWN) { | 252 state.status == NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_UNKNOWN) { |
265 return; | 253 return; |
266 } | 254 } |
267 | 255 |
268 // Restart portal detection for the first notification about offline state. | 256 // Restart portal detection for the first notification about offline state. |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
510 GetErrorScreen()->SetUIState(ErrorScreen::UI_STATE_UPDATE); | 498 GetErrorScreen()->SetUIState(ErrorScreen::UI_STATE_UPDATE); |
511 get_screen_observer()->ShowErrorScreen(); | 499 get_screen_observer()->ShowErrorScreen(); |
512 } | 500 } |
513 | 501 |
514 void UpdateScreen::HideErrorMessage() { | 502 void UpdateScreen::HideErrorMessage() { |
515 LOG(WARNING) << "UpdateScreen::HideErrorMessage()"; | 503 LOG(WARNING) << "UpdateScreen::HideErrorMessage()"; |
516 get_screen_observer()->HideErrorScreen(this); | 504 get_screen_observer()->HideErrorScreen(this); |
517 } | 505 } |
518 | 506 |
519 void UpdateScreen::UpdateErrorMessage( | 507 void UpdateScreen::UpdateErrorMessage( |
520 const Network* network, | 508 const NetworkState* network, |
521 const NetworkPortalDetector::CaptivePortalStatus status) { | 509 const NetworkPortalDetector::CaptivePortalStatus status) { |
522 switch (status) { | 510 switch (status) { |
523 case NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_ONLINE: | 511 case NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_ONLINE: |
524 NOTREACHED(); | 512 NOTREACHED(); |
525 break; | 513 break; |
526 case NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_UNKNOWN: | 514 case NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_UNKNOWN: |
527 case NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_OFFLINE: | 515 case NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_OFFLINE: |
528 GetErrorScreen()->SetErrorState(ErrorScreen::ERROR_STATE_OFFLINE, | 516 GetErrorScreen()->SetErrorState(ErrorScreen::ERROR_STATE_OFFLINE, |
529 std::string()); | 517 std::string()); |
530 break; | 518 break; |
(...skipping 10 matching lines...) Expand all Loading... |
541 GetErrorScreen()->SetErrorState(ErrorScreen::ERROR_STATE_PROXY, | 529 GetErrorScreen()->SetErrorState(ErrorScreen::ERROR_STATE_PROXY, |
542 std::string()); | 530 std::string()); |
543 break; | 531 break; |
544 default: | 532 default: |
545 NOTREACHED(); | 533 NOTREACHED(); |
546 break; | 534 break; |
547 } | 535 } |
548 } | 536 } |
549 | 537 |
550 } // namespace chromeos | 538 } // namespace chromeos |
OLD | NEW |