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

Side by Side Diff: chrome/browser/ui/views/extensions/extension_dialog.cc

Issue 10913243: extensions: Add ExtensionView interface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add GetNativeView to interface, will override it later Created 8 years, 3 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 (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/views/extensions/extension_dialog.h" 5 #include "chrome/browser/ui/views/extensions/extension_dialog.h"
6 6
7 #include "chrome/browser/extensions/extension_host.h" 7 #include "chrome/browser/extensions/extension_host.h"
8 #include "chrome/browser/extensions/extension_process_manager.h" 8 #include "chrome/browser/extensions/extension_process_manager.h"
9 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/ui/base_window.h" 10 #include "chrome/browser/ui/base_window.h"
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 ExtensionDialog* dialog = new ExtensionDialog(host, observer); 96 ExtensionDialog* dialog = new ExtensionDialog(host, observer);
97 dialog->set_title(title); 97 dialog->set_title(title);
98 98
99 if (fullscreen) 99 if (fullscreen)
100 dialog->InitWindowFullscreen(); 100 dialog->InitWindowFullscreen();
101 else 101 else
102 dialog->InitWindow(base_window, width, height); 102 dialog->InitWindow(base_window, width, height);
103 103
104 // Show a white background while the extension loads. This is prettier than 104 // Show a white background while the extension loads. This is prettier than
105 // flashing a black unfilled window frame. 105 // flashing a black unfilled window frame.
106 host->view()->set_background( 106 host->GetExtensionView()->set_background(
tfarina 2012/09/14 13:36:59 Aaron, Ben, any idea how I will get the ExtensionV
Aaron Boodman 2012/09/16 01:07:38 You can static_cast, I assume. You know that it wi
107 views::Background::CreateSolidBackground(0xFF, 0xFF, 0xFF)); 107 views::Background::CreateSolidBackground(0xFF, 0xFF, 0xFF));
108 host->view()->SetVisible(true); 108 host->GetExtensionView()->SetVisible(true);
109 109
110 // Ensure the DOM JavaScript can respond immediately to keyboard shortcuts. 110 // Ensure the DOM JavaScript can respond immediately to keyboard shortcuts.
111 host->host_contents()->Focus(); 111 host->host_contents()->Focus();
112 return dialog; 112 return dialog;
113 } 113 }
114 114
115 // static 115 // static
116 extensions::ExtensionHost* ExtensionDialog::CreateExtensionHost( 116 extensions::ExtensionHost* ExtensionDialog::CreateExtensionHost(
117 const GURL& url, 117 const GURL& url,
118 Profile* profile) { 118 Profile* profile) {
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 // See bug.com/127222. 204 // See bug.com/127222.
205 focus_manager->SetFocusedView(GetContentsView()); 205 focus_manager->SetFocusedView(GetContentsView());
206 view->Focus(); 206 view->Focus();
207 } 207 }
208 208
209 ///////////////////////////////////////////////////////////////////////////// 209 /////////////////////////////////////////////////////////////////////////////
210 // views::WidgetDelegate overrides. 210 // views::WidgetDelegate overrides.
211 211
212 bool ExtensionDialog::CanResize() const { 212 bool ExtensionDialog::CanResize() const {
213 // Can resize only if minimum contents size set. 213 // Can resize only if minimum contents size set.
214 return extension_host_->view()->GetPreferredSize() != gfx::Size(); 214 return extension_host_->GetExtensionView()->GetPreferredSize() != gfx::Size();
215 } 215 }
216 216
217 void ExtensionDialog::SetMinimumContentsSize(int width, int height) { 217 void ExtensionDialog::SetMinimumContentsSize(int width, int height) {
218 extension_host_->view()->SetPreferredSize(gfx::Size(width, height)); 218 extension_host_->GetExtensionView()->SetPreferredSize(
219 gfx::Size(width, height));
219 } 220 }
220 221
221 ui::ModalType ExtensionDialog::GetModalType() const { 222 ui::ModalType ExtensionDialog::GetModalType() const {
222 return ui::MODAL_TYPE_WINDOW; 223 return ui::MODAL_TYPE_WINDOW;
223 } 224 }
224 225
225 bool ExtensionDialog::ShouldShowWindowTitle() const { 226 bool ExtensionDialog::ShouldShowWindowTitle() const {
226 return !window_title_.empty(); 227 return !window_title_.empty();
227 } 228 }
228 229
229 string16 ExtensionDialog::GetWindowTitle() const { 230 string16 ExtensionDialog::GetWindowTitle() const {
230 return window_title_; 231 return window_title_;
231 } 232 }
232 233
233 void ExtensionDialog::WindowClosing() { 234 void ExtensionDialog::WindowClosing() {
234 if (observer_) 235 if (observer_)
235 observer_->ExtensionDialogClosing(this); 236 observer_->ExtensionDialogClosing(this);
236 } 237 }
237 238
238 void ExtensionDialog::DeleteDelegate() { 239 void ExtensionDialog::DeleteDelegate() {
239 // The window has finished closing. Allow ourself to be deleted. 240 // The window has finished closing. Allow ourself to be deleted.
240 Release(); 241 Release();
241 } 242 }
242 243
243 views::Widget* ExtensionDialog::GetWidget() { 244 views::Widget* ExtensionDialog::GetWidget() {
244 return extension_host_->view()->GetWidget(); 245 return extension_host_->GetExtensionView()->GetWidget();
245 } 246 }
246 247
247 const views::Widget* ExtensionDialog::GetWidget() const { 248 const views::Widget* ExtensionDialog::GetWidget() const {
248 return extension_host_->view()->GetWidget(); 249 return extension_host_->GetExtensionView()->GetWidget();
249 } 250 }
250 251
251 views::View* ExtensionDialog::GetContentsView() { 252 views::View* ExtensionDialog::GetContentsView() {
252 return extension_host_->view(); 253 return extension_host_->GetExtensionView();
253 } 254 }
254 255
255 ///////////////////////////////////////////////////////////////////////////// 256 /////////////////////////////////////////////////////////////////////////////
256 // content::NotificationObserver overrides. 257 // content::NotificationObserver overrides.
257 258
258 void ExtensionDialog::Observe(int type, 259 void ExtensionDialog::Observe(int type,
259 const content::NotificationSource& source, 260 const content::NotificationSource& source,
260 const content::NotificationDetails& details) { 261 const content::NotificationDetails& details) {
261 switch (type) { 262 switch (type) {
262 case chrome::NOTIFICATION_EXTENSION_HOST_DID_STOP_LOADING: 263 case chrome::NOTIFICATION_EXTENSION_HOST_DID_STOP_LOADING:
263 // Avoid potential overdraw by removing the temporary background after 264 // Avoid potential overdraw by removing the temporary background after
264 // the extension finishes loading. 265 // the extension finishes loading.
265 extension_host_->view()->set_background(NULL); 266 extension_host_->GetExtensionView()->set_background(NULL);
266 // The render view is created during the LoadURL(), so we should 267 // The render view is created during the LoadURL(), so we should
267 // set the focus to the view if nobody else takes the focus. 268 // set the focus to the view if nobody else takes the focus.
268 if (content::Details<extensions::ExtensionHost>(host()) == details) 269 if (content::Details<extensions::ExtensionHost>(host()) == details)
269 MaybeFocusRenderView(); 270 MaybeFocusRenderView();
270 break; 271 break;
271 case chrome::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE: 272 case chrome::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE:
272 // If we aren't the host of the popup, then disregard the notification. 273 // If we aren't the host of the popup, then disregard the notification.
273 if (content::Details<extensions::ExtensionHost>(host()) != details) 274 if (content::Details<extensions::ExtensionHost>(host()) != details)
274 return; 275 return;
275 Close(); 276 Close();
276 break; 277 break;
277 case chrome::NOTIFICATION_EXTENSION_PROCESS_TERMINATED: 278 case chrome::NOTIFICATION_EXTENSION_PROCESS_TERMINATED:
278 if (content::Details<extensions::ExtensionHost>(host()) != details) 279 if (content::Details<extensions::ExtensionHost>(host()) != details)
279 return; 280 return;
280 if (observer_) 281 if (observer_)
281 observer_->ExtensionTerminated(this); 282 observer_->ExtensionTerminated(this);
282 break; 283 break;
283 default: 284 default:
284 NOTREACHED() << L"Received unexpected notification"; 285 NOTREACHED() << L"Received unexpected notification";
285 break; 286 break;
286 } 287 }
287 } 288 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698