Skip to content

Instantly share code, notes, and snippets.

@tiagovignatti
Last active December 22, 2015 19:08
Show Gist options
  • Save tiagovignatti/efc863ea860444902639 to your computer and use it in GitHub Desktop.
Save tiagovignatti/efc863ea860444902639 to your computer and use it in GitHub Desktop.
Chrome browser on Wayland
From 6f7c063f81bcc3e5c794f815787b4a9a597aaa18 Mon Sep 17 00:00:00 2001
From: Tiago Vignatti <tiago.vignatti@intel.com>
Date: Tue, 10 Sep 2013 20:38:50 -0300
Subject: [PATCH] WIP: Chromium support on Ozone
Conflicts:
chrome/browser/themes/theme_service_factory.cc
chrome/chrome_browser_extensions.gypi
chrome/chrome_browser_ui.gypi
---
ash/accelerators/accelerator_dispatcher.cc | 5 +
ash/display/display_controller.cc | 2 +-
ash/system/monitor/tray_monitor.cc | 2 +
ash/wm/sticky_keys.cc | 4 +
chrome/app/chrome_main_delegate.cc | 9 +
chrome/browser/fullscreen_aura.cc | 4 -
chrome/browser/idle_linux.cc | 2 +-
chrome/browser/themes/theme_service_factory.cc | 8 +-
.../browser/ui/ash/chrome_shell_delegate_views.cc | 2 +
chrome/browser/ui/aura/tabs/dock_info_aura.cc | 221 ++++++++++++++++++++
chrome/browser/ui/aura/tabs/dock_info_aurax11.cc | 210 -------------------
.../frame/browser_desktop_root_window_host_aura.cc | 79 +++++++
.../frame/browser_desktop_root_window_host_aura.h | 57 +++++
.../frame/browser_desktop_root_window_host_x11.cc | 78 -------
.../frame/browser_desktop_root_window_host_x11.h | 52 -----
.../webui/options/advanced_options_utils_aura.cc | 159 ++++++++++++++
.../ui/webui/options/advanced_options_utils_x11.cc | 159 --------------
chrome/chrome_browser_ui.gypi | 16 +-
.../unhandled_keyboard_event_handler_aura.cc | 30 +++
.../unhandled_keyboard_event_handler_aurax11.cc | 30 ---
ui/views/controls/webview/webview.gyp | 2 +-
21 files changed, 583 insertions(+), 548 deletions(-)
create mode 100644 chrome/browser/ui/aura/tabs/dock_info_aura.cc
delete mode 100644 chrome/browser/ui/aura/tabs/dock_info_aurax11.cc
create mode 100644 chrome/browser/ui/views/frame/browser_desktop_root_window_host_aura.cc
create mode 100644 chrome/browser/ui/views/frame/browser_desktop_root_window_host_aura.h
delete mode 100644 chrome/browser/ui/views/frame/browser_desktop_root_window_host_x11.cc
delete mode 100644 chrome/browser/ui/views/frame/browser_desktop_root_window_host_x11.h
create mode 100644 chrome/browser/ui/webui/options/advanced_options_utils_aura.cc
delete mode 100644 chrome/browser/ui/webui/options/advanced_options_utils_x11.cc
create mode 100644 ui/views/controls/webview/unhandled_keyboard_event_handler_aura.cc
delete mode 100644 ui/views/controls/webview/unhandled_keyboard_event_handler_aurax11.cc
diff --git a/ash/accelerators/accelerator_dispatcher.cc b/ash/accelerators/accelerator_dispatcher.cc
index 91f0154..11729fa 100644
--- a/ash/accelerators/accelerator_dispatcher.cc
+++ b/ash/accelerators/accelerator_dispatcher.cc
@@ -40,6 +40,11 @@ bool IsKeyEvent(const MSG& msg) {
bool IsKeyEvent(const XEvent* xev) {
return xev->type == KeyPress || xev->type == KeyRelease;
}
+#else
+bool IsKeyEvent(const void* event) {
+ // XXX(vignatti)
+ return false;
+}
#endif
bool IsPossibleAcceleratorNotForMenu(const ui::KeyEvent& key_event) {
diff --git a/ash/display/display_controller.cc b/ash/display/display_controller.cc
index 8dde730..3ab258b 100644
--- a/ash/display/display_controller.cc
+++ b/ash/display/display_controller.cc
@@ -221,8 +221,8 @@ DisplayController::DisplayController()
: primary_root_window_for_replace_(NULL),
focus_activation_store_(new internal::FocusActivationStore()),
mirror_window_controller_(new internal::MirrorWindowController) {
- CommandLine* command_line = CommandLine::ForCurrentProcess();
#if defined(OS_CHROMEOS)
+ CommandLine* command_line = CommandLine::ForCurrentProcess();
if (!command_line->HasSwitch(switches::kAshDisableDisplayChangeLimiter) &&
base::chromeos::IsRunningOnChromeOS())
limiter_.reset(new DisplayChangeLimiter);
diff --git a/ash/system/monitor/tray_monitor.cc b/ash/system/monitor/tray_monitor.cc
index eb9a4db..e241cb8 100644
--- a/ash/system/monitor/tray_monitor.cc
+++ b/ash/system/monitor/tray_monitor.cc
@@ -66,12 +66,14 @@ void TrayMonitor::OnGotHandles(const std::list<base::ProcessHandle>& handles) {
base::string16 free_bytes =
ui::FormatBytes(static_cast<int64>(mem_info.free) * 1024);
output = base::StringPrintf("free: %s", UTF16ToUTF8(free_bytes).c_str());
+#ifdef OS_CHROMEOS
if (mem_info.gem_size != -1) {
base::string16 gem_size = ui::FormatBytes(mem_info.gem_size);
output += base::StringPrintf(" gmem: %s", UTF16ToUTF8(gem_size).c_str());
if (mem_info.gem_objects != -1)
output += base::StringPrintf(" gobjects: %d", mem_info.gem_objects);
}
+#endif
size_t total_private_bytes = 0, total_shared_bytes = 0;
for (std::list<base::ProcessHandle>::const_iterator i = handles.begin();
i != handles.end(); ++i) {
diff --git a/ash/wm/sticky_keys.cc b/ash/wm/sticky_keys.cc
index dd2c75a..979746c 100644
--- a/ash/wm/sticky_keys.cc
+++ b/ash/wm/sticky_keys.cc
@@ -4,8 +4,10 @@
#include "ash/wm/sticky_keys.h"
+#if defined(USE_X11)
#include <X11/Xlib.h>
#undef RootWindow
+#endif
#include "base/basictypes.h"
#include "base/debug/stack_trace.h"
@@ -199,6 +201,7 @@ bool StickyKeysHandler::HandleLockedState(ui::KeyEvent* event) {
}
void StickyKeysHandler::AppendModifier(ui::KeyEvent* event) {
+#if defined(USE_X11)
XEvent* xev = event->native_event();
XKeyEvent* xkey = &(xev->xkey);
switch (modifier_flag_) {
@@ -214,6 +217,7 @@ void StickyKeysHandler::AppendModifier(ui::KeyEvent* event) {
default:
NOTREACHED();
}
+#endif
event->set_flags(event->flags() | modifier_flag_);
event->set_character(ui::GetCharacterFromKeyCode(event->key_code(),
event->flags()));
diff --git a/chrome/app/chrome_main_delegate.cc b/chrome/app/chrome_main_delegate.cc
index 08b9e43..c178799 100644
--- a/chrome/app/chrome_main_delegate.cc
+++ b/chrome/app/chrome_main_delegate.cc
@@ -100,6 +100,9 @@
#include "chrome/app/breakpad_linux.h"
#endif
+#include "ozone/impl/ozone_display.h"
+#include "ozone/impl/desktop_factory_wayland.h"
+
#if !defined(CHROME_MULTIPLE_DLL_CHILD)
base::LazyInstance<chrome::ChromeContentBrowserClient>
g_chrome_content_browser_client = LAZY_INSTANCE_INITIALIZER;
@@ -589,6 +592,12 @@ void ChromeMainDelegate::PreSandboxStartup() {
std::string process_type =
command_line.GetSwitchValueASCII(switches::kProcessType);
+ /* TODO: Implementation specific. Has to go away */
+ ui::SurfaceFactoryOzone *o_factory = new ozonewayland::OzoneDisplay();
+ ui::SurfaceFactoryOzone::SetInstance(o_factory);
+ views::DesktopFactoryOzone *d_factory = new ozonewayland::DesktopFactoryWayland();
+ views::DesktopFactoryOzone::SetInstance(d_factory);
+
#if defined(OS_POSIX)
breakpad::SetBreakpadClient(g_chrome_breakpad_client.Pointer());
#endif
diff --git a/chrome/browser/fullscreen_aura.cc b/chrome/browser/fullscreen_aura.cc
index db768be..7a1a8d9 100644
--- a/chrome/browser/fullscreen_aura.cc
+++ b/chrome/browser/fullscreen_aura.cc
@@ -6,8 +6,6 @@
#include "base/logging.h"
-#if !defined(USE_ASH)
-
bool IsFullScreenMode() {
// TODO(erg): An implementation here would have to check all existing
// RootWindows instead of just recursively walking the Shell's RootWindow as
@@ -15,5 +13,3 @@ bool IsFullScreenMode() {
NOTIMPLEMENTED();
return false;
}
-
-#endif
diff --git a/chrome/browser/idle_linux.cc b/chrome/browser/idle_linux.cc
index 28d2037..0a13735 100644
--- a/chrome/browser/idle_linux.cc
+++ b/chrome/browser/idle_linux.cc
@@ -24,7 +24,7 @@ void CalculateIdleTime(IdleTimeCallback notify) {
bool CheckIdleStateIsLocked() {
// Usually the screensaver is used to lock the screen, so we do not need to
// check if the workstation is locked.
-#if defined(OS_CHROMEOS)
+#if defined(OS_CHROMEOS) || defined(USE_OZONE)
return false;
#else
return ScreensaverWindowFinder::ScreensaverWindowExists();
diff --git a/chrome/browser/themes/theme_service_factory.cc b/chrome/browser/themes/theme_service_factory.cc
index e91a160..930dcf6 100644
--- a/chrome/browser/themes/theme_service_factory.cc
+++ b/chrome/browser/themes/theme_service_factory.cc
@@ -18,7 +18,7 @@
#include "chrome/browser/ui/gtk/gtk_theme_service.h"
#endif
-#if defined(USE_AURA) && defined(OS_LINUX) && !defined(OS_CHROMEOS)
+#if defined(USE_AURA) && defined(USE_X11) && !defined(OS_CHROMEOS)
#include "chrome/browser/themes/theme_service_aurax11.h"
#include "ui/views/linux_ui/linux_ui.h"
#endif
@@ -56,7 +56,7 @@ BrowserContextKeyedService* ThemeServiceFactory::BuildServiceInstanceFor(
ThemeService* provider = NULL;
#if defined(TOOLKIT_GTK)
provider = new GtkThemeService;
-#elif defined(USE_AURA) && defined(OS_LINUX) && !defined(OS_CHROMEOS)
+#elif defined(USE_AURA) && defined(USE_X11) && !defined(OS_CHROMEOS)
provider = new ThemeServiceAuraX11;
#else
provider = new ThemeService;
@@ -68,12 +68,12 @@ BrowserContextKeyedService* ThemeServiceFactory::BuildServiceInstanceFor(
void ThemeServiceFactory::RegisterProfilePrefs(
user_prefs::PrefRegistrySyncable* registry) {
-#if defined(OS_LINUX) && !defined(OS_CHROMEOS)
+#if defined(USE_X11) && !defined(OS_CHROMEOS)
bool default_uses_system_theme = false;
#if defined(TOOLKIT_GTK)
default_uses_system_theme = GtkThemeService::DefaultUsesSystemTheme();
-#elif defined(USE_AURA) && defined(OS_LINUX) && !defined(OS_CHROMEOS)
+#elif defined(USE_AURA) && defined(USE_X11) && !defined(OS_CHROMEOS)
const views::LinuxUI* linux_ui = views::LinuxUI::instance();
if (linux_ui)
default_uses_system_theme = linux_ui->GetDefaultUsesSystemTheme();
diff --git a/chrome/browser/ui/ash/chrome_shell_delegate_views.cc b/chrome/browser/ui/ash/chrome_shell_delegate_views.cc
index 1b01998..f76edb8 100644
--- a/chrome/browser/ui/ash/chrome_shell_delegate_views.cc
+++ b/chrome/browser/ui/ash/chrome_shell_delegate_views.cc
@@ -130,12 +130,14 @@ void ChromeShellDelegate::Observe(int type,
const content::NotificationDetails& details) {
switch (type) {
case chrome::NOTIFICATION_ASH_SESSION_STARTED: {
+#if defined(OS_WIN)
// If we are launched to service a windows 8 search request then let the
// IPC which carries the search string create the browser and initiate
// the navigation.
if (CommandLine::ForCurrentProcess()->HasSwitch(
switches::kWindows8Search))
break;
+#endif
// If Chrome ASH is launched when no browser is open in the desktop,
// we should execute the startup code.
// If there are browsers open in the desktop, we create a browser window
diff --git a/chrome/browser/ui/aura/tabs/dock_info_aura.cc b/chrome/browser/ui/aura/tabs/dock_info_aura.cc
new file mode 100644
index 0000000..8032074
--- /dev/null
+++ b/chrome/browser/ui/aura/tabs/dock_info_aura.cc
@@ -0,0 +1,221 @@
+// Copyright (c) 2012 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/tabs/dock_info.h"
+
+#include "chrome/browser/ui/host_desktop.h"
+#include "ui/aura/root_window.h"
+#include "ui/aura/window.h"
+#if defined(USE_X11)
+#include "ui/base/x/x11_util.h"
+#endif
+
+#if !defined(OS_CHROMEOS)
+#include "ui/views/widget/desktop_aura/desktop_root_window_host_x11.h"
+#endif
+
+#if !defined(OS_CHROMEOS) && defined(USE_X11)
+namespace {
+
+////////////////////////////////////////////////////////////////////////////////
+// BaseWindowFinder
+//
+// Base class used to locate a window. A subclass need only override
+// ShouldStopIterating to determine when iteration should stop.
+class BaseWindowFinder : public ui::EnumerateWindowsDelegate {
+ public:
+ explicit BaseWindowFinder(const std::set<aura::Window*>& ignore) {
+ std::set<aura::Window*>::iterator iter;
+ for (iter = ignore.begin(); iter != ignore.end(); iter++) {
+ XID xid = (*iter)->GetRootWindow()->GetAcceleratedWidget();
+ ignore_.insert(xid);
+ }
+ }
+
+ virtual ~BaseWindowFinder() {}
+
+ protected:
+ // Returns true if |window| is in the ignore list.
+ bool ShouldIgnoreWindow(XID window) {
+ return (ignore_.find(window) != ignore_.end());
+ }
+
+ // Returns true if iteration should stop, false otherwise.
+ virtual bool ShouldStopIterating(XID window) OVERRIDE {
+ return false;
+ }
+
+ private:
+ std::set<XID> ignore_;
+
+ DISALLOW_COPY_AND_ASSIGN(BaseWindowFinder);
+};
+
+////////////////////////////////////////////////////////////////////////////////
+// TopMostFinder
+//
+// Helper class to determine if a particular point of a window is not obscured
+// by another window.
+class TopMostFinder : public BaseWindowFinder {
+ public:
+ // Returns true if |window| is not obscured by another window at the
+ // location |screen_loc|, not including the windows in |ignore|.
+ static bool IsTopMostWindowAtPoint(XID window,
+ const gfx::Point& screen_loc,
+ const std::set<aura::Window*>& ignore) {
+ TopMostFinder finder(window, screen_loc, ignore);
+ return finder.is_top_most_;
+ }
+
+ protected:
+ virtual bool ShouldStopIterating(XID window) OVERRIDE {
+ if (BaseWindowFinder::ShouldIgnoreWindow(window))
+ return false;
+
+ if (window == target_) {
+ // Window is topmost, stop iterating.
+ is_top_most_ = true;
+ return true;
+ }
+
+ if (!ui::IsWindowVisible(window)) {
+ // The window isn't visible, keep iterating.
+ return false;
+ }
+
+ // At this point we haven't found our target window, so this window is
+ // higher in the z-order than the target window. If this window contains
+ // the point, then we can stop the search now because this window is
+ // obscuring the target window at this point.
+ return ui::WindowContainsPoint(window, screen_loc_);
+ }
+
+ private:
+ TopMostFinder(XID window,
+ const gfx::Point& screen_loc,
+ const std::set<aura::Window*>& ignore)
+ : BaseWindowFinder(ignore),
+ target_(window),
+ screen_loc_(screen_loc),
+ is_top_most_(false) {
+ ui::EnumerateTopLevelWindows(this);
+ }
+
+ // The window we're looking for.
+ XID target_;
+
+ // Location of window to find.
+ gfx::Point screen_loc_;
+
+ // Is target_ the top most window? This is initially false but set to true
+ // in ShouldStopIterating if target_ is passed in.
+ bool is_top_most_;
+
+ DISALLOW_COPY_AND_ASSIGN(TopMostFinder);
+};
+
+////////////////////////////////////////////////////////////////////////////////
+// LocalProcessWindowFinder
+//
+// Helper class to determine if a particular point of a window from our process
+// is not obscured by another window.
+class LocalProcessWindowFinder : public BaseWindowFinder {
+ public:
+ // Returns the XID from our process at screen_loc that is not obscured by
+ // another window. Returns 0 otherwise.
+ static XID GetProcessWindowAtPoint(const gfx::Point& screen_loc,
+ const std::set<aura::Window*>& ignore) {
+ LocalProcessWindowFinder finder(screen_loc, ignore);
+ if (finder.result_ &&
+ TopMostFinder::IsTopMostWindowAtPoint(finder.result_, screen_loc,
+ ignore)) {
+ return finder.result_;
+ }
+ return 0;
+ }
+
+ protected:
+ virtual bool ShouldStopIterating(XID window) OVERRIDE {
+ if (BaseWindowFinder::ShouldIgnoreWindow(window))
+ return false;
+
+ // Check if this window is in our process.
+ if (!aura::RootWindow::GetForAcceleratedWidget(window))
+ return false;
+
+ if (!ui::IsWindowVisible(window))
+ return false;
+
+ if (ui::WindowContainsPoint(window, screen_loc_)) {
+ result_ = window;
+ return true;
+ }
+
+ return false;
+ }
+
+ private:
+ LocalProcessWindowFinder(const gfx::Point& screen_loc,
+ const std::set<aura::Window*>& ignore)
+ : BaseWindowFinder(ignore),
+ screen_loc_(screen_loc),
+ result_(0) {
+ ui::EnumerateTopLevelWindows(this);
+ }
+
+ // Position of the mouse.
+ gfx::Point screen_loc_;
+
+ // The resulting window. This is initially null but set to true in
+ // ShouldStopIterating if an appropriate window is found.
+ XID result_;
+
+ DISALLOW_COPY_AND_ASSIGN(LocalProcessWindowFinder);
+};
+
+} // namespace
+
+// static
+gfx::NativeView DockInfo::GetLocalProcessWindowAtPoint(
+ chrome::HostDesktopType host_desktop_type,
+ const gfx::Point& screen_point,
+ const std::set<gfx::NativeView>& ignore) {
+ // The X11 server is the canonical state of what the window stacking order
+ // is.
+ XID xid =
+ LocalProcessWindowFinder::GetProcessWindowAtPoint(screen_point, ignore);
+ return views::DesktopRootWindowHostX11::GetContentWindowForXID(xid);
+}
+#endif
+
+// static
+DockInfo DockInfo::GetDockInfoAtPoint(chrome::HostDesktopType host_desktop_type,
+ const gfx::Point& screen_point,
+ const std::set<gfx::NativeView>& ignore) {
+ // TODO(beng):
+ NOTIMPLEMENTED();
+ return DockInfo();
+}
+
+// static
+gfx::NativeView DockInfo::GetLocalProcessWindowAtPoint(
+ chrome::HostDesktopType host_desktop_type,
+ const gfx::Point& screen_point,
+ const std::set<gfx::NativeView>& ignore) {
+
+ // TODO(vignatti):
+ NOTIMPLEMENTED();
+ return NULL;
+}
+
+bool DockInfo::GetWindowBounds(gfx::Rect* bounds) const {
+ if (!window())
+ return false;
+ *bounds = window_->bounds();
+ return true;
+}
+
+void DockInfo::SizeOtherWindowTo(const gfx::Rect& bounds) const {
+ window_->SetBounds(bounds);
+}
diff --git a/chrome/browser/ui/aura/tabs/dock_info_aurax11.cc b/chrome/browser/ui/aura/tabs/dock_info_aurax11.cc
deleted file mode 100644
index 274f5c2..0000000
--- a/chrome/browser/ui/aura/tabs/dock_info_aurax11.cc
+++ /dev/null
@@ -1,210 +0,0 @@
-// Copyright (c) 2012 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/tabs/dock_info.h"
-
-#include "chrome/browser/ui/host_desktop.h"
-#include "ui/aura/root_window.h"
-#include "ui/aura/window.h"
-#include "ui/base/x/x11_util.h"
-
-#if !defined(OS_CHROMEOS)
-#include "ui/views/widget/desktop_aura/desktop_root_window_host_x11.h"
-#endif
-
-#if !defined(OS_CHROMEOS)
-
-namespace {
-
-////////////////////////////////////////////////////////////////////////////////
-// BaseWindowFinder
-//
-// Base class used to locate a window. A subclass need only override
-// ShouldStopIterating to determine when iteration should stop.
-class BaseWindowFinder : public ui::EnumerateWindowsDelegate {
- public:
- explicit BaseWindowFinder(const std::set<aura::Window*>& ignore) {
- std::set<aura::Window*>::iterator iter;
- for (iter = ignore.begin(); iter != ignore.end(); iter++) {
- XID xid = (*iter)->GetRootWindow()->GetAcceleratedWidget();
- ignore_.insert(xid);
- }
- }
-
- virtual ~BaseWindowFinder() {}
-
- protected:
- // Returns true if |window| is in the ignore list.
- bool ShouldIgnoreWindow(XID window) {
- return (ignore_.find(window) != ignore_.end());
- }
-
- // Returns true if iteration should stop, false otherwise.
- virtual bool ShouldStopIterating(XID window) OVERRIDE {
- return false;
- }
-
- private:
- std::set<XID> ignore_;
-
- DISALLOW_COPY_AND_ASSIGN(BaseWindowFinder);
-};
-
-////////////////////////////////////////////////////////////////////////////////
-// TopMostFinder
-//
-// Helper class to determine if a particular point of a window is not obscured
-// by another window.
-class TopMostFinder : public BaseWindowFinder {
- public:
- // Returns true if |window| is not obscured by another window at the
- // location |screen_loc|, not including the windows in |ignore|.
- static bool IsTopMostWindowAtPoint(XID window,
- const gfx::Point& screen_loc,
- const std::set<aura::Window*>& ignore) {
- TopMostFinder finder(window, screen_loc, ignore);
- return finder.is_top_most_;
- }
-
- protected:
- virtual bool ShouldStopIterating(XID window) OVERRIDE {
- if (BaseWindowFinder::ShouldIgnoreWindow(window))
- return false;
-
- if (window == target_) {
- // Window is topmost, stop iterating.
- is_top_most_ = true;
- return true;
- }
-
- if (!ui::IsWindowVisible(window)) {
- // The window isn't visible, keep iterating.
- return false;
- }
-
- // At this point we haven't found our target window, so this window is
- // higher in the z-order than the target window. If this window contains
- // the point, then we can stop the search now because this window is
- // obscuring the target window at this point.
- return ui::WindowContainsPoint(window, screen_loc_);
- }
-
- private:
- TopMostFinder(XID window,
- const gfx::Point& screen_loc,
- const std::set<aura::Window*>& ignore)
- : BaseWindowFinder(ignore),
- target_(window),
- screen_loc_(screen_loc),
- is_top_most_(false) {
- ui::EnumerateTopLevelWindows(this);
- }
-
- // The window we're looking for.
- XID target_;
-
- // Location of window to find.
- gfx::Point screen_loc_;
-
- // Is target_ the top most window? This is initially false but set to true
- // in ShouldStopIterating if target_ is passed in.
- bool is_top_most_;
-
- DISALLOW_COPY_AND_ASSIGN(TopMostFinder);
-};
-
-////////////////////////////////////////////////////////////////////////////////
-// LocalProcessWindowFinder
-//
-// Helper class to determine if a particular point of a window from our process
-// is not obscured by another window.
-class LocalProcessWindowFinder : public BaseWindowFinder {
- public:
- // Returns the XID from our process at screen_loc that is not obscured by
- // another window. Returns 0 otherwise.
- static XID GetProcessWindowAtPoint(const gfx::Point& screen_loc,
- const std::set<aura::Window*>& ignore) {
- LocalProcessWindowFinder finder(screen_loc, ignore);
- if (finder.result_ &&
- TopMostFinder::IsTopMostWindowAtPoint(finder.result_, screen_loc,
- ignore)) {
- return finder.result_;
- }
- return 0;
- }
-
- protected:
- virtual bool ShouldStopIterating(XID window) OVERRIDE {
- if (BaseWindowFinder::ShouldIgnoreWindow(window))
- return false;
-
- // Check if this window is in our process.
- if (!aura::RootWindow::GetForAcceleratedWidget(window))
- return false;
-
- if (!ui::IsWindowVisible(window))
- return false;
-
- if (ui::WindowContainsPoint(window, screen_loc_)) {
- result_ = window;
- return true;
- }
-
- return false;
- }
-
- private:
- LocalProcessWindowFinder(const gfx::Point& screen_loc,
- const std::set<aura::Window*>& ignore)
- : BaseWindowFinder(ignore),
- screen_loc_(screen_loc),
- result_(0) {
- ui::EnumerateTopLevelWindows(this);
- }
-
- // Position of the mouse.
- gfx::Point screen_loc_;
-
- // The resulting window. This is initially null but set to true in
- // ShouldStopIterating if an appropriate window is found.
- XID result_;
-
- DISALLOW_COPY_AND_ASSIGN(LocalProcessWindowFinder);
-};
-
-} // namespace
-
-// static
-DockInfo DockInfo::GetDockInfoAtPoint(chrome::HostDesktopType host_desktop_type,
- const gfx::Point& screen_point,
- const std::set<gfx::NativeView>& ignore) {
- // TODO(beng):
- NOTIMPLEMENTED();
- return DockInfo();
-}
-
-// static
-gfx::NativeView DockInfo::GetLocalProcessWindowAtPoint(
- chrome::HostDesktopType host_desktop_type,
- const gfx::Point& screen_point,
- const std::set<gfx::NativeView>& ignore) {
- // The X11 server is the canonical state of what the window stacking order
- // is.
- XID xid =
- LocalProcessWindowFinder::GetProcessWindowAtPoint(screen_point, ignore);
- return views::DesktopRootWindowHostX11::GetContentWindowForXID(xid);
-}
-
-bool DockInfo::GetWindowBounds(gfx::Rect* bounds) const {
- if (!window())
- return false;
- *bounds = window_->bounds();
- return true;
-}
-
-void DockInfo::SizeOtherWindowTo(const gfx::Rect& bounds) const {
- window_->SetBounds(bounds);
-}
-
-#endif
diff --git a/chrome/browser/ui/views/frame/browser_desktop_root_window_host_aura.cc b/chrome/browser/ui/views/frame/browser_desktop_root_window_host_aura.cc
new file mode 100644
index 0000000..ab002d3
--- /dev/null
+++ b/chrome/browser/ui/views/frame/browser_desktop_root_window_host_aura.cc
@@ -0,0 +1,79 @@
+// Copyright (c) 2012 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/views/frame/browser_desktop_root_window_host_aura.h"
+
+////////////////////////////////////////////////////////////////////////////////
+// BrowserDesktopRootWindowHostAura, public:
+
+BrowserDesktopRootWindowHostAura::BrowserDesktopRootWindowHostAura(
+ views::internal::NativeWidgetDelegate* native_widget_delegate,
+ views::DesktopNativeWidgetAura* desktop_native_widget_aura,
+ const gfx::Rect& initial_bounds,
+ BrowserView* browser_view)
+ : browser_view_(browser_view) {
+ desktop_root_window_host_ = views::DesktopRootWindowHost::Create(
+ native_widget_delegate,
+ desktop_native_widget_aura,
+ initial_bounds);
+}
+
+BrowserDesktopRootWindowHostAura::~BrowserDesktopRootWindowHostAura() {
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// BrowserDesktopRootWindowHostAura,
+// BrowserDesktopRootWindowHost implementation:
+
+views::DesktopRootWindowHost*
+ BrowserDesktopRootWindowHostAura::AsDesktopRootWindowHost() {
+ return desktop_root_window_host_;
+}
+
+int BrowserDesktopRootWindowHostAura::GetMinimizeButtonOffset() const {
+ return 0;
+}
+
+bool BrowserDesktopRootWindowHostAura::UsesNativeSystemMenu() const {
+ return false;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// BrowserDesktopRootWindowHostAura,
+// views::DesktopRootWindowHostAura implementation:
+
+aura::RootWindow* BrowserDesktopRootWindowHostAura::Init(
+ aura::Window* content_window,
+ const views::Widget::InitParams& params) {
+ aura::RootWindow* root_window =
+ desktop_root_window_host_->Init(content_window, params);
+
+ // We have now created our backing X11 window. We now need to (possibly)
+ // alert Unity that there's a menu bar attached to it.
+ //global_menu_bar_x11_.reset(new GlobalMenuBarX11(browser_view_, this));
+
+ return root_window;
+}
+
+void BrowserDesktopRootWindowHostAura::CloseNow() {
+ //global_menu_bar_x11_.reset();
+ desktop_root_window_host_->CloseNow();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// BrowserDesktopRootWindowHost, public:
+
+// static
+BrowserDesktopRootWindowHost*
+ BrowserDesktopRootWindowHost::CreateBrowserDesktopRootWindowHost(
+ views::internal::NativeWidgetDelegate* native_widget_delegate,
+ views::DesktopNativeWidgetAura* desktop_native_widget_aura,
+ const gfx::Rect& initial_bounds,
+ BrowserView* browser_view,
+ BrowserFrame* browser_frame) {
+ return new BrowserDesktopRootWindowHostAura(native_widget_delegate,
+ desktop_native_widget_aura,
+ initial_bounds,
+ browser_view);
+}
diff --git a/chrome/browser/ui/views/frame/browser_desktop_root_window_host_aura.h b/chrome/browser/ui/views/frame/browser_desktop_root_window_host_aura.h
new file mode 100644
index 0000000..21fa22f
--- /dev/null
+++ b/chrome/browser/ui/views/frame/browser_desktop_root_window_host_aura.h
@@ -0,0 +1,57 @@
+// Copyright (c) 2012 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.
+
+#ifndef CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_DESKTOP_ROOT_WINDOW_HOST_AURA_H_
+#define CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_DESKTOP_ROOT_WINDOW_HOST_AURA_H_
+
+#include "ui/aura/root_window_host.h"
+#include "ui/views/widget/desktop_aura/desktop_root_window_host.h"
+#include "chrome/browser/ui/views/frame/browser_desktop_root_window_host.h"
+// XXX(vignatti):
+///#include "chrome/browser/ui/views/frame/global_menu_bar_x11.h"
+
+class BrowserFrame;
+class BrowserView;
+
+namespace views {
+class DesktopNativeWidgetAura;
+class DesktopRootWindowHost;
+}
+
+class BrowserDesktopRootWindowHostAura
+ : public BrowserDesktopRootWindowHost {
+ public:
+ BrowserDesktopRootWindowHostAura(
+ views::internal::NativeWidgetDelegate* native_widget_delegate,
+ views::DesktopNativeWidgetAura* desktop_native_widget_aura,
+ const gfx::Rect& initial_bounds,
+ BrowserView* browser_view);
+ virtual ~BrowserDesktopRootWindowHostAura();
+
+ private:
+ // Overridden from BrowserDesktopRootWindowHost:
+ virtual views::DesktopRootWindowHost* AsDesktopRootWindowHost() OVERRIDE;
+ virtual int GetMinimizeButtonOffset() const OVERRIDE;
+ virtual bool UsesNativeSystemMenu() const OVERRIDE;
+
+ // Overridden from views::DesktopRootWindowHostAura:
+ virtual aura::RootWindow* Init(
+ aura::Window* content_window,
+ const views::Widget::InitParams& params) OVERRIDE;
+ virtual void CloseNow() OVERRIDE;
+
+ BrowserView* browser_view_;
+
+ // Ownership passed to RootWindow on Init.
+ views::DesktopRootWindowHost* desktop_root_window_host_;
+
+ // Each browser frame maintains its own menu bar object because the lower
+ // level dbus protocol associates a xid to a menu bar; we can't map multiple
+ // xids to the same menu bar.
+ //scoped_ptr<GlobalMenuBarX11> global_menu_bar_x11_;
+
+ DISALLOW_COPY_AND_ASSIGN(BrowserDesktopRootWindowHostAura);
+};
+
+#endif // CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_DESKTOP_ROOT_WINDOW_HOST_AURA_H_
diff --git a/chrome/browser/ui/views/frame/browser_desktop_root_window_host_x11.cc b/chrome/browser/ui/views/frame/browser_desktop_root_window_host_x11.cc
deleted file mode 100644
index b7f3fdb..0000000
--- a/chrome/browser/ui/views/frame/browser_desktop_root_window_host_x11.cc
+++ /dev/null
@@ -1,78 +0,0 @@
-// Copyright (c) 2012 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/views/frame/browser_desktop_root_window_host_x11.h"
-
-////////////////////////////////////////////////////////////////////////////////
-// BrowserDesktopRootWindowHostX11, public:
-
-BrowserDesktopRootWindowHostX11::BrowserDesktopRootWindowHostX11(
- views::internal::NativeWidgetDelegate* native_widget_delegate,
- views::DesktopNativeWidgetAura* desktop_native_widget_aura,
- const gfx::Rect& initial_bounds,
- BrowserView* browser_view)
- : DesktopRootWindowHostX11(native_widget_delegate,
- desktop_native_widget_aura,
- initial_bounds),
- browser_view_(browser_view) {
-}
-
-BrowserDesktopRootWindowHostX11::~BrowserDesktopRootWindowHostX11() {
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// BrowserDesktopRootWindowHostX11,
-// BrowserDesktopRootWindowHost implementation:
-
-views::DesktopRootWindowHost*
- BrowserDesktopRootWindowHostX11::AsDesktopRootWindowHost() {
- return this;
-}
-
-int BrowserDesktopRootWindowHostX11::GetMinimizeButtonOffset() const {
- return 0;
-}
-
-bool BrowserDesktopRootWindowHostX11::UsesNativeSystemMenu() const {
- return false;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// BrowserDesktopRootWindowHostX11,
-// views::DesktopRootWindowHostX11 implementation:
-
-aura::RootWindow* BrowserDesktopRootWindowHostX11::Init(
- aura::Window* content_window,
- const views::Widget::InitParams& params) {
- aura::RootWindow* root_window = views::DesktopRootWindowHostX11::Init(
- content_window, params);
-
- // We have now created our backing X11 window. We now need to (possibly)
- // alert Unity that there's a menu bar attached to it.
- global_menu_bar_x11_.reset(new GlobalMenuBarX11(browser_view_, this));
-
- return root_window;
-}
-
-void BrowserDesktopRootWindowHostX11::CloseNow() {
- global_menu_bar_x11_.reset();
- DesktopRootWindowHostX11::CloseNow();
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// BrowserDesktopRootWindowHost, public:
-
-// static
-BrowserDesktopRootWindowHost*
- BrowserDesktopRootWindowHost::CreateBrowserDesktopRootWindowHost(
- views::internal::NativeWidgetDelegate* native_widget_delegate,
- views::DesktopNativeWidgetAura* desktop_native_widget_aura,
- const gfx::Rect& initial_bounds,
- BrowserView* browser_view,
- BrowserFrame* browser_frame) {
- return new BrowserDesktopRootWindowHostX11(native_widget_delegate,
- desktop_native_widget_aura,
- initial_bounds,
- browser_view);
-}
diff --git a/chrome/browser/ui/views/frame/browser_desktop_root_window_host_x11.h b/chrome/browser/ui/views/frame/browser_desktop_root_window_host_x11.h
deleted file mode 100644
index 52aa8d7..0000000
--- a/chrome/browser/ui/views/frame/browser_desktop_root_window_host_x11.h
+++ /dev/null
@@ -1,52 +0,0 @@
-// Copyright (c) 2012 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.
-
-#ifndef CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_DESKTOP_ROOT_WINDOW_HOST_X11_H_
-#define CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_DESKTOP_ROOT_WINDOW_HOST_X11_H_
-
-#include "ui/views/widget/desktop_aura/desktop_root_window_host_x11.h"
-#include "chrome/browser/ui/views/frame/browser_desktop_root_window_host.h"
-#include "chrome/browser/ui/views/frame/global_menu_bar_x11.h"
-
-class BrowserFrame;
-class BrowserView;
-
-namespace views {
-class DesktopNativeWidgetAura;
-}
-
-class BrowserDesktopRootWindowHostX11
- : public BrowserDesktopRootWindowHost,
- public views::DesktopRootWindowHostX11 {
- public:
- BrowserDesktopRootWindowHostX11(
- views::internal::NativeWidgetDelegate* native_widget_delegate,
- views::DesktopNativeWidgetAura* desktop_native_widget_aura,
- const gfx::Rect& initial_bounds,
- BrowserView* browser_view);
- virtual ~BrowserDesktopRootWindowHostX11();
-
- private:
- // Overridden from BrowserDesktopRootWindowHost:
- virtual DesktopRootWindowHost* AsDesktopRootWindowHost() OVERRIDE;
- virtual int GetMinimizeButtonOffset() const OVERRIDE;
- virtual bool UsesNativeSystemMenu() const OVERRIDE;
-
- // Overridden from views::DesktopRootWindowHostX11:
- virtual aura::RootWindow* Init(
- aura::Window* content_window,
- const views::Widget::InitParams& params) OVERRIDE;
- virtual void CloseNow() OVERRIDE;
-
- BrowserView* browser_view_;
-
- // Each browser frame maintains its own menu bar object because the lower
- // level dbus protocol associates a xid to a menu bar; we can't map multiple
- // xids to the same menu bar.
- scoped_ptr<GlobalMenuBarX11> global_menu_bar_x11_;
-
- DISALLOW_COPY_AND_ASSIGN(BrowserDesktopRootWindowHostX11);
-};
-
-#endif // CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_DESKTOP_ROOT_WINDOW_HOST_X11_H_
diff --git a/chrome/browser/ui/webui/options/advanced_options_utils_aura.cc b/chrome/browser/ui/webui/options/advanced_options_utils_aura.cc
new file mode 100644
index 0000000..211f5b9
--- /dev/null
+++ b/chrome/browser/ui/webui/options/advanced_options_utils_aura.cc
@@ -0,0 +1,159 @@
+// Copyright (c) 2012 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.
+
+#if !defined(OS_CHROMEOS)
+
+#include "chrome/browser/ui/webui/options/advanced_options_utils.h"
+
+#include "base/bind.h"
+#include "base/environment.h"
+#include "base/file_util.h"
+#include "base/files/file_path.h"
+#include "base/nix/xdg_util.h"
+#include "base/process/launch.h"
+#include "base/strings/string_util.h"
+#include "chrome/browser/tab_contents/tab_util.h"
+#include "content/public/browser/browser_thread.h"
+#include "content/public/browser/render_process_host.h"
+#include "content/public/browser/render_view_host.h"
+#include "content/public/browser/web_contents.h"
+
+using content::BrowserThread;
+using content::OpenURLParams;
+using content::Referrer;
+using content::WebContents;
+
+namespace options {
+
+// Command used to configure GNOME 2 proxy settings.
+const char* kGNOME2ProxyConfigCommand[] = {"gnome-network-properties", NULL};
+// In GNOME 3, we might need to run gnome-control-center instead. We try this
+// only after gnome-network-properties is not found, because older GNOME also
+// has this but it doesn't do the same thing. See below where we use it.
+const char* kGNOME3ProxyConfigCommand[] = {"gnome-control-center", "network",
+ NULL};
+// KDE3 and KDE4 are only slightly different, but incompatible. Go figure.
+const char* kKDE3ProxyConfigCommand[] = {"kcmshell", "proxy", NULL};
+const char* kKDE4ProxyConfigCommand[] = {"kcmshell4", "proxy", NULL};
+
+// The URL for Linux proxy configuration help when not running under a
+// supported desktop environment.
+const char kLinuxProxyConfigUrl[] = "about:linux-proxy-config";
+
+namespace {
+
+// Show the proxy config URL in the given tab.
+void ShowLinuxProxyConfigUrl(int render_process_id, int render_view_id) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ scoped_ptr<base::Environment> env(base::Environment::Create());
+ const char* name = base::nix::GetDesktopEnvironmentName(env.get());
+ if (name)
+ LOG(ERROR) << "Could not find " << name << " network settings in $PATH";
+ OpenURLParams params(
+ GURL(kLinuxProxyConfigUrl), Referrer(), NEW_FOREGROUND_TAB,
+ content::PAGE_TRANSITION_LINK, false);
+
+ WebContents* web_contents =
+ tab_util::GetWebContentsByID(render_process_id, render_view_id);
+ if (web_contents)
+ web_contents->OpenURL(params);
+}
+
+// Start the given proxy configuration utility.
+bool StartProxyConfigUtil(const char* command[]) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
+ // base::LaunchProcess() returns true ("success") if the fork()
+ // succeeds, but not necessarily the exec(). We'd like to be able to
+ // use StartProxyConfigUtil() to search possible options and stop on
+ // success, so we search $PATH first to predict whether the exec is
+ // expected to succeed.
+ // TODO(mdm): this is a useful check, and is very similar to some
+ // code in proxy_config_service_linux.cc. It should probably be in
+ // base:: somewhere.
+ scoped_ptr<base::Environment> env(base::Environment::Create());
+ std::string path;
+ if (!env->GetVar("PATH", &path)) {
+ LOG(ERROR) << "No $PATH variable. Assuming no " << command[0] << ".";
+ return false;
+ }
+ std::vector<std::string> paths;
+ Tokenize(path, ":", &paths);
+ bool found = false;
+ for (size_t i = 0; i < paths.size(); ++i) {
+ base::FilePath file(paths[i]);
+ if (base::PathExists(file.Append(command[0]))) {
+ found = true;
+ break;
+ }
+ }
+ if (!found)
+ return false;
+ std::vector<std::string> argv;
+ for (size_t i = 0; command[i]; ++i)
+ argv.push_back(command[i]);
+ base::ProcessHandle handle;
+ if (!base::LaunchProcess(argv, base::LaunchOptions(), &handle)) {
+ LOG(ERROR) << "StartProxyConfigUtil failed to start " << command[0];
+ return false;
+ }
+ base::EnsureProcessGetsReaped(handle);
+ return true;
+}
+
+// Detect, and if possible, start the appropriate proxy config utility. On
+// failure to do so, show the Linux proxy config URL in a new tab instead.
+void DetectAndStartProxyConfigUtil(int render_process_id,
+ int render_view_id) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
+ scoped_ptr<base::Environment> env(base::Environment::Create());
+
+ bool launched = false;
+ switch (base::nix::GetDesktopEnvironment(env.get())) {
+ case base::nix::DESKTOP_ENVIRONMENT_GNOME:
+ case base::nix::DESKTOP_ENVIRONMENT_UNITY: {
+ launched = StartProxyConfigUtil(kGNOME2ProxyConfigCommand);
+ if (!launched) {
+ // We try this second, even though it's the newer way, because this
+ // command existed in older versions of GNOME, but it didn't do the
+ // same thing. The older command is gone though, so this should do
+ // the right thing. (Also some distributions have blurred the lines
+ // between GNOME 2 and 3, so we can't necessarily detect what the
+ // right thing is based on indications of which version we have.)
+ launched = StartProxyConfigUtil(kGNOME3ProxyConfigCommand);
+ }
+ break;
+ }
+
+ case base::nix::DESKTOP_ENVIRONMENT_KDE3:
+ launched = StartProxyConfigUtil(kKDE3ProxyConfigCommand);
+ break;
+
+ case base::nix::DESKTOP_ENVIRONMENT_KDE4:
+ launched = StartProxyConfigUtil(kKDE4ProxyConfigCommand);
+ break;
+
+ case base::nix::DESKTOP_ENVIRONMENT_XFCE:
+ case base::nix::DESKTOP_ENVIRONMENT_OTHER:
+ break;
+ }
+
+ if (launched)
+ return;
+ BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
+ base::Bind(&ShowLinuxProxyConfigUrl, render_process_id, render_view_id));
+}
+
+} // anonymous namespace
+
+void AdvancedOptionsUtilities::ShowNetworkProxySettings(
+ WebContents* web_contents) {
+ BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE,
+ base::Bind(&DetectAndStartProxyConfigUtil,
+ web_contents->GetRenderProcessHost()->GetID(),
+ web_contents->GetRenderViewHost()->GetRoutingID()));
+}
+
+} // namespace options
+
+#endif // !defined(OS_CHROMEOS)
diff --git a/chrome/browser/ui/webui/options/advanced_options_utils_x11.cc b/chrome/browser/ui/webui/options/advanced_options_utils_x11.cc
deleted file mode 100644
index 211f5b9..0000000
--- a/chrome/browser/ui/webui/options/advanced_options_utils_x11.cc
+++ /dev/null
@@ -1,159 +0,0 @@
-// Copyright (c) 2012 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.
-
-#if !defined(OS_CHROMEOS)
-
-#include "chrome/browser/ui/webui/options/advanced_options_utils.h"
-
-#include "base/bind.h"
-#include "base/environment.h"
-#include "base/file_util.h"
-#include "base/files/file_path.h"
-#include "base/nix/xdg_util.h"
-#include "base/process/launch.h"
-#include "base/strings/string_util.h"
-#include "chrome/browser/tab_contents/tab_util.h"
-#include "content/public/browser/browser_thread.h"
-#include "content/public/browser/render_process_host.h"
-#include "content/public/browser/render_view_host.h"
-#include "content/public/browser/web_contents.h"
-
-using content::BrowserThread;
-using content::OpenURLParams;
-using content::Referrer;
-using content::WebContents;
-
-namespace options {
-
-// Command used to configure GNOME 2 proxy settings.
-const char* kGNOME2ProxyConfigCommand[] = {"gnome-network-properties", NULL};
-// In GNOME 3, we might need to run gnome-control-center instead. We try this
-// only after gnome-network-properties is not found, because older GNOME also
-// has this but it doesn't do the same thing. See below where we use it.
-const char* kGNOME3ProxyConfigCommand[] = {"gnome-control-center", "network",
- NULL};
-// KDE3 and KDE4 are only slightly different, but incompatible. Go figure.
-const char* kKDE3ProxyConfigCommand[] = {"kcmshell", "proxy", NULL};
-const char* kKDE4ProxyConfigCommand[] = {"kcmshell4", "proxy", NULL};
-
-// The URL for Linux proxy configuration help when not running under a
-// supported desktop environment.
-const char kLinuxProxyConfigUrl[] = "about:linux-proxy-config";
-
-namespace {
-
-// Show the proxy config URL in the given tab.
-void ShowLinuxProxyConfigUrl(int render_process_id, int render_view_id) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- scoped_ptr<base::Environment> env(base::Environment::Create());
- const char* name = base::nix::GetDesktopEnvironmentName(env.get());
- if (name)
- LOG(ERROR) << "Could not find " << name << " network settings in $PATH";
- OpenURLParams params(
- GURL(kLinuxProxyConfigUrl), Referrer(), NEW_FOREGROUND_TAB,
- content::PAGE_TRANSITION_LINK, false);
-
- WebContents* web_contents =
- tab_util::GetWebContentsByID(render_process_id, render_view_id);
- if (web_contents)
- web_contents->OpenURL(params);
-}
-
-// Start the given proxy configuration utility.
-bool StartProxyConfigUtil(const char* command[]) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
- // base::LaunchProcess() returns true ("success") if the fork()
- // succeeds, but not necessarily the exec(). We'd like to be able to
- // use StartProxyConfigUtil() to search possible options and stop on
- // success, so we search $PATH first to predict whether the exec is
- // expected to succeed.
- // TODO(mdm): this is a useful check, and is very similar to some
- // code in proxy_config_service_linux.cc. It should probably be in
- // base:: somewhere.
- scoped_ptr<base::Environment> env(base::Environment::Create());
- std::string path;
- if (!env->GetVar("PATH", &path)) {
- LOG(ERROR) << "No $PATH variable. Assuming no " << command[0] << ".";
- return false;
- }
- std::vector<std::string> paths;
- Tokenize(path, ":", &paths);
- bool found = false;
- for (size_t i = 0; i < paths.size(); ++i) {
- base::FilePath file(paths[i]);
- if (base::PathExists(file.Append(command[0]))) {
- found = true;
- break;
- }
- }
- if (!found)
- return false;
- std::vector<std::string> argv;
- for (size_t i = 0; command[i]; ++i)
- argv.push_back(command[i]);
- base::ProcessHandle handle;
- if (!base::LaunchProcess(argv, base::LaunchOptions(), &handle)) {
- LOG(ERROR) << "StartProxyConfigUtil failed to start " << command[0];
- return false;
- }
- base::EnsureProcessGetsReaped(handle);
- return true;
-}
-
-// Detect, and if possible, start the appropriate proxy config utility. On
-// failure to do so, show the Linux proxy config URL in a new tab instead.
-void DetectAndStartProxyConfigUtil(int render_process_id,
- int render_view_id) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
- scoped_ptr<base::Environment> env(base::Environment::Create());
-
- bool launched = false;
- switch (base::nix::GetDesktopEnvironment(env.get())) {
- case base::nix::DESKTOP_ENVIRONMENT_GNOME:
- case base::nix::DESKTOP_ENVIRONMENT_UNITY: {
- launched = StartProxyConfigUtil(kGNOME2ProxyConfigCommand);
- if (!launched) {
- // We try this second, even though it's the newer way, because this
- // command existed in older versions of GNOME, but it didn't do the
- // same thing. The older command is gone though, so this should do
- // the right thing. (Also some distributions have blurred the lines
- // between GNOME 2 and 3, so we can't necessarily detect what the
- // right thing is based on indications of which version we have.)
- launched = StartProxyConfigUtil(kGNOME3ProxyConfigCommand);
- }
- break;
- }
-
- case base::nix::DESKTOP_ENVIRONMENT_KDE3:
- launched = StartProxyConfigUtil(kKDE3ProxyConfigCommand);
- break;
-
- case base::nix::DESKTOP_ENVIRONMENT_KDE4:
- launched = StartProxyConfigUtil(kKDE4ProxyConfigCommand);
- break;
-
- case base::nix::DESKTOP_ENVIRONMENT_XFCE:
- case base::nix::DESKTOP_ENVIRONMENT_OTHER:
- break;
- }
-
- if (launched)
- return;
- BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
- base::Bind(&ShowLinuxProxyConfigUrl, render_process_id, render_view_id));
-}
-
-} // anonymous namespace
-
-void AdvancedOptionsUtilities::ShowNetworkProxySettings(
- WebContents* web_contents) {
- BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE,
- base::Bind(&DetectAndStartProxyConfigUtil,
- web_contents->GetRenderProcessHost()->GetID(),
- web_contents->GetRenderViewHost()->GetRoutingID()));
-}
-
-} // namespace options
-
-#endif // !defined(OS_CHROMEOS)
diff --git a/chrome/chrome_browser_ui.gypi b/chrome/chrome_browser_ui.gypi
index a0df3c0..c554bb8 100644
--- a/chrome/chrome_browser_ui.gypi
+++ b/chrome/chrome_browser_ui.gypi
@@ -289,7 +289,7 @@
'browser/ui/aura/chrome_browser_main_extra_parts_aura.h',
'browser/ui/aura/tab_contents/web_drag_bookmark_handler_aura.cc',
'browser/ui/aura/tab_contents/web_drag_bookmark_handler_aura.h',
- 'browser/ui/aura/tabs/dock_info_aurax11.cc',
+ 'browser/ui/aura/tabs/dock_info_aura.cc',
'browser/ui/autofill/account_chooser_model.cc',
'browser/ui/autofill/account_chooser_model.h',
'browser/ui/autofill/autofill_dialog_common.cc',
@@ -1742,8 +1742,8 @@
'browser/ui/views/frame/browser_desktop_root_window_host.h',
'browser/ui/views/frame/browser_desktop_root_window_host_win.cc',
'browser/ui/views/frame/browser_desktop_root_window_host_win.h',
- 'browser/ui/views/frame/browser_desktop_root_window_host_x11.cc',
- 'browser/ui/views/frame/browser_desktop_root_window_host_x11.h',
+ 'browser/ui/views/frame/browser_desktop_root_window_host_aura.cc',
+ 'browser/ui/views/frame/browser_desktop_root_window_host_aura.h',
'browser/ui/views/frame/glass_browser_frame_view.cc',
'browser/ui/views/frame/glass_browser_frame_view.h',
'browser/ui/views/frame/global_menu_bar_x11.cc',
@@ -2255,7 +2255,7 @@
'browser/ui/webui/options/advanced_options_utils.h',
'browser/ui/webui/options/advanced_options_utils_mac.mm',
'browser/ui/webui/options/advanced_options_utils_win.cc',
- 'browser/ui/webui/options/advanced_options_utils_x11.cc',
+ 'browser/ui/webui/options/advanced_options_utils_aura.cc',
'browser/ui/webui/options/autofill_options_handler.cc',
'browser/ui/webui/options/autofill_options_handler.h',
'browser/ui/webui/options/browser_options_handler.cc',
@@ -2635,8 +2635,8 @@
'browser/ui/screen_capture_notification_ui_stub.cc',
'browser/ui/startup/default_browser_prompt.cc',
'browser/ui/startup/default_browser_prompt.h',
- 'browser/ui/views/frame/browser_desktop_root_window_host_x11.cc',
- 'browser/ui/views/frame/browser_desktop_root_window_host_x11.h',
+ 'browser/ui/views/frame/browser_desktop_root_window_host_aura.cc',
+ 'browser/ui/views/frame/browser_desktop_root_window_host_aura.h',
'browser/ui/views/frame/desktop_browser_frame_aura.cc',
'browser/ui/views/frame/desktop_browser_frame_aura.h',
'browser/ui/views/frame/desktop_user_action_handler_aura.cc',
@@ -2775,8 +2775,8 @@
['exclude', '^browser/ui/views/frame/browser_desktop_root_window_host.h'],
['exclude', '^browser/ui/views/frame/browser_desktop_root_window_host_win.cc'],
['exclude', '^browser/ui/views/frame/browser_desktop_root_window_host_win.h'],
- ['exclude', '^browser/ui/views/frame/browser_desktop_root_window_host_x11.cc'],
- ['exclude', '^browser/ui/views/frame/browser_desktop_root_window_host_x11.h'],
+ ['exclude', '^browser/ui/views/frame/browser_desktop_root_window_host_aura.cc'],
+ ['exclude', '^browser/ui/views/frame/browser_desktop_root_window_host_aura.h'],
['exclude', '^browser/ui/views/theme_image_mapper_aura_win.cc'],
['exclude', '^browser/ui/webui/gesture_config_ui.cc'],
['exclude', '^browser/ui/webui/gesture_config_ui.h'],
diff --git a/ui/views/controls/webview/unhandled_keyboard_event_handler_aura.cc b/ui/views/controls/webview/unhandled_keyboard_event_handler_aura.cc
new file mode 100644
index 0000000..41c90ff
--- /dev/null
+++ b/ui/views/controls/webview/unhandled_keyboard_event_handler_aura.cc
@@ -0,0 +1,30 @@
+// Copyright (c) 2012 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 "ui/views/controls/webview/unhandled_keyboard_event_handler.h"
+
+#include "base/logging.h"
+#include "content/public/browser/native_web_keyboard_event.h"
+#include "ui/base/events/event.h"
+#include "ui/views/focus/focus_manager.h"
+
+using content::NativeWebKeyboardEvent;
+
+namespace views {
+
+UnhandledKeyboardEventHandler::UnhandledKeyboardEventHandler() {
+}
+
+void UnhandledKeyboardEventHandler::HandleKeyboardEvent(
+ const NativeWebKeyboardEvent& event,
+ FocusManager* focus_manager) {
+ if (!focus_manager) {
+ NOTREACHED();
+ return;
+ }
+ if (event.os_event && !event.skip_in_browser)
+ focus_manager->OnKeyEvent(*static_cast<ui::KeyEvent*>(event.os_event));
+}
+
+} // namespace views
diff --git a/ui/views/controls/webview/unhandled_keyboard_event_handler_aurax11.cc b/ui/views/controls/webview/unhandled_keyboard_event_handler_aurax11.cc
deleted file mode 100644
index 41c90ff..0000000
--- a/ui/views/controls/webview/unhandled_keyboard_event_handler_aurax11.cc
+++ /dev/null
@@ -1,30 +0,0 @@
-// Copyright (c) 2012 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 "ui/views/controls/webview/unhandled_keyboard_event_handler.h"
-
-#include "base/logging.h"
-#include "content/public/browser/native_web_keyboard_event.h"
-#include "ui/base/events/event.h"
-#include "ui/views/focus/focus_manager.h"
-
-using content::NativeWebKeyboardEvent;
-
-namespace views {
-
-UnhandledKeyboardEventHandler::UnhandledKeyboardEventHandler() {
-}
-
-void UnhandledKeyboardEventHandler::HandleKeyboardEvent(
- const NativeWebKeyboardEvent& event,
- FocusManager* focus_manager) {
- if (!focus_manager) {
- NOTREACHED();
- return;
- }
- if (event.os_event && !event.skip_in_browser)
- focus_manager->OnKeyEvent(*static_cast<ui::KeyEvent*>(event.os_event));
-}
-
-} // namespace views
diff --git a/ui/views/controls/webview/webview.gyp b/ui/views/controls/webview/webview.gyp
index 1814d2f..db30227 100644
--- a/ui/views/controls/webview/webview.gyp
+++ b/ui/views/controls/webview/webview.gyp
@@ -27,7 +27,7 @@
'sources': [
'unhandled_keyboard_event_handler.cc',
'unhandled_keyboard_event_handler.h',
- 'unhandled_keyboard_event_handler_aurax11.cc',
+ 'unhandled_keyboard_event_handler_aura.cc',
'unhandled_keyboard_event_handler_win.cc',
'web_dialog_view.cc',
'web_dialog_view.h',
--
1.7.9.5
diff --git a/impl/ozone_display.cc b/impl/ozone_display.cc
index 7104ed4..2cde2b4 100644
--- a/impl/ozone_display.cc
+++ b/impl/ozone_display.cc
@@ -52,6 +52,9 @@ OzoneDisplay::~OzoneDisplay()
}
const char* OzoneDisplay::DefaultDisplaySpec() {
+ if (!spec_)
+ return "1024x640*2";
+
return spec_;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment