OLD | NEW |
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 Loading... |
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 } |
OLD | NEW |