| 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 Profile* profile = | 47 Profile* profile = |
| 48 Profile::FromBrowserContext(web_contents->GetBrowserContext()); | 48 Profile::FromBrowserContext(web_contents->GetBrowserContext()); |
| 49 content::WebUIDataSource* data_source = content::WebUIDataSource::Create( | 49 content::WebUIDataSource* data_source = content::WebUIDataSource::Create( |
| 50 chrome::kChromeUITabModalConfirmDialogHost); | 50 chrome::kChromeUITabModalConfirmDialogHost); |
| 51 data_source->SetDefaultResource(IDR_TAB_MODAL_CONFIRM_DIALOG_HTML); | 51 data_source->SetDefaultResource(IDR_TAB_MODAL_CONFIRM_DIALOG_HTML); |
| 52 data_source->DisableContentSecurityPolicy(); | 52 data_source->DisableContentSecurityPolicy(); |
| 53 content::WebUIDataSource::Add(profile, data_source); | 53 content::WebUIDataSource::Add(profile, data_source); |
| 54 | 54 |
| 55 constrained_web_dialog_delegate_ = | 55 constrained_web_dialog_delegate_ = |
| 56 CreateConstrainedWebDialog(profile, this, NULL, web_contents); | 56 CreateConstrainedWebDialog(profile, this, NULL, web_contents); |
| 57 delegate_->set_window(constrained_web_dialog_delegate_->GetWindow()); | 57 delegate_->set_close_delegate(this); |
| 58 } | 58 } |
| 59 | 59 |
| 60 ui::ModalType TabModalConfirmDialogWebUI::GetDialogModalType() const { | 60 ui::ModalType TabModalConfirmDialogWebUI::GetDialogModalType() const { |
| 61 return ui::MODAL_TYPE_WINDOW; | 61 return ui::MODAL_TYPE_WINDOW; |
| 62 } | 62 } |
| 63 | 63 |
| 64 string16 TabModalConfirmDialogWebUI::GetDialogTitle() const { | 64 string16 TabModalConfirmDialogWebUI::GetDialogTitle() const { |
| 65 return delegate_->GetTitle(); | 65 return delegate_->GetTitle(); |
| 66 } | 66 } |
| 67 | 67 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 89 | 89 |
| 90 void TabModalConfirmDialogWebUI::OnDialogClosed( | 90 void TabModalConfirmDialogWebUI::OnDialogClosed( |
| 91 const std::string& json_retval) { | 91 const std::string& json_retval) { |
| 92 bool accepted = false; | 92 bool accepted = false; |
| 93 if (!json_retval.empty()) { | 93 if (!json_retval.empty()) { |
| 94 scoped_ptr<Value> value(base::JSONReader::Read(json_retval)); | 94 scoped_ptr<Value> value(base::JSONReader::Read(json_retval)); |
| 95 if (!value.get() || !value->GetAsBoolean(&accepted)) | 95 if (!value.get() || !value->GetAsBoolean(&accepted)) |
| 96 NOTREACHED() << "Missing or unreadable response from dialog"; | 96 NOTREACHED() << "Missing or unreadable response from dialog"; |
| 97 } | 97 } |
| 98 | 98 |
| 99 delegate_->set_window(NULL); | 99 delegate_->set_close_delegate(NULL); |
| 100 if (accepted) | 100 if (accepted) |
| 101 delegate_->Accept(); | 101 delegate_->Accept(); |
| 102 else | 102 else |
| 103 delegate_->Cancel(); | 103 delegate_->Cancel(); |
| 104 } | 104 } |
| 105 | 105 |
| 106 void TabModalConfirmDialogWebUI::OnCloseContents(WebContents* source, | 106 void TabModalConfirmDialogWebUI::OnCloseContents(WebContents* source, |
| 107 bool* out_close_dialog) {} | 107 bool* out_close_dialog) {} |
| 108 | 108 |
| 109 bool TabModalConfirmDialogWebUI::ShouldShowDialogTitle() const { | 109 bool TabModalConfirmDialogWebUI::ShouldShowDialogTitle() const { |
| 110 return true; | 110 return true; |
| 111 } | 111 } |
| 112 | 112 |
| 113 TabModalConfirmDialogWebUI::~TabModalConfirmDialogWebUI() {} | 113 TabModalConfirmDialogWebUI::~TabModalConfirmDialogWebUI() {} |
| 114 | 114 |
| 115 void TabModalConfirmDialogWebUI::AcceptTabModalDialog() { | 115 void TabModalConfirmDialogWebUI::AcceptTabModalDialog() { |
| 116 } | 116 } |
| 117 | 117 |
| 118 void TabModalConfirmDialogWebUI::CancelTabModalDialog() { | 118 void TabModalConfirmDialogWebUI::CancelTabModalDialog() { |
| 119 } | 119 } |
| 120 |
| 121 void TabModalConfirmDialogWebUI::CloseDialog() { |
| 122 constrained_web_dialog_delegate_->OnDialogCloseFromWebUI(); |
| 123 } |
| OLD | NEW |