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

Side by Side Diff: chrome/browser/ui/webui/chromeos/login/controller_pairing_screen_handler.cc

Issue 326933004: Example of usage of new features of context and screen. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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/controller_pairing_screen_handl er.h"
6
7 #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h"
8 #include "content/public/browser/web_contents.h"
9
10 namespace chromeos {
11
12 namespace {
13
14 const char kJsScreenPath[] = "login.ControllerPairingScreen";
15
16 const char kMethodContextChanged[] = "contextChanged";
17
18 const char kCallbackButtonClicked[] = "buttonClicked";
19 const char kCallbackContextChanged[] = "contextChanged";
20
21 } // namespace
22
23 ControllerPairingScreenHandler::ControllerPairingScreenHandler()
24 : BaseScreenHandler(kJsScreenPath), delegate_(NULL), show_on_init_(false) {
25 }
26
27 ControllerPairingScreenHandler::~ControllerPairingScreenHandler() {
28 if (delegate_)
29 delegate_->OnActorDestroyed(this);
30 }
31
32 void ControllerPairingScreenHandler::HandleButtonClicked(
33 const std::string& action) {
34 if (!delegate_)
35 return;
36 delegate_->OnButtonClicked(action);
37 }
38
39 void ControllerPairingScreenHandler::HandleContextChanged(
40 const base::DictionaryValue* diff) {
41 if (!delegate_)
42 return;
43 delegate_->OnScreenContextChanged(*diff);
44 }
45
46 void ControllerPairingScreenHandler::Initialize() {
47 if (!page_is_ready() || !delegate_)
48 return;
49
50 if (show_on_init_) {
51 Show();
52 show_on_init_ = false;
53 }
54 }
55
56 void ControllerPairingScreenHandler::DeclareLocalizedValues(
57 LocalizedValuesBuilder* builder) {
58 }
59
60 void ControllerPairingScreenHandler::RegisterMessages() {
61 AddPrefixedCallback(kCallbackButtonClicked,
62 &ControllerPairingScreenHandler::HandleButtonClicked);
63 AddPrefixedCallback(kCallbackContextChanged,
64 &ControllerPairingScreenHandler::HandleContextChanged);
65 }
66
67 void ControllerPairingScreenHandler::Show() {
68 if (!page_is_ready()) {
69 show_on_init_ = true;
70 return;
71 }
72 ShowScreen(OobeUI::kScreenControllerPairing, NULL);
73 }
74
75 void ControllerPairingScreenHandler::Hide() {
76 }
77
78 void ControllerPairingScreenHandler::SetDelegate(Delegate* delegate) {
79 delegate_ = delegate;
80 if (page_is_ready())
81 Initialize();
82 }
83
84 void ControllerPairingScreenHandler::OnContextChanged(
85 const base::DictionaryValue& diff) {
86 CallJS(kMethodContextChanged, diff);
87 }
88
89 content::BrowserContext* ControllerPairingScreenHandler::GetBrowserContext() {
90 return web_ui()->GetWebContents()->GetBrowserContext();
91 }
92
93 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698