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