| Index: chrome/browser/ui/webui/chromeos/login/host_pairing_screen_handler.cc
|
| diff --git a/chrome/browser/ui/webui/chromeos/login/host_pairing_screen_handler.cc b/chrome/browser/ui/webui/chromeos/login/host_pairing_screen_handler.cc
|
| index dda343c5a7e94d586470b7b8de60419bc7e1efa0..6a1ffcb90762ed965a14f0a37dbdc3ebff146b71 100644
|
| --- a/chrome/browser/ui/webui/chromeos/login/host_pairing_screen_handler.cc
|
| +++ b/chrome/browser/ui/webui/chromeos/login/host_pairing_screen_handler.cc
|
| @@ -14,10 +14,18 @@ const char kJsScreenPath[] = "login.HostPairingScreen";
|
|
|
| const char kMethodContextChanged[] = "contextChanged";
|
|
|
| +// Sent from JS when screen is ready to receive context updates.
|
| +// TODO(dzhioev): Move 'contextReady' logic to the base screen handler when
|
| +// all screens migrate to context-based communications.
|
| +const char kCallbackContextReady[] = "contextReady";
|
| +
|
| } // namespace
|
|
|
| HostPairingScreenHandler::HostPairingScreenHandler()
|
| - : BaseScreenHandler(kJsScreenPath), delegate_(NULL), show_on_init_(false) {
|
| + : BaseScreenHandler(kJsScreenPath),
|
| + delegate_(NULL),
|
| + show_on_init_(false),
|
| + js_context_ready_(false) {
|
| }
|
|
|
| HostPairingScreenHandler::~HostPairingScreenHandler() {
|
| @@ -25,6 +33,11 @@ HostPairingScreenHandler::~HostPairingScreenHandler() {
|
| delegate_->OnActorDestroyed(this);
|
| }
|
|
|
| +void HostPairingScreenHandler::HandleContextReady() {
|
| + js_context_ready_ = true;
|
| + OnContextChanged(context_cache_.storage());
|
| +}
|
| +
|
| void HostPairingScreenHandler::Initialize() {
|
| if (!page_is_ready() || !delegate_)
|
| return;
|
| @@ -40,6 +53,8 @@ void HostPairingScreenHandler::DeclareLocalizedValues(
|
| }
|
|
|
| void HostPairingScreenHandler::RegisterMessages() {
|
| + AddPrefixedCallback(kCallbackContextReady,
|
| + &HostPairingScreenHandler::HandleContextReady);
|
| }
|
|
|
| void HostPairingScreenHandler::Show() {
|
| @@ -61,6 +76,10 @@ void HostPairingScreenHandler::SetDelegate(Delegate* delegate) {
|
|
|
| void HostPairingScreenHandler::OnContextChanged(
|
| const base::DictionaryValue& diff) {
|
| + if (!js_context_ready_) {
|
| + context_cache_.ApplyChanges(diff, NULL);
|
| + return;
|
| + }
|
| CallJS(kMethodContextChanged, diff);
|
| }
|
|
|
|
|