Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(354)

Side by Side Diff: chrome/browser/ui/webui/tab_modal_confirm_dialog_webui.cc

Issue 10972002: chrome: Add TabModalConfirmDialog interface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: no else after return Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/webui/tab_modal_confirm_dialog_webui.h ('k') | chrome/chrome_browser_ui.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/browser_dialogs.h"
18 #include "chrome/browser/ui/constrained_window.h" 17 #include "chrome/browser/ui/constrained_window.h"
19 #include "chrome/browser/ui/tab_contents/tab_contents.h" 18 #include "chrome/browser/ui/tab_contents/tab_contents.h"
20 #include "chrome/browser/ui/tab_modal_confirm_dialog_delegate.h" 19 #include "chrome/browser/ui/tab_modal_confirm_dialog_delegate.h"
21 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" 20 #include "chrome/browser/ui/webui/chrome_url_data_manager.h"
22 #include "chrome/browser/ui/webui/chrome_web_ui_data_source.h" 21 #include "chrome/browser/ui/webui/chrome_web_ui_data_source.h"
23 #include "chrome/common/jstemplate_builder.h" 22 #include "chrome/common/jstemplate_builder.h"
24 #include "chrome/common/url_constants.h" 23 #include "chrome/common/url_constants.h"
25 #include "grit/browser_resources.h" 24 #include "grit/browser_resources.h"
26 #include "grit/generated_resources.h" 25 #include "grit/generated_resources.h"
27 #include "ui/base/l10n/l10n_util.h" 26 #include "ui/base/l10n/l10n_util.h"
28 #include "ui/base/resource/resource_bundle.h" 27 #include "ui/base/resource/resource_bundle.h"
29 #include "ui/gfx/size.h" 28 #include "ui/gfx/size.h"
30 #include "ui/web_dialogs/constrained_web_dialog_ui.h" 29 #include "ui/web_dialogs/constrained_web_dialog_ui.h"
31 30
32 using content::WebContents; 31 using content::WebContents;
33 using content::WebUIMessageHandler; 32 using content::WebUIMessageHandler;
34 33
35 namespace chrome { 34 // static
36 35 TabModalConfirmDialog* TabModalConfirmDialog::Create(
37 // Declared in browser_dialogs.h so others don't have to depend on our header. 36 TabModalConfirmDialogDelegate* delegate,
38 void ShowTabModalConfirmDialog(TabModalConfirmDialogDelegate* delegate, 37 TabContents* tab_contents) {
39 TabContents* tab_contents) { 38 return new TabModalConfirmDialogWebUI(delegate, tab_contents);
40 new TabModalConfirmDialogWebUI(delegate, tab_contents);
41 } 39 }
42 40
43 } // namespace chrome
44
45 const int kDialogWidth = 400; 41 const int kDialogWidth = 400;
46 const int kDialogHeight = 120; 42 const int kDialogHeight = 120;
47 43
48 TabModalConfirmDialogWebUI::TabModalConfirmDialogWebUI( 44 TabModalConfirmDialogWebUI::TabModalConfirmDialogWebUI(
49 TabModalConfirmDialogDelegate* delegate, 45 TabModalConfirmDialogDelegate* delegate,
50 TabContents* tab_contents) 46 TabContents* tab_contents)
51 : delegate_(delegate) { 47 : delegate_(delegate) {
52 Profile* profile = tab_contents->profile(); 48 Profile* profile = tab_contents->profile();
53 ChromeWebUIDataSource* data_source = 49 ChromeWebUIDataSource* data_source =
54 new ChromeWebUIDataSource(chrome::kChromeUITabModalConfirmDialogHost); 50 new ChromeWebUIDataSource(chrome::kChromeUITabModalConfirmDialogHost);
55 data_source->set_default_resource(IDR_TAB_MODAL_CONFIRM_DIALOG_HTML); 51 data_source->set_default_resource(IDR_TAB_MODAL_CONFIRM_DIALOG_HTML);
56 ChromeURLDataManager::AddDataSource(profile, data_source); 52 ChromeURLDataManager::AddDataSource(profile, data_source);
57 53
58 constrained_web_dialog_delegate_ = 54 constrained_web_dialog_delegate_ =
59 ui::CreateConstrainedWebDialog(profile, 55 ui::CreateConstrainedWebDialog(profile,
60 this, 56 this,
61 NULL, 57 NULL,
62 tab_contents); 58 tab_contents);
63 delegate_->set_window(constrained_web_dialog_delegate_->window()); 59 delegate_->set_window(constrained_web_dialog_delegate_->window());
64 } 60 }
65 61
66 TabModalConfirmDialogWebUI::~TabModalConfirmDialogWebUI() {}
67
68 ui::ModalType TabModalConfirmDialogWebUI::GetDialogModalType() const { 62 ui::ModalType TabModalConfirmDialogWebUI::GetDialogModalType() const {
69 return ui::MODAL_TYPE_WINDOW; 63 return ui::MODAL_TYPE_WINDOW;
70 } 64 }
71 65
72 string16 TabModalConfirmDialogWebUI::GetDialogTitle() const { 66 string16 TabModalConfirmDialogWebUI::GetDialogTitle() const {
73 return delegate_->GetTitle(); 67 return delegate_->GetTitle();
74 } 68 }
75 69
76 GURL TabModalConfirmDialogWebUI::GetDialogContentURL() const { 70 GURL TabModalConfirmDialogWebUI::GetDialogContentURL() const {
77 return GURL(chrome::kChromeUITabModalConfirmDialogURL); 71 return GURL(chrome::kChromeUITabModalConfirmDialogURL);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 else 104 else
111 delegate_->Cancel(); 105 delegate_->Cancel();
112 } 106 }
113 107
114 void TabModalConfirmDialogWebUI::OnCloseContents(WebContents* source, 108 void TabModalConfirmDialogWebUI::OnCloseContents(WebContents* source,
115 bool* out_close_dialog) {} 109 bool* out_close_dialog) {}
116 110
117 bool TabModalConfirmDialogWebUI::ShouldShowDialogTitle() const { 111 bool TabModalConfirmDialogWebUI::ShouldShowDialogTitle() const {
118 return true; 112 return true;
119 } 113 }
114
115 TabModalConfirmDialogWebUI::~TabModalConfirmDialogWebUI() {}
116
117 void TabModalConfirmDialogWebUI::AcceptTabModalDialog() {
118 }
119
120 void TabModalConfirmDialogWebUI::CancelTabModalDialog() {
121 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/tab_modal_confirm_dialog_webui.h ('k') | chrome/chrome_browser_ui.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698