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

Unified Diff: chrome/browser/ui/webui/chromeos/login/host_pairing_screen_handler.cc

Issue 581593003: Added 'contextReady' message for HostPairingScreen. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comment addressed. Created 6 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/webui/chromeos/login/host_pairing_screen_handler.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
}
« no previous file with comments | « chrome/browser/ui/webui/chromeos/login/host_pairing_screen_handler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698