1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef UI_VIEWS_LINUX_UI_LINUX_UI_H_
6 #define UI_VIEWS_LINUX_UI_LINUX_UI_H_
10 #include "base/callback.h"
11 #include "third_party/skia/include/core/SkColor.h"
12 #include "ui/base/ime/linux/linux_input_method_context_factory.h"
13 #include "ui/events/linux/text_edit_key_bindings_delegate_auralinux.h"
14 #include "ui/gfx/linux_font_delegate.h"
15 #include "ui/shell_dialogs/linux_shell_dialog.h"
16 #include "ui/views/controls/button/button.h"
17 #include "ui/views/linux_ui/status_icon_linux.h"
18 #include "ui/views/views_export.h"
20 // The main entrypoint into Linux toolkit specific code. GTK code should only
21 // be executed behind this interface.
38 class LabelButtonBorder
;
40 class WindowButtonOrderObserver
;
42 // Adapter class with targets to render like different toolkits. Set by any
43 // project that wants to do linux desktop native rendering.
45 // TODO(erg): We're hardcoding GTK2, when we'll need to have backends for (at
46 // minimum) GTK2 and GTK3. LinuxUI::instance() should actually be a very
47 // complex method that pokes around with dlopen against a libuigtk2.so, a
49 class VIEWS_EXPORT LinuxUI
: public ui::LinuxInputMethodContextFactory
,
50 public gfx::LinuxFontDelegate
,
51 public ui::LinuxShellDialog
,
52 public ui::TextEditKeyBindingsDelegateAuraLinux
{
54 // Describes the window management actions that could be taken in response to
55 // a middle click in the non client area.
56 enum NonClientMiddleClickAction
{
57 MIDDLE_CLICK_ACTION_NONE
,
58 MIDDLE_CLICK_ACTION_LOWER
,
59 MIDDLE_CLICK_ACTION_MINIMIZE
,
60 MIDDLE_CLICK_ACTION_TOGGLE_MAXIMIZE
63 typedef base::Callback
<ui::NativeTheme
*(aura::Window
* window
)>
68 // Sets the dynamically loaded singleton that draws the desktop native UI.
69 static void SetInstance(LinuxUI
* instance
);
71 // Returns a LinuxUI instance for the toolkit used in the user's desktop
74 // Can return NULL, in case no toolkit has been set. (For example, if we're
75 // running with the "--ash" flag.)
76 static LinuxUI
* instance();
78 virtual void Initialize() = 0;
80 // Returns a themed image per theme_provider.h
81 virtual gfx::Image
GetThemeImageNamed(int id
) const = 0;
82 virtual bool GetColor(int id
, SkColor
* color
) const = 0;
83 virtual bool HasCustomImage(int id
) const = 0;
85 // Returns the preferences that we pass to WebKit.
86 virtual SkColor
GetFocusRingColor() const = 0;
87 virtual SkColor
GetThumbActiveColor() const = 0;
88 virtual SkColor
GetThumbInactiveColor() const = 0;
89 virtual SkColor
GetTrackColor() const = 0;
90 virtual SkColor
GetActiveSelectionBgColor() const = 0;
91 virtual SkColor
GetActiveSelectionFgColor() const = 0;
92 virtual SkColor
GetInactiveSelectionBgColor() const = 0;
93 virtual SkColor
GetInactiveSelectionFgColor() const = 0;
94 virtual double GetCursorBlinkInterval() const = 0;
96 // Returns a NativeTheme that will provide system colors and draw system
98 virtual ui::NativeTheme
* GetNativeTheme(aura::Window
* window
) const = 0;
100 // Used to set an override NativeTheme.
101 virtual void SetNativeThemeOverride(const NativeThemeGetter
& callback
) = 0;
103 // Returns whether we should be using the native theme provided by this
104 // object by default.
105 virtual bool GetDefaultUsesSystemTheme() const = 0;
107 // Sets visual properties in the desktop environment related to download
108 // progress, if available.
109 virtual void SetDownloadCount(int count
) const = 0;
110 virtual void SetProgressFraction(float percentage
) const = 0;
112 // Checks for platform support for status icons.
113 virtual bool IsStatusIconSupported() const = 0;
115 // Create a native status icon.
116 virtual scoped_ptr
<StatusIconLinux
> CreateLinuxStatusIcon(
117 const gfx::ImageSkia
& image
,
118 const base::string16
& tool_tip
) const = 0;
120 // Returns the icon for a given content type from the icon theme.
121 // TODO(davidben): Add an observer for the theme changing, so we can drop the
123 virtual gfx::Image
GetIconForContentType(
124 const std::string
& content_type
, int size
) const = 0;
126 // Builds a Border which paints the native button style.
127 virtual scoped_ptr
<Border
> CreateNativeBorder(
128 views::LabelButton
* owning_button
,
129 scoped_ptr
<views::LabelButtonBorder
> border
) = 0;
131 // Notifies the observer about changes about how window buttons should be
132 // laid out. If the order is anything other than the default min,max,close on
133 // the right, will immediately send a button change event to the observer.
134 virtual void AddWindowButtonOrderObserver(
135 WindowButtonOrderObserver
* observer
) = 0;
137 // Removes the observer from the LinuxUI's list.
138 virtual void RemoveWindowButtonOrderObserver(
139 WindowButtonOrderObserver
* observer
) = 0;
141 // Determines whether the user's window manager is Unity.
142 virtual bool UnityIsRunning() = 0;
144 // What action we should take when the user middle clicks on non-client
145 // area. The default is lowering the window.
146 virtual NonClientMiddleClickAction
GetNonClientMiddleClickAction() = 0;
148 // Notifies the window manager that start up has completed.
149 // Normally Chromium opens a new window on startup and GTK does this
150 // automatically. In case Chromium does not open a new window on startup,
151 // e.g. an existing browser window already exists, this should be called.
152 virtual void NotifyWindowManagerStartupComplete() = 0;
157 #endif // UI_VIEWS_LINUX_UI_LINUX_UI_H_