Initialize message pump not to use gtk.
  This is a temp fix to remove gtk_init. We should remove this once we remove gtk from message pump, which should be done as a part of AURA->TOOLKIT_USES_GTK=0

WindowSizer/gfx::screen for aura

BUG=none
TEST=none

Review URL: http://codereview.chromium.org/7943006

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@101922 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/chrome/browser/ui/window_sizer_aura.cc b/chrome/browser/ui/window_sizer_aura.cc
new file mode 100644
index 0000000..07354c3
--- /dev/null
+++ b/chrome/browser/ui/window_sizer_aura.cc
@@ -0,0 +1,64 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/window_sizer.h"
+
+#include "ui/aura/desktop.h"
+#include "ui/aura/window.h"
+#include "ui/gfx/screen.h"
+
+// TODO(oshima): Get This from WindowManager
+const int WindowSizer::kWindowTilePixels = 10;
+
+// An implementation of WindowSizer::MonitorInfoProvider that gets the actual
+// monitor information from X via GDK.
+class DefaultMonitorInfoProvider : public WindowSizer::MonitorInfoProvider {
+ public:
+  DefaultMonitorInfoProvider() { }
+
+  virtual gfx::Rect GetPrimaryMonitorWorkArea() const {
+    return gfx::Screen::GetMonitorWorkAreaNearestPoint(
+        gfx::Point(0, 0));
+  }
+
+  virtual gfx::Rect GetPrimaryMonitorBounds() const {
+    aura::Window* desktop_window = aura::Desktop::GetInstance()->window();
+    return desktop_window->bounds();
+  }
+
+  virtual gfx::Rect GetMonitorWorkAreaMatching(
+      const gfx::Rect& match_rect) const {
+    return gfx::Screen::GetMonitorWorkAreaNearestPoint(
+        match_rect.origin());
+  }
+
+  virtual gfx::Point GetBoundsOffsetMatching(
+      const gfx::Rect& match_rect) const {
+    return GetMonitorWorkAreaMatching(match_rect).origin();
+  }
+
+  void UpdateWorkAreas() {
+    work_areas_.clear();
+    work_areas_.push_back(GetPrimaryMonitorBounds());
+  }
+
+ private:
+
+  DISALLOW_COPY_AND_ASSIGN(DefaultMonitorInfoProvider);
+};
+
+// static
+WindowSizer::MonitorInfoProvider*
+WindowSizer::CreateDefaultMonitorInfoProvider() {
+  return new DefaultMonitorInfoProvider();
+}
+
+// static
+gfx::Point WindowSizer::GetDefaultPopupOrigin(const gfx::Size& size) {
+  // TODO(oshima):This is used to control panel/popups, and this may
+  // not be needed on aura environment as they must be controlled by
+  // WM.
+  NOTIMPLEMENTED();
+  return gfx::Point();
+}
diff --git a/chrome/browser/ui/window_sizer_linux.cc b/chrome/browser/ui/window_sizer_gtk.cc
similarity index 100%
rename from chrome/browser/ui/window_sizer_linux.cc
rename to chrome/browser/ui/window_sizer_gtk.cc
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index 18f979c..300ed1e 100644
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -3798,7 +3798,8 @@
         'browser/ui/webui/workers_ui.h',
         'browser/ui/window_sizer.cc',
         'browser/ui/window_sizer.h',
-        'browser/ui/window_sizer_linux.cc',
+        'browser/ui/window_sizer_aura.cc',
+        'browser/ui/window_sizer_gtk.cc',
         'browser/ui/window_sizer_mac.mm',
         'browser/ui/window_sizer_win.cc',
         'browser/ui/window_snapshot/window_snapshot.h',
@@ -4985,6 +4986,7 @@
             ['exclude', '^browser/ui/views/tab_contents/native_tab_contents_container_gtk.h'],
             ['exclude', '^browser/ui/views/tab_contents/native_tab_contents_view_gtk.cc'],
             ['exclude', '^browser/ui/views/tab_contents/native_tab_contents_view_gtk.h'],
