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

Side by Side Diff: chrome/browser/ui/gtk/constrained_web_dialog_delegate_gtk.cc

Issue 12851002: Remove ConstrainedWindowGtkDelegate (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 9 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
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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/constrained_web_dialog_delegate_base.h" 5 #include "chrome/browser/ui/webui/constrained_web_dialog_delegate_base.h"
6 6
7 #include "chrome/browser/ui/gtk/constrained_window_gtk.h" 7 #include "chrome/browser/ui/gtk/constrained_window_gtk.h"
8 #include "chrome/browser/ui/web_contents_modal_dialog_manager.h" 8 #include "chrome/browser/ui/web_contents_modal_dialog_manager.h"
9 #include "content/public/browser/notification_source.h" 9 #include "content/public/browser/notification_source.h"
10 #include "content/public/browser/render_view_host.h" 10 #include "content/public/browser/render_view_host.h"
(...skipping 30 matching lines...) Expand all
41 41
42 private: 42 private:
43 GtkWidget* window_; 43 GtkWidget* window_;
44 44
45 DISALLOW_COPY_AND_ASSIGN(ConstrainedWebDialogDelegateGtk); 45 DISALLOW_COPY_AND_ASSIGN(ConstrainedWebDialogDelegateGtk);
46 }; 46 };
47 47
48 } // namespace 48 } // namespace
49 49
50 class ConstrainedWebDialogDelegateViewGtk 50 class ConstrainedWebDialogDelegateViewGtk
51 : public ConstrainedWindowGtkDelegate, 51 : public ConstrainedWebDialogDelegate {
52 public ConstrainedWebDialogDelegate {
53 public: 52 public:
54 ConstrainedWebDialogDelegateViewGtk( 53 ConstrainedWebDialogDelegateViewGtk(
55 content::BrowserContext* browser_context, 54 content::BrowserContext* browser_context,
56 WebDialogDelegate* delegate, 55 WebDialogDelegate* delegate,
57 WebDialogWebContentsDelegate* tab_delegate); 56 WebDialogWebContentsDelegate* tab_delegate);
58 57
59 virtual ~ConstrainedWebDialogDelegateViewGtk() {} 58 virtual ~ConstrainedWebDialogDelegateViewGtk() {}
60 59
61 // ConstrainedWebDialogDelegate interface 60 // ConstrainedWebDialogDelegate interface
62 virtual const WebDialogDelegate* 61 virtual const WebDialogDelegate*
63 GetWebDialogDelegate() const OVERRIDE { 62 GetWebDialogDelegate() const OVERRIDE {
64 return impl_->GetWebDialogDelegate(); 63 return impl_->GetWebDialogDelegate();
65 } 64 }
66 virtual WebDialogDelegate* GetWebDialogDelegate() OVERRIDE { 65 virtual WebDialogDelegate* GetWebDialogDelegate() OVERRIDE {
67 return impl_->GetWebDialogDelegate(); 66 return impl_->GetWebDialogDelegate();
68 } 67 }
69 virtual void OnDialogCloseFromWebUI() OVERRIDE { 68 virtual void OnDialogCloseFromWebUI() OVERRIDE {
70 return impl_->OnDialogCloseFromWebUI(); 69 return impl_->OnDialogCloseFromWebUI();
71 } 70 }
72 virtual void ReleaseWebContentsOnDialogClose() OVERRIDE { 71 virtual void ReleaseWebContentsOnDialogClose() OVERRIDE {
73 return impl_->ReleaseWebContentsOnDialogClose(); 72 return impl_->ReleaseWebContentsOnDialogClose();
74 } 73 }
75 virtual NativeWebContentsModalDialog GetNativeDialog() OVERRIDE { 74 virtual NativeWebContentsModalDialog GetNativeDialog() OVERRIDE {
76 return impl_->window(); 75 return impl_->window();
77 } 76 }
78 virtual WebContents* GetWebContents() OVERRIDE { 77 virtual WebContents* GetWebContents() OVERRIDE {
79 return impl_->GetWebContents(); 78 return impl_->GetWebContents();
80 } 79 }
81 80
82 // ConstrainedWindowGtkDelegate interface
83 virtual GtkWidget* GetWidgetRoot() OVERRIDE {
84 return GetWebContents()->GetView()->GetNativeView();
85 }
86 virtual GtkWidget* GetFocusWidget() OVERRIDE {
87 return GetWebContents()->GetView()->GetContentNativeView();
88 }
89 virtual void DeleteDelegate() OVERRIDE {
90 if (!impl_->closed_via_webui())
91 GetWebDialogDelegate()->OnDialogClosed("");
92 delete this;
93 }
94 virtual bool GetBackgroundColor(GdkColor* color) OVERRIDE {
95 *color = ui::kGdkWhite;
96 return true;
97 }
98
99 void SetWindow(GtkWidget* window) { 81 void SetWindow(GtkWidget* window) {
100 impl_->set_window(window); 82 impl_->set_window(window);
101 } 83 }
102 84
103 GtkWidget* GetWindow() { 85 GtkWidget* GetWindow() {
104 return impl_->window(); 86 return impl_->window();
105 } 87 }
106 88
107 private: 89 private:
90 CHROMEGTK_CALLBACK_0(ConstrainedWebDialogDelegateViewGtk, void, OnDestroy);
91
108 scoped_ptr<ConstrainedWebDialogDelegateGtk> impl_; 92 scoped_ptr<ConstrainedWebDialogDelegateGtk> impl_;
109 93
110 DISALLOW_COPY_AND_ASSIGN(ConstrainedWebDialogDelegateViewGtk); 94 DISALLOW_COPY_AND_ASSIGN(ConstrainedWebDialogDelegateViewGtk);
111 }; 95 };
112 96
113 ConstrainedWebDialogDelegateViewGtk::ConstrainedWebDialogDelegateViewGtk( 97 ConstrainedWebDialogDelegateViewGtk::ConstrainedWebDialogDelegateViewGtk(
114 content::BrowserContext* browser_context, 98 content::BrowserContext* browser_context,
115 WebDialogDelegate* delegate, 99 WebDialogDelegate* delegate,
116 WebDialogWebContentsDelegate* tab_delegate) 100 WebDialogWebContentsDelegate* tab_delegate)
117 : impl_(new ConstrainedWebDialogDelegateGtk( 101 : impl_(new ConstrainedWebDialogDelegateGtk(
118 browser_context, 102 browser_context,
119 delegate, 103 delegate,
120 tab_delegate)) { 104 tab_delegate)) {
121 gfx::Size dialog_size; 105 gfx::Size dialog_size;
122 delegate->GetDialogSize(&dialog_size); 106 delegate->GetDialogSize(&dialog_size);
123 gtk_widget_set_size_request(GTK_WIDGET(GetWidgetRoot()), 107 GtkWidget* contents =
108 GTK_WIDGET(GetWebContents()->GetView()->GetNativeView());
109 gtk_widget_set_size_request(contents,
124 dialog_size.width(), 110 dialog_size.width(),
125 dialog_size.height()); 111 dialog_size.height());
126 112
127 gtk_widget_show_all(GetWidgetRoot()); 113 gtk_widget_show_all(contents);
114
115 g_signal_connect(contents, "destroy", G_CALLBACK(OnDestroyThunk), this);
128 } 116 }
129 117
118 void ConstrainedWebDialogDelegateViewGtk::OnDestroy(GtkWidget* widget) {
119 if (!impl_->closed_via_webui())
120 GetWebDialogDelegate()->OnDialogClosed("");
121 delete this;
122 }
123
124 namespace {
125 void SetBackgroundColor(GtkWidget* widget, const GdkColor &color) {
Elliot Glaysher 2013/03/13 23:48:10 This should go in the existing anonymous namespace
Mike Wittman 2013/03/14 00:34:48 Done.
126 gtk_widget_modify_base(widget, GTK_STATE_NORMAL, &color);
127 gtk_widget_modify_fg(widget, GTK_STATE_NORMAL, &color);
128 gtk_widget_modify_bg(widget, GTK_STATE_NORMAL, &color);
129 }
130 } // namespace
131
130 ConstrainedWebDialogDelegate* CreateConstrainedWebDialog( 132 ConstrainedWebDialogDelegate* CreateConstrainedWebDialog(
131 content::BrowserContext* browser_context, 133 content::BrowserContext* browser_context,
132 WebDialogDelegate* delegate, 134 WebDialogDelegate* delegate,
133 WebDialogWebContentsDelegate* tab_delegate, 135 WebDialogWebContentsDelegate* tab_delegate,
134 content::WebContents* web_contents) { 136 content::WebContents* web_contents) {
135 ConstrainedWebDialogDelegateViewGtk* constrained_delegate = 137 ConstrainedWebDialogDelegateViewGtk* constrained_delegate =
136 new ConstrainedWebDialogDelegateViewGtk( 138 new ConstrainedWebDialogDelegateViewGtk(
137 browser_context, delegate, tab_delegate); 139 browser_context, delegate, tab_delegate);
138 GtkWidget* window = 140 GtkWidget* window =
139 CreateWebContentsModalDialogGtk(web_contents, constrained_delegate); 141 CreateWebContentsModalDialogGtk(
142 web_contents,
143 constrained_delegate->GetWebContents()->GetView()->GetNativeView(),
144 constrained_delegate->GetWebContents()->GetView()->
145 GetContentNativeView());
146 SetBackgroundColor(window, ui::kGdkWhite);
140 constrained_delegate->SetWindow(window); 147 constrained_delegate->SetWindow(window);
141 148
142 WebContentsModalDialogManager* web_contents_modal_dialog_manager = 149 WebContentsModalDialogManager* web_contents_modal_dialog_manager =
143 WebContentsModalDialogManager::FromWebContents(web_contents); 150 WebContentsModalDialogManager::FromWebContents(web_contents);
144 web_contents_modal_dialog_manager->ShowDialog(window); 151 web_contents_modal_dialog_manager->ShowDialog(window);
145 152
146 return constrained_delegate; 153 return constrained_delegate;
147 } 154 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698