OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "content/shell/browser/shell.h" | 5 #include "content/shell/browser/shell.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "content/public/browser/render_widget_host_view.h" |
9 #include "content/public/browser/web_contents.h" | 10 #include "content/public/browser/web_contents.h" |
10 #include "content/public/browser/web_contents_view.h" | 11 #include "content/public/browser/web_contents_view.h" |
11 #include "ui/aura/env.h" | 12 #include "ui/aura/env.h" |
12 #include "ui/aura/root_window.h" | 13 #include "ui/aura/root_window.h" |
13 #include "ui/aura/window.h" | 14 #include "ui/aura/window.h" |
14 #include "ui/base/accessibility/accessibility_types.h" | 15 #include "ui/base/accessibility/accessibility_types.h" |
15 #include "ui/base/clipboard/clipboard.h" | 16 #include "ui/base/clipboard/clipboard.h" |
16 #include "ui/base/resource/resource_bundle.h" | 17 #include "ui/base/resource/resource_bundle.h" |
17 #include "ui/events/event.h" | 18 #include "ui/events/event.h" |
18 #include "ui/gfx/screen.h" | 19 #include "ui/gfx/screen.h" |
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 #if defined(OS_CHROMEOS) | 330 #if defined(OS_CHROMEOS) |
330 chromeos::DBusThreadManager::Shutdown(); | 331 chromeos::DBusThreadManager::Shutdown(); |
331 #endif | 332 #endif |
332 aura::Env::DeleteInstance(); | 333 aura::Env::DeleteInstance(); |
333 } | 334 } |
334 | 335 |
335 void Shell::PlatformCleanUp() { | 336 void Shell::PlatformCleanUp() { |
336 } | 337 } |
337 | 338 |
338 void Shell::PlatformEnableUIControl(UIControl control, bool is_enabled) { | 339 void Shell::PlatformEnableUIControl(UIControl control, bool is_enabled) { |
| 340 if (headless_) |
| 341 return; |
| 342 |
339 ShellWindowDelegateView* delegate_view = | 343 ShellWindowDelegateView* delegate_view = |
340 static_cast<ShellWindowDelegateView*>(window_widget_->widget_delegate()); | 344 static_cast<ShellWindowDelegateView*>(window_widget_->widget_delegate()); |
341 if (control == BACK_BUTTON) { | 345 if (control == BACK_BUTTON) { |
342 delegate_view->EnableUIControl(ShellWindowDelegateView::BACK_BUTTON, | 346 delegate_view->EnableUIControl(ShellWindowDelegateView::BACK_BUTTON, |
343 is_enabled); | 347 is_enabled); |
344 } else if (control == FORWARD_BUTTON) { | 348 } else if (control == FORWARD_BUTTON) { |
345 delegate_view->EnableUIControl(ShellWindowDelegateView::FORWARD_BUTTON, | 349 delegate_view->EnableUIControl(ShellWindowDelegateView::FORWARD_BUTTON, |
346 is_enabled); | 350 is_enabled); |
347 } else if (control == STOP_BUTTON) { | 351 } else if (control == STOP_BUTTON) { |
348 delegate_view->EnableUIControl(ShellWindowDelegateView::STOP_BUTTON, | 352 delegate_view->EnableUIControl(ShellWindowDelegateView::STOP_BUTTON, |
349 is_enabled); | 353 is_enabled); |
350 } | 354 } |
351 } | 355 } |
352 | 356 |
353 void Shell::PlatformSetAddressBarURL(const GURL& url) { | 357 void Shell::PlatformSetAddressBarURL(const GURL& url) { |
| 358 if (headless_) |
| 359 return; |
| 360 |
354 ShellWindowDelegateView* delegate_view = | 361 ShellWindowDelegateView* delegate_view = |
355 static_cast<ShellWindowDelegateView*>(window_widget_->widget_delegate()); | 362 static_cast<ShellWindowDelegateView*>(window_widget_->widget_delegate()); |
356 delegate_view->SetAddressBarURL(url); | 363 delegate_view->SetAddressBarURL(url); |
357 } | 364 } |
358 | 365 |
359 void Shell::PlatformSetIsLoading(bool loading) { | 366 void Shell::PlatformSetIsLoading(bool loading) { |
360 } | 367 } |
361 | 368 |
362 void Shell::PlatformCreateWindow(int width, int height) { | 369 void Shell::PlatformCreateWindow(int width, int height) { |
363 #if defined(OS_CHROMEOS) | 370 #if defined(OS_CHROMEOS) |
364 window_widget_ = views::Widget::CreateWindowWithContextAndBounds( | 371 window_widget_ = views::Widget::CreateWindowWithContextAndBounds( |
365 new ShellWindowDelegateView(this), | 372 new ShellWindowDelegateView(this), |
366 wm_test_helper_->GetDefaultParent(NULL, NULL, gfx::Rect()), | 373 wm_test_helper_->GetDefaultParent(NULL, NULL, gfx::Rect()), |
367 gfx::Rect(0, 0, width, height)); | 374 gfx::Rect(0, 0, width, height)); |
368 #else | 375 #else |
| 376 if (headless_) { |
| 377 content_width_ = width; |
| 378 content_height_ = height; |
| 379 return; |
| 380 } |
| 381 |
369 window_widget_ = views::Widget::CreateWindowWithBounds( | 382 window_widget_ = views::Widget::CreateWindowWithBounds( |
370 new ShellWindowDelegateView(this), gfx::Rect(0, 0, width, height)); | 383 new ShellWindowDelegateView(this), gfx::Rect(0, 0, width, height)); |
371 #endif | 384 #endif |
372 | 385 |
373 content_size_ = gfx::Size(width, height); | 386 content_size_ = gfx::Size(width, height); |
374 | 387 |
375 window_ = window_widget_->GetNativeWindow(); | 388 window_ = window_widget_->GetNativeWindow(); |
376 // Call ShowRootWindow on RootWindow created by WMTestHelper without | 389 // Call ShowRootWindow on RootWindow created by WMTestHelper without |
377 // which XWindow owned by RootWindow doesn't get mapped. | 390 // which XWindow owned by RootWindow doesn't get mapped. |
378 window_->GetDispatcher()->host()->Show(); | 391 window_->GetDispatcher()->host()->Show(); |
379 window_widget_->Show(); | 392 window_widget_->Show(); |
380 } | 393 } |
381 | 394 |
382 void Shell::PlatformSetContents() { | 395 void Shell::PlatformSetContents() { |
| 396 if (headless_) { |
| 397 if (web_contents_) { |
| 398 RenderWidgetHostView* rwhv = |
| 399 web_contents_->GetRenderWidgetHostView(); |
| 400 if (rwhv) |
| 401 rwhv->SetSize(gfx::Size(content_width_, content_height_)); |
| 402 } |
| 403 return; |
| 404 } |
| 405 |
383 ShellWindowDelegateView* delegate_view = | 406 ShellWindowDelegateView* delegate_view = |
384 static_cast<ShellWindowDelegateView*>(window_widget_->widget_delegate()); | 407 static_cast<ShellWindowDelegateView*>(window_widget_->widget_delegate()); |
385 delegate_view->SetWebContents(web_contents_.get(), content_size_); | 408 delegate_view->SetWebContents(web_contents_.get(), content_size_); |
386 } | 409 } |
387 | 410 |
388 void Shell::PlatformResizeSubViews() { | 411 void Shell::PlatformResizeSubViews() { |
389 } | 412 } |
390 | 413 |
391 void Shell::Close() { | 414 void Shell::Close() { |
| 415 if (headless_) { |
| 416 delete this; |
| 417 return; |
| 418 } |
| 419 |
392 window_widget_->CloseNow(); | 420 window_widget_->CloseNow(); |
393 } | 421 } |
394 | 422 |
395 void Shell::PlatformSetTitle(const string16& title) { | 423 void Shell::PlatformSetTitle(const string16& title) { |
| 424 if (headless_) |
| 425 return; |
| 426 |
396 ShellWindowDelegateView* delegate_view = | 427 ShellWindowDelegateView* delegate_view = |
397 static_cast<ShellWindowDelegateView*>(window_widget_->widget_delegate()); | 428 static_cast<ShellWindowDelegateView*>(window_widget_->widget_delegate()); |
398 delegate_view->SetWindowTitle(title); | 429 delegate_view->SetWindowTitle(title); |
399 window_widget_->UpdateWindowTitle(); | 430 window_widget_->UpdateWindowTitle(); |
400 } | 431 } |
401 | 432 |
402 } // namespace content | 433 } // namespace content |
OLD | NEW |