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

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: 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->extension_view()->set_background(
107 views::Background::CreateSolidBackground(0xFF, 0xFF, 0xFF)); 107 views::Background::CreateSolidBackground(0xFF, 0xFF, 0xFF));
108 host->view()->SetVisible(true); 108 host->extension_view()->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_->extension_view()->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_->extension_view()->SetPreferredSize(gfx::Size(width, height));
219 } 219 }
220 220
221 ui::ModalType ExtensionDialog::GetModalType() const { 221 ui::ModalType ExtensionDialog::GetModalType() const {
222 return ui::MODAL_TYPE_WINDOW; 222 return ui::MODAL_TYPE_WINDOW;
223 } 223 }
224 224
225 bool ExtensionDialog::ShouldShowWindowTitle() const { 225 bool ExtensionDialog::ShouldShowWindowTitle() const {
226 return !window_title_.empty(); 226 return !window_title_.empty();
227 } 227 }
228 228
229 string16 ExtensionDialog::GetWindowTitle() const { 229 string16 ExtensionDialog::GetWindowTitle() const {
230 return window_title_; 230 return window_title_;
231 } 231 }
232 232
233 void ExtensionDialog::WindowClosing() { 233 void ExtensionDialog::WindowClosing() {
234 if (observer_) 234 if (observer_)
235 observer_->ExtensionDialogClosing(this); 235 observer_->ExtensionDialogClosing(this);
236 } 236 }
237 237
238 void ExtensionDialog::DeleteDelegate() { 238 void ExtensionDialog::DeleteDelegate() {
239 // The window has finished closing. Allow ourself to be deleted. 239 // The window has finished closing. Allow ourself to be deleted.
240 Release(); 240 Release();
241 } 241 }
242 242
243 views::Widget* ExtensionDialog::GetWidget() { 243 views::Widget* ExtensionDialog::GetWidget() {
244 return extension_host_->view()->GetWidget(); 244 return extension_host_->extension_view()->GetWidget();
245 } 245 }
246 246
247 const views::Widget* ExtensionDialog::GetWidget() const { 247 const views::Widget* ExtensionDialog::GetWidget() const {
248 return extension_host_->view()->GetWidget(); 248 return extension_host_->extension_view()->GetWidget();
249 } 249 }
250 250
251 views::View* ExtensionDialog::GetContentsView() { 251 views::View* ExtensionDialog::GetContentsView() {
252 return extension_host_->view(); 252 return extension_host_->extension_view();
253 } 253 }
254 254
255 ///////////////////////////////////////////////////////////////////////////// 255 /////////////////////////////////////////////////////////////////////////////
256 // content::NotificationObserver overrides. 256 // content::NotificationObserver overrides.
257 257
258 void ExtensionDialog::Observe(int type, 258 void ExtensionDialog::Observe(int type,
259 const content::NotificationSource& source, 259 const content::NotificationSource& source,
260 const content::NotificationDetails& details) { 260 const content::NotificationDetails& details) {
261 switch (type) { 261 switch (type) {
262 case chrome::NOTIFICATION_EXTENSION_HOST_DID_STOP_LOADING: 262 case chrome::NOTIFICATION_EXTENSION_HOST_DID_STOP_LOADING:
263 // Avoid potential overdraw by removing the temporary background after 263 // Avoid potential overdraw by removing the temporary background after
264 // the extension finishes loading. 264 // the extension finishes loading.
265 extension_host_->view()->set_background(NULL); 265 extension_host_->extension_view()->set_background(NULL);
266 // The render view is created during the LoadURL(), so we should 266 // The render view is created during the LoadURL(), so we should
267 // set the focus to the view if nobody else takes the focus. 267 // set the focus to the view if nobody else takes the focus.
268 if (content::Details<extensions::ExtensionHost>(host()) == details) 268 if (content::Details<extensions::ExtensionHost>(host()) == details)
269 MaybeFocusRenderView(); 269 MaybeFocusRenderView();
270 break; 270 break;
271 case chrome::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE: 271 case chrome::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE:
272 // If we aren't the host of the popup, then disregard the notification. 272 // If we aren't the host of the popup, then disregard the notification.
273 if (content::Details<extensions::ExtensionHost>(host()) != details) 273 if (content::Details<extensions::ExtensionHost>(host()) != details)
274 return; 274 return;
275 Close(); 275 Close();
276 break; 276 break;
277 case chrome::NOTIFICATION_EXTENSION_PROCESS_TERMINATED: 277 case chrome::NOTIFICATION_EXTENSION_PROCESS_TERMINATED:
278 if (content::Details<extensions::ExtensionHost>(host()) != details) 278 if (content::Details<extensions::ExtensionHost>(host()) != details)
279 return; 279 return;
280 if (observer_) 280 if (observer_)
281 observer_->ExtensionTerminated(this); 281 observer_->ExtensionTerminated(this);
282 break; 282 break;
283 default: 283 default:
284 NOTREACHED() << L"Received unexpected notification"; 284 NOTREACHED() << L"Received unexpected notification";
285 break; 285 break;
286 } 286 }
287 } 287 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698