| 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/context_factory.h" | 9 #include "content/public/browser/context_factory.h" |
| 10 #include "content/public/browser/render_widget_host_view.h" | 10 #include "content/public/browser/render_widget_host_view.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 #include "ui/wm/test/wm_test_helper.h" | 42 #include "ui/wm/test/wm_test_helper.h" |
| 43 #else // !defined(OS_CHROMEOS) | 43 #else // !defined(OS_CHROMEOS) |
| 44 #include "ui/views/widget/desktop_aura/desktop_screen.h" | 44 #include "ui/views/widget/desktop_aura/desktop_screen.h" |
| 45 #endif | 45 #endif |
| 46 | 46 |
| 47 #if defined(OS_WIN) | 47 #if defined(OS_WIN) |
| 48 #include <fcntl.h> | 48 #include <fcntl.h> |
| 49 #include <io.h> | 49 #include <io.h> |
| 50 #endif | 50 #endif |
| 51 | 51 |
| 52 #if defined(OS_ANDROID) |
| 53 #include "jni/Shell_jni.h" |
| 54 #endif |
| 55 |
| 56 #if defined(OS_ANDROID) |
| 57 using base::android::AttachCurrentThread; |
| 58 #endif |
| 59 |
| 52 namespace content { | 60 namespace content { |
| 53 | 61 |
| 54 namespace { | 62 namespace { |
| 55 // ViewDelegate implementation for aura content shell | 63 // ViewDelegate implementation for aura content shell |
| 56 class ShellViewsDelegateAura : public views::DesktopTestViewsDelegate { | 64 class ShellViewsDelegateAura : public views::DesktopTestViewsDelegate { |
| 57 public: | 65 public: |
| 58 ShellViewsDelegateAura() : use_transparent_windows_(false) { | 66 ShellViewsDelegateAura() : use_transparent_windows_(false) { |
| 59 } | 67 } |
| 60 | 68 |
| 61 ~ShellViewsDelegateAura() override {} | 69 ~ShellViewsDelegateAura() override {} |
| (...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 398 | 406 |
| 399 } // namespace | 407 } // namespace |
| 400 | 408 |
| 401 #if defined(OS_CHROMEOS) | 409 #if defined(OS_CHROMEOS) |
| 402 wm::WMTestHelper* Shell::wm_test_helper_ = NULL; | 410 wm::WMTestHelper* Shell::wm_test_helper_ = NULL; |
| 403 gfx::Screen* Shell::test_screen_ = NULL; | 411 gfx::Screen* Shell::test_screen_ = NULL; |
| 404 #endif | 412 #endif |
| 405 views::ViewsDelegate* Shell::views_delegate_ = NULL; | 413 views::ViewsDelegate* Shell::views_delegate_ = NULL; |
| 406 | 414 |
| 407 // static | 415 // static |
| 416 #if defined(OS_ANDROID) |
| 417 bool Shell::Register(JNIEnv* env) { |
| 418 return RegisterNativesImpl(env); |
| 419 } |
| 420 |
| 421 void CloseShell(JNIEnv* env, jclass clazz, jlong shellPtr) { |
| 422 Shell* shell = reinterpret_cast<Shell*>(shellPtr); |
| 423 shell->Close(); |
| 424 } |
| 425 #endif |
| 426 |
| 408 void Shell::PlatformInitialize(const gfx::Size& default_window_size) { | 427 void Shell::PlatformInitialize(const gfx::Size& default_window_size) { |
| 409 #if defined(OS_WIN) | 428 #if defined(OS_WIN) |
| 410 _setmode(_fileno(stdout), _O_BINARY); | 429 _setmode(_fileno(stdout), _O_BINARY); |
| 411 _setmode(_fileno(stderr), _O_BINARY); | 430 _setmode(_fileno(stderr), _O_BINARY); |
| 412 #endif | 431 #endif |
| 413 #if defined(OS_CHROMEOS) | 432 #if defined(OS_CHROMEOS) |
| 414 chromeos::DBusThreadManager::Initialize(); | 433 chromeos::DBusThreadManager::Initialize(); |
| 415 test_screen_ = aura::TestScreen::Create(gfx::Size()); | 434 test_screen_ = aura::TestScreen::Create(gfx::Size()); |
| 416 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, test_screen_); | 435 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, test_screen_); |
| 417 wm_test_helper_ = new wm::WMTestHelper(default_window_size, | 436 wm_test_helper_ = new wm::WMTestHelper(default_window_size, |
| (...skipping 18 matching lines...) Expand all Loading... |
| 436 delete platform_; | 455 delete platform_; |
| 437 platform_ = NULL; | 456 platform_ = NULL; |
| 438 #if defined(OS_CHROMEOS) | 457 #if defined(OS_CHROMEOS) |
| 439 device::BluetoothAdapterFactory::Shutdown(); | 458 device::BluetoothAdapterFactory::Shutdown(); |
| 440 chromeos::DBusThreadManager::Shutdown(); | 459 chromeos::DBusThreadManager::Shutdown(); |
| 441 #endif | 460 #endif |
| 442 aura::Env::DeleteInstance(); | 461 aura::Env::DeleteInstance(); |
| 443 } | 462 } |
| 444 | 463 |
| 445 void Shell::PlatformCleanUp() { | 464 void Shell::PlatformCleanUp() { |
| 465 #if defined(OS_ANDROID) |
| 466 JNIEnv* env = AttachCurrentThread(); |
| 467 if (java_object_.is_null()) |
| 468 return; |
| 469 Java_Shell_onNativeDestroyed(env, java_object_.obj()); |
| 470 #endif |
| 446 } | 471 } |
| 447 | 472 |
| 448 void Shell::PlatformEnableUIControl(UIControl control, bool is_enabled) { | 473 void Shell::PlatformEnableUIControl(UIControl control, bool is_enabled) { |
| 449 if (headless_) | 474 if (headless_) |
| 450 return; | 475 return; |
| 451 ShellWindowDelegateView* delegate_view = | 476 ShellWindowDelegateView* delegate_view = |
| 452 static_cast<ShellWindowDelegateView*>(window_widget_->widget_delegate()); | 477 static_cast<ShellWindowDelegateView*>(window_widget_->widget_delegate()); |
| 453 if (control == BACK_BUTTON) { | 478 if (control == BACK_BUTTON) { |
| 454 delegate_view->EnableUIControl(ShellWindowDelegateView::BACK_BUTTON, | 479 delegate_view->EnableUIControl(ShellWindowDelegateView::BACK_BUTTON, |
| 455 is_enabled); | 480 is_enabled); |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 548 const content::ContextMenuParams& params) { | 573 const content::ContextMenuParams& params) { |
| 549 if (headless_) | 574 if (headless_) |
| 550 return true; | 575 return true; |
| 551 ShellWindowDelegateView* delegate_view = | 576 ShellWindowDelegateView* delegate_view = |
| 552 static_cast<ShellWindowDelegateView*>(window_widget_->widget_delegate()); | 577 static_cast<ShellWindowDelegateView*>(window_widget_->widget_delegate()); |
| 553 delegate_view->ShowWebViewContextMenu(params); | 578 delegate_view->ShowWebViewContextMenu(params); |
| 554 return true; | 579 return true; |
| 555 } | 580 } |
| 556 | 581 |
| 557 } // namespace content | 582 } // namespace content |
| OLD | NEW |