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

Side by Side Diff: chrome/browser/printing/cloud_print/cloud_print_setup_flow.cc

Issue 8879016: Add more per-tab preferences. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix browser_tests Created 9 years 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
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/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 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 // Create the message handler only after we are asked, the caller is 123 // Create the message handler only after we are asked, the caller is
124 // responsible for deleting the objects. 124 // responsible for deleting the objects.
125 handlers->push_back( 125 handlers->push_back(
126 new CloudPrintSetupMessageHandler( 126 new CloudPrintSetupMessageHandler(
127 const_cast<CloudPrintSetupFlow*>(this))); 127 const_cast<CloudPrintSetupFlow*>(this)));
128 } 128 }
129 129
130 void CloudPrintSetupFlow::GetDialogSize(gfx::Size* size) const { 130 void CloudPrintSetupFlow::GetDialogSize(gfx::Size* size) const {
131 PrefService* prefs = profile_->GetPrefs(); 131 PrefService* prefs = profile_->GetPrefs();
132 gfx::Font approximate_web_font( 132 gfx::Font approximate_web_font(
133 prefs->GetString(prefs::kWebKitSansSerifFontFamily), 133 prefs->GetString(prefs::kWebKitGlobalSansSerifFontFamily),
134 prefs->GetInteger(prefs::kWebKitDefaultFontSize)); 134 prefs->GetInteger(prefs::kWebKitGlobalDefaultFontSize));
135 135
136 if (setup_done_) { 136 if (setup_done_) {
137 *size = ui::GetLocalizedContentsSizeForFont( 137 *size = ui::GetLocalizedContentsSizeForFont(
138 IDS_CLOUD_PRINT_SETUP_WIZARD_DONE_WIDTH_CHARS, 138 IDS_CLOUD_PRINT_SETUP_WIZARD_DONE_WIDTH_CHARS,
139 IDS_CLOUD_PRINT_SETUP_WIZARD_DONE_HEIGHT_LINES, 139 IDS_CLOUD_PRINT_SETUP_WIZARD_DONE_HEIGHT_LINES,
140 approximate_web_font); 140 approximate_web_font);
141 } else { 141 } else {
142 *size = ui::GetLocalizedContentsSizeForFont( 142 *size = ui::GetLocalizedContentsSizeForFont(
143 IDS_CLOUD_PRINT_SETUP_WIZARD_WIDTH_CHARS, 143 IDS_CLOUD_PRINT_SETUP_WIZARD_WIDTH_CHARS,
144 IDS_CLOUD_PRINT_SETUP_WIZARD_HEIGHT_LINES, 144 IDS_CLOUD_PRINT_SETUP_WIZARD_HEIGHT_LINES,
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 string16 message = l10n_util::GetStringFUTF16(IDS_CLOUD_PRINT_SETUP_DONE, 302 string16 message = l10n_util::GetStringFUTF16(IDS_CLOUD_PRINT_SETUP_DONE,
303 product_name, 303 product_name,
304 UTF8ToUTF16(login_)); 304 UTF8ToUTF16(login_));
305 string16 javascript(ASCIIToUTF16("cloudprint.setMessage('") + message + 305 string16 javascript(ASCIIToUTF16("cloudprint.setMessage('") + message +
306 ASCIIToUTF16("');")); 306 ASCIIToUTF16("');"));
307 ExecuteJavascriptInIFrame(DoneIframeXPath(), javascript); 307 ExecuteJavascriptInIFrame(DoneIframeXPath(), javascript);
308 308
309 if (web_ui_) { 309 if (web_ui_) {
310 PrefService* prefs = profile_->GetPrefs(); 310 PrefService* prefs = profile_->GetPrefs();
311 gfx::Font approximate_web_font( 311 gfx::Font approximate_web_font(
312 prefs->GetString(prefs::kWebKitSansSerifFontFamily), 312 prefs->GetString(prefs::kWebKitGlobalSansSerifFontFamily),
313 prefs->GetInteger(prefs::kWebKitDefaultFontSize)); 313 prefs->GetInteger(prefs::kWebKitGlobalDefaultFontSize));
314 gfx::Size done_size = ui::GetLocalizedContentsSizeForFont( 314 gfx::Size done_size = ui::GetLocalizedContentsSizeForFont(
315 IDS_CLOUD_PRINT_SETUP_WIZARD_DONE_WIDTH_CHARS, 315 IDS_CLOUD_PRINT_SETUP_WIZARD_DONE_WIDTH_CHARS,
316 IDS_CLOUD_PRINT_SETUP_WIZARD_DONE_HEIGHT_LINES, 316 IDS_CLOUD_PRINT_SETUP_WIZARD_DONE_HEIGHT_LINES,
317 approximate_web_font); 317 approximate_web_font);
318 318
319 base::FundamentalValue new_width(done_size.width()); 319 base::FundamentalValue new_width(done_size.width());
320 base::FundamentalValue new_height(done_size.height()); 320 base::FundamentalValue new_height(done_size.height());
321 web_ui_->CallJavascriptFunction("cloudprint.showSetupDone", 321 web_ui_->CallJavascriptFunction("cloudprint.showSetupDone",
322 new_width, new_height); 322 new_width, new_height);
323 } 323 }
324 324
325 ExecuteJavascriptInIFrame(DoneIframeXPath(), 325 ExecuteJavascriptInIFrame(DoneIframeXPath(),
326 ASCIIToUTF16("cloudprint.onPageShown();")); 326 ASCIIToUTF16("cloudprint.onPageShown();"));
327 } 327 }
328 328
329 void CloudPrintSetupFlow::ExecuteJavascriptInIFrame( 329 void CloudPrintSetupFlow::ExecuteJavascriptInIFrame(
330 const string16& iframe_xpath, 330 const string16& iframe_xpath,
331 const string16& js) { 331 const string16& js) {
332 if (web_ui_) { 332 if (web_ui_) {
333 RenderViewHost* rvh = web_ui_->tab_contents()->render_view_host(); 333 RenderViewHost* rvh = web_ui_->tab_contents()->render_view_host();
334 rvh->ExecuteJavascriptInWebFrame(iframe_xpath, js); 334 rvh->ExecuteJavascriptInWebFrame(iframe_xpath, js);
335 } 335 }
336 } 336 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698