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