OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/ui/webui/chromeos/login/host_pairing_screen_handler.h" | 5 #include "chrome/browser/ui/webui/chromeos/login/host_pairing_screen_handler.h" |
6 | 6 |
| 7 #include "base/strings/string_util.h" |
7 #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h" | 8 #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h" |
| 9 #include "grit/generated_resources.h" |
8 | 10 |
9 namespace chromeos { | 11 namespace chromeos { |
10 | 12 |
11 namespace { | 13 namespace { |
12 | 14 |
13 const char kJsScreenPath[] = "login.HostPairingScreen"; | 15 const char kJsScreenPath[] = "login.HostPairingScreen"; |
14 | 16 |
15 const char kMethodContextChanged[] = "contextChanged"; | 17 const char kMethodContextChanged[] = "contextChanged"; |
16 | 18 |
17 // Sent from JS when screen is ready to receive context updates. | 19 // Sent from JS when screen is ready to receive context updates. |
(...skipping 25 matching lines...) Expand all Loading... |
43 return; | 45 return; |
44 | 46 |
45 if (show_on_init_) { | 47 if (show_on_init_) { |
46 Show(); | 48 Show(); |
47 show_on_init_ = false; | 49 show_on_init_ = false; |
48 } | 50 } |
49 } | 51 } |
50 | 52 |
51 void HostPairingScreenHandler::DeclareLocalizedValues( | 53 void HostPairingScreenHandler::DeclareLocalizedValues( |
52 LocalizedValuesBuilder* builder) { | 54 LocalizedValuesBuilder* builder) { |
| 55 // TODO(dzhioev): Move the prefix logic to the base screen handler after |
| 56 // migration. |
| 57 std::string prefix; |
| 58 base::ReplaceChars(kJsScreenPath, ".", "_", &prefix); |
| 59 prefix += "_"; |
| 60 |
| 61 builder->Add(prefix + "welcomeTitle", IDS_PAIRING_HOST_WELCOME_TITLE); |
| 62 builder->Add(prefix + "welcomeText", IDS_PAIRING_HOST_WELCOME_TEXT); |
| 63 builder->Add(prefix + "confirmationTitle", |
| 64 IDS_PAIRING_HOST_CONFIRMATION_TITLE); |
| 65 builder->Add(prefix + "updatingTitle", IDS_PAIRING_HOST_UPDATING_TITLE); |
| 66 builder->Add(prefix + "updatingText", IDS_PAIRING_HOST_UPDATING_TEXT); |
| 67 builder->Add(prefix + "enrollTitle", IDS_PAIRING_ENROLL_TITLE); |
| 68 builder->Add(prefix + "enrollingTitle", |
| 69 IDS_PAIRING_ENROLLMENT_IN_PROGRESS); |
| 70 builder->Add(prefix + "doneTitle", IDS_PAIRING_HOST_DONE_TITLE); |
| 71 builder->Add(prefix + "doneText", IDS_PAIRING_HOST_DONE_TEXT); |
| 72 builder->Add(prefix + "enrollmentErrorTitle", |
| 73 IDS_PAIRING_ENROLLMENT_ERROR_TITLE); |
| 74 builder->Add(prefix + "errorNeedsRestart", |
| 75 IDS_PAIRING_HOST_EROLLMENT_ERROR_NEEDS_RESTART); |
53 } | 76 } |
54 | 77 |
55 void HostPairingScreenHandler::RegisterMessages() { | 78 void HostPairingScreenHandler::RegisterMessages() { |
56 AddPrefixedCallback(kCallbackContextReady, | 79 AddPrefixedCallback(kCallbackContextReady, |
57 &HostPairingScreenHandler::HandleContextReady); | 80 &HostPairingScreenHandler::HandleContextReady); |
58 } | 81 } |
59 | 82 |
60 void HostPairingScreenHandler::Show() { | 83 void HostPairingScreenHandler::Show() { |
61 if (!page_is_ready()) { | 84 if (!page_is_ready()) { |
62 show_on_init_ = true; | 85 show_on_init_ = true; |
(...skipping 14 matching lines...) Expand all Loading... |
77 void HostPairingScreenHandler::OnContextChanged( | 100 void HostPairingScreenHandler::OnContextChanged( |
78 const base::DictionaryValue& diff) { | 101 const base::DictionaryValue& diff) { |
79 if (!js_context_ready_) { | 102 if (!js_context_ready_) { |
80 context_cache_.ApplyChanges(diff, NULL); | 103 context_cache_.ApplyChanges(diff, NULL); |
81 return; | 104 return; |
82 } | 105 } |
83 CallJS(kMethodContextChanged, diff); | 106 CallJS(kMethodContextChanged, diff); |
84 } | 107 } |
85 | 108 |
86 } // namespace chromeos | 109 } // namespace chromeos |
OLD | NEW |