OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 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 | 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/terms_of_service_screen_handler
.h" | 5 #include "chrome/browser/ui/webui/chromeos/login/terms_of_service_screen_handler
.h" |
6 | 6 |
7 #include "base/values.h" | |
8 #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h" | 7 #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h" |
9 #include "grit/chromium_strings.h" | 8 #include "grit/chromium_strings.h" |
10 #include "grit/generated_resources.h" | 9 #include "grit/generated_resources.h" |
11 | 10 |
12 namespace chromeos { | 11 namespace chromeos { |
13 | 12 |
14 TermsOfServiceScreenHandler::TermsOfServiceScreenHandler() | 13 TermsOfServiceScreenHandler::TermsOfServiceScreenHandler() |
15 : screen_(NULL), | 14 : screen_(NULL), |
16 show_on_init_(false), | 15 show_on_init_(false), |
17 load_error_(false) { | 16 load_error_(false) { |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 } | 86 } |
88 | 87 |
89 void TermsOfServiceScreenHandler::Initialize() { | 88 void TermsOfServiceScreenHandler::Initialize() { |
90 if (show_on_init_) { | 89 if (show_on_init_) { |
91 Show(); | 90 Show(); |
92 show_on_init_ = false; | 91 show_on_init_ = false; |
93 } | 92 } |
94 } | 93 } |
95 | 94 |
96 void TermsOfServiceScreenHandler::UpdateDomainInUI() { | 95 void TermsOfServiceScreenHandler::UpdateDomainInUI() { |
97 if (!page_is_ready()) | 96 if (page_is_ready()) |
98 return; | 97 CallJS("cr.ui.Oobe.setTermsOfServiceDomain", domain_); |
99 | |
100 base::StringValue domain(domain_); | |
101 CallJS("cr.ui.Oobe.setTermsOfServiceDomain", domain); | |
102 } | 98 } |
103 | 99 |
104 void TermsOfServiceScreenHandler::UpdateTermsOfServiceInUI() { | 100 void TermsOfServiceScreenHandler::UpdateTermsOfServiceInUI() { |
105 if (!page_is_ready()) | 101 if (!page_is_ready()) |
106 return; | 102 return; |
107 | 103 |
108 // If either |load_error_| or |terms_of_service_| is set, the download of the | 104 // If either |load_error_| or |terms_of_service_| is set, the download of the |
109 // Terms of Service has completed and the UI should be updated. Otherwise, the | 105 // Terms of Service has completed and the UI should be updated. Otherwise, the |
110 // download is still in progress and the UI will be updated when the | 106 // download is still in progress and the UI will be updated when the |
111 // OnLoadError() or the OnLoadSuccess() callback is called. | 107 // OnLoadError() or the OnLoadSuccess() callback is called. |
112 if (load_error_) { | 108 if (load_error_) |
113 web_ui()->CallJavascriptFunction("cr.ui.Oobe.setTermsOfServiceLoadError"); | 109 CallJS("cr.ui.Oobe.setTermsOfServiceLoadError"); |
114 } else if (!terms_of_service_.empty()) { | 110 else if (!terms_of_service_.empty()) |
115 base::StringValue terms_of_service(terms_of_service_); | 111 CallJS("cr.ui.Oobe.setTermsOfService", terms_of_service_); |
116 web_ui()->CallJavascriptFunction("cr.ui.Oobe.setTermsOfService", | |
117 terms_of_service); | |
118 } | |
119 } | 112 } |
120 | 113 |
121 void TermsOfServiceScreenHandler::HandleBack() { | 114 void TermsOfServiceScreenHandler::HandleBack() { |
122 if (screen_) | 115 if (screen_) |
123 screen_->OnDecline(); | 116 screen_->OnDecline(); |
124 } | 117 } |
125 | 118 |
126 void TermsOfServiceScreenHandler::HandleAccept() { | 119 void TermsOfServiceScreenHandler::HandleAccept() { |
127 if (!screen_) | 120 if (!screen_) |
128 return; | 121 return; |
129 | 122 |
130 // If the Terms of Service have not been successfully downloaded, the "accept | 123 // If the Terms of Service have not been successfully downloaded, the "accept |
131 // and continue" button should not be accessible. If the user managed to | 124 // and continue" button should not be accessible. If the user managed to |
132 // activate it somehow anway, do not treat this as acceptance of the Terms | 125 // activate it somehow anway, do not treat this as acceptance of the Terms |
133 // and Conditions and end the session instead, as if the user had declined. | 126 // and Conditions and end the session instead, as if the user had declined. |
134 if (terms_of_service_.empty()) | 127 if (terms_of_service_.empty()) |
135 screen_->OnDecline(); | 128 screen_->OnDecline(); |
136 else | 129 else |
137 screen_->OnAccept(); | 130 screen_->OnAccept(); |
138 } | 131 } |
139 | 132 |
140 } // namespace chromeos | 133 } // namespace chromeos |
OLD | NEW |