summaryrefslogtreecommitdiffstats
path: root/ui/views
diff options
context:
space:
mode:
Diffstat (limited to 'ui/views')
-rw-r--r--ui/views/linux_ui/OWNERS1
-rw-r--r--ui/views/linux_ui/linux_ui.cc28
-rw-r--r--ui/views/linux_ui/linux_ui.gyp33
-rw-r--r--ui/views/linux_ui/linux_ui.h77
-rw-r--r--ui/views/linux_ui/status_icon_linux.cc21
-rw-r--r--ui/views/linux_ui/status_icon_linux.h62
-rw-r--r--ui/views/views.gyp11
-rw-r--r--ui/views/widget/desktop_aura/desktop_root_window_host_x11.cc4
8 files changed, 233 insertions, 4 deletions
diff --git a/ui/views/linux_ui/OWNERS b/ui/views/linux_ui/OWNERS
new file mode 100644
index 0000000..4733a4f
--- /dev/null
+++ b/ui/views/linux_ui/OWNERS
@@ -0,0 +1 @@
+erg@chromium.org
diff --git a/ui/views/linux_ui/linux_ui.cc b/ui/views/linux_ui/linux_ui.cc
new file mode 100644
index 0000000..9a4dccd
--- /dev/null
+++ b/ui/views/linux_ui/linux_ui.cc
@@ -0,0 +1,28 @@
+// Copyright 2013 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/linux_ui/linux_ui.h"
+
+#include "ui/shell_dialogs/linux_shell_dialog.h"
+
+namespace {
+
+views::LinuxUI* g_linux_ui = NULL;
+
+} // namespace
+
+namespace views {
+
+void LinuxUI::SetInstance(LinuxUI* instance) {
+ delete g_linux_ui;
+ g_linux_ui = instance;
+
+ LinuxShellDialog::SetInstance(instance);
+}
+
+const LinuxUI* LinuxUI::instance() {
+ return g_linux_ui;
+}
+
+} // namespace views
diff --git a/ui/views/linux_ui/linux_ui.gyp b/ui/views/linux_ui/linux_ui.gyp
new file mode 100644
index 0000000..7feb238
--- /dev/null
+++ b/ui/views/linux_ui/linux_ui.gyp
@@ -0,0 +1,33 @@
+# Copyright 2013 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.
+
+{
+ 'variables': {
+ 'chromium_code': 1,
+ },
+ 'targets': [
+ {
+ 'target_name': 'linux_ui',
+ 'type': '<(component)',
+ 'dependencies': [
+ '../../base/base.gyp:base',
+ '../../base/third_party/dynamic_annotations/dynamic_annotations.gyp:dynamic_annotations',
+ '../../skia/skia.gyp:skia',
+ '../ui.gyp:ui',
+ '../ui.gyp:ui_resources',
+ '../native_theme/native_theme.gyp:native_theme',
+ ],
+ 'defines': [
+ 'LINUX_UI_IMPLEMENTATION',
+ ],
+ 'sources': [
+ 'linux_ui.cc',
+ 'linux_ui.h',
+ 'linux_ui_export.h',
+ 'status_icon_linux.cc',
+ 'status_icon_linux.h',
+ ],
+ },
+ ],
+}
diff --git a/ui/views/linux_ui/linux_ui.h b/ui/views/linux_ui/linux_ui.h
new file mode 100644
index 0000000..8c0bf4c
--- /dev/null
+++ b/ui/views/linux_ui/linux_ui.h
@@ -0,0 +1,77 @@
+// Copyright 2013 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 UI_VIEWS_LINUX_UI_LINUX_UI_H_
+#define UI_VIEWS_LINUX_UI_LINUX_UI_H_
+
+#include "third_party/skia/include/core/SkColor.h"
+#include "ui/shell_dialogs/linux_shell_dialog.h"
+#include "ui/views/linux_ui/status_icon_linux.h"
+#include "ui/views/views_export.h"
+
+// The main entrypoint into Linux toolkit specific code. GTK code should only
+// be executed behind this interface.
+
+namespace gfx {
+class Image;
+}
+
+namespace ui {
+class NativeTheme;
+}
+
+namespace views {
+
+// Adapter class with targets to render like different toolkits. Set by any
+// project that wants to do linux desktop native rendering.
+//
+// TODO(erg): We're hardcoding GTK2, when we'll need to have backends for (at
+// minimum) GTK2 and GTK3. LinuxUI::instance() should actually be a very
+// complex method that pokes around with dlopen against a libuigtk2.so, a
+// liuigtk3.so, etc.
+class VIEWS_EXPORT LinuxUI : public ui::LinuxShellDialog {
+ public:
+ virtual ~LinuxUI() {}
+
+ // Sets the dynamically loaded singleton that draws the desktop native UI.
+ static void SetInstance(LinuxUI* instance);
+
+ // Returns a LinuxUI instance for the toolkit used in the user's desktop
+ // environment.
+ //
+ // Can return NULL, in case no toolkit has been set. (For example, if we're
+ // running with the "--ash" flag.)
+ static const LinuxUI* instance();
+
+ // Returns an themed image per theme_provider.h
+ virtual bool UseNativeTheme() const = 0;
+ virtual gfx::Image GetThemeImageNamed(int id) const = 0;
+ virtual bool GetColor(int id, SkColor* color) const = 0;
+ virtual bool HasCustomImage(int id) const = 0;
+
+ // Returns a NativeTheme that will provide system colors and draw system
+ // style widgets.
+ virtual ui::NativeTheme* GetNativeTheme() const = 0;
+
+ // Returns whether we should be using the native theme provided by this
+ // object by default.
+ virtual bool GetDefaultUsesSystemTheme() const = 0;
+
+ // Sets visual properties in the desktop environment related to download
+ // progress, if available.
+ virtual void SetDownloadCount(int count) const = 0;
+ virtual void SetProgressFraction(float percentage) const = 0;
+
+ // Checks for platform support for status icons.
+ virtual bool IsStatusIconSupported() const = 0;
+
+ // Create a native status icon.
+ virtual scoped_ptr<StatusIconLinux> CreateLinuxStatusIcon(
+ const gfx::ImageSkia& image,
+ const string16& tool_tip) const = 0;
+};
+
+} // namespace views
+
+#endif // UI_VIEWS_LINUX_UI_LINUX_UI_H_
diff --git a/ui/views/linux_ui/status_icon_linux.cc b/ui/views/linux_ui/status_icon_linux.cc
new file mode 100644
index 0000000..bf2ec05
--- /dev/null
+++ b/ui/views/linux_ui/status_icon_linux.cc
@@ -0,0 +1,21 @@
+// Copyright 2013 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/linux_ui/status_icon_linux.h"
+
+namespace views {
+
+StatusIconLinux::Delegate::~Delegate() {
+}
+
+StatusIconLinux::StatusIconLinux() : delegate_(NULL) {
+}
+
+StatusIconLinux::~StatusIconLinux() {
+}
+
+void StatusIconLinux::RefreshPlatformContextMenu() {
+}
+
+} // namespace views
diff --git a/ui/views/linux_ui/status_icon_linux.h b/ui/views/linux_ui/status_icon_linux.h
new file mode 100644
index 0000000..5ed8be2
--- /dev/null
+++ b/ui/views/linux_ui/status_icon_linux.h
@@ -0,0 +1,62 @@
+// Copyright 2013 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 UI_VIEWS_LINUX_UI_STATUS_ICON_LINUX_H_
+#define UI_VIEWS_LINUX_UI_STATUS_ICON_LINUX_H_
+
+#include "base/strings/string16.h"
+#include "ui/views/views_export.h"
+
+namespace gfx {
+class ImageSkia;
+}
+
+namespace ui {
+class MenuModel;
+} // namespace ui
+
+namespace views {
+
+// Since liblinux_ui cannot have dependencies on any chrome browser components
+// we cannot inherit from StatusIcon. So we implement the necessary methods
+// and let a wrapper class implement the StatusIcon interface and defer the
+// callbacks to a delegate. For the same reason, do not use StatusIconMenuModel.
+class VIEWS_EXPORT StatusIconLinux {
+ public:
+ class Delegate {
+ public:
+ virtual void OnClick() = 0;
+ virtual bool HasClickAction() = 0;
+
+ protected:
+ virtual ~Delegate();
+ };
+
+ StatusIconLinux();
+ virtual ~StatusIconLinux();
+
+ virtual void SetImage(const gfx::ImageSkia& image) = 0;
+ virtual void SetPressedImage(const gfx::ImageSkia& image) = 0;
+ virtual void SetToolTip(const string16& tool_tip) = 0;
+
+ // Invoked after a call to SetContextMenu() to let the platform-specific
+ // subclass update the native context menu based on the new model. The
+ // subclass should destroy the existing native context menu on this call.
+ virtual void UpdatePlatformContextMenu(ui::MenuModel* model) = 0;
+
+ // Update all the enabled/checked states and the dynamic labels. Some status
+ // icon implementations do not refresh the native menu before showing so we
+ // need to manually refresh it when the menu model changes.
+ virtual void RefreshPlatformContextMenu();
+
+ Delegate* delegate() { return delegate_; }
+ void set_delegate(Delegate* delegate) { delegate_ = delegate; }
+
+ private:
+ Delegate* delegate_;
+};
+
+} // namespace views
+
+#endif // UI_LINUX_UI_STATUS_ICON_LINUX_H_
diff --git a/ui/views/views.gyp b/ui/views/views.gyp
index 34b8093..db247e6 100644
--- a/ui/views/views.gyp
+++ b/ui/views/views.gyp
@@ -313,6 +313,10 @@
'layout/layout_constants.h',
'layout/layout_manager.cc',
'layout/layout_manager.h',
+ 'linux_ui/linux_ui.h',
+ 'linux_ui/linux_ui.cc',
+ 'linux_ui/status_icon_linux.h',
+ 'linux_ui/status_icon_linux.cc',
'metrics.cc',
'metrics.h',
'metrics_aura.cc',
@@ -548,10 +552,13 @@
['include', 'accessibility/native_view_accessibility_win.h'],
],
}],
- ['use_aura==1 and OS=="linux" and chromeos==0', {
+ ['OS=="linux" and chromeos==0', {
'dependencies': [
'../ui.gyp:shell_dialogs',
- '../linux_ui/linux_ui.gyp:linux_ui',
+ ],
+ }, { # OS=="linux" and chromeos==0
+ 'sources/': [
+ ['exclude', 'linux_ui'],
],
}],
['OS=="win"', {
diff --git a/ui/views/widget/desktop_aura/desktop_root_window_host_x11.cc b/ui/views/widget/desktop_aura/desktop_root_window_host_x11.cc
index e405bf6..acb84ff 100644
--- a/ui/views/widget/desktop_aura/desktop_root_window_host_x11.cc
+++ b/ui/views/widget/desktop_aura/desktop_root_window_host_x11.cc
@@ -25,13 +25,13 @@
#include "ui/base/x/x11_util.h"
#include "ui/gfx/insets.h"
#include "ui/gfx/path_x11.h"
-#include "ui/linux_ui/linux_ui.h"
#include "ui/native_theme/native_theme.h"
#include "ui/views/corewm/compound_event_filter.h"
#include "ui/views/corewm/corewm_switches.h"
#include "ui/views/corewm/cursor_manager.h"
#include "ui/views/corewm/focus_controller.h"
#include "ui/views/ime/input_method.h"
+#include "ui/views/linux_ui/linux_ui.h"
#include "ui/views/widget/desktop_aura/desktop_cursor_loader_updater_aurax11.h"
#include "ui/views/widget/desktop_aura/desktop_dispatcher_client.h"
#include "ui/views/widget/desktop_aura/desktop_drag_drop_client_aurax11.h"
@@ -1322,7 +1322,7 @@ DesktopRootWindowHost* DesktopRootWindowHost::Create(
// static
ui::NativeTheme* DesktopRootWindowHost::GetNativeTheme(aura::Window* window) {
- const ui::LinuxUI* linux_ui = ui::LinuxUI::instance();
+ const views::LinuxUI* linux_ui = views::LinuxUI::instance();
if (linux_ui) {
ui::NativeTheme* native_theme = linux_ui->GetNativeTheme();
if (native_theme)