• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 2013 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/wrong_hwid_screen_handler.h"
6 
7 #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h"
8 #include "chrome/grit/generated_resources.h"
9 
10 namespace {
11 
12 const char kJsScreenPath[] = "login.WrongHWIDScreen";
13 
14 }  // namespace
15 
16 namespace chromeos {
17 
WrongHWIDScreenHandler()18 WrongHWIDScreenHandler::WrongHWIDScreenHandler()
19     : BaseScreenHandler(kJsScreenPath),
20       delegate_(NULL),
21       show_on_init_(false) {
22 }
23 
~WrongHWIDScreenHandler()24 WrongHWIDScreenHandler::~WrongHWIDScreenHandler() {
25   if (delegate_)
26     delegate_->OnActorDestroyed(this);
27 }
28 
PrepareToShow()29 void WrongHWIDScreenHandler::PrepareToShow() {
30 }
31 
Show()32 void WrongHWIDScreenHandler::Show() {
33   if (!page_is_ready()) {
34     show_on_init_ = true;
35     return;
36   }
37   ShowScreen(OobeUI::kScreenWrongHWID, NULL);
38 }
39 
Hide()40 void WrongHWIDScreenHandler::Hide() {
41 }
42 
SetDelegate(Delegate * delegate)43 void WrongHWIDScreenHandler::SetDelegate(Delegate* delegate) {
44   delegate_ = delegate;
45   if (page_is_ready())
46     Initialize();
47 }
48 
DeclareLocalizedValues(LocalizedValuesBuilder * builder)49 void WrongHWIDScreenHandler::DeclareLocalizedValues(
50     LocalizedValuesBuilder* builder) {
51   builder->Add("wrongHWIDScreenHeader", IDS_WRONG_HWID_SCREEN_HEADER);
52   builder->Add("wrongHWIDMessageFirstPart",
53                 IDS_WRONG_HWID_SCREEN_MESSAGE_FIRST_PART);
54   builder->Add("wrongHWIDMessageSecondPart",
55                 IDS_WRONG_HWID_SCREEN_MESSAGE_SECOND_PART);
56   builder->Add("wrongHWIDScreenSkipLink",
57                 IDS_WRONG_HWID_SCREEN_SKIP_LINK);
58 }
59 
Initialize()60 void WrongHWIDScreenHandler::Initialize() {
61   if (!page_is_ready() || !delegate_)
62     return;
63 
64   if (show_on_init_) {
65     Show();
66     show_on_init_ = false;
67   }
68 }
69 
RegisterMessages()70 void WrongHWIDScreenHandler::RegisterMessages() {
71   AddCallback("wrongHWIDOnSkip", &WrongHWIDScreenHandler::HandleOnSkip);
72 }
73 
HandleOnSkip()74 void WrongHWIDScreenHandler::HandleOnSkip() {
75   if (delegate_)
76     delegate_->OnExit();
77 }
78 
79 }  // namespace chromeos
80