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

Unified Diff: content/shell/browser/shell_views.cc

Issue 1391893003: NOT FOR REVIEW: Aura on Android (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: content/shell/browser/shell_views.cc
diff --git a/content/shell/browser/shell_views.cc b/content/shell/browser/shell_views.cc
index 4ce0fa6806ffb5a87c9390f0a4659a804a9e6db1..a4695708989503e402d6770a703230df4a259867 100644
--- a/content/shell/browser/shell_views.cc
+++ b/content/shell/browser/shell_views.cc
@@ -38,9 +38,11 @@
#if defined(OS_CHROMEOS)
#include "chromeos/dbus/dbus_thread_manager.h"
+#endif
+#if defined(OS_CHROMEOS) || defined(OS_ANDROID)
#include "ui/aura/test/test_screen.h"
#include "ui/wm/test/wm_test_helper.h"
-#else // !defined(OS_CHROMEOS)
+#else // !defined(OS_CHROMEOS) && !dfined(OS_ANDROID)
#include "ui/views/widget/desktop_aura/desktop_screen.h"
#endif
@@ -49,6 +51,15 @@
#include <io.h>
#endif
+#if defined(OS_ANDROID)
+#include "base/run_loop.h"
+#include "jni/Shell_jni.h"
+#endif
+
+#if defined(OS_ANDROID)
+using base::android::AttachCurrentThread;
+#endif
+
namespace content {
namespace {
@@ -309,6 +320,8 @@ class ShellWindowDelegateView : public views::WidgetDelegateView,
GURL url(text);
if (!url.has_scheme()) {
url = GURL(std::string("http://") + std::string(text));
+ if (url.is_empty() || !url.is_valid())
+ return false;
url_entry_->SetText(base::ASCIIToUTF16(url.spec()));
}
shell_->LoadURL(url);
@@ -398,22 +411,38 @@ class ShellWindowDelegateView : public views::WidgetDelegateView,
} // namespace
-#if defined(OS_CHROMEOS)
+#if defined(OS_CHROMEOS) || defined(OS_ANDROID)
wm::WMTestHelper* Shell::wm_test_helper_ = NULL;
gfx::Screen* Shell::test_screen_ = NULL;
#endif
views::ViewsDelegate* Shell::views_delegate_ = NULL;
// static
+#if defined(OS_ANDROID)
+bool Shell::Register(JNIEnv* env) {
+ return RegisterNativesImpl(env);
+}
+
+void CloseShell(JNIEnv* env, jclass clazz, jlong shellPtr) {
+ Shell* shell = reinterpret_cast<Shell*>(shellPtr);
+ shell->Close();
+}
+#endif
+
void Shell::PlatformInitialize(const gfx::Size& default_window_size) {
+ LOG(ERROR) << "Shell::PlatformInitialize";
#if defined(OS_WIN)
_setmode(_fileno(stdout), _O_BINARY);
_setmode(_fileno(stderr), _O_BINARY);
#endif
+#if defined(OS_CHROMEOS) || defined(OS_ANDROID)
#if defined(OS_CHROMEOS)
chromeos::DBusThreadManager::Initialize();
- test_screen_ = aura::TestScreen::Create(gfx::Size());
- gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, test_screen_);
+#endif //OS_CHROMEOS
+ // TODO(mfomitchev): We should pick the screen we use on Android.
+ // If we use screen_android, we shouldn't do this.
+// test_screen_ = aura::TestScreen::Create(gfx::Size());
+// gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, test_screen_);
wm_test_helper_ = new wm::WMTestHelper(default_window_size,
GetContextFactory());
#else
@@ -424,7 +453,7 @@ void Shell::PlatformInitialize(const gfx::Size& default_window_size) {
}
void Shell::PlatformExit() {
-#if defined(OS_CHROMEOS)
+#if defined(OS_CHROMEOS) || defined(OS_ANDROID)
delete wm_test_helper_;
wm_test_helper_ = NULL;
@@ -443,6 +472,12 @@ void Shell::PlatformExit() {
}
void Shell::PlatformCleanUp() {
+#if defined(OS_ANDROID)
+ JNIEnv* env = AttachCurrentThread();
+ if (java_object_.is_null())
+ return;
+ Java_Shell_onNativeDestroyed(env, java_object_.obj());
+#endif
}
void Shell::PlatformEnableUIControl(UIControl control, bool is_enabled) {
@@ -474,6 +509,7 @@ void Shell::PlatformSetIsLoading(bool loading) {
}
void Shell::PlatformCreateWindow(int width, int height) {
+ LOG(ERROR) << "auraclank: Shell::PlatformCreateWindow";
if (headless_) {
content_size_ = gfx::Size(width, height);
if (!platform_)
@@ -482,7 +518,21 @@ void Shell::PlatformCreateWindow(int width, int height) {
platform_->ResizeWindow(content_size_);
return;
}
-#if defined(OS_CHROMEOS)
+
+//TODO(mfomitchev): nested loop waiting for the compositor
+#if defined(OS_ANDROID)
+ wm_test_helper_->host()->Show();
+// LOG(ERROR) << "auraclank: Starting nested message loop";
+// aura::Env::GetInstance()->AddObserver(this);
+// base::RunLoop().RunUntilIdle();
+// base::RunLoop run_loop;
+// quit_closure_ = run_loop.QuitClosure();
+// base::MessageLoopForUI* loop = base::MessageLoopForUI::current();
+// base::MessageLoop::ScopedNestableTaskAllower allow_nested(loop);
+// run_loop.Run();
+#endif
+
+#if defined(OS_CHROMEOS) || defined(OS_ANDROID)
window_widget_ = views::Widget::CreateWindowWithContextAndBounds(
new ShellWindowDelegateView(this),
wm_test_helper_->GetDefaultParent(NULL, NULL, gfx::Rect()),
@@ -500,9 +550,24 @@ void Shell::PlatformCreateWindow(int width, int height) {
window_ = window_widget_->GetNativeWindow();
// Call ShowRootWindow on RootWindow created by WMTestHelper without
// which XWindow owned by RootWindow doesn't get mapped.
+//TODO(mfomitchev)
+#if !defined(OS_ANDROID)
window_->GetHost()->Show();
+#endif
window_widget_->Show();
+
+
+}
+
+#if defined(OS_ANDROID)
+// aura::EnvObserver:
+void Shell::OnHostInitialized(aura::WindowTreeHost* host) {
+ LOG(ERROR) << "auraclank: Shell::OnHostInitialized!";
+// quit_closure_.Run();
+ aura::Env::GetInstance()->RemoveObserver(this);
}
+#endif
+
void Shell::PlatformSetContents() {
if (headless_) {

Powered by Google App Engine
This is Rietveld 408576698