| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/base_screen_handler.h" | 5 #include "chrome/browser/ui/webui/chromeos/login/base_screen_handler.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/values.h" | 8 #include "base/values.h" |
| 9 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" | 9 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" |
| 10 #include "content/public/browser/web_ui.h" | 10 #include "content/public/browser/web_ui.h" |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 page_is_ready_ = true; | 78 page_is_ready_ = true; |
| 79 Initialize(); | 79 Initialize(); |
| 80 } | 80 } |
| 81 | 81 |
| 82 void BaseScreenHandler::GetLocalizedStrings(base::DictionaryValue* dict) { | 82 void BaseScreenHandler::GetLocalizedStrings(base::DictionaryValue* dict) { |
| 83 scoped_ptr<LocalizedValuesBuilder> builder(new LocalizedValuesBuilder(dict)); | 83 scoped_ptr<LocalizedValuesBuilder> builder(new LocalizedValuesBuilder(dict)); |
| 84 DeclareLocalizedValues(builder.get()); | 84 DeclareLocalizedValues(builder.get()); |
| 85 GetAdditionalParameters(dict); | 85 GetAdditionalParameters(dict); |
| 86 } | 86 } |
| 87 | 87 |
| 88 void BaseScreenHandler::RegisterMessages() { |
| 89 AddPrefixedCallback("contextChanged", |
| 90 &BaseScreenHandler::HandleContextChanged); |
| 91 DeclareJSCallbacks(); |
| 92 } |
| 93 |
| 88 void BaseScreenHandler::GetAdditionalParameters(base::DictionaryValue* dict) { | 94 void BaseScreenHandler::GetAdditionalParameters(base::DictionaryValue* dict) { |
| 89 } | 95 } |
| 90 | 96 |
| 91 void BaseScreenHandler::CallJS(const std::string& method) { | 97 void BaseScreenHandler::CallJS(const std::string& method) { |
| 92 web_ui()->CallJavascriptFunction(FullMethodPath(method)); | 98 web_ui()->CallJavascriptFunction(FullMethodPath(method)); |
| 93 } | 99 } |
| 94 | 100 |
| 95 void BaseScreenHandler::ShowScreen(const char* screen_name, | 101 void BaseScreenHandler::ShowScreen(const char* screen_name, |
| 96 const base::DictionaryValue* data) { | 102 const base::DictionaryValue* data) { |
| 97 if (!web_ui()) | 103 if (!web_ui()) |
| 98 return; | 104 return; |
| 99 base::DictionaryValue screen_params; | 105 base::DictionaryValue screen_params; |
| 100 screen_params.SetString("id", screen_name); | 106 screen_params.SetString("id", screen_name); |
| 101 if (data) | 107 if (data) |
| 102 screen_params.SetWithoutPathExpansion("data", data->DeepCopy()); | 108 screen_params.SetWithoutPathExpansion("data", data->DeepCopy()); |
| 103 web_ui()->CallJavascriptFunction("cr.ui.Oobe.showScreen", screen_params); | 109 web_ui()->CallJavascriptFunction("cr.ui.Oobe.showScreen", screen_params); |
| 104 } | 110 } |
| 105 | 111 |
| 106 gfx::NativeWindow BaseScreenHandler::GetNativeWindow() { | 112 gfx::NativeWindow BaseScreenHandler::GetNativeWindow() { |
| 107 return LoginDisplayHostImpl::default_host()->GetNativeWindow(); | 113 return LoginDisplayHostImpl::default_host()->GetNativeWindow(); |
| 108 } | 114 } |
| 109 | 115 |
| 110 std::string BaseScreenHandler::FullMethodPath(const std::string& method) const { | 116 std::string BaseScreenHandler::FullMethodPath(const std::string& method) const { |
| 111 DCHECK(!method.empty()); | 117 DCHECK(!method.empty()); |
| 112 return js_screen_path_prefix_ + method; | 118 return js_screen_path_prefix_ + method; |
| 113 } | 119 } |
| 114 | 120 |
| 121 void BaseScreenHandler::HandleContextChanged( |
| 122 const base::DictionaryValue* diff) { |
| 123 if (diff && base_screen_) |
| 124 base_screen_->OnContextChanged(*diff); |
| 125 } |
| 126 |
| 115 } // namespace chromeos | 127 } // namespace chromeos |
| OLD | NEW |