Skip to content

Commit

Permalink
linux_aura: Compile ash into chrome.
Browse files Browse the repository at this point in the history
[This is a reland now that the static initializers should be fixed.]

Running chrome with the "--open-ash" parameter will create an ash
desktop window. Ash on Linux has some problems, but at least we're now
compiling the code into the binary.

TODO: The applist isn't positioned correctly, and some details of the
system tray aren't correct.

BUG=300084, 303862
TBR=sky@chromium.org
First Review URL: https://codereview.chromium.org/25108005

Review URL: https://codereview.chromium.org/270383007

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@270232 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
erg@chromium.org committed May 13, 2014
1 parent 5aba5bc commit 1050630
Show file tree
Hide file tree
Showing 49 changed files with 383 additions and 214 deletions.
10 changes: 7 additions & 3 deletions ash/accelerators/magnifier_key_scroller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,13 @@ bool magnifier_key_scroller_enabled = false;

// static
bool MagnifierKeyScroller::IsEnabled() {
return (magnifier_key_scroller_enabled ||
CommandLine::ForCurrentProcess()->HasSwitch(
switches::kAshEnableMagnifierKeyScroller)) &&
bool has_switch = false;
#if defined(OS_CHROMEOS)
has_switch = CommandLine::ForCurrentProcess()->HasSwitch(
switches::kAshEnableMagnifierKeyScroller);
#endif

return (magnifier_key_scroller_enabled || has_switch) &&
ash::Shell::GetInstance()->magnification_controller()->IsEnabled();
}