+            ['exclude', '^browser/ui/window_sizer_gtk.cc'],
             ['include', '^browser/ui/login/login_prompt_ui.cc'],
             ['include', '^browser/ui/views/aura/aura_init.cc'],
             ['include', '^browser/ui/views/browser_bubble_aura.cc'],
diff --git a/content/browser/browser_main.cc b/content/browser/browser_main.cc
index b2ba07da..9171a01 100644
--- a/content/browser/browser_main.cc
+++ b/content/browser/browser_main.cc
@@ -292,8 +292,8 @@
   dbus_g_thread_init();
 #endif
 #if defined(USE_AURA)
-  // TODO(saintlou): We still need some GTK at the lowest level, so init here.
-  gtk_init(NULL, NULL);
+  // TODO(oshima|saintlou): Remove this once we remove gtk from build
+  base::MessagePumpX::DisableGtkMessagePump();
 #else
   gfx::GtkInitFromCommandLine(parameters().command_line_);
 #endif
diff --git a/ui/aura/desktop.cc b/ui/aura/desktop.cc
index aadcdef..cbf9d19 100644
--- a/ui/aura/desktop.cc
+++ b/ui/aura/desktop.cc
@@ -34,6 +34,15 @@
     instance_ = NULL;
 }
 
+void Desktop::Init() {
+  window_->Init();
+  compositor()->set_root_layer(window_->layer());
+#if defined(USE_X11)
+  // TODO(oshima): Implement configure notify and remove this.
+  OnHostResized(host_->GetSize());
+#endif
+}
+
 void Desktop::Show() {
   host_->Show();
 }
@@ -76,8 +85,7 @@
 Desktop* Desktop::GetInstance() {
   if (!instance_) {
     instance_ = new Desktop;
-    instance_->window_->Init();
-    instance_->compositor()->set_root_layer(instance_->window_->layer());
+    instance_->Init();
   }
   return instance_;
 }
diff --git a/ui/aura/desktop.h b/ui/aura/desktop.h
index 089ed4e6..aea93e1c 100644
--- a/ui/aura/desktop.h
+++ b/ui/aura/desktop.h
@@ -29,6 +29,9 @@
   Desktop();
   ~Desktop();
 
+  // Initializes the desktop.
+  void Init();
+
   // Shows the desktop host.
   void Show();
 
diff --git a/ui/gfx/screen_aura.cc b/ui/gfx/screen_aura.cc
index 2ed1800..b3eb406 100644
--- a/ui/gfx/screen_aura.cc
+++ b/ui/gfx/screen_aura.cc
@@ -9,6 +9,8 @@
 #endif
 
 #include "base/logging.h"
+#include "ui/aura/desktop.h"
+#include "ui/aura/window.h"
 #include "ui/gfx/native_widget_types.h"
 
 namespace gfx {
@@ -26,20 +28,22 @@
 
 // static
 gfx::Rect Screen::GetMonitorWorkAreaNearestWindow(gfx::NativeWindow window) {
-  NOTIMPLEMENTED();
-  return gfx::Rect();
+  // TODO(oshima): Take window into account. Support multiple monitors.
+  aura::Window* desktop_window = aura::Desktop::GetInstance()->window();
+  return desktop_window->bounds();
 }
 
 // static
 gfx::Rect Screen::GetMonitorAreaNearestWindow(gfx::NativeWindow window) {
-  NOTIMPLEMENTED();
-  return gfx::Rect();
+  // TODO(oshima): Fix this for aura desktop.
+  return GetMonitorAreaNearestWindow(window);
 }
 
 static gfx::Rect GetMonitorAreaOrWorkAreaNearestPoint(const gfx::Point& point,
                                                       bool work_area) {
-  NOTIMPLEMENTED();
-  return gfx::Rect();
+  // TODO(oshima): Take point/work_area into account. Support multiple monitors.
+  aura::Window* desktop_window = aura::Desktop::GetInstance()->window();
+  return desktop_window->bounds();
 }
 
 // static