| 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" |
| 11 #include "base/json/json_reader.h" | 11 #include "base/json/json_reader.h" |
| 12 #include "base/json/json_writer.h" | 12 #include "base/json/json_writer.h" |
| 13 #include "base/string_piece.h" | 13 #include "base/string_piece.h" |
| 14 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
| 15 #include "base/values.h" | 15 #include "base/values.h" |
| 16 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
| 17 #include "chrome/browser/ui/constrained_window.h" | 17 #include "chrome/browser/ui/constrained_window.h" |
| 18 #include "chrome/browser/ui/tab_contents/tab_contents.h" | 18 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
| 19 #include "chrome/browser/ui/tab_modal_confirm_dialog_delegate.h" | 19 #include "chrome/browser/ui/tab_modal_confirm_dialog_delegate.h" |
| 20 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" | 20 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" |
| 21 #include "chrome/browser/ui/webui/chrome_web_ui_data_source.h" | 21 #include "chrome/browser/ui/webui/chrome_web_ui_data_source.h" |
| 22 #include "chrome/browser/ui/webui/constrained_web_dialog_ui.h" |
| 22 #include "chrome/common/jstemplate_builder.h" | 23 #include "chrome/common/jstemplate_builder.h" |
| 23 #include "chrome/common/url_constants.h" | 24 #include "chrome/common/url_constants.h" |
| 24 #include "grit/browser_resources.h" | 25 #include "grit/browser_resources.h" |
| 25 #include "grit/generated_resources.h" | 26 #include "grit/generated_resources.h" |
| 26 #include "ui/base/l10n/l10n_util.h" | 27 #include "ui/base/l10n/l10n_util.h" |
| 27 #include "ui/base/resource/resource_bundle.h" | 28 #include "ui/base/resource/resource_bundle.h" |
| 28 #include "ui/gfx/size.h" | 29 #include "ui/gfx/size.h" |
| 29 #include "ui/web_dialogs/constrained_web_dialog_ui.h" | |
| 30 | 30 |
| 31 using content::WebContents; | 31 using content::WebContents; |
| 32 using content::WebUIMessageHandler; | 32 using content::WebUIMessageHandler; |
| 33 | 33 |
| 34 // static | 34 // static |
| 35 TabModalConfirmDialog* TabModalConfirmDialog::Create( | 35 TabModalConfirmDialog* TabModalConfirmDialog::Create( |
| 36 TabModalConfirmDialogDelegate* delegate, | 36 TabModalConfirmDialogDelegate* delegate, |
| 37 TabContents* tab_contents) { | 37 TabContents* tab_contents) { |
| 38 return new TabModalConfirmDialogWebUI(delegate, tab_contents); | 38 return new TabModalConfirmDialogWebUI(delegate, tab_contents); |
| 39 } | 39 } |
| 40 | 40 |
| 41 const int kDialogWidth = 400; | 41 const int kDialogWidth = 400; |
| 42 const int kDialogHeight = 120; | 42 const int kDialogHeight = 120; |
| 43 | 43 |
| 44 TabModalConfirmDialogWebUI::TabModalConfirmDialogWebUI( | 44 TabModalConfirmDialogWebUI::TabModalConfirmDialogWebUI( |
| 45 TabModalConfirmDialogDelegate* delegate, | 45 TabModalConfirmDialogDelegate* delegate, |
| 46 TabContents* tab_contents) | 46 TabContents* tab_contents) |
| 47 : delegate_(delegate) { | 47 : delegate_(delegate) { |
| 48 Profile* profile = tab_contents->profile(); | 48 Profile* profile = tab_contents->profile(); |
| 49 ChromeWebUIDataSource* data_source = | 49 ChromeWebUIDataSource* data_source = |
| 50 new ChromeWebUIDataSource(chrome::kChromeUITabModalConfirmDialogHost); | 50 new ChromeWebUIDataSource(chrome::kChromeUITabModalConfirmDialogHost); |
| 51 data_source->set_default_resource(IDR_TAB_MODAL_CONFIRM_DIALOG_HTML); | 51 data_source->set_default_resource(IDR_TAB_MODAL_CONFIRM_DIALOG_HTML); |
| 52 ChromeURLDataManager::AddDataSource(profile, data_source); | 52 ChromeURLDataManager::AddDataSource(profile, data_source); |
| 53 | 53 |
| 54 constrained_web_dialog_delegate_ = | 54 constrained_web_dialog_delegate_ = |
| 55 ui::CreateConstrainedWebDialog(profile, | 55 CreateConstrainedWebDialog(profile, |
| 56 this, | 56 this, |
| 57 NULL, | 57 NULL, |
| 58 tab_contents); | 58 tab_contents->web_contents()); |
| 59 delegate_->set_window(constrained_web_dialog_delegate_->window()); | 59 delegate_->set_window(constrained_web_dialog_delegate_->window()); |
| 60 } | 60 } |
| 61 | 61 |
| 62 ui::ModalType TabModalConfirmDialogWebUI::GetDialogModalType() const { | 62 ui::ModalType TabModalConfirmDialogWebUI::GetDialogModalType() const { |
| 63 return ui::MODAL_TYPE_WINDOW; | 63 return ui::MODAL_TYPE_WINDOW; |
| 64 } | 64 } |
| 65 | 65 |
| 66 string16 TabModalConfirmDialogWebUI::GetDialogTitle() const { | 66 string16 TabModalConfirmDialogWebUI::GetDialogTitle() const { |
| 67 return delegate_->GetTitle(); | 67 return delegate_->GetTitle(); |
| 68 } | 68 } |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 return true; | 112 return true; |
| 113 } | 113 } |
| 114 | 114 |
| 115 TabModalConfirmDialogWebUI::~TabModalConfirmDialogWebUI() {} | 115 TabModalConfirmDialogWebUI::~TabModalConfirmDialogWebUI() {} |
| 116 | 116 |
| 117 void TabModalConfirmDialogWebUI::AcceptTabModalDialog() { | 117 void TabModalConfirmDialogWebUI::AcceptTabModalDialog() { |
| 118 } | 118 } |
| 119 | 119 |
| 120 void TabModalConfirmDialogWebUI::CancelTabModalDialog() { | 120 void TabModalConfirmDialogWebUI::CancelTabModalDialog() { |
| 121 } | 121 } |
| OLD | NEW |