| OLD | NEW |
| 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 "content/shell/shell.h" | 5 #include "content/shell/shell.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
| 9 #include "content/public/browser/web_contents.h" | 9 #include "content/public/browser/web_contents.h" |
| 10 #include "ui/aura/env.h" | 10 #include "ui/aura/env.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 #include "ui/views/layout/fill_layout.h" | 22 #include "ui/views/layout/fill_layout.h" |
| 23 #include "ui/views/layout/grid_layout.h" | 23 #include "ui/views/layout/grid_layout.h" |
| 24 #include "ui/views/view.h" | 24 #include "ui/views/view.h" |
| 25 #include "ui/views/test/desktop_test_views_delegate.h" | 25 #include "ui/views/test/desktop_test_views_delegate.h" |
| 26 #include "ui/views/widget/desktop_aura/desktop_screen.h" | 26 #include "ui/views/widget/desktop_aura/desktop_screen.h" |
| 27 #include "ui/views/widget/widget.h" | 27 #include "ui/views/widget/widget.h" |
| 28 #include "ui/views/widget/widget_delegate.h" | 28 #include "ui/views/widget/widget_delegate.h" |
| 29 | 29 |
| 30 #if defined(OS_CHROMEOS) | 30 #if defined(OS_CHROMEOS) |
| 31 #include "chromeos/dbus/dbus_thread_manager.h" | 31 #include "chromeos/dbus/dbus_thread_manager.h" |
| 32 #include "content/shell/minimal_ash.h" | 32 #include "content/shell/shell_stacking_client_ash.h" |
| 33 #include "ui/aura/test/test_screen.h" | 33 #include "ui/aura/test/test_screen.h" |
| 34 #else |
| 35 #include "ui/views/widget/desktop_aura/desktop_stacking_client.h" |
| 34 #endif | 36 #endif |
| 35 | 37 |
| 36 // ViewDelegate implementation for aura content shell | 38 // ViewDelegate implementation for aura content shell |
| 37 class ShellViewsDelegateAura : public views::DesktopTestViewsDelegate { | 39 class ShellViewsDelegateAura : public views::DesktopTestViewsDelegate { |
| 38 public: | 40 public: |
| 39 ShellViewsDelegateAura() : use_transparent_windows_(false) { | 41 ShellViewsDelegateAura() : use_transparent_windows_(false) { |
| 40 } | 42 } |
| 41 | 43 |
| 42 virtual ~ShellViewsDelegateAura() { | 44 virtual ~ShellViewsDelegateAura() { |
| 43 ViewsDelegate::views_delegate = NULL; | 45 ViewsDelegate::views_delegate = NULL; |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 | 267 |
| 266 DISALLOW_COPY_AND_ASSIGN(ShellWindowDelegateView); | 268 DISALLOW_COPY_AND_ASSIGN(ShellWindowDelegateView); |
| 267 }; | 269 }; |
| 268 | 270 |
| 269 } // namespace views | 271 } // namespace views |
| 270 | 272 |
| 271 using views::ShellWindowDelegateView; | 273 using views::ShellWindowDelegateView; |
| 272 | 274 |
| 273 namespace content { | 275 namespace content { |
| 274 | 276 |
| 275 #if defined(OS_CHROMEOS) | 277 aura::client::StackingClient* Shell::stacking_client_ = NULL; |
| 276 MinimalAsh* Shell::minimal_ash_ = NULL; | |
| 277 #endif | |
| 278 views::ViewsDelegate* Shell::views_delegate_ = NULL; | 278 views::ViewsDelegate* Shell::views_delegate_ = NULL; |
| 279 | 279 |
| 280 // static | 280 // static |
| 281 void Shell::PlatformInitialize() { | 281 void Shell::PlatformInitialize() { |
| 282 #if defined(OS_CHROMEOS) | 282 #if defined(OS_CHROMEOS) |
| 283 chromeos::DBusThreadManager::Initialize(); | 283 chromeos::DBusThreadManager::Initialize(); |
| 284 #endif | 284 #endif |
| 285 #if defined(OS_CHROMEOS) | 285 #if defined(OS_CHROMEOS) |
| 286 stacking_client_ = new content::ShellStackingClientAsh(); |
| 286 gfx::Screen::SetScreenInstance( | 287 gfx::Screen::SetScreenInstance( |
| 287 gfx::SCREEN_TYPE_NATIVE, new aura::TestScreen); | 288 gfx::SCREEN_TYPE_NATIVE, new aura::TestScreen); |
| 288 minimal_ash_ = new content::MinimalAsh(); | |
| 289 #else | 289 #else |
| 290 stacking_client_ = new views::DesktopStackingClient(); |
| 290 gfx::Screen::SetScreenInstance( | 291 gfx::Screen::SetScreenInstance( |
| 291 gfx::SCREEN_TYPE_NATIVE, views::CreateDesktopScreen()); | 292 gfx::SCREEN_TYPE_NATIVE, views::CreateDesktopScreen()); |
| 292 #endif | 293 #endif |
| 294 aura::client::SetStackingClient(stacking_client_); |
| 293 views_delegate_ = new ShellViewsDelegateAura(); | 295 views_delegate_ = new ShellViewsDelegateAura(); |
| 294 } | 296 } |
| 295 | 297 |
| 296 void Shell::PlatformExit() { | 298 void Shell::PlatformExit() { |
| 297 #if defined(OS_CHROMEOS) | 299 if (stacking_client_) |
| 298 if (minimal_ash_) | 300 delete stacking_client_; |
| 299 delete minimal_ash_; | |
| 300 #endif | |
| 301 if (views_delegate_) | 301 if (views_delegate_) |
| 302 delete views_delegate_; | 302 delete views_delegate_; |
| 303 #if defined(OS_CHROMEOS) | 303 #if defined(OS_CHROMEOS) |
| 304 chromeos::DBusThreadManager::Shutdown(); | 304 chromeos::DBusThreadManager::Shutdown(); |
| 305 #endif | 305 #endif |
| 306 aura::Env::DeleteInstance(); | 306 aura::Env::DeleteInstance(); |
| 307 } | 307 } |
| 308 | 308 |
| 309 void Shell::PlatformCleanUp() { | 309 void Shell::PlatformCleanUp() { |
| 310 } | 310 } |
| (...skipping 16 matching lines...) Expand all Loading... |
| 327 void Shell::PlatformSetAddressBarURL(const GURL& url) { | 327 void Shell::PlatformSetAddressBarURL(const GURL& url) { |
| 328 ShellWindowDelegateView* delegate_view = | 328 ShellWindowDelegateView* delegate_view = |
| 329 static_cast<ShellWindowDelegateView*>(window_widget_->widget_delegate()); | 329 static_cast<ShellWindowDelegateView*>(window_widget_->widget_delegate()); |
| 330 delegate_view->SetAddressBarURL(url); | 330 delegate_view->SetAddressBarURL(url); |
| 331 } | 331 } |
| 332 | 332 |
| 333 void Shell::PlatformSetIsLoading(bool loading) { | 333 void Shell::PlatformSetIsLoading(bool loading) { |
| 334 } | 334 } |
| 335 | 335 |
| 336 void Shell::PlatformCreateWindow(int width, int height) { | 336 void Shell::PlatformCreateWindow(int width, int height) { |
| 337 #if defined(OS_CHROMEOS) | |
| 338 window_widget_ = | |
| 339 views::Widget::CreateWindowWithContextAndBounds( | |
| 340 new ShellWindowDelegateView(this), | |
| 341 minimal_ash_->GetDefaultParent(NULL, NULL, gfx::Rect()), | |
| 342 gfx::Rect(0, 0, width, height)); | |
| 343 #else | |
| 344 window_widget_ = | 337 window_widget_ = |
| 345 views::Widget::CreateWindowWithBounds(new ShellWindowDelegateView(this), | 338 views::Widget::CreateWindowWithBounds(new ShellWindowDelegateView(this), |
| 346 gfx::Rect(0, 0, width, height)); | 339 gfx::Rect(0, 0, width, height)); |
| 347 #endif | |
| 348 | |
| 349 window_ = window_widget_->GetNativeWindow(); | 340 window_ = window_widget_->GetNativeWindow(); |
| 350 window_widget_->Show(); | 341 window_widget_->Show(); |
| 351 } | 342 } |
| 352 | 343 |
| 353 void Shell::PlatformSetContents() { | 344 void Shell::PlatformSetContents() { |
| 354 ShellWindowDelegateView* delegate_view = | 345 ShellWindowDelegateView* delegate_view = |
| 355 static_cast<ShellWindowDelegateView*>(window_widget_->widget_delegate()); | 346 static_cast<ShellWindowDelegateView*>(window_widget_->widget_delegate()); |
| 356 delegate_view->SetWebContents(web_contents_.get()); | 347 delegate_view->SetWebContents(web_contents_.get()); |
| 357 } | 348 } |
| 358 | 349 |
| 359 void Shell::PlatformResizeSubViews() { | 350 void Shell::PlatformResizeSubViews() { |
| 360 } | 351 } |
| 361 | 352 |
| 362 void Shell::Close() { | 353 void Shell::Close() { |
| 363 window_widget_->Close(); | 354 window_widget_->Close(); |
| 364 } | 355 } |
| 365 | 356 |
| 366 void Shell::PlatformSetTitle(const string16& title) { | 357 void Shell::PlatformSetTitle(const string16& title) { |
| 367 ShellWindowDelegateView* delegate_view = | 358 ShellWindowDelegateView* delegate_view = |
| 368 static_cast<ShellWindowDelegateView*>(window_widget_->widget_delegate()); | 359 static_cast<ShellWindowDelegateView*>(window_widget_->widget_delegate()); |
| 369 delegate_view->SetWindowTitle(title); | 360 delegate_view->SetWindowTitle(title); |
| 370 window_widget_->UpdateWindowTitle(); | 361 window_widget_->UpdateWindowTitle(); |
| 371 } | 362 } |
| 372 | 363 |
| 373 } // namespace content | 364 } // namespace content |
| OLD | NEW |