| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/ui/webui/chromeos/login/host_pairing_screen_handler.h" | 5 #include "chrome/browser/ui/webui/chromeos/login/host_pairing_screen_handler.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
| 9 #include "chrome/browser/chromeos/login/oobe_screen.h" | 9 #include "chrome/browser/chromeos/login/oobe_screen.h" |
| 10 #include "chrome/grit/generated_resources.h" | 10 #include "chrome/grit/generated_resources.h" |
| 11 #include "chromeos/chromeos_switches.h" | 11 #include "chromeos/chromeos_switches.h" |
| 12 #include "components/login/localized_values_builder.h" | 12 #include "components/login/localized_values_builder.h" |
| 13 | 13 |
| 14 namespace chromeos { | 14 namespace chromeos { |
| 15 | 15 |
| 16 namespace { | 16 namespace { |
| 17 | 17 |
| 18 const char kJsScreenPath[] = "login.HostPairingScreen"; | 18 const char kJsScreenPath[] = "login.HostPairingScreen"; |
| 19 | 19 |
| 20 const char kMethodContextChanged[] = "contextChanged"; | 20 const char kMethodContextChanged[] = "contextChanged"; |
| 21 | 21 |
| 22 // Sent from JS when screen is ready to receive context updates. | 22 // Sent from JS when screen is ready to receive context updates. |
| 23 // TODO(dzhioev): Move 'contextReady' logic to the base screen handler when | 23 // TODO(dzhioev): Move 'contextReady' logic to the base screen handler when |
| 24 // all screens migrate to context-based communications. | 24 // all screens migrate to context-based communications. |
| 25 const char kCallbackContextReady[] = "contextReady"; | 25 const char kCallbackContextReady[] = "contextReady"; |
| 26 | 26 |
| 27 } // namespace | 27 } // namespace |
| 28 | 28 |
| 29 HostPairingScreenHandler::HostPairingScreenHandler() { | 29 HostPairingScreenHandler::HostPairingScreenHandler() |
| 30 : BaseScreenHandler(kScreenId) { |
| 30 set_call_js_prefix(kJsScreenPath); | 31 set_call_js_prefix(kJsScreenPath); |
| 31 } | 32 } |
| 32 | 33 |
| 33 HostPairingScreenHandler::~HostPairingScreenHandler() { | 34 HostPairingScreenHandler::~HostPairingScreenHandler() { |
| 34 if (delegate_) | 35 if (delegate_) |
| 35 delegate_->OnViewDestroyed(this); | 36 delegate_->OnViewDestroyed(this); |
| 36 } | 37 } |
| 37 | 38 |
| 38 void HostPairingScreenHandler::HandleContextReady() { | 39 void HostPairingScreenHandler::HandleContextReady() { |
| 39 js_context_ready_ = true; | 40 js_context_ready_ = true; |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 void HostPairingScreenHandler::RegisterMessages() { | 89 void HostPairingScreenHandler::RegisterMessages() { |
| 89 AddPrefixedCallback(kCallbackContextReady, | 90 AddPrefixedCallback(kCallbackContextReady, |
| 90 &HostPairingScreenHandler::HandleContextReady); | 91 &HostPairingScreenHandler::HandleContextReady); |
| 91 } | 92 } |
| 92 | 93 |
| 93 void HostPairingScreenHandler::Show() { | 94 void HostPairingScreenHandler::Show() { |
| 94 if (!page_is_ready()) { | 95 if (!page_is_ready()) { |
| 95 show_on_init_ = true; | 96 show_on_init_ = true; |
| 96 return; | 97 return; |
| 97 } | 98 } |
| 98 ShowScreen(OobeScreen::SCREEN_OOBE_HOST_PAIRING); | 99 ShowScreen(kScreenId); |
| 99 } | 100 } |
| 100 | 101 |
| 101 void HostPairingScreenHandler::Hide() { | 102 void HostPairingScreenHandler::Hide() { |
| 102 } | 103 } |
| 103 | 104 |
| 104 void HostPairingScreenHandler::SetDelegate(Delegate* delegate) { | 105 void HostPairingScreenHandler::SetDelegate(Delegate* delegate) { |
| 105 delegate_ = delegate; | 106 delegate_ = delegate; |
| 106 if (page_is_ready()) | 107 if (page_is_ready()) |
| 107 Initialize(); | 108 Initialize(); |
| 108 } | 109 } |
| 109 | 110 |
| 110 void HostPairingScreenHandler::OnContextChanged( | 111 void HostPairingScreenHandler::OnContextChanged( |
| 111 const base::DictionaryValue& diff) { | 112 const base::DictionaryValue& diff) { |
| 112 if (!js_context_ready_) { | 113 if (!js_context_ready_) { |
| 113 context_cache_.ApplyChanges(diff, NULL); | 114 context_cache_.ApplyChanges(diff, NULL); |
| 114 return; | 115 return; |
| 115 } | 116 } |
| 116 CallJS(kMethodContextChanged, diff); | 117 CallJS(kMethodContextChanged, diff); |
| 117 } | 118 } |
| 118 | 119 |
| 119 } // namespace chromeos | 120 } // namespace chromeos |
| OLD | NEW |