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

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

Issue 9590002: JSONWriter cleanup: integrate pretty print into write options. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix merge conflict 7. Created 8 years, 9 months 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 args.SetInteger("error", 0); 69 args.SetInteger("error", 0);
70 args.SetBoolean("editable_user", true); 70 args.SetBoolean("editable_user", true);
71 71
72 bool setup_done = false; 72 bool setup_done = false;
73 if (profile->GetPrefs()->HasPrefPath(prefs::kCloudPrintEmail) && 73 if (profile->GetPrefs()->HasPrefPath(prefs::kCloudPrintEmail) &&
74 !profile->GetPrefs()->GetString(prefs::kCloudPrintEmail).empty()) 74 !profile->GetPrefs()->GetString(prefs::kCloudPrintEmail).empty())
75 setup_done = true; 75 setup_done = true;
76 args.SetString("pageToShow", setup_done ? "setupdone" : "cloudprintsetup"); 76 args.SetString("pageToShow", setup_done ? "setupdone" : "cloudprintsetup");
77 77
78 std::string json_args; 78 std::string json_args;
79 base::JSONWriter::Write(&args, false, &json_args); 79 base::JSONWriter::Write(&args, &json_args);
80 80
81 CloudPrintSetupFlow* flow = new CloudPrintSetupFlow(json_args, profile, 81 CloudPrintSetupFlow* flow = new CloudPrintSetupFlow(json_args, profile,
82 delegate, setup_done); 82 delegate, setup_done);
83 // We may not always have a browser. This can happen when we are being 83 // We may not always have a browser. This can happen when we are being
84 // invoked in the context of a "token expired" notfication. If we don't have 84 // invoked in the context of a "token expired" notfication. If we don't have
85 // a brower, use the underlying dialog system to show the dialog without 85 // a brower, use the underlying dialog system to show the dialog without
86 // using a browser. 86 // using a browser.
87 if (!parent_window && browser && browser->window()) 87 if (!parent_window && browser && browser->window())
88 parent_window = browser->window()->GetNativeHandle(); 88 parent_window = browser->window()->GetNativeHandle();
89 browser::ShowHtmlDialog(parent_window, profile, browser, flow, STYLE_GENERIC); 89 browser::ShowHtmlDialog(parent_window, profile, browser, flow, STYLE_GENERIC);
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 web_ui_->GetWebContents()->OpenURL(params); 273 web_ui_->GetWebContents()->OpenURL(params);
274 } 274 }
275 275
276 /////////////////////////////////////////////////////////////////////////////// 276 ///////////////////////////////////////////////////////////////////////////////
277 // Helper methods for showing contents of the Web UI 277 // Helper methods for showing contents of the Web UI
278 void CloudPrintSetupFlow::ShowGaiaLogin(const DictionaryValue& args) { 278 void CloudPrintSetupFlow::ShowGaiaLogin(const DictionaryValue& args) {
279 if (web_ui_) 279 if (web_ui_)
280 web_ui_->CallJavascriptFunction("cloudprint.showSetupLogin"); 280 web_ui_->CallJavascriptFunction("cloudprint.showSetupLogin");
281 281
282 std::string json; 282 std::string json;
283 base::JSONWriter::Write(&args, false, &json); 283 base::JSONWriter::Write(&args, &json);
284 string16 javascript = UTF8ToUTF16("cloudprint.showGaiaLogin(" + json + ");"); 284 string16 javascript = UTF8ToUTF16("cloudprint.showGaiaLogin(" + json + ");");
285 285
286 ExecuteJavascriptInIFrame(SetupIframeXPath(), javascript); 286 ExecuteJavascriptInIFrame(SetupIframeXPath(), javascript);
287 } 287 }
288 288
289 void CloudPrintSetupFlow::ShowGaiaSuccessAndSettingUp() { 289 void CloudPrintSetupFlow::ShowGaiaSuccessAndSettingUp() {
290 ExecuteJavascriptInIFrame( 290 ExecuteJavascriptInIFrame(
291 SetupIframeXPath(), 291 SetupIframeXPath(),
292 ASCIIToUTF16("cloudprint.showGaiaSuccessAndSettingUp();")); 292 ASCIIToUTF16("cloudprint.showGaiaSuccessAndSettingUp();"));
293 } 293 }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 334
335 void CloudPrintSetupFlow::ExecuteJavascriptInIFrame( 335 void CloudPrintSetupFlow::ExecuteJavascriptInIFrame(
336 const string16& iframe_xpath, 336 const string16& iframe_xpath,
337 const string16& js) { 337 const string16& js) {
338 if (web_ui_) { 338 if (web_ui_) {
339 content::RenderViewHost* rvh = 339 content::RenderViewHost* rvh =
340 web_ui_->GetWebContents()->GetRenderViewHost(); 340 web_ui_->GetWebContents()->GetRenderViewHost();
341 rvh->ExecuteJavascriptInWebFrame(iframe_xpath, js); 341 rvh->ExecuteJavascriptInWebFrame(iframe_xpath, js);
342 } 342 }
343 } 343 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698