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 "third_party/skia/include/core/SkColor.h"
11 #include "ui/base/ime/linux/linux_input_method_context_factory.h"
12 #include "ui/events/linux/text_edit_key_bindings_delegate_auralinux.h"
13 #include "ui/gfx/linux_font_delegate.h"
14 #include "ui/shell_dialogs/linux_shell_dialog.h"
15 #include "ui/views/controls/button/button.h"
16 #include "ui/views/linux_ui/status_icon_linux.h"
17 #include "ui/views/views_export.h"
19 // The main entrypoint into Linux toolkit specific code. GTK code should only
20 // be executed behind this interface.
34 class NativeThemeChangeObserver;
35 class WindowButtonOrderObserver;
37 // Adapter class with targets to render like different toolkits. Set by any
38 // project that wants to do linux desktop native rendering.
40 // TODO(erg): We're hardcoding GTK2, when we'll need to have backends for (at
41 // minimum) GTK2 and GTK3. LinuxUI::instance() should actually be a very
42 // complex method that pokes around with dlopen against a libuigtk2.so, a
44 class VIEWS_EXPORT LinuxUI : public ui::LinuxInputMethodContextFactory,
45 public gfx::LinuxFontDelegate,
46 public ui::LinuxShellDialog,
47 public ui::TextEditKeyBindingsDelegateAuraLinux {
51 // Sets the dynamically loaded singleton that draws the desktop native UI.
52 static void SetInstance(LinuxUI* instance);
54 // Returns a LinuxUI instance for the toolkit used in the user's desktop
57 // Can return NULL, in case no toolkit has been set. (For example, if we're
58 // running with the "--ash" flag.)
59 static LinuxUI* instance();
61 virtual void Initialize() = 0;
63 // Returns a themed image per theme_provider.h
64 virtual gfx::Image GetThemeImageNamed(int id) const = 0;
65 virtual bool GetColor(int id, SkColor* color) const = 0;
66 virtual bool HasCustomImage(int id) const = 0;
68 // Returns the preferences that we pass to WebKit.
69 virtual SkColor GetFocusRingColor() const = 0;
70 virtual SkColor GetThumbActiveColor() const = 0;
71 virtual SkColor GetThumbInactiveColor() const = 0;
72 virtual SkColor GetTrackColor() const = 0;
73 virtual SkColor GetActiveSelectionBgColor() const = 0;
74 virtual SkColor GetActiveSelectionFgColor() const = 0;
75 virtual SkColor GetInactiveSelectionBgColor() const = 0;
76 virtual SkColor GetInactiveSelectionFgColor() const = 0;
77 virtual double GetCursorBlinkInterval() const = 0;
79 // Returns a NativeTheme that will provide system colors and draw system
81 virtual ui::NativeTheme* GetNativeTheme() const = 0;
83 // Returns whether we should be using the native theme provided by this
85 virtual bool GetDefaultUsesSystemTheme() const = 0;
87 // Sets visual properties in the desktop environment related to download
88 // progress, if available.
89 virtual void SetDownloadCount(int count) const = 0;
90 virtual void SetProgressFraction(float percentage) const = 0;
92 // Checks for platform support for status icons.
93 virtual bool IsStatusIconSupported() const = 0;
95 // Create a native status icon.
96 virtual scoped_ptr<StatusIconLinux> CreateLinuxStatusIcon(
97 const gfx::ImageSkia& image,
98 const base::string16& tool_tip) const = 0;
100 // Returns the icon for a given content type from the icon theme.
101 // TODO(davidben): Add an observer for the theme changing, so we can drop the
103 virtual gfx::Image GetIconForContentType(
104 const std::string& content_type, int size) const = 0;
106 // Builds a Border which paints the native button style.
107 virtual scoped_ptr<Border> CreateNativeBorder(
108 views::LabelButton* owning_button,
109 scoped_ptr<views::Border> border) = 0;
111 // Notifies the observer about changes about how window buttons should be
112 // laid out. If the order is anything other than the default min,max,close on
113 // the right, will immediately send a button change event to the observer.
114 virtual void AddWindowButtonOrderObserver(
115 WindowButtonOrderObserver* observer) = 0;
117 // Removes the observer from the LinuxUI's list.
118 virtual void RemoveWindowButtonOrderObserver(
119 WindowButtonOrderObserver* observer) = 0;
121 // Notifies the observer when the native theme changes.
122 virtual void AddNativeThemeChangeObserver(
123 NativeThemeChangeObserver* observer) = 0;
124 virtual void RemoveNativeThemeChangeObserver(
125 NativeThemeChangeObserver* observer) = 0;
127 // Determines whether the user's window manager is Unity.
128 virtual bool UnityIsRunning() = 0;
130 // Notifies the window manager that start up has completed.
131 // Normally Chromium opens a new window on startup and GTK does this
132 // automatically. In case Chromium does not open a new window on startup,
133 // e.g. an existing browser window already exists, this should be called.
134 virtual void NotifyWindowManagerStartupComplete() = 0;
139 #endif // UI_VIEWS_LINUX_UI_LINUX_UI_H_