Expand Down
2 changes: 1 addition & 1 deletion ash/ash.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -1022,7 +1022,7 @@
'wm/workspace_controller_unittest.cc',
],
'conditions': [
['OS=="win"', {
['chromeos==0', {
'sources/': [
# TODO(zork): fix this test to build on Windows. See: crosbug.com/26906
['exclude', 'focus_cycler_unittest.cc'],
Expand Down
2 changes: 2 additions & 0 deletions ash/ash_constants.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ const int kResizeOutsideBoundsSize = 6;
const int kResizeOutsideBoundsScaleForTouch = 5;
const int kResizeInsideBoundsSize = 1;

#if defined(OS_CHROMEOS)
const SkColor kChromeOsBootColor = SkColorSetRGB(0xfe, 0xfe, 0xfe);
#endif

const SkColor kFocusBorderColor = SkColorSetRGB(64, 128, 250);

Expand Down
4 changes: 3 additions & 1 deletion ash/display/display_controller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
#include "ash/display/display_configurator_animation.h"
#include "base/sys_info.h"
#include "base/time/time.h"
#endif // defined(OS_CHROMEOS)

#if defined(USE_X11)
#include "ui/base/x/x11_util.h"
#include "ui/gfx/x/x11_types.h"
Expand All @@ -52,7 +54,7 @@
#include <X11/extensions/Xrandr.h>
#undef RootWindow
#endif // defined(USE_X11)
#endif // defined(OS_CHROMEOS)


namespace ash {
namespace {
Expand Down
2 changes: 1 addition & 1 deletion ash/drag_drop/drag_drop_interactive_uitest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ class DragDropTest : public test::AshTestBase {
}
};

#if defined(OS_WIN)
#if !defined(OS_CHROMEOS)
#define MAYBE_DragDropAcrossMultiDisplay DISABLED_DragDropAcrossMultiDisplay
#else
#define MAYBE_DragDropAcrossMultiDisplay DragDropAcrossMultiDisplay
Expand Down
8 changes: 8 additions & 0 deletions ash/host/ash_window_tree_host_x11.cc
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,9 @@ void AshWindowTreeHostX11::UpdateRootWindowSize(const gfx::Size& host_size) {
}

void AshWindowTreeHostX11::OnCursorVisibilityChangedNative(bool show) {
#if defined(OS_CHROMEOS)
SetCrOSTapPaused(!show);
#endif
}

void AshWindowTreeHostX11::OnWindowInitialized(aura::Window* window) {}
Expand All @@ -300,9 +302,11 @@ void AshWindowTreeHostX11::OnHostInitialized(aura::WindowTreeHost* host) {
return;
UpdateIsInternalDisplay();

#if defined(OS_CHROMEOS)
// We have to enable Tap-to-click by default because the cursor is set to
// visible in Shell::InitRootWindowController.
SetCrOSTapPaused(false);
#endif
}

void AshWindowTreeHostX11::OnConfigureNotify() {
Expand All @@ -323,6 +327,7 @@ void AshWindowTreeHostX11::TranslateAndDispatchLocatedEvent(
case ui::ET_TOUCH_PRESSED:
case ui::ET_TOUCH_CANCELLED:
case ui::ET_TOUCH_RELEASED: {
#if defined(OS_CHROMEOS)
ui::TouchEvent* touchev = static_cast<ui::TouchEvent*>(event);
if (base::SysInfo::IsRunningOnChromeOS()) {
// X maps the touch-surface to the size of the X root-window.
Expand All @@ -337,6 +342,7 @@ void AshWindowTreeHostX11::TranslateAndDispatchLocatedEvent(
touch_calibrate_->Calibrate(touchev, bounds());
#endif // defined(USE_XI2_MT)
}
#endif // defined(OS_CHROMEOS)
break;
}
default: {
Expand Down Expand Up @@ -372,6 +378,7 @@ void AshWindowTreeHostX11::UpdateIsInternalDisplay() {
is_internal_display_ = display.IsInternal();
}

#if defined(OS_CHROMEOS)
void AshWindowTreeHostX11::SetCrOSTapPaused(bool state) {
if (!ui::IsXInput2Available())
return;
Expand Down Expand Up @@ -414,6 +421,7 @@ void AshWindowTreeHostX11::SetCrOSTapPaused(bool state) {
}
}
}
#endif

AshWindowTreeHost* AshWindowTreeHost::Create(const gfx::Rect& initial_bounds) {
return new AshWindowTreeHostX11(initial_bounds);
Expand Down
2 changes: 2 additions & 0 deletions ash/host/ash_window_tree_host_x11.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,11 @@ class ASH_EXPORT AshWindowTreeHostX11 : public AshWindowTreeHost,
// Update is_internal_display_ based on the current state.
void UpdateIsInternalDisplay();

#if defined(OS_CHROMEOS)
// Set the CrOS touchpad "tap paused" property. It is used to temporarily
// turn off the Tap-to-click feature when the mouse pointer is invisible.
void SetCrOSTapPaused(bool state);
#endif

// True if the root host resides on the internal display
bool is_internal_display_;
Expand Down
51 changes: 27 additions & 24 deletions ash/host/ash_window_tree_host_x11_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,35 @@ class RootWindowEventHandler : public ui::EventHandler {

namespace ash {

typedef aura::test::AuraTestBase WindowTreeHostX11Test;
class AshWindowTreeHostX11Test : public aura::test::AuraTestBase {
public:
virtual void SetUp() OVERRIDE {
aura::test::AuraTestBase::SetUp();

#if defined(OS_CHROMEOS)
// Fake a ChromeOS running env.
const char* kLsbRelease = "CHROMEOS_RELEASE_NAME=Chromium OS\n";
base::SysInfo::SetChromeOSVersionInfoForTest(kLsbRelease, base::Time());
#endif
}

virtual void TearDown() OVERRIDE {
aura::test::AuraTestBase::TearDown();

#if defined(OS_CHROMEOS)
// Revert the CrOS testing env otherwise the following non-CrOS aura
// tests will fail.
// Fake a ChromeOS running env.
const char* kLsbRelease = "";
base::SysInfo::SetChromeOSVersionInfoForTest(kLsbRelease, base::Time());
#endif
}
};

// Send X touch events to one WindowTreeHost. The WindowTreeHost's
// delegate will get corresponding ui::TouchEvent if the touch events
// are winthin the bound of the WindowTreeHost.
TEST_F(WindowTreeHostX11Test, DispatchTouchEventToOneRootWindow) {
// Fake a ChromeOS running env.
const char* kLsbRelease = "CHROMEOS_RELEASE_NAME=Chromium OS\n";
base::SysInfo::SetChromeOSVersionInfoForTest(kLsbRelease, base::Time());

// are targeting this WindowTreeHost.
TEST_F(AshWindowTreeHostX11Test, DispatchTouchEventToOneRootWindow) {
scoped_ptr<AshWindowTreeHostX11> window_tree_host(
new AshWindowTreeHostX11(gfx::Rect(0, 0, 2560, 1700)));
window_tree_host->InitHost();
Expand Down Expand Up @@ -112,22 +131,12 @@ TEST_F(WindowTreeHostX11Test, DispatchTouchEventToOneRootWindow) {
EXPECT_EQ(gfx::Point(1500, 1600), handler->last_touch_location());

handler.reset();

// Revert the CrOS testing env otherwise the following non-CrOS aura
// tests will fail.
// Fake a ChromeOS running env.
kLsbRelease = "";
base::SysInfo::SetChromeOSVersionInfoForTest(kLsbRelease, base::Time());
}

// Send X touch events to two WindowTreeHost. The WindowTreeHost which is
// the event target of the X touch events should generate the corresponding
// ui::TouchEvent for its delegate.
TEST_F(WindowTreeHostX11Test, DispatchTouchEventToTwoRootWindow) {
// Fake a ChromeOS running env.
const char* kLsbRelease = "CHROMEOS_RELEASE_NAME=Chromium OS\n";
base::SysInfo::SetChromeOSVersionInfoForTest(kLsbRelease, base::Time());

TEST_F(AshWindowTreeHostX11Test, DispatchTouchEventToTwoRootWindow) {
scoped_ptr<AshWindowTreeHostX11> window_tree_host1(
new AshWindowTreeHostX11(gfx::Rect(0, 0, 2560, 1700)));
window_tree_host1->InitHost();
Expand Down Expand Up @@ -226,12 +235,6 @@ TEST_F(WindowTreeHostX11Test, DispatchTouchEventToTwoRootWindow) {

handler1.reset();
handler2.reset();

// Revert the CrOS testing env otherwise the following non-CrOS aura
// tests will fail.
// Fake a ChromeOS running env.
kLsbRelease = "";
base::SysInfo::SetChromeOSVersionInfoForTest(kLsbRelease, base::Time());
}

} // namespace aura
10 changes: 1 addition & 9 deletions build/common.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@

'conditions': [
# ChromeOS and Windows use Aura and Ash.
['chromeos==1 or OS=="win"', {
['chromeos==1 or OS=="win" or OS=="linux"', {
'use_ash%': 1,
'use_aura%': 1,
}],
Expand All @@ -97,14 +97,6 @@
'use_aura%': 1,
}],

# ToT Linux should be aura.
#
# TODO(erg): Merge this into the previous block once compiling with
# aura safely implies including ash capabilities.
['OS=="linux"', {
'use_aura%': 1,
}],

# Whether we're a traditional desktop unix.
['(OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="solaris") and chromeos==0', {
'desktop_linux%': 1,
Expand Down
28 changes: 14 additions & 14 deletions chrome/app/theme/theme_resources.grd
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,8 @@
</if>
<if expr="use_ash">
<structure type="chrome_scaled_image" name="IDR_CONTENT_TOP_CENTER" file="common/ash/content_top_center.png" />
<if expr="is_win">
<structure type="chrome_scaled_image" name="IDR_CONTENT_TOP_CENTER_WIN" file="content_top_center.png" />
<if expr="not chromeos">
<structure type="chrome_scaled_image" name="IDR_CONTENT_TOP_CENTER_DESKTOP" file="content_top_center.png" />
</if>
</if>
<structure type="chrome_scaled_image" name="IDR_CONTENT_TOP_LEFT_CORNER" file="content_top_left_corner.png" />
Expand Down Expand Up @@ -661,8 +661,8 @@
</if>
<if expr="use_ash">
<structure type="chrome_scaled_image" name="IDR_OTR_ICON" file="common/ash/otr_icon.png" />
<if expr="is_win">
<structure type="chrome_scaled_image" name="IDR_OTR_ICON_WIN" file="common/otr_icon.png" />
<if expr="not chromeos">
<structure type="chrome_scaled_image" name="IDR_OTR_ICON_DESKTOP" file="common/otr_icon.png" />
</if>
</if>
</if>
Expand Down Expand Up @@ -1188,11 +1188,11 @@
<structure type="chrome_scaled_image" name="IDR_THEME_FRAME_INACTIVE" file="common/ash/theme_frame_inactive.png" />
<structure type="chrome_scaled_image" name="IDR_THEME_FRAME_INCOGNITO" file="common/ash/theme_frame_incognito_active.png" />
<structure type="chrome_scaled_image" name="IDR_THEME_FRAME_INCOGNITO_INACTIVE" file="common/ash/theme_frame_incognito_inactive.png" />
<if expr="is_win">
<structure type="chrome_scaled_image" name="IDR_THEME_FRAME_WIN" file="theme_frame.png" />
<structure type="chrome_scaled_image" name="IDR_THEME_FRAME_INACTIVE_WIN" file="theme_frame_inactive.png" />
<structure type="chrome_scaled_image" name="IDR_THEME_FRAME_INCOGNITO_WIN" file="theme_frame_incognito.png" />
<structure type="chrome_scaled_image" name="IDR_THEME_FRAME_INCOGNITO_INACTIVE_WIN" file="theme_frame_incognito_inactive.png" />
<if expr="not chromeos">
<structure type="chrome_scaled_image" name="IDR_THEME_FRAME_DESKTOP" file="theme_frame.png" />
<structure type="chrome_scaled_image" name="IDR_THEME_FRAME_INACTIVE_DESKTOP" file="theme_frame_inactive.png" />
<structure type="chrome_scaled_image" name="IDR_THEME_FRAME_INCOGNITO_DESKTOP" file="theme_frame_incognito.png" />
<structure type="chrome_scaled_image" name="IDR_THEME_FRAME_INCOGNITO_INACTIVE_DESKTOP" file="theme_frame_incognito_inactive.png" />
</if>
</if>
<structure type="chrome_scaled_image" name="IDR_THEME_FRAME_OVERLAY" file="notused.png" />
Expand All @@ -1207,9 +1207,9 @@
<!-- Ash has gray tab backgrounds, Windows uses blue. -->
<structure type="chrome_scaled_image" name="IDR_THEME_TAB_BACKGROUND" file="common/ash/theme_default_inactive.png" />
<structure type="chrome_scaled_image" name="IDR_THEME_TAB_BACKGROUND_INCOGNITO" file="common/ash/theme_default_inactive.png" />
<if expr="is_win">
<structure type="chrome_scaled_image" name="IDR_THEME_TAB_BACKGROUND_WIN" file="theme_tab_background.png" />
<structure type="chrome_scaled_image" name="IDR_THEME_TAB_BACKGROUND_INCOGNITO_WIN" file="theme_tab_background_incognito.png" />
<if expr="not chromeos">
<structure type="chrome_scaled_image" name="IDR_THEME_TAB_BACKGROUND_DESKTOP" file="theme_tab_background.png" />
<structure type="chrome_scaled_image" name="IDR_THEME_TAB_BACKGROUND_INCOGNITO_DESKTOP" file="theme_tab_background_incognito.png" />
</if>
</if>
<if expr="is_macosx or is_ios">
Expand All @@ -1223,8 +1223,8 @@
<if expr="use_ash">
<!-- Ash has a dark gray toolbar background, Windows has light gray. -->
<structure type="chrome_scaled_image" name="IDR_THEME_TOOLBAR" file="common/ash/theme_default_active.png" />
<if expr="is_win">
<structure type="chrome_scaled_image" name="IDR_THEME_TOOLBAR_WIN" file="theme_toolbar_default.png" />
<if expr="not chromeos">
<structure type="chrome_scaled_image" name="IDR_THEME_TOOLBAR_DESKTOP" file="theme_toolbar_default.png" />
</if>
</if>
<if expr="is_macosx or is_ios">
Expand Down
16 changes: 12 additions & 4 deletions chrome/browser/extensions/window_open_apitest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
#include "apps/app_window_registry.h"
#endif

#if defined(USE_ASH) && !defined(OS_WIN)
#if defined(USE_ASH) && defined(OS_CHROMEOS)
// TODO(stevenjb): Figure out the correct behavior for Ash + Win
#define USE_ASH_PANELS
#endif
Expand Down Expand Up @@ -273,8 +273,16 @@ IN_PROC_BROWSER_TEST_F(WindowOpenPanelTest, MAYBE_WindowOpenPanelDetached) {
ASSERT_TRUE(RunExtensionTest("window_open/panel_detached")) << message_;
}

#if defined(OS_LINUX) && !defined(OS_CHROMEOS)
// TODO(erg): Bring up ash http://crbug.com/300084
#define MAYBE_CloseNonExtensionPanelsOnUninstall \
DISABLED_CloseNonExtensionPanelsOnUninstall
#else
#define MAYBE_CloseNonExtensionPanelsOnUninstall \
CloseNonExtensionPanelsOnUninstall
#endif
IN_PROC_BROWSER_TEST_F(WindowOpenPanelTest,
CloseNonExtensionPanelsOnUninstall) {
MAYBE_CloseNonExtensionPanelsOnUninstall) {
#if defined(OS_WIN) && defined(USE_ASH)
// Disable this test in Metro+Ash for now (http://crbug.com/262796).
if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests))
Expand Down Expand Up @@ -345,8 +353,8 @@ IN_PROC_BROWSER_TEST_F(WindowOpenPanelTest,
EXPECT_TRUE(WaitForTabsAndPopups(browser(), 1, num_popups, 0));
}

// This test isn't applicable on Chrome OS, which automatically reloads
// crashed pages.
// This test isn't applicable on Chrome OS, which automatically reloads crashed
// pages.
#if !defined(OS_CHROMEOS)
IN_PROC_BROWSER_TEST_F(WindowOpenPanelTest, ClosePanelsOnExtensionCrash) {
#if defined(USE_ASH_PANELS)
Expand Down
10 changes: 10 additions & 0 deletions chrome/browser/fullscreen_aurax11.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,21 @@

#include <vector>

#include "ash/root_window_controller.h"
#include "chrome/browser/ui/host_desktop.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h"
#include "ui/views/widget/widget.h"

bool IsFullScreenMode() {
#if defined(USE_ASH)
if (chrome::GetActiveDesktop() == chrome::HOST_DESKTOP_TYPE_ASH) {
ash::RootWindowController* controller =
ash::RootWindowController::ForTargetRootWindow();
return controller && controller->GetWindowForFullscreenMode();
}
#endif

std::vector<aura::Window*> all_windows =
views::DesktopWindowTreeHostX11::GetAllOpenWindows();
// Only the topmost window is checked. This works fine in the most cases, but
Expand Down
12 changes: 6 additions & 6 deletions chrome/browser/managed_mode/managed_user_theme.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,19 @@ const SkColor kDefaultColorManagedUserLabelBackground =
int MapToManagedUserResourceIds(int id) {
switch (id) {
case IDR_THEME_FRAME:
#if defined(OS_WIN)
case IDR_THEME_FRAME_WIN:
#if defined(USE_ASH) && !defined(OS_CHROMEOS)
case IDR_THEME_FRAME_DESKTOP:
#endif
return IDR_MANAGED_USER_THEME_FRAME;
case IDR_THEME_FRAME_INACTIVE:
#if defined(OS_WIN)
case IDR_THEME_FRAME_INACTIVE_WIN:
#if defined(USE_ASH) && !defined(OS_CHROMEOS)
case IDR_THEME_FRAME_INACTIVE_DESKTOP:
#endif
return IDR_MANAGED_USER_THEME_FRAME_INACTIVE;
case IDR_THEME_TAB_BACKGROUND:
case IDR_THEME_TAB_BACKGROUND_V:
#if defined(OS_WIN)
case IDR_THEME_TAB_BACKGROUND_WIN:
#if defined(USE_ASH) && !defined(OS_CHROMEOS)
case IDR_THEME_TAB_BACKGROUND_DESKTOP:
#endif
return IDR_MANAGED_USER_THEME_TAB_BACKGROUND;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ MessageCenterNotificationManager::MessageCenterNotificationManager(
blockers_.push_back(new FullscreenNotificationBlocker(message_center));

#if defined(OS_WIN) || defined(OS_MACOSX) \
|| (defined(USE_AURA) && !defined(USE_ASH))
|| (defined(OS_LINUX) && !defined(OS_CHROMEOS))
// On Windows, Linux and Mac, the notification manager owns the tray icon and
// views.Other platforms have global ownership and Create will return NULL.
tray_.reset(message_center::CreateMessageCenterTray());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class SigninErrorNotifierTest : public AshTestBase {
AshTestBase::SetUp();

// Set up screen for Windows.
#if !defined(OS_CHROMEOS)
#if defined(OS_WIN)
aura::TestScreen* test_screen = aura::TestScreen::Create();
gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, test_screen);
gfx::Screen::SetScreenTypeDelegate(new ScreenTypeDelegateDesktop);
Expand Down
Loading

0 comments on commit 1050630

Please sign in to comment.