Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / ui / webui / chromeos / login / host_pairing_screen_handler.cc
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/ui/webui/chromeos/login/host_pairing_screen_handler.h"
6
7 #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h"
8
9 namespace chromeos {
10
11 namespace {
12
13 const char kJsScreenPath[] = "login.HostPairingScreen";
14
15 const char kMethodContextChanged[] = "contextChanged";
16
17 }  // namespace
18
19 HostPairingScreenHandler::HostPairingScreenHandler()
20     : BaseScreenHandler(kJsScreenPath), delegate_(NULL), show_on_init_(false) {
21 }
22
23 HostPairingScreenHandler::~HostPairingScreenHandler() {
24   if (delegate_)
25     delegate_->OnActorDestroyed(this);
26 }
27
28 void HostPairingScreenHandler::Initialize() {
29   if (!page_is_ready() || !delegate_)
30     return;
31
32   if (show_on_init_) {
33     Show();
34     show_on_init_ = false;
35   }
36 }
37
38 void HostPairingScreenHandler::DeclareLocalizedValues(
39     LocalizedValuesBuilder* builder) {
40 }
41
42 void HostPairingScreenHandler::RegisterMessages() {
43 }
44
45 void HostPairingScreenHandler::Show() {
46   if (!page_is_ready()) {
47     show_on_init_ = true;
48     return;
49   }
50   ShowScreen(OobeUI::kScreenHostPairing, NULL);
51 }
52
53 void HostPairingScreenHandler::Hide() {
54 }
55
56 void HostPairingScreenHandler::SetDelegate(Delegate* delegate) {
57   delegate_ = delegate;
58   if (page_is_ready())
59     Initialize();
60 }
61
62 void HostPairingScreenHandler::OnContextChanged(
63     const base::DictionaryValue& diff) {
64   CallJS(kMethodContextChanged, diff);
65 }
66
67 }  // namespace chromeos