| 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 UTF16ToWideHack( | 173 return l10n_util::GetString(IDS_CLOUD_PRINT_SETUP_DIALOG_TITLE); |
| 174 l10n_util::GetStringUTF16(IDS_CLOUD_PRINT_SETUP_DIALOG_TITLE)); | |
| 175 } | 174 } |
| 176 | 175 |
| 177 bool CloudPrintSetupFlow::IsDialogModal() const { | 176 bool CloudPrintSetupFlow::IsDialogModal() const { |
| 178 // We are always modeless. | 177 // We are always modeless. |
| 179 return false; | 178 return false; |
| 180 } | 179 } |
| 181 | 180 |
| 182 bool CloudPrintSetupFlow::ShouldShowDialogTitle() const { | 181 bool CloudPrintSetupFlow::ShouldShowDialogTitle() const { |
| 183 return true; | 182 return true; |
| 184 } | 183 } |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 args.SetString("pageToShow", "cloudprintsetup"); | 263 args.SetString("pageToShow", "cloudprintsetup"); |
| 265 args.SetString("user", ""); | 264 args.SetString("user", ""); |
| 266 args.SetInteger("error", error.state()); | 265 args.SetInteger("error", error.state()); |
| 267 args.SetBoolean("editable_user", true); | 266 args.SetBoolean("editable_user", true); |
| 268 args.SetString("captchaUrl", error.captcha().image_url.spec()); | 267 args.SetString("captchaUrl", error.captcha().image_url.spec()); |
| 269 ShowGaiaLogin(args); | 268 ShowGaiaLogin(args); |
| 270 } | 269 } |
| 271 | 270 |
| 272 void CloudPrintSetupFlow::ShowSetupDone() { | 271 void CloudPrintSetupFlow::ShowSetupDone() { |
| 273 setup_done_ = true; | 272 setup_done_ = true; |
| 274 string16 product_name = l10n_util::GetStringUTF16(IDS_PRODUCT_NAME); | 273 std::wstring product_name = l10n_util::GetString(IDS_PRODUCT_NAME); |
| 275 std::wstring message = | 274 std::wstring message = l10n_util::GetStringF(IDS_CLOUD_PRINT_SETUP_DONE, |
| 276 UTF16ToWideHack(l10n_util::GetStringFUTF16(IDS_CLOUD_PRINT_SETUP_DONE, | 275 product_name, |
| 277 product_name, | 276 UTF8ToWide(login_)); |
| 278 UTF8ToUTF16(login_))); | |
| 279 std::wstring javascript = L"cloudprint.setMessage('" + message + L"');"; | 277 std::wstring javascript = L"cloudprint.setMessage('" + message + L"');"; |
| 280 ExecuteJavascriptInIFrame(kDoneIframeXPath, javascript); | 278 ExecuteJavascriptInIFrame(kDoneIframeXPath, javascript); |
| 281 | 279 |
| 282 if (dom_ui_) { | 280 if (dom_ui_) { |
| 283 PrefService* prefs = profile_->GetPrefs(); | 281 PrefService* prefs = profile_->GetPrefs(); |
| 284 gfx::Font approximate_web_font( | 282 gfx::Font approximate_web_font( |
| 285 UTF8ToWide(prefs->GetString(prefs::kWebKitSansSerifFontFamily)), | 283 UTF8ToWide(prefs->GetString(prefs::kWebKitSansSerifFontFamily)), |
| 286 prefs->GetInteger(prefs::kWebKitDefaultFontSize)); | 284 prefs->GetInteger(prefs::kWebKitDefaultFontSize)); |
| 287 gfx::Size done_size = gfx::GetLocalizedContentsSizeForFont( | 285 gfx::Size done_size = gfx::GetLocalizedContentsSizeForFont( |
| 288 IDS_CLOUD_PRINT_SETUP_WIZARD_DONE_WIDTH_CHARS, | 286 IDS_CLOUD_PRINT_SETUP_WIZARD_DONE_WIDTH_CHARS, |
| (...skipping 10 matching lines...) Expand all Loading... |
| 299 } | 297 } |
| 300 | 298 |
| 301 void CloudPrintSetupFlow::ExecuteJavascriptInIFrame( | 299 void CloudPrintSetupFlow::ExecuteJavascriptInIFrame( |
| 302 const std::wstring& iframe_xpath, | 300 const std::wstring& iframe_xpath, |
| 303 const std::wstring& js) { | 301 const std::wstring& js) { |
| 304 if (dom_ui_) { | 302 if (dom_ui_) { |
| 305 RenderViewHost* rvh = dom_ui_->tab_contents()->render_view_host(); | 303 RenderViewHost* rvh = dom_ui_->tab_contents()->render_view_host(); |
| 306 rvh->ExecuteJavascriptInWebFrame(iframe_xpath, js); | 304 rvh->ExecuteJavascriptInWebFrame(iframe_xpath, js); |
| 307 } | 305 } |
| 308 } | 306 } |
| OLD | NEW |