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

Side by Side Diff: chrome/browser/ui/webui/tab_modal_confirm_dialog_webui.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/ui/webui/tab_modal_confirm_dialog_webui.h" 5 #include "chrome/browser/ui/webui/tab_modal_confirm_dialog_webui.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 size->SetSize(kDialogWidth, kDialogHeight); 83 size->SetSize(kDialogWidth, kDialogHeight);
84 } 84 }
85 85
86 std::string TabModalConfirmDialogWebUI::GetDialogArgs() const { 86 std::string TabModalConfirmDialogWebUI::GetDialogArgs() const {
87 DictionaryValue dict; 87 DictionaryValue dict;
88 dict.SetString("message", delegate_->GetMessage()); 88 dict.SetString("message", delegate_->GetMessage());
89 dict.SetString("accept", delegate_->GetAcceptButtonTitle()); 89 dict.SetString("accept", delegate_->GetAcceptButtonTitle());
90 dict.SetString("cancel", delegate_->GetCancelButtonTitle()); 90 dict.SetString("cancel", delegate_->GetCancelButtonTitle());
91 ChromeWebUIDataSource::SetFontAndTextDirection(&dict); 91 ChromeWebUIDataSource::SetFontAndTextDirection(&dict);
92 std::string json; 92 std::string json;
93 base::JSONWriter::Write(&dict, false, &json); 93 base::JSONWriter::Write(&dict, &json);
94 return json; 94 return json;
95 } 95 }
96 96
97 void TabModalConfirmDialogWebUI::OnDialogClosed( 97 void TabModalConfirmDialogWebUI::OnDialogClosed(
98 const std::string& json_retval) { 98 const std::string& json_retval) {
99 bool accepted = false; 99 bool accepted = false;
100 if (!json_retval.empty()) { 100 if (!json_retval.empty()) {
101 base::JSONReader reader; 101 base::JSONReader reader;
102 scoped_ptr<Value> value(reader.JsonToValue(json_retval, false, false)); 102 scoped_ptr<Value> value(reader.JsonToValue(json_retval, false, false));
103 if (!value.get() || !value->GetAsBoolean(&accepted)) 103 if (!value.get() || !value->GetAsBoolean(&accepted))
104 NOTREACHED() << "Missing or unreadable response from dialog"; 104 NOTREACHED() << "Missing or unreadable response from dialog";
105 } 105 }
106 106
107 delegate_->set_window(NULL); 107 delegate_->set_window(NULL);
108 if (accepted) 108 if (accepted)
109 delegate_->Accept(); 109 delegate_->Accept();
110 else 110 else
111 delegate_->Cancel(); 111 delegate_->Cancel();
112 delete this; 112 delete this;
113 } 113 }
114 114
115 void TabModalConfirmDialogWebUI::OnCloseContents(WebContents* source, 115 void TabModalConfirmDialogWebUI::OnCloseContents(WebContents* source,
116 bool* out_close_dialog) {} 116 bool* out_close_dialog) {}
117 117
118 bool TabModalConfirmDialogWebUI::ShouldShowDialogTitle() const { 118 bool TabModalConfirmDialogWebUI::ShouldShowDialogTitle() const {
119 return true; 119 return true;
120 } 120 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/print_preview/print_preview_handler_unittest.cc ('k') | chrome/browser/ui/webui/workers_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698