| 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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 ChromeWebUIDataSource::SetFontAndTextDirection(&dict); | 92 ChromeWebUIDataSource::SetFontAndTextDirection(&dict); |
| 93 std::string json; | 93 std::string json; |
| 94 base::JSONWriter::Write(&dict, &json); | 94 base::JSONWriter::Write(&dict, &json); |
| 95 return json; | 95 return json; |
| 96 } | 96 } |
| 97 | 97 |
| 98 void TabModalConfirmDialogWebUI::OnDialogClosed( | 98 void TabModalConfirmDialogWebUI::OnDialogClosed( |
| 99 const std::string& json_retval) { | 99 const std::string& json_retval) { |
| 100 bool accepted = false; | 100 bool accepted = false; |
| 101 if (!json_retval.empty()) { | 101 if (!json_retval.empty()) { |
| 102 base::JSONReader reader; | 102 scoped_ptr<Value> value(base::JSONReader::Read(json_retval)); |
| 103 scoped_ptr<Value> value(reader.JsonToValue(json_retval, false, false)); | |
| 104 if (!value.get() || !value->GetAsBoolean(&accepted)) | 103 if (!value.get() || !value->GetAsBoolean(&accepted)) |
| 105 NOTREACHED() << "Missing or unreadable response from dialog"; | 104 NOTREACHED() << "Missing or unreadable response from dialog"; |
| 106 } | 105 } |
| 107 | 106 |
| 108 delegate_->set_window(NULL); | 107 delegate_->set_window(NULL); |
| 109 if (accepted) | 108 if (accepted) |
| 110 delegate_->Accept(); | 109 delegate_->Accept(); |
| 111 else | 110 else |
| 112 delegate_->Cancel(); | 111 delegate_->Cancel(); |
| 113 delete this; | 112 delete this; |
| 114 } | 113 } |
| 115 | 114 |
| 116 void TabModalConfirmDialogWebUI::OnCloseContents(WebContents* source, | 115 void TabModalConfirmDialogWebUI::OnCloseContents(WebContents* source, |
| 117 bool* out_close_dialog) {} | 116 bool* out_close_dialog) {} |
| 118 | 117 |
| 119 bool TabModalConfirmDialogWebUI::ShouldShowDialogTitle() const { | 118 bool TabModalConfirmDialogWebUI::ShouldShowDialogTitle() const { |
| 120 return true; | 119 return true; |
| 121 } | 120 } |
| OLD | NEW |