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

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

Issue 7541038: Merge 95406 - Added version info to WebUI (Closed) Base URL: svn://svn.chromium.org/chrome/branches/835/src/
Patch Set: Created 9 years, 4 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
« no previous file with comments | « chrome/browser/ui/webui/chromeos/login/core_oobe_handler.cc ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/oobe_ui.h" 5 #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/ref_counted_memory.h" 10 #include "base/memory/ref_counted_memory.h"
11 #include "base/values.h" 11 #include "base/values.h"
12 #include "chrome/browser/browser_about_handler.h" 12 #include "chrome/browser/browser_about_handler.h"
13 #include "chrome/browser/chromeos/accessibility_util.h"
14 #include "chrome/browser/chromeos/login/enterprise_enrollment_screen_actor.h" 13 #include "chrome/browser/chromeos/login/enterprise_enrollment_screen_actor.h"
15 #include "chrome/browser/chromeos/login/wizard_controller.h" 14 #include "chrome/browser/chromeos/login/wizard_controller.h"
16 #include "chrome/browser/profiles/profile.h" 15 #include "chrome/browser/profiles/profile.h"
17 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" 16 #include "chrome/browser/ui/webui/chrome_url_data_manager.h"
18 #include "chrome/browser/ui/webui/chromeos/login/base_screen_handler.h" 17 #include "chrome/browser/ui/webui/chromeos/login/base_screen_handler.h"
18 #include "chrome/browser/ui/webui/chromeos/login/core_oobe_handler.h"
19 #include "chrome/browser/ui/webui/chromeos/login/enterprise_enrollment_screen_ha ndler.h" 19 #include "chrome/browser/ui/webui/chromeos/login/enterprise_enrollment_screen_ha ndler.h"
20 #include "chrome/browser/ui/webui/chromeos/login/eula_screen_handler.h" 20 #include "chrome/browser/ui/webui/chromeos/login/eula_screen_handler.h"
21 #include "chrome/browser/ui/webui/chromeos/login/network_screen_handler.h" 21 #include "chrome/browser/ui/webui/chromeos/login/network_screen_handler.h"
22 #include "chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h" 22 #include "chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h"
23 #include "chrome/browser/ui/webui/chromeos/login/update_screen_handler.h" 23 #include "chrome/browser/ui/webui/chromeos/login/update_screen_handler.h"
24 #include "chrome/browser/ui/webui/chromeos/login/user_image_screen_handler.h" 24 #include "chrome/browser/ui/webui/chromeos/login/user_image_screen_handler.h"
25 #include "chrome/browser/ui/webui/options/chromeos/user_image_source.h" 25 #include "chrome/browser/ui/webui/options/chromeos/user_image_source.h"
26 #include "chrome/browser/ui/webui/theme_source.h" 26 #include "chrome/browser/ui/webui/theme_source.h"
27 #include "chrome/common/jstemplate_builder.h" 27 #include "chrome/common/jstemplate_builder.h"
28 #include "chrome/common/url_constants.h" 28 #include "chrome/common/url_constants.h"
29 #include "content/browser/tab_contents/tab_contents.h" 29 #include "content/browser/tab_contents/tab_contents.h"
30 #include "grit/browser_resources.h" 30 #include "grit/browser_resources.h"
31 #include "grit/chromium_strings.h"
32 #include "grit/generated_resources.h"
33 #include "ui/base/l10n/l10n_util.h"
34 #include "ui/base/resource/resource_bundle.h" 31 #include "ui/base/resource/resource_bundle.h"
35 32
36 namespace { 33 namespace {
37 34
38 // JS API callbacks names.
39 const char kJsApiScreenStateInitialize[] = "screenStateInitialize";
40 const char kJsApiToggleAccessibility[] = "toggleAccessibility";
41
42 // Path for the enterprise enrollment gaia page hosting. 35 // Path for the enterprise enrollment gaia page hosting.
43 const char kEnterpriseEnrollmentGaiaLoginPath[] = "gaialogin"; 36 const char kEnterpriseEnrollmentGaiaLoginPath[] = "gaialogin";
44 37
45 } // namespace 38 } // namespace
46 39
47 namespace chromeos { 40 namespace chromeos {
48 41
49 class OobeUIHTMLSource : public ChromeURLDataManager::DataSource { 42 class OobeUIHTMLSource : public ChromeURLDataManager::DataSource {
50 public: 43 public:
51 explicit OobeUIHTMLSource(DictionaryValue* localized_strings); 44 explicit OobeUIHTMLSource(DictionaryValue* localized_strings);
52 45
53 // Called when the network layer has requested a resource underneath 46 // Called when the network layer has requested a resource underneath
54 // the path we registered. 47 // the path we registered.
55 virtual void StartDataRequest(const std::string& path, 48 virtual void StartDataRequest(const std::string& path,
56 bool is_incognito, 49 bool is_incognito,
57 int request_id); 50 int request_id);
58 virtual std::string GetMimeType(const std::string&) const { 51 virtual std::string GetMimeType(const std::string&) const {
59 return "text/html"; 52 return "text/html";
60 } 53 }
61 54
62 private: 55 private:
63 virtual ~OobeUIHTMLSource() {} 56 virtual ~OobeUIHTMLSource() {}
64 57
65 scoped_ptr<DictionaryValue> localized_strings_; 58 scoped_ptr<DictionaryValue> localized_strings_;
66 DISALLOW_COPY_AND_ASSIGN(OobeUIHTMLSource); 59 DISALLOW_COPY_AND_ASSIGN(OobeUIHTMLSource);
67 }; 60 };
68 61
69 // CoreOobeHandler -------------------------------------------------------------
70
71 // The core handler for Javascript messages related to the "oobe" view.
72 class CoreOobeHandler : public BaseScreenHandler {
73 public:
74 explicit CoreOobeHandler(OobeUI* oobe_ui);
75 virtual ~CoreOobeHandler();
76
77 // BaseScreenHandler implementation:
78 virtual void GetLocalizedStrings(base::DictionaryValue* localized_strings);
79 virtual void Initialize();
80
81 // WebUIMessageHandler implementation.
82 virtual void RegisterMessages();
83
84 // Show or hide OOBE UI.
85 void ShowOobeUI(bool show);
86
87 bool show_oobe_ui() const {
88 return show_oobe_ui_;
89 }
90
91 private:
92 // Handlers for JS WebUI messages.
93 void OnInitialized(const ListValue* args);
94 void OnToggleAccessibility(const ListValue* args);
95
96 // Calls javascript to sync OOBE UI visibility with show_oobe_ui_.
97 void UpdateOobeUIVisibility();
98
99 // Owner of this handler.
100 OobeUI* oobe_ui_;
101
102 // True if we should show OOBE instead of login.
103 bool show_oobe_ui_;
104
105 DISALLOW_COPY_AND_ASSIGN(CoreOobeHandler);
106 };
107
108 // OobeUIHTMLSource ------------------------------------------------------- 62 // OobeUIHTMLSource -------------------------------------------------------
109 63
110 OobeUIHTMLSource::OobeUIHTMLSource(DictionaryValue* localized_strings) 64 OobeUIHTMLSource::OobeUIHTMLSource(DictionaryValue* localized_strings)
111 : DataSource(chrome::kChromeUIOobeHost, MessageLoop::current()), 65 : DataSource(chrome::kChromeUIOobeHost, MessageLoop::current()),
112 localized_strings_(localized_strings) { 66 localized_strings_(localized_strings) {
113 } 67 }
114 68
115 void OobeUIHTMLSource::StartDataRequest(const std::string& path, 69 void OobeUIHTMLSource::StartDataRequest(const std::string& path,
116 bool is_incognito, 70 bool is_incognito,
117 int request_id) { 71 int request_id) {
118 std::string response; 72 std::string response;
119 if (path.empty()) { 73 if (path.empty()) {
120 static const base::StringPiece html( 74 static const base::StringPiece html(
121 ResourceBundle::GetSharedInstance().GetRawDataResource(IDR_OOBE_HTML)); 75 ResourceBundle::GetSharedInstance().GetRawDataResource(IDR_OOBE_HTML));
122 response = jstemplate_builder::GetI18nTemplateHtml( 76 response = jstemplate_builder::GetI18nTemplateHtml(
123 html, localized_strings_.get()); 77 html, localized_strings_.get());
124 } else if (path == kEnterpriseEnrollmentGaiaLoginPath) { 78 } else if (path == kEnterpriseEnrollmentGaiaLoginPath) {
125 static const base::StringPiece html( 79 static const base::StringPiece html(
126 ResourceBundle::GetSharedInstance().GetRawDataResource( 80 ResourceBundle::GetSharedInstance().GetRawDataResource(
127 IDR_GAIA_LOGIN_HTML)); 81 IDR_GAIA_LOGIN_HTML));
128 response = jstemplate_builder::GetI18nTemplateHtml( 82 response = jstemplate_builder::GetI18nTemplateHtml(
129 html, localized_strings_.get()); 83 html, localized_strings_.get());
130 } 84 }
131 85
132 SendResponse(request_id, base::RefCountedString::TakeString(&response)); 86 SendResponse(request_id, base::RefCountedString::TakeString(&response));
133 } 87 }
134 88
135 // CoreOobeHandler ------------------------------------------------------------
136
137 // Note that show_oobe_ui_ defaults to false because WizardController assumes
138 // OOBE UI is not visible by default.
139 CoreOobeHandler::CoreOobeHandler(OobeUI* oobe_ui)
140 : oobe_ui_(oobe_ui),
141 show_oobe_ui_(false) {
142 }
143
144 CoreOobeHandler::~CoreOobeHandler() {
145 }
146
147 void CoreOobeHandler::GetLocalizedStrings(
148 base::DictionaryValue* localized_strings) {
149 localized_strings->SetString(
150 "productName", l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME));
151 }
152
153 void CoreOobeHandler::Initialize() {
154 UpdateOobeUIVisibility();
155 }
156
157 void CoreOobeHandler::RegisterMessages() {
158 web_ui_->RegisterMessageCallback(kJsApiToggleAccessibility,
159 NewCallback(this, &CoreOobeHandler::OnToggleAccessibility));
160 web_ui_->RegisterMessageCallback(kJsApiScreenStateInitialize,
161 NewCallback(this, &CoreOobeHandler::OnInitialized));
162 }
163
164 void CoreOobeHandler::OnInitialized(const ListValue* args) {
165 oobe_ui_->InitializeHandlers();
166 }
167
168 void CoreOobeHandler::OnToggleAccessibility(const ListValue* args) {
169 accessibility::ToggleAccessibility();
170 }
171
172 void CoreOobeHandler::ShowOobeUI(bool show) {
173 if (show == show_oobe_ui_)
174 return;
175
176 show_oobe_ui_ = show;
177
178 if (page_is_ready())
179 UpdateOobeUIVisibility();
180 }
181
182 void CoreOobeHandler::UpdateOobeUIVisibility() {
183 base::FundamentalValue showValue(show_oobe_ui_);
184 web_ui_->CallJavascriptFunction("cr.ui.Oobe.showOobeUI", showValue);
185 }
186
187 // OobeUI ---------------------------------------------------------------------- 89 // OobeUI ----------------------------------------------------------------------
188 90
189 OobeUI::OobeUI(TabContents* contents) 91 OobeUI::OobeUI(TabContents* contents)
190 : ChromeWebUI(contents), 92 : ChromeWebUI(contents),
191 update_screen_actor_(NULL), 93 update_screen_actor_(NULL),
192 network_screen_actor_(NULL), 94 network_screen_actor_(NULL),
193 eula_screen_actor_(NULL), 95 eula_screen_actor_(NULL),
194 signin_screen_handler_(NULL), 96 signin_screen_handler_(NULL),
195 user_image_screen_actor_(NULL) { 97 user_image_screen_actor_(NULL) {
196 core_handler_ = new CoreOobeHandler(this); 98 core_handler_ = new CoreOobeHandler(this);
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 205
304 void OobeUI::ShowOobeUI(bool show) { 206 void OobeUI::ShowOobeUI(bool show) {
305 core_handler_->ShowOobeUI(show); 207 core_handler_->ShowOobeUI(show);
306 } 208 }
307 209
308 void OobeUI::ShowSigninScreen() { 210 void OobeUI::ShowSigninScreen() {
309 signin_screen_handler_->Show(core_handler_->show_oobe_ui()); 211 signin_screen_handler_->Show(core_handler_->show_oobe_ui());
310 } 212 }
311 213
312 } // namespace chromeos 214 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/chromeos/login/core_oobe_handler.cc ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698