| OLD | NEW |
| 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/printing/cloud_print/cloud_print_setup_flow.h" | 5 #include "chrome/browser/printing/cloud_print/cloud_print_setup_flow.h" |
| 6 | 6 |
| 7 #include "base/json/json_writer.h" | 7 #include "base/json/json_writer.h" |
| 8 #include "base/memory/singleton.h" | 8 #include "base/memory/singleton.h" |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 // Create the message handler only after we are asked, the caller is | 126 // Create the message handler only after we are asked, the caller is |
| 127 // responsible for deleting the objects. | 127 // responsible for deleting the objects. |
| 128 handlers->push_back( | 128 handlers->push_back( |
| 129 new CloudPrintSetupMessageHandler( | 129 new CloudPrintSetupMessageHandler( |
| 130 const_cast<CloudPrintSetupFlow*>(this))); | 130 const_cast<CloudPrintSetupFlow*>(this))); |
| 131 } | 131 } |
| 132 | 132 |
| 133 void CloudPrintSetupFlow::GetDialogSize(gfx::Size* size) const { | 133 void CloudPrintSetupFlow::GetDialogSize(gfx::Size* size) const { |
| 134 PrefService* prefs = profile_->GetPrefs(); | 134 PrefService* prefs = profile_->GetPrefs(); |
| 135 gfx::Font approximate_web_font( | 135 gfx::Font approximate_web_font( |
| 136 UTF8ToUTF16(prefs->GetString(prefs::kWebKitSansSerifFontFamily)), | 136 prefs->GetString(prefs::kWebKitSansSerifFontFamily), |
| 137 prefs->GetInteger(prefs::kWebKitDefaultFontSize)); | 137 prefs->GetInteger(prefs::kWebKitDefaultFontSize)); |
| 138 | 138 |
| 139 if (setup_done_) { | 139 if (setup_done_) { |
| 140 *size = ui::GetLocalizedContentsSizeForFont( | 140 *size = ui::GetLocalizedContentsSizeForFont( |
| 141 IDS_CLOUD_PRINT_SETUP_WIZARD_DONE_WIDTH_CHARS, | 141 IDS_CLOUD_PRINT_SETUP_WIZARD_DONE_WIDTH_CHARS, |
| 142 IDS_CLOUD_PRINT_SETUP_WIZARD_DONE_HEIGHT_LINES, | 142 IDS_CLOUD_PRINT_SETUP_WIZARD_DONE_HEIGHT_LINES, |
| 143 approximate_web_font); | 143 approximate_web_font); |
| 144 } else { | 144 } else { |
| 145 *size = ui::GetLocalizedContentsSizeForFont( | 145 *size = ui::GetLocalizedContentsSizeForFont( |
| 146 IDS_CLOUD_PRINT_SETUP_WIZARD_WIDTH_CHARS, | 146 IDS_CLOUD_PRINT_SETUP_WIZARD_WIDTH_CHARS, |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 string16 message = l10n_util::GetStringFUTF16(IDS_CLOUD_PRINT_SETUP_DONE, | 305 string16 message = l10n_util::GetStringFUTF16(IDS_CLOUD_PRINT_SETUP_DONE, |
| 306 product_name, | 306 product_name, |
| 307 UTF8ToUTF16(login_)); | 307 UTF8ToUTF16(login_)); |
| 308 string16 javascript(ASCIIToUTF16("cloudprint.setMessage('") + message + | 308 string16 javascript(ASCIIToUTF16("cloudprint.setMessage('") + message + |
| 309 ASCIIToUTF16("');")); | 309 ASCIIToUTF16("');")); |
| 310 ExecuteJavascriptInIFrame(DoneIframeXPath(), javascript); | 310 ExecuteJavascriptInIFrame(DoneIframeXPath(), javascript); |
| 311 | 311 |
| 312 if (web_ui_) { | 312 if (web_ui_) { |
| 313 PrefService* prefs = profile_->GetPrefs(); | 313 PrefService* prefs = profile_->GetPrefs(); |
| 314 gfx::Font approximate_web_font( | 314 gfx::Font approximate_web_font( |
| 315 UTF8ToUTF16(prefs->GetString(prefs::kWebKitSansSerifFontFamily)), | 315 prefs->GetString(prefs::kWebKitSansSerifFontFamily), |
| 316 prefs->GetInteger(prefs::kWebKitDefaultFontSize)); | 316 prefs->GetInteger(prefs::kWebKitDefaultFontSize)); |
| 317 gfx::Size done_size = ui::GetLocalizedContentsSizeForFont( | 317 gfx::Size done_size = ui::GetLocalizedContentsSizeForFont( |
| 318 IDS_CLOUD_PRINT_SETUP_WIZARD_DONE_WIDTH_CHARS, | 318 IDS_CLOUD_PRINT_SETUP_WIZARD_DONE_WIDTH_CHARS, |
| 319 IDS_CLOUD_PRINT_SETUP_WIZARD_DONE_HEIGHT_LINES, | 319 IDS_CLOUD_PRINT_SETUP_WIZARD_DONE_HEIGHT_LINES, |
| 320 approximate_web_font); | 320 approximate_web_font); |
| 321 | 321 |
| 322 base::FundamentalValue new_width(done_size.width()); | 322 base::FundamentalValue new_width(done_size.width()); |
| 323 base::FundamentalValue new_height(done_size.height()); | 323 base::FundamentalValue new_height(done_size.height()); |
| 324 web_ui_->CallJavascriptFunction("cloudprint.showSetupDone", | 324 web_ui_->CallJavascriptFunction("cloudprint.showSetupDone", |
| 325 new_width, new_height); | 325 new_width, new_height); |
| 326 } | 326 } |
| 327 | 327 |
| 328 ExecuteJavascriptInIFrame(DoneIframeXPath(), | 328 ExecuteJavascriptInIFrame(DoneIframeXPath(), |
| 329 ASCIIToUTF16("cloudprint.onPageShown();")); | 329 ASCIIToUTF16("cloudprint.onPageShown();")); |
| 330 } | 330 } |
| 331 | 331 |
| 332 void CloudPrintSetupFlow::ExecuteJavascriptInIFrame( | 332 void CloudPrintSetupFlow::ExecuteJavascriptInIFrame( |
| 333 const string16& iframe_xpath, | 333 const string16& iframe_xpath, |
| 334 const string16& js) { | 334 const string16& js) { |
| 335 if (web_ui_) { | 335 if (web_ui_) { |
| 336 RenderViewHost* rvh = web_ui_->tab_contents()->render_view_host(); | 336 RenderViewHost* rvh = web_ui_->tab_contents()->render_view_host(); |
| 337 rvh->ExecuteJavascriptInWebFrame(iframe_xpath, js); | 337 rvh->ExecuteJavascriptInWebFrame(iframe_xpath, js); |
| 338 } | 338 } |
| 339 } | 339 } |
| OLD | NEW |