OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/printing/cloud_print/cloud_print_setup_flow.h" | 5 #include "chrome/browser/printing/cloud_print/cloud_print_setup_flow.h" |
6 | 6 |
7 #include "app/gfx/font_util.h" | 7 #include "app/gfx/font_util.h" |
8 #include "base/json/json_writer.h" | 8 #include "base/json/json_writer.h" |
9 #include "base/singleton.h" | 9 #include "base/singleton.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 | 163 |
164 std::string CloudPrintSetupFlow::GetDialogArgs() const { | 164 std::string CloudPrintSetupFlow::GetDialogArgs() const { |
165 return dialog_start_args_; | 165 return dialog_start_args_; |
166 } | 166 } |
167 | 167 |
168 void CloudPrintSetupFlow::OnCloseContents(TabContents* source, | 168 void CloudPrintSetupFlow::OnCloseContents(TabContents* source, |
169 bool* out_close_dialog) { | 169 bool* out_close_dialog) { |
170 } | 170 } |
171 | 171 |
172 std::wstring CloudPrintSetupFlow::GetDialogTitle() const { | 172 std::wstring CloudPrintSetupFlow::GetDialogTitle() const { |
173 return l10n_util::GetString(IDS_CLOUD_PRINT_SETUP_DIALOG_TITLE); | 173 return UTF16ToWideHack( |
| 174 l10n_util::GetStringUTF16(IDS_CLOUD_PRINT_SETUP_DIALOG_TITLE)); |
174 } | 175 } |
175 | 176 |
176 bool CloudPrintSetupFlow::IsDialogModal() const { | 177 bool CloudPrintSetupFlow::IsDialogModal() const { |
177 // We are always modeless. | 178 // We are always modeless. |
178 return false; | 179 return false; |
179 } | 180 } |
180 | 181 |
181 bool CloudPrintSetupFlow::ShouldShowDialogTitle() const { | 182 bool CloudPrintSetupFlow::ShouldShowDialogTitle() const { |
182 return true; | 183 return true; |
183 } | 184 } |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 args.SetString("pageToShow", "cloudprintsetup"); | 264 args.SetString("pageToShow", "cloudprintsetup"); |
264 args.SetString("user", ""); | 265 args.SetString("user", ""); |
265 args.SetInteger("error", error.state()); | 266 args.SetInteger("error", error.state()); |
266 args.SetBoolean("editable_user", true); | 267 args.SetBoolean("editable_user", true); |
267 args.SetString("captchaUrl", error.captcha().image_url.spec()); | 268 args.SetString("captchaUrl", error.captcha().image_url.spec()); |
268 ShowGaiaLogin(args); | 269 ShowGaiaLogin(args); |
269 } | 270 } |
270 | 271 |
271 void CloudPrintSetupFlow::ShowSetupDone() { | 272 void CloudPrintSetupFlow::ShowSetupDone() { |
272 setup_done_ = true; | 273 setup_done_ = true; |
273 std::wstring product_name = l10n_util::GetString(IDS_PRODUCT_NAME); | 274 string16 product_name = l10n_util::GetStringUTF16(IDS_PRODUCT_NAME); |
274 std::wstring message = l10n_util::GetStringF(IDS_CLOUD_PRINT_SETUP_DONE, | 275 std::wstring message = |
275 product_name, | 276 UTF16ToWideHack(l10n_util::GetStringFUTF16(IDS_CLOUD_PRINT_SETUP_DONE, |
276 UTF8ToWide(login_)); | 277 product_name, |
| 278 UTF8ToUTF16(login_))); |
277 std::wstring javascript = L"cloudprint.setMessage('" + message + L"');"; | 279 std::wstring javascript = L"cloudprint.setMessage('" + message + L"');"; |
278 ExecuteJavascriptInIFrame(kDoneIframeXPath, javascript); | 280 ExecuteJavascriptInIFrame(kDoneIframeXPath, javascript); |
279 | 281 |
280 if (dom_ui_) { | 282 if (dom_ui_) { |
281 PrefService* prefs = profile_->GetPrefs(); | 283 PrefService* prefs = profile_->GetPrefs(); |
282 gfx::Font approximate_web_font( | 284 gfx::Font approximate_web_font( |
283 UTF8ToWide(prefs->GetString(prefs::kWebKitSansSerifFontFamily)), | 285 UTF8ToWide(prefs->GetString(prefs::kWebKitSansSerifFontFamily)), |
284 prefs->GetInteger(prefs::kWebKitDefaultFontSize)); | 286 prefs->GetInteger(prefs::kWebKitDefaultFontSize)); |
285 gfx::Size done_size = gfx::GetLocalizedContentsSizeForFont( | 287 gfx::Size done_size = gfx::GetLocalizedContentsSizeForFont( |
286 IDS_CLOUD_PRINT_SETUP_WIZARD_DONE_WIDTH_CHARS, | 288 IDS_CLOUD_PRINT_SETUP_WIZARD_DONE_WIDTH_CHARS, |
(...skipping 10 matching lines...) Expand all Loading... |
297 } | 299 } |
298 | 300 |
299 void CloudPrintSetupFlow::ExecuteJavascriptInIFrame( | 301 void CloudPrintSetupFlow::ExecuteJavascriptInIFrame( |
300 const std::wstring& iframe_xpath, | 302 const std::wstring& iframe_xpath, |
301 const std::wstring& js) { | 303 const std::wstring& js) { |
302 if (dom_ui_) { | 304 if (dom_ui_) { |
303 RenderViewHost* rvh = dom_ui_->tab_contents()->render_view_host(); | 305 RenderViewHost* rvh = dom_ui_->tab_contents()->render_view_host(); |
304 rvh->ExecuteJavascriptInWebFrame(iframe_xpath, js); | 306 rvh->ExecuteJavascriptInWebFrame(iframe_xpath, js); |
305 } | 307 } |
306 } | 308 } |
OLD | NEW |