summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
Diffstat (limited to 'ui')
-rw-r--r--ui/base/accelerators/platform_accelerator_gtk.cc93
-rw-r--r--ui/base/accelerators/platform_accelerator_gtk.h49
-rw-r--r--ui/base/clipboard/clipboard_gtk.cc677
-rw-r--r--ui/base/dragdrop/drag_drop_types.h3
-rw-r--r--ui/base/dragdrop/gtk_dnd_util.cc285
-rw-r--r--ui/base/dragdrop/gtk_dnd_util.h95
-rw-r--r--ui/base/dragdrop/gtk_dnd_util_unittest.cc81
-rw-r--r--ui/base/dragdrop/os_exchange_data.h2
-rw-r--r--ui/base/gtk/event_synthesis_gtk.cc90
-rw-r--r--ui/base/gtk/event_synthesis_gtk.h38
-rw-r--r--ui/base/gtk/focus_store_gtk.cc55
-rw-r--r--ui/base/gtk/focus_store_gtk.h46
-rw-r--r--ui/base/gtk/g_object_destructor_filo.cc89
-rw-r--r--ui/base/gtk/g_object_destructor_filo.h91
-rw-r--r--ui/base/gtk/gtk_expanded_container.cc195
-rw-r--r--ui/base/gtk/gtk_expanded_container.h78
-rw-r--r--ui/base/gtk/gtk_expanded_container_unittest.cc164
-rw-r--r--ui/base/gtk/gtk_floating_container.cc322
-rw-r--r--ui/base/gtk/gtk_floating_container.h89
-rw-r--r--ui/base/gtk/gtk_hig_constants.h54
-rw-r--r--ui/base/gtk/gtk_screen_util.cc58
-rw-r--r--ui/base/gtk/gtk_screen_util.h34
-rw-r--r--ui/base/gtk/gtk_windowing.cc48
-rw-r--r--ui/base/gtk/gtk_windowing.h19
-rw-r--r--ui/base/gtk/owned_widget_gtk.cc47
-rw-r--r--ui/base/gtk/owned_widget_gtk.h95
-rw-r--r--ui/base/gtk/scoped_region.cc41
-rw-r--r--ui/base/gtk/scoped_region.h40
-rw-r--r--ui/base/resource/resource_bundle_gtk.cc112
-rw-r--r--ui/base/test/ui_controls_gtk.cc261
-rw-r--r--ui/base/ui_base.gyp26
-rw-r--r--ui/base/webui/web_ui_util.cc7
-rw-r--r--ui/base/x/x11_util.cc51
-rw-r--r--ui/base/x/x11_util.h21
-rw-r--r--ui/events/events.gyp2
-rw-r--r--ui/events/keycodes/keyboard_code_conversion_gtk.cc85
-rw-r--r--ui/events/keycodes/keyboard_code_conversion_gtk.h58
-rw-r--r--ui/events/keycodes/keyboard_code_conversion_x.cc14
-rw-r--r--ui/gfx/canvas_paint_gtk.cc107
-rw-r--r--ui/gfx/canvas_paint_gtk.h102
-rw-r--r--ui/gfx/canvas_skia_paint.h4
-rw-r--r--ui/gfx/font_render_params_linux.cc57
-rw-r--r--ui/gfx/geometry/insets.cc13
-rw-r--r--ui/gfx/geometry/insets.h7
-rw-r--r--ui/gfx/geometry/rect.cc13
-rw-r--r--ui/gfx/geometry/rect.h6
-rw-r--r--ui/gfx/gfx.gyp6
-rw-r--r--ui/gfx/gtk_compat.h97
-rw-r--r--ui/gfx/gtk_native_view_id_manager.cc254
-rw-r--r--ui/gfx/gtk_native_view_id_manager.h138
-rw-r--r--ui/gfx/gtk_preserve_window.cc264
-rw-r--r--ui/gfx/gtk_preserve_window.h74
-rw-r--r--ui/gfx/gtk_util.cc190
-rw-r--r--ui/gfx/gtk_util.h55
-rw-r--r--ui/gfx/image/image.cc246
-rw-r--r--ui/gfx/image/image_unittest.cc28
-rw-r--r--ui/gfx/image/image_unittest_util.cc27
-rw-r--r--ui/gfx/image/image_unittest_util.h2
-rw-r--r--ui/gfx/native_widget_types.h22
-rw-r--r--ui/gfx/pango_util.cc8
-rw-r--r--ui/gfx/path_gtk.cc57
-rw-r--r--ui/gfx/render_text_unittest.cc8
-rw-r--r--ui/gfx/screen_gtk.cc210
-rw-r--r--ui/gfx/skia_utils_gtk.cc32
-rw-r--r--ui/gfx/skia_utils_gtk.h23
-rw-r--r--ui/native_theme/fallback_theme.cc1
-rw-r--r--ui/native_theme/native_theme.gyp2
-rw-r--r--ui/native_theme/native_theme_gtk.cc110
-rw-r--r--ui/native_theme/native_theme_gtk.h28
-rw-r--r--ui/shell_dialogs/gtk/OWNERS2
-rw-r--r--ui/shell_dialogs/gtk/select_file_dialog_impl.cc92
-rw-r--r--ui/shell_dialogs/gtk/select_file_dialog_impl.h89
-rw-r--r--ui/shell_dialogs/gtk/select_file_dialog_impl_gtk.cc596
-rw-r--r--ui/shell_dialogs/gtk/select_file_dialog_impl_kde.cc485
-rw-r--r--ui/shell_dialogs/shell_dialogs.gyp4
-rw-r--r--ui/snapshot/snapshot.gyp1
-rw-r--r--ui/snapshot/snapshot_gtk.cc112
-rw-r--r--ui/surface/surface.gyp1
-rw-r--r--ui/surface/transport_dib_gtk.cc160
-rw-r--r--ui/ui_unittests.gyp1
80 files changed, 9 insertions, 7340 deletions
diff --git a/ui/base/accelerators/platform_accelerator_gtk.cc b/ui/base/accelerators/platform_accelerator_gtk.cc
deleted file mode 100644
index 5662452..0000000
--- a/ui/base/accelerators/platform_accelerator_gtk.cc
+++ /dev/null
@@ -1,93 +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/base/accelerators/platform_accelerator_gtk.h"
-
-#include "ui/events/keycodes/keyboard_code_conversion_gtk.h"
-
-namespace ui {
-
-namespace {
-
-int GdkModifierToEventFlag(GdkModifierType gdk_modifier) {
- int event_flags = 0;
- if (gdk_modifier & GDK_SHIFT_MASK)
- event_flags |= EF_SHIFT_DOWN;
- if (gdk_modifier & GDK_CONTROL_MASK)
- event_flags |= EF_CONTROL_DOWN;
- if (gdk_modifier & GDK_MOD1_MASK)
- event_flags |= EF_ALT_DOWN;
- return event_flags;
-}
-
-GdkModifierType EventFlagToGdkModifier(int event_flag) {
- int modifier = 0;
- if (event_flag & EF_SHIFT_DOWN)
- modifier |= GDK_SHIFT_MASK;
- if (event_flag & EF_CONTROL_DOWN)
- modifier |= GDK_CONTROL_MASK;
- if (event_flag & EF_ALT_DOWN)
- modifier |= GDK_MOD1_MASK;
- return static_cast<GdkModifierType>(modifier);
-}
-
-} // namespace
-
-PlatformAcceleratorGtk::PlatformAcceleratorGtk()
- : gdk_key_code_(0),
- gdk_modifier_(static_cast<GdkModifierType>(0)) {
-}
-
-PlatformAcceleratorGtk::PlatformAcceleratorGtk(guint gdk_key_code,
- GdkModifierType gdk_modifier)
- : gdk_key_code_(gdk_key_code),
- gdk_modifier_(gdk_modifier) {
-}
-
-PlatformAcceleratorGtk::~PlatformAcceleratorGtk() {
-}
-
-scoped_ptr<PlatformAccelerator> PlatformAcceleratorGtk::CreateCopy() const {
- scoped_ptr<PlatformAcceleratorGtk> copy(new PlatformAcceleratorGtk);
- copy->gdk_key_code_ = gdk_key_code_;
- copy->gdk_modifier_ = gdk_modifier_;
- return scoped_ptr<PlatformAccelerator>(copy.release());
-}
-
-bool PlatformAcceleratorGtk::Equals(const PlatformAccelerator& rhs) const {
- const PlatformAcceleratorGtk& rhs_gtk =
- static_cast<const PlatformAcceleratorGtk&>(rhs);
- return gdk_key_code_ == rhs_gtk.gdk_key_code_ &&
- gdk_modifier_ == rhs_gtk.gdk_modifier_;
-}
-
-Accelerator AcceleratorForGdkKeyCodeAndModifier(guint gdk_key_code,
- GdkModifierType gdk_modifier) {
- ui::Accelerator accelerator(ui::WindowsKeyCodeForGdkKeyCode(gdk_key_code),
- ui::GdkModifierToEventFlag(gdk_modifier));
- scoped_ptr<PlatformAccelerator> platform_accelerator(
- new PlatformAcceleratorGtk(gdk_key_code, gdk_modifier));
- accelerator.set_platform_accelerator(platform_accelerator.Pass());
- return accelerator;
-}
-
-guint GetGdkKeyCodeForAccelerator(const Accelerator& accelerator) {
- if (accelerator.platform_accelerator()) {
- return static_cast<const PlatformAcceleratorGtk*>(
- accelerator.platform_accelerator())->gdk_key_code();
- }
- // The second parameter is false because accelerator keys are expressed in
- // terms of the non-shift-modified key.
- return GdkKeyCodeForWindowsKeyCode(accelerator.key_code(), false);
-}
-
-GdkModifierType GetGdkModifierForAccelerator(const Accelerator& accelerator) {
- if (accelerator.platform_accelerator()) {
- return static_cast<const PlatformAcceleratorGtk*>(
- accelerator.platform_accelerator())->gdk_modifier();
- }
- return EventFlagToGdkModifier(accelerator.modifiers());
-}
-
-} // namespace ui
diff --git a/ui/base/accelerators/platform_accelerator_gtk.h b/ui/base/accelerators/platform_accelerator_gtk.h
deleted file mode 100644
index 59c8fa0..0000000
--- a/ui/base/accelerators/platform_accelerator_gtk.h
+++ /dev/null
@@ -1,49 +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 UI_BASE_ACCELERATORS_PLATFORM_ACCELERATOR_GTK_H_
-#define UI_BASE_ACCELERATORS_PLATFORM_ACCELERATOR_GTK_H_
-
-#include <gdk/gdk.h>
-
-#include "base/compiler_specific.h"
-#include "ui/base/accelerators/accelerator.h"
-#include "ui/base/accelerators/platform_accelerator.h"
-
-namespace ui {
-
-class Accelerator;
-
-// This is a GTK specific class for specifing accelerator keys.
-class UI_BASE_EXPORT PlatformAcceleratorGtk : public PlatformAccelerator {
- public:
- PlatformAcceleratorGtk();
- PlatformAcceleratorGtk(guint gdk_key_code, GdkModifierType gdk_modifier);
- virtual ~PlatformAcceleratorGtk();
-
- // PlatformAccelerator:
- virtual scoped_ptr<PlatformAccelerator> CreateCopy() const OVERRIDE;
- virtual bool Equals(const PlatformAccelerator& rhs) const OVERRIDE;
-
- guint gdk_key_code() const { return gdk_key_code_; }
- GdkModifierType gdk_modifier() const { return gdk_modifier_; }
-
- private:
- guint gdk_key_code_;
- GdkModifierType gdk_modifier_;
-
- DISALLOW_COPY_AND_ASSIGN(PlatformAcceleratorGtk);
-};
-
-UI_BASE_EXPORT Accelerator AcceleratorForGdkKeyCodeAndModifier(
- guint gdk_key_code,
- GdkModifierType gdk_modifier);
-UI_BASE_EXPORT guint
- GetGdkKeyCodeForAccelerator(const Accelerator& accelerator);
-UI_BASE_EXPORT GdkModifierType GetGdkModifierForAccelerator(
- const Accelerator& accelerator);
-
-} // namespace ui
-
-#endif // UI_BASE_ACCELERATORS_PLATFORM_ACCELERATOR_GTK_H_
diff --git a/ui/base/clipboard/clipboard_gtk.cc b/ui/base/clipboard/clipboard_gtk.cc
deleted file mode 100644
index 8f81911..0000000
--- a/ui/base/clipboard/clipboard_gtk.cc
+++ /dev/null
@@ -1,677 +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/base/clipboard/clipboard.h"
-
-#include <gtk/gtk.h>
-#include <X11/extensions/Xfixes.h>
-#include <X11/Xatom.h>
-#include <map>
-#include <set>
-#include <string>
-#include <utility>
-
-#include "base/basictypes.h"
-#include "base/files/file_path.h"
-#include "base/logging.h"
-#include "base/memory/singleton.h"
-#include "base/strings/utf_string_conversions.h"
-#include "third_party/skia/include/core/SkBitmap.h"
-#include "ui/base/clipboard/custom_data_helper.h"
-#include "ui/base/gtk/gtk_signal.h"
-#include "ui/base/x/x11_util.h"
-#include "ui/gfx/canvas.h"
-#include "ui/gfx/gtk_util.h"
-#include "ui/gfx/scoped_gobject.h"
-#include "ui/gfx/size.h"
-
-namespace ui {
-
-namespace {
-
-class SelectionChangeObserver {
- public:
- static SelectionChangeObserver* GetInstance();
-
- uint64 clipboard_sequence_number() const {
- return clipboard_sequence_number_;
- }
- uint64 primary_sequence_number() const { return primary_sequence_number_; }
-
- private:
- friend struct DefaultSingletonTraits<SelectionChangeObserver>;
-
- SelectionChangeObserver();
- ~SelectionChangeObserver();
-
- CHROMEG_CALLBACK_1(SelectionChangeObserver, GdkFilterReturn, OnXEvent,
- GdkXEvent*, GdkEvent*);
-
- int event_base_;
- Atom clipboard_atom_;
- uint64 clipboard_sequence_number_;
- uint64 primary_sequence_number_;
-
- DISALLOW_COPY_AND_ASSIGN(SelectionChangeObserver);
-};
-
-SelectionChangeObserver::SelectionChangeObserver()
- : event_base_(-1),
- clipboard_atom_(None),
- clipboard_sequence_number_(0),
- primary_sequence_number_(0) {
- int ignored;
- if (XFixesQueryExtension(gfx::GetXDisplay(), &event_base_, &ignored)) {
- clipboard_atom_ = XInternAtom(gfx::GetXDisplay(), "CLIPBOARD", false);
- XFixesSelectSelectionInput(gfx::GetXDisplay(), GetX11RootWindow(),
- clipboard_atom_,
- XFixesSetSelectionOwnerNotifyMask |
- XFixesSelectionWindowDestroyNotifyMask |
- XFixesSelectionClientCloseNotifyMask);
- // This seems to be semi-optional. For some reason, registering for any
- // selection notify events seems to subscribe us to events for both the
- // primary and the clipboard buffers. Register anyway just to be safe.
- XFixesSelectSelectionInput(gfx::GetXDisplay(), GetX11RootWindow(),
- XA_PRIMARY,
- XFixesSetSelectionOwnerNotifyMask |
- XFixesSelectionWindowDestroyNotifyMask |
- XFixesSelectionClientCloseNotifyMask);
- gdk_window_add_filter(NULL, &SelectionChangeObserver::OnXEventThunk, this);
- }
-}
-
-SelectionChangeObserver::~SelectionChangeObserver() {
-}
-
-SelectionChangeObserver* SelectionChangeObserver::GetInstance() {
- return Singleton<SelectionChangeObserver>::get();
-}
-
-GdkFilterReturn SelectionChangeObserver::OnXEvent(GdkXEvent* xevent,
- GdkEvent* event) {
- XEvent* xev = static_cast<XEvent*>(xevent);
-
- if (xev->type == event_base_ + XFixesSelectionNotify) {
- XFixesSelectionNotifyEvent* ev =
- reinterpret_cast<XFixesSelectionNotifyEvent*>(xev);
- if (ev->selection == clipboard_atom_) {
- clipboard_sequence_number_++;
- } else if (ev->selection == XA_PRIMARY) {
- primary_sequence_number_++;
- } else {
- DLOG(ERROR) << "Unexpected selection atom: " << ev->selection;
- }
- }
- return GDK_FILTER_CONTINUE;
-}
-
-const char kMimeTypeBitmap[] = "image/bmp";
-const char kMimeTypeMozillaURL[] = "text/x-moz-url";
-const char kMimeTypePepperCustomData[] = "chromium/x-pepper-custom-data";
-const char kMimeTypeWebkitSmartPaste[] = "chromium/x-webkit-paste";
-
-std::string GdkAtomToString(const GdkAtom& atom) {
- gchar* name = gdk_atom_name(atom);
- std::string rv(name);
- g_free(name);
- return rv;
-}
-
-GdkAtom StringToGdkAtom(const std::string& str) {
- return gdk_atom_intern(str.c_str(), FALSE);
-}
-
-// GtkClipboardGetFunc callback.
-// GTK will call this when an application wants data we copied to the clipboard.
-void GetData(GtkClipboard* clipboard,
- GtkSelectionData* selection_data,
- guint info,
- gpointer user_data) {
- Clipboard::TargetMap* data_map =
- reinterpret_cast<Clipboard::TargetMap*>(user_data);
-
- std::string target_string = GdkAtomToString(
- gtk_selection_data_get_target(selection_data));
- Clipboard::TargetMap::iterator iter = data_map->find(target_string);
-
- if (iter == data_map->end())
- return;
-
- if (target_string == kMimeTypeBitmap) {
- gtk_selection_data_set_pixbuf(selection_data,
- reinterpret_cast<GdkPixbuf*>(iter->second.first));
- } else {
- gtk_selection_data_set(selection_data,
- gtk_selection_data_get_target(selection_data), 8,
- reinterpret_cast<guchar*>(iter->second.first),
- iter->second.second);
- }
-}
-
-// GtkClipboardClearFunc callback.
-// We are guaranteed this will be called exactly once for each call to
-// gtk_clipboard_set_with_data.
-void ClearData(GtkClipboard* /*clipboard*/,
- gpointer user_data) {
- Clipboard::TargetMap* map =
- reinterpret_cast<Clipboard::TargetMap*>(user_data);
- // The same data may be inserted under multiple keys, so use a set to
- // uniq them.
- std::set<char*> ptrs;
-
- for (Clipboard::TargetMap::iterator iter = map->begin();
- iter != map->end(); ++iter) {
- if (iter->first == kMimeTypeBitmap)
- g_object_unref(reinterpret_cast<GdkPixbuf*>(iter->second.first));
- else
- ptrs.insert(iter->second.first);
- }
-
- for (std::set<char*>::iterator iter = ptrs.begin();
- iter != ptrs.end(); ++iter) {
- delete[] *iter;
- }
-
- delete map;
-}
-
-} // namespace
-
-Clipboard::FormatType::FormatType() : data_(GDK_NONE) {
-}
-
-Clipboard::FormatType::FormatType(const std::string& format_string)
- : data_(StringToGdkAtom(format_string)) {
-}
-
-Clipboard::FormatType::FormatType(const GdkAtom& native_format)
- : data_(native_format) {
-}
-
-Clipboard::FormatType::~FormatType() {
-}
-
-std::string Clipboard::FormatType::Serialize() const {
- return GdkAtomToString(data_);
-}
-
-// static
-Clipboard::FormatType Clipboard::FormatType::Deserialize(
- const std::string& serialization) {
- return FormatType(serialization);
-}
-
-bool Clipboard::FormatType::Equals(const FormatType& other) const {
- return data_ == other.data_;
-}
-
-Clipboard::Clipboard() : clipboard_data_(NULL) {
- DCHECK(CalledOnValidThread());
- clipboard_ = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD);
- primary_selection_ = gtk_clipboard_get(GDK_SELECTION_PRIMARY);
-}
-
-Clipboard::~Clipboard() {
- DCHECK(CalledOnValidThread());
- gtk_clipboard_store(clipboard_);
-}
-
-void Clipboard::WriteObjects(ClipboardType type, const ObjectMap& objects) {
- DCHECK(CalledOnValidThread());
- clipboard_data_ = new TargetMap();
-
- for (ObjectMap::const_iterator iter = objects.begin();
- iter != objects.end(); ++iter) {
- DispatchObject(static_cast<ObjectType>(iter->first), iter->second);
- }
- SetGtkClipboard(type);
-
- if (type == CLIPBOARD_TYPE_COPY_PASTE) {
- ObjectMap::const_iterator text_iter = objects.find(CBF_TEXT);
- if (text_iter != objects.end()) {
- // Copy text and SourceTag to the selection clipboard.
- ObjectMap::const_iterator next_iter = text_iter;
- WriteObjects(CLIPBOARD_TYPE_SELECTION, ObjectMap(text_iter, ++next_iter));
- }
- }
-}
-
-// Take ownership of the GTK clipboard and inform it of the targets we support.
-void Clipboard::SetGtkClipboard(ClipboardType type) {
- scoped_ptr<GtkTargetEntry[]> targets(
- new GtkTargetEntry[clipboard_data_->size()]);
-
- int i = 0;
- for (Clipboard::TargetMap::iterator iter = clipboard_data_->begin();
- iter != clipboard_data_->end(); ++iter, ++i) {
- targets[i].target = const_cast<char*>(iter->first.c_str());
- targets[i].flags = 0;
- targets[i].info = 0;
- }
-
- GtkClipboard *clipboard = LookupBackingClipboard(type);
-
- if (gtk_clipboard_set_with_data(clipboard, targets.get(),
- clipboard_data_->size(),
- GetData, ClearData,
- clipboard_data_)) {
- gtk_clipboard_set_can_store(clipboard,
- targets.get(),
- clipboard_data_->size());
- }
-
- // clipboard_data_ now owned by the GtkClipboard.
- clipboard_data_ = NULL;
-}
-
-void Clipboard::WriteText(const char* text_data, size_t text_len) {
- char* data = new char[text_len];
- memcpy(data, text_data, text_len);
-
- InsertMapping(kMimeTypeText, data, text_len);
- InsertMapping("TEXT", data, text_len);
- InsertMapping("STRING", data, text_len);
- InsertMapping("UTF8_STRING", data, text_len);
- InsertMapping("COMPOUND_TEXT", data, text_len);
-}
-
-void Clipboard::WriteHTML(const char* markup_data,
- size_t markup_len,
- const char* url_data,
- size_t url_len) {
- // TODO(estade): We need to expand relative links with |url_data|.
- static const char* html_prefix = "<meta http-equiv=\"content-type\" "
- "content=\"text/html; charset=utf-8\">";
- size_t html_prefix_len = strlen(html_prefix);
- size_t total_len = html_prefix_len + markup_len + 1;
-
- char* data = new char[total_len];
- snprintf(data, total_len, "%s", html_prefix);
- memcpy(data + html_prefix_len, markup_data, markup_len);
- // Some programs expect NULL-terminated data. See http://crbug.com/42624
- data[total_len - 1] = '\0';
-
- InsertMapping(kMimeTypeHTML, data, total_len);
-}
-
-void Clipboard::WriteRTF(const char* rtf_data, size_t data_len) {
- WriteData(GetRtfFormatType(), rtf_data, data_len);
-}
-
-// Write an extra flavor that signifies WebKit was the last to modify the
-// pasteboard. This flavor has no data.
-void Clipboard::WriteWebSmartPaste() {
- InsertMapping(kMimeTypeWebkitSmartPaste, NULL, 0);
-}
-
-void Clipboard::WriteBitmap(const SkBitmap& bitmap) {
- GdkPixbuf* pixbuf = gfx::GdkPixbufFromSkBitmap(bitmap);
-
- // We store the GdkPixbuf*, and the size_t half of the pair is meaningless.
- // Note that this contrasts with the vast majority of entries in our target
- // map, which directly store the data and its length.
- InsertMapping(kMimeTypeBitmap, reinterpret_cast<char*>(pixbuf), 0);
-}
-
-void Clipboard::WriteBookmark(const char* title_data, size_t title_len,
- const char* url_data, size_t url_len) {
- // Write as a mozilla url (UTF16: URL, newline, title).
- base::string16 url = base::UTF8ToUTF16(std::string(url_data, url_len) + "\n");
- base::string16 title = base::UTF8ToUTF16(std::string(title_data, title_len));
- if (title.length() >= std::numeric_limits<size_t>::max() / 4 ||
- url.length() >= std::numeric_limits<size_t>::max() / 4)
- return;
- size_t data_len = 2 * (title.length() + url.length());
-
- char* data = new char[data_len];
- memcpy(data, url.data(), 2 * url.length());
- memcpy(data + 2 * url.length(), title.data(), 2 * title.length());
- InsertMapping(kMimeTypeMozillaURL, data, data_len);
-}
-
-void Clipboard::WriteData(const FormatType& format,
- const char* data_data,
- size_t data_len) {
- // We assume that certain mapping types are only written by trusted code.
- // Therefore we must upkeep their integrity.
- if (format.Equals(GetBitmapFormatType()))
- return;
- char* data = new char[data_len];
- memcpy(data, data_data, data_len);
- // TODO(dcheng): Maybe this map should use GdkAtoms...
- InsertMapping(GdkAtomToString(format.ToGdkAtom()).c_str(), data, data_len);
-}
-
-// We do not use gtk_clipboard_wait_is_target_available because of
-// a bug with the gtk clipboard. It caches the available targets
-// and does not always refresh the cache when it is appropriate.
-bool Clipboard::IsFormatAvailable(const Clipboard::FormatType& format,
- ClipboardType type) const {
- DCHECK(CalledOnValidThread());
- GtkClipboard* clipboard = LookupBackingClipboard(type);
- if (clipboard == NULL)
- return false;
-
- bool retval = false;
- GtkSelectionData* data = gtk_clipboard_wait_for_contents(
- clipboard, gdk_atom_intern_static_string("TARGETS"));
-
- bool format_is_plain_text = GetPlainTextFormatType().Equals(format);
- if (format_is_plain_text) {
- // This tries a number of common text targets.
- if (data) {
- retval = gtk_selection_data_targets_include_text(data);
- }
- // Some programs like Java decide to set an empty TARGETS list, so even if
- // data is not NULL, we still have to fall back.
- if (!retval) {
- // Some programs post data to the clipboard without any targets. If this
- // is the case we attempt to make sense of the contents as text. This is
- // pretty unfortunate since it means we have to actually copy the data to
- // see if it is available, but at least this path shouldn't be hit for
- // conforming programs.
- gchar* text = gtk_clipboard_wait_for_text(clipboard);
- if (text) {
- g_free(text);
- retval = true;
- }
- }
- } else if (data) {
- GdkAtom* targets = NULL;
- int num = 0;
- gtk_selection_data_get_targets(data, &targets, &num);
-
- for (int i = 0; i < num; i++) {
- if (targets[i] == format.ToGdkAtom()) {
- retval = true;
- break;
- }
- }
-
- g_free(targets);
- }
-
- if (data)
- gtk_selection_data_free(data);
-
- return retval;
-}
-
-void Clipboard::Clear(ClipboardType type) {
- DCHECK(CalledOnValidThread());
- GtkClipboard* clipboard = LookupBackingClipboard(type);
- if (clipboard == NULL)
- return;
- gtk_clipboard_clear(clipboard);
-}
-
-void Clipboard::ReadAvailableTypes(ClipboardType type,
- std::vector<base::string16>* types,
- bool* contains_filenames) const {
- DCHECK(CalledOnValidThread());
- if (!types || !contains_filenames) {
- NOTREACHED();
- return;
- }
-
- types->clear();
- if (IsFormatAvailable(GetPlainTextFormatType(), type))
- types->push_back(base::UTF8ToUTF16(kMimeTypeText));
- if (IsFormatAvailable(GetHtmlFormatType(), type))
- types->push_back(base::UTF8ToUTF16(kMimeTypeHTML));
- if (IsFormatAvailable(GetRtfFormatType(), type))
- types->push_back(base::UTF8ToUTF16(kMimeTypeRTF));
- if (IsFormatAvailable(GetBitmapFormatType(), type))
- types->push_back(base::UTF8ToUTF16(kMimeTypePNG));
- *contains_filenames = false;
-
- GtkClipboard* clipboard = LookupBackingClipboard(type);
- if (!clipboard)
- return;
-
- GtkSelectionData* data = gtk_clipboard_wait_for_contents(
- clipboard, GetWebCustomDataFormatType().ToGdkAtom());
- if (!data)
- return;
- ReadCustomDataTypes(gtk_selection_data_get_data(data),
- gtk_selection_data_get_length(data),
- types);
- gtk_selection_data_free(data);
-}
-
-
-void Clipboard::ReadText(ClipboardType type, base::string16* result) const {
- DCHECK(CalledOnValidThread());
- GtkClipboard* clipboard = LookupBackingClipboard(type);
- if (clipboard == NULL)
- return;
-
- result->clear();
- gchar* text = gtk_clipboard_wait_for_text(clipboard);
-
- if (text == NULL)
- return;
-
- // TODO(estade): do we want to handle the possible error here?
- base::UTF8ToUTF16(text, strlen(text), result);
- g_free(text);
-}
-
-void Clipboard::ReadAsciiText(ClipboardType type,
- std::string* result) const {
- DCHECK(CalledOnValidThread());
- GtkClipboard* clipboard = LookupBackingClipboard(type);
- if (clipboard == NULL)
- return;
-
- result->clear();
- gchar* text = gtk_clipboard_wait_for_text(clipboard);
-
- if (text == NULL)
- return;
-
- result->assign(text);
- g_free(text);
-}
-
-// TODO(estade): handle different charsets.
-// TODO(port): set *src_url.
-void Clipboard::ReadHTML(ClipboardType type,
- base::string16* markup,
- std::string* src_url,
- uint32* fragment_start,
- uint32* fragment_end) const {
- DCHECK(CalledOnValidThread());
- markup->clear();
- if (src_url)
- src_url->clear();
- *fragment_start = 0;
- *fragment_end = 0;
-
- GtkClipboard* clipboard = LookupBackingClipboard(type);
- if (clipboard == NULL)
- return;
- GtkSelectionData* data = gtk_clipboard_wait_for_contents(clipboard,
- GetHtmlFormatType().ToGdkAtom());
-
- if (!data)
- return;
-
- // If the data starts with 0xFEFF, i.e., Byte Order Mark, assume it is
- // UTF-16, otherwise assume UTF-8.
- gint data_length = gtk_selection_data_get_length(data);
- const guchar* raw_data = gtk_selection_data_get_data(data);
-
- if (data_length >= 2 &&
- reinterpret_cast<const uint16_t*>(raw_data)[0] == 0xFEFF) {
- markup->assign(reinterpret_cast<const uint16_t*>(raw_data) + 1,
- (data_length / 2) - 1);
- } else {
- base::UTF8ToUTF16(
- reinterpret_cast<const char*>(raw_data), data_length, markup);
- }
-
- // If there is a terminating NULL, drop it.
- if (!markup->empty() && markup->at(markup->length() - 1) == '\0')
- markup->resize(markup->length() - 1);
-
- *fragment_start = 0;
- DCHECK(markup->length() <= kuint32max);
- *fragment_end = static_cast<uint32>(markup->length());
-
- gtk_selection_data_free(data);
-}
-
-void Clipboard::ReadRTF(ClipboardType type, std::string* result) const {
- DCHECK(CalledOnValidThread());
- ReadData(GetRtfFormatType(), result);
-}
-
-SkBitmap Clipboard::ReadImage(ClipboardType type) const {
- DCHECK(CalledOnValidThread());
- ScopedGObject<GdkPixbuf>::Type pixbuf(
- gtk_clipboard_wait_for_image(clipboard_));
- if (!pixbuf.get())
- return SkBitmap();
-
- gfx::Canvas canvas(gfx::Size(gdk_pixbuf_get_width(pixbuf.get()),
- gdk_pixbuf_get_height(pixbuf.get())),
- 1.0f, false);
- {
- skia::ScopedPlatformPaint scoped_platform_paint(canvas.sk_canvas());
- cairo_t* context = scoped_platform_paint.GetPlatformSurface();
- gdk_cairo_set_source_pixbuf(context, pixbuf.get(), 0.0, 0.0);
- cairo_paint(context);
- }
- return canvas.ExtractImageRep().sk_bitmap();
-}
-
-void Clipboard::ReadCustomData(ClipboardType clipboard_type,
- const base::string16& type,
- base::string16* result) const {
- DCHECK(CalledOnValidThread());
- GtkClipboard* clipboard = LookupBackingClipboard(clipboard_type);
- if (!clipboard)
- return;
-
- GtkSelectionData* data = gtk_clipboard_wait_for_contents(
- clipboard, GetWebCustomDataFormatType().ToGdkAtom());
- if (!data)
- return;
- ReadCustomDataForType(gtk_selection_data_get_data(data),
- gtk_selection_data_get_length(data),
- type, result);
- gtk_selection_data_free(data);
-}
-
-void Clipboard::ReadBookmark(base::string16* title, std::string* url) const {
- // TODO(estade): implement this.
- NOTIMPLEMENTED();
-}
-
-void Clipboard::ReadData(const FormatType& format, std::string* result) const {
- DCHECK(CalledOnValidThread());
- result->clear();
- GtkSelectionData* data =
- gtk_clipboard_wait_for_contents(clipboard_, format.ToGdkAtom());
- if (!data)
- return;
- result->assign(reinterpret_cast<const char*>(
- gtk_selection_data_get_data(data)),
- gtk_selection_data_get_length(data));
- gtk_selection_data_free(data);
-}
-
-uint64 Clipboard::GetSequenceNumber(ClipboardType type) {
- DCHECK(CalledOnValidThread());
- if (type == CLIPBOARD_TYPE_COPY_PASTE)
- return SelectionChangeObserver::GetInstance()->clipboard_sequence_number();
- else
- return SelectionChangeObserver::GetInstance()->primary_sequence_number();
-}
-
-//static
-Clipboard::FormatType Clipboard::GetFormatType(
- const std::string& format_string) {
- return FormatType::Deserialize(format_string);
-}
-
-// static
-const Clipboard::FormatType& Clipboard::GetPlainTextFormatType() {
- CR_DEFINE_STATIC_LOCAL(
- FormatType, type, (GDK_TARGET_STRING));
- return type;
-}
-
-// static
-const Clipboard::FormatType& Clipboard::GetPlainTextWFormatType() {
- return GetPlainTextFormatType();
-}
-
-// static
-const Clipboard::FormatType& Clipboard::GetUrlFormatType() {
- return GetPlainTextFormatType();
-}
-
-// static
-const Clipboard::FormatType& Clipboard::GetUrlWFormatType() {
- return GetPlainTextWFormatType();
-}
-
-// static
-const Clipboard::FormatType& Clipboard::GetHtmlFormatType() {
- CR_DEFINE_STATIC_LOCAL(FormatType, type, (kMimeTypeHTML));
- return type;
-}
-
-// static
-const Clipboard::FormatType& Clipboard::GetRtfFormatType() {
- CR_DEFINE_STATIC_LOCAL(FormatType, type, (kMimeTypeRTF));
- return type;
-}
-
-// static
-const Clipboard::FormatType& Clipboard::GetBitmapFormatType() {
- CR_DEFINE_STATIC_LOCAL(FormatType, type, (kMimeTypeBitmap));
- return type;
-}
-
-// static
-const Clipboard::FormatType& Clipboard::GetWebKitSmartPasteFormatType() {
- CR_DEFINE_STATIC_LOCAL(FormatType, type, (kMimeTypeWebkitSmartPaste));
- return type;
-}
-
-// static
-const Clipboard::FormatType& Clipboard::GetWebCustomDataFormatType() {
- CR_DEFINE_STATIC_LOCAL(FormatType, type, (kMimeTypeWebCustomData));
- return type;
-}
-
-// static
-const Clipboard::FormatType& Clipboard::GetPepperCustomDataFormatType() {
- CR_DEFINE_STATIC_LOCAL(FormatType, type, (kMimeTypePepperCustomData));
- return type;
-}
-
-void Clipboard::InsertMapping(const char* key,
- char* data,
- size_t data_len) {
- DCHECK(clipboard_data_->find(key) == clipboard_data_->end());
- (*clipboard_data_)[key] = std::make_pair(data, data_len);
-}
-
-GtkClipboard* Clipboard::LookupBackingClipboard(ClipboardType type) const {
- switch (type) {
- case CLIPBOARD_TYPE_COPY_PASTE:
- return clipboard_;
- case CLIPBOARD_TYPE_SELECTION:
- return primary_selection_;
- default:
- NOTREACHED();
- return NULL;
- }
-}
-
-} // namespace ui
diff --git a/ui/base/dragdrop/drag_drop_types.h b/ui/base/dragdrop/drag_drop_types.h
index afa8f9e..c74d4e2 100644
--- a/ui/base/dragdrop/drag_drop_types.h
+++ b/ui/base/dragdrop/drag_drop_types.h
@@ -28,9 +28,6 @@ class UI_BASE_EXPORT DragDropTypes {
#if defined(OS_WIN)
static uint32 DragOperationToDropEffect(int drag_operation);
static int DropEffectToDragOperation(uint32 effect);
-#elif defined(TOOLKIT_GTK)
- static int DragOperationToGdkDragAction(int drag_operation);
- static int GdkDragActionToDragOperation(int gdk_drag_action);
#endif
};
diff --git a/ui/base/dragdrop/gtk_dnd_util.cc b/ui/base/dragdrop/gtk_dnd_util.cc
deleted file mode 100644
index 1282723..0000000
--- a/ui/base/dragdrop/gtk_dnd_util.cc
+++ /dev/null
@@ -1,285 +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/base/dragdrop/gtk_dnd_util.h"
-
-#include <string>
-
-#include "base/logging.h"
-#include "base/pickle.h"
-#include "base/strings/utf_string_conversions.h"
-#include "ui/base/clipboard/custom_data_helper.h"
-#include "url/gurl.h"
-
-namespace ui {
-
-namespace {
-
-const int kBitsPerByte = 8;
-
-void AddTargetToList(GtkTargetList* targets, int target_code) {
- switch (target_code) {
- case ui::TEXT_PLAIN:
- gtk_target_list_add_text_targets(targets, ui::TEXT_PLAIN);
- break;
-
- case ui::TEXT_URI_LIST:
- gtk_target_list_add_uri_targets(targets, ui::TEXT_URI_LIST);
- break;
-
- case ui::TEXT_HTML:
- gtk_target_list_add(
- targets, ui::GetAtomForTarget(ui::TEXT_HTML), 0, ui::TEXT_HTML);
- break;
-
- case ui::NETSCAPE_URL:
- gtk_target_list_add(targets,
- ui::GetAtomForTarget(ui::NETSCAPE_URL), 0, ui::NETSCAPE_URL);
- break;
-
- case ui::CHROME_TAB:
- case ui::CHROME_BOOKMARK_ITEM:
- case ui::CHROME_NAMED_URL:
- gtk_target_list_add(targets, ui::GetAtomForTarget(target_code),
- GTK_TARGET_SAME_APP, target_code);
- break;
-
- case ui::DIRECT_SAVE_FILE:
- gtk_target_list_add(targets,
- ui::GetAtomForTarget(ui::DIRECT_SAVE_FILE), 0, ui::DIRECT_SAVE_FILE);
- break;
-
- case ui::CUSTOM_DATA:
- gtk_target_list_add(targets,
- ui::GetAtomForTarget(ui::CUSTOM_DATA), 0, ui::CUSTOM_DATA);
- break;
-
- case ui::RENDERER_TAINT:
- gtk_target_list_add(targets,
- ui::GetAtomForTarget(ui::RENDERER_TAINT), 0, ui::RENDERER_TAINT);
- break;
-
- default:
- NOTREACHED() << " Unexpected target code: " << target_code;
- }
-}
-
-} // namespace
-
-GdkAtom GetAtomForTarget(int target) {
- switch (target) {
- case CHROME_TAB:
- static const GdkAtom kTabAtom = gdk_atom_intern(
- "application/x-chrome-tab", false);
- return kTabAtom;
-
- case TEXT_HTML:
- static const GdkAtom kHtmlAtom = gdk_atom_intern(
- "text/html", false);
- return kHtmlAtom;
-
- case CHROME_BOOKMARK_ITEM:
- static const GdkAtom kBookmarkAtom = gdk_atom_intern(
- "application/x-chrome-bookmark-item", false);
- return kBookmarkAtom;
-
- case TEXT_PLAIN:
- static const GdkAtom kTextAtom= gdk_atom_intern(
- "text/plain;charset=utf-8", false);
- return kTextAtom;
-
- case TEXT_URI_LIST:
- static const GdkAtom kUrisAtom = gdk_atom_intern(
- "text/uri-list", false);
- return kUrisAtom;
-
- case CHROME_NAMED_URL:
- static const GdkAtom kNamedUrl = gdk_atom_intern(
- "application/x-chrome-named-url", false);
- return kNamedUrl;
-
- case NETSCAPE_URL:
- static const GdkAtom kNetscapeUrl = gdk_atom_intern(
- "_NETSCAPE_URL", false);
- return kNetscapeUrl;
-
- case TEXT_PLAIN_NO_CHARSET:
- static const GdkAtom kTextNoCharsetAtom = gdk_atom_intern(
- "text/plain", false);
- return kTextNoCharsetAtom;
-
- case DIRECT_SAVE_FILE:
- static const GdkAtom kXdsAtom = gdk_atom_intern(
- "XdndDirectSave0", false);
- return kXdsAtom;
-
- case CUSTOM_DATA:
- static const GdkAtom kCustomData = gdk_atom_intern(
- kMimeTypeWebCustomData, false);
- return kCustomData;
-
- case RENDERER_TAINT:
- static const GdkAtom kRendererTaint = gdk_atom_intern(
- "chromium/x-renderer-taint", false);
- return kRendererTaint;
-
- default:
- NOTREACHED();
- }
-
- return NULL;
-}
-
-GtkTargetList* GetTargetListFromCodeMask(int code_mask) {
- GtkTargetList* targets = gtk_target_list_new(NULL, 0);
-
- for (size_t i = 1; i < INVALID_TARGET; i = i << 1) {
- if (i == CHROME_WEBDROP_FILE_CONTENTS)
- continue;
-
- if (i & code_mask)
- AddTargetToList(targets, i);
- }
-
- return targets;
-}
-
-void SetSourceTargetListFromCodeMask(GtkWidget* source, int code_mask) {
- GtkTargetList* targets = GetTargetListFromCodeMask(code_mask);
- gtk_drag_source_set_target_list(source, targets);
- gtk_target_list_unref(targets);
-}
-
-void SetDestTargetList(GtkWidget* dest, const int* target_codes) {
- GtkTargetList* targets = gtk_target_list_new(NULL, 0);
-
- for (size_t i = 0; target_codes[i] != -1; ++i) {
- AddTargetToList(targets, target_codes[i]);
- }
-
- gtk_drag_dest_set_target_list(dest, targets);
- gtk_target_list_unref(targets);
-}
-
-void WriteURLWithName(GtkSelectionData* selection_data,
- const GURL& url,
- base::string16 title,
- int type) {
- if (title.empty()) {
- // We prefer to not have empty titles. Set it to the filename extracted
- // from the URL.
- title = base::UTF8ToUTF16(url.ExtractFileName());
- }
-
- switch (type) {
- case TEXT_PLAIN: {
- gtk_selection_data_set_text(selection_data, url.spec().c_str(),
- url.spec().length());
- break;
- }
- case TEXT_URI_LIST: {
- gchar* uri_array[2];
- uri_array[0] = strdup(url.spec().c_str());
- uri_array[1] = NULL;
- gtk_selection_data_set_uris(selection_data, uri_array);
- free(uri_array[0]);
- break;
- }
- case CHROME_NAMED_URL: {
- Pickle pickle;
- pickle.WriteString(base::UTF16ToUTF8(title));
- pickle.WriteString(url.spec());
- gtk_selection_data_set(
- selection_data,
- GetAtomForTarget(ui::CHROME_NAMED_URL),
- kBitsPerByte,
- reinterpret_cast<const guchar*>(pickle.data()),
- pickle.size());
- break;
- }
- case NETSCAPE_URL: {
- // _NETSCAPE_URL format is URL + \n + title.
- std::string utf8_text = url.spec() + "\n" + base::UTF16ToUTF8(title);
- gtk_selection_data_set(selection_data,
- gtk_selection_data_get_target(selection_data),
- kBitsPerByte,
- reinterpret_cast<const guchar*>(utf8_text.c_str()),
- utf8_text.length());
- break;
- }
-
- default: {
- NOTREACHED();
- break;
- }
- }
-}
-
-bool ExtractNamedURL(GtkSelectionData* selection_data,
- GURL* url,
- base::string16* title) {
- if (!selection_data || gtk_selection_data_get_length(selection_data) <= 0)
- return false;
-
- Pickle data(
- reinterpret_cast<const char*>(
- gtk_selection_data_get_data(selection_data)),
- gtk_selection_data_get_length(selection_data));
- PickleIterator iter(data);
- std::string title_utf8, url_utf8;
- if (!data.ReadString(&iter, &title_utf8) ||
- !data.ReadString(&iter, &url_utf8)) {
- return false;
- }
-
- GURL gurl(url_utf8);
- if (!gurl.is_valid())
- return false;
-
- *url = gurl;
- *title = base::UTF8ToUTF16(title_utf8);
- return true;
-}
-
-bool ExtractURIList(GtkSelectionData* selection_data, std::vector<GURL>* urls) {
- gchar** uris = gtk_selection_data_get_uris(selection_data);
- if (!uris)
- return false;
-
- for (size_t i = 0; uris[i] != NULL; ++i) {
- GURL url(uris[i]);
- if (url.is_valid())
- urls->push_back(url);
- }
-
- g_strfreev(uris);
- return true;
-}
-
-bool ExtractNetscapeURL(GtkSelectionData* selection_data,
- GURL* url,
- base::string16* title) {
- if (!selection_data || gtk_selection_data_get_length(selection_data) <= 0)
- return false;
-
- // Find the first '\n' in the data. It is the separator between the url and
- // the title.
- std::string data(
- reinterpret_cast<const char*>(
- gtk_selection_data_get_data(selection_data)),
- gtk_selection_data_get_length(selection_data));
- std::string::size_type newline = data.find('\n');
- if (newline == std::string::npos)
- return false;
-
- GURL gurl(data.substr(0, newline));
- if (!gurl.is_valid())
- return false;
-
- *url = gurl;
- *title = base::UTF8ToUTF16(data.substr(newline + 1));
- return true;
-}
-
-} // namespace ui
diff --git a/ui/base/dragdrop/gtk_dnd_util.h b/ui/base/dragdrop/gtk_dnd_util.h
deleted file mode 100644
index 33ee837..0000000
--- a/ui/base/dragdrop/gtk_dnd_util.h
+++ /dev/null
@@ -1,95 +0,0 @@
-// Copyright (c) 2011 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_BASE_DRAGDROP_GTK_DND_UTIL_H_
-#define UI_BASE_DRAGDROP_GTK_DND_UTIL_H_
-
-#include <gtk/gtk.h>
-
-#include <vector>
-
-#include "base/strings/string16.h"
-#include "ui/base/ui_base_export.h"
-
-class GURL;
-
-namespace ui {
-
-// Registry of all internal int codes for drag and drop.
-enum {
- // Intra-application types.
- CHROME_TAB = 1 << 0,
- CHROME_BOOKMARK_ITEM = 1 << 1,
- CHROME_WEBDROP_FILE_CONTENTS = 1 << 2,
- CHROME_NAMED_URL = 1 << 3,
-
- // Standard types.
- TEXT_PLAIN = 1 << 4,
- TEXT_URI_LIST = 1 << 5,
- TEXT_HTML = 1 << 6,
-
- // Other types. NETSCAPE_URL is provided for compatibility with other
- // apps.
- NETSCAPE_URL = 1 << 7,
-
- // Used for drag-out download.
- TEXT_PLAIN_NO_CHARSET = 1 << 8,
- DIRECT_SAVE_FILE = 1 << 9,
-
- // Custom data for web drag/drop.
- CUSTOM_DATA = 1 << 10,
-
- // Tracks if the drag originated from the renderer.
- RENDERER_TAINT = 1 << 11,
-
- INVALID_TARGET = 1 << 12,
-};
-
-// Get the atom for a given target (of the above enum type). Will return NULL
-// for non-custom targets, such as CHROME_TEXT_PLAIN.
-UI_BASE_EXPORT GdkAtom GetAtomForTarget(int target);
-
-// Creates a target list from the given mask. The mask should be an OR of
-// CHROME_* values. The target list is returned with ref count 1; the caller
-// is responsible for calling gtk_target_list_unref() when it is no longer
-// needed.
-// Since the MIME type for WEBDROP_FILE_CONTENTS depends on the file's
-// contents, that flag is ignored by this function. It is the responsibility
-// of the client code to do the right thing.
-UI_BASE_EXPORT GtkTargetList* GetTargetListFromCodeMask(int code_mask);
-
-// Set the drag target list for |source| with the target list that
-// corresponds to |code_mask|.
-UI_BASE_EXPORT void SetSourceTargetListFromCodeMask(GtkWidget* source,
- int code_mask);
-
-// Set the accepted targets list for |dest|. The |target_codes| array should
-// be sorted in preference order and should be terminated with -1.
-UI_BASE_EXPORT void SetDestTargetList(GtkWidget* dest, const int* target_codes);
-
-// Write a URL to the selection in the given type.
-UI_BASE_EXPORT void WriteURLWithName(GtkSelectionData* selection_data,
- const GURL& url,
- base::string16 title,
- int type);
-
-// Extracts data of type CHROME_NAMED_URL from |selection_data| into
-// |url| and |title|. Returns true if the url/title were safely extracted
-// and the url is valid.
-UI_BASE_EXPORT bool ExtractNamedURL(GtkSelectionData* selection_data,
- GURL* url,
- base::string16* title);
-
-// Extracts data of type TEXT_URI_LIST from |selection_data| into |urls|.
-UI_BASE_EXPORT bool ExtractURIList(GtkSelectionData* selection_data,
- std::vector<GURL>* urls);
-
-// Extracts a Netscape URL (url\ntitle) from |selection_data|.
-UI_BASE_EXPORT bool ExtractNetscapeURL(GtkSelectionData* selection_data,
- GURL* url,
- base::string16* title);
-
-} // namespace ui
-
-#endif // UI_BASE_DRAGDROP_GTK_DND_UTIL_H_
diff --git a/ui/base/dragdrop/gtk_dnd_util_unittest.cc b/ui/base/dragdrop/gtk_dnd_util_unittest.cc
deleted file mode 100644
index 977b67b..0000000
--- a/ui/base/dragdrop/gtk_dnd_util_unittest.cc
+++ /dev/null
@@ -1,81 +0,0 @@
-// Copyright (c) 2011 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 <string>
-
-#include "base/memory/scoped_ptr.h"
-#include "base/pickle.h"
-#include "base/strings/utf_string_conversions.h"
-#include "testing/gtest/include/gtest/gtest.h"
-#include "ui/base/dragdrop/gtk_dnd_util.h"
-#include "url/gurl.h"
-
-namespace ui {
-
-TEST(GtkDndUtilTest, ExtractNamedURLValid) {
- const std::string kTitle = "title";
- const std::string kUrl = "http://www.foobar.com/";
- Pickle pickle;
- pickle.WriteString(kTitle);
- pickle.WriteString(kUrl);
-
- GtkSelectionData data;
- scoped_ptr<guchar[]> test_data(new guchar[pickle.size()]);
- memcpy(test_data.get(), pickle.data(), pickle.size());
- data.data = test_data.get();
- data.length = pickle.size();
-
- GURL url;
- base::string16 title;
- ASSERT_EQ(true, ui::ExtractNamedURL(&data, &url, &title));
- EXPECT_EQ(base::UTF8ToUTF16(kTitle), title);
- EXPECT_EQ(GURL(kUrl), url);
-}
-
-TEST(GtkDndUtilTest, ExtractNamedURLInvalidURL) {
- const std::string kTitle = "title";
- const std::string kBadUrl = "foobar";
- Pickle pickle;
- pickle.WriteString(kTitle);
- pickle.WriteString(kBadUrl);
-
- GtkSelectionData data;
- scoped_ptr<guchar[]> test_data(new guchar[pickle.size()]);
- memcpy(test_data.get(), pickle.data(), pickle.size());
- data.data = test_data.get();
- data.length = pickle.size();
-
- GURL url;
- base::string16 title;
- EXPECT_FALSE(ui::ExtractNamedURL(&data, &url, &title));
-}
-
-TEST(GtkDndUtilTest, ExtractNamedURLInvalidInput) {
- GURL url;
- base::string16 title;
- GtkSelectionData data;
- data.data = NULL;
- data.length = 0;
-
- EXPECT_FALSE(ui::ExtractNamedURL(&data, &url, &title));
-
- guchar empty_data[] = "";
- data.data = empty_data;
- data.length = 0;
-
- EXPECT_FALSE(ui::ExtractNamedURL(&data, &url, &title));
-
- const std::string kTitle = "title";
- Pickle pickle;
- pickle.WriteString(kTitle);
-
- scoped_ptr<guchar[]> test_data(new guchar[pickle.size()]);
- memcpy(test_data.get(), pickle.data(), pickle.size());
- data.data = test_data.get();
- data.length = pickle.size();
-
- EXPECT_FALSE(ui::ExtractNamedURL(&data, &url, &title));
-}
-
-} // namespace ui
diff --git a/ui/base/dragdrop/os_exchange_data.h b/ui/base/dragdrop/os_exchange_data.h
index 5a1cbd5..cbe56e1 100644
--- a/ui/base/dragdrop/os_exchange_data.h
+++ b/ui/base/dragdrop/os_exchange_data.h
@@ -12,8 +12,6 @@
#if defined(OS_WIN)
#include <objidl.h>
-#elif defined(TOOLKIT_GTK)
-#include <gtk/gtk.h>
#endif
#include "base/basictypes.h"
diff --git a/ui/base/gtk/event_synthesis_gtk.cc b/ui/base/gtk/event_synthesis_gtk.cc
deleted file mode 100644
index ea56162..0000000
--- a/ui/base/gtk/event_synthesis_gtk.cc
+++ /dev/null
@@ -1,90 +0,0 @@
-// Copyright (c) 2011 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/base/gtk/event_synthesis_gtk.h"
-
-#include "ui/events/keycodes/keyboard_code_conversion_gtk.h"
-
-namespace ui {
-
-GdkEvent* SynthesizeKeyEvent(GdkWindow* window,
- bool press, guint gdk_key, guint state) {
- GdkEvent* event = gdk_event_new(press ? GDK_KEY_PRESS : GDK_KEY_RELEASE);
-
- event->key.type = press ? GDK_KEY_PRESS : GDK_KEY_RELEASE;
- event->key.window = window;
- if (window)
- g_object_ref(window);
- event->key.send_event = false;
-
- struct timespec ts;
- clock_gettime(CLOCK_MONOTONIC, &ts);
- event->key.time = ts.tv_sec * 1000 + ts.tv_nsec / 1000000;
-
- event->key.state = state;
- event->key.keyval = gdk_key;
-
- GdkKeymapKey* keys;
- gint n_keys;
- if (event->key.keyval != 0 &&
- gdk_keymap_get_entries_for_keyval(gdk_keymap_get_default(),
- event->key.keyval, &keys, &n_keys)) {
- event->key.hardware_keycode = keys[0].keycode;
- event->key.group = keys[0].group;
- g_free(keys);
- }
-
- return event;
-}
-
-void SynthesizeKeyPressEvents(GdkWindow* window,
- KeyboardCode key,
- bool control, bool shift, bool alt,
- std::vector<GdkEvent*>* events) {
- if (control)
- events->push_back(
- SynthesizeKeyEvent(window, true, GDK_Control_L, 0));
-
- if (shift) {
- events->push_back(SynthesizeKeyEvent(window, true, GDK_Shift_L,
- control ? GDK_CONTROL_MASK : 0));
- }
-
- if (alt) {
- guint state = (control ? GDK_CONTROL_MASK : 0) |
- (shift ? GDK_SHIFT_MASK : 0);
- events->push_back(
- SynthesizeKeyEvent(window, true, GDK_Alt_L, state));
- }
-
- // TODO(estade): handle other state flags besides control, shift, alt?
- // For example caps lock.
- guint state = (control ? GDK_CONTROL_MASK : 0) |
- (shift ? GDK_SHIFT_MASK : 0) |
- (alt ? GDK_MOD1_MASK : 0);
-
- guint gdk_key = GdkKeyCodeForWindowsKeyCode(key, shift);
- events->push_back(SynthesizeKeyEvent(window, true, gdk_key, state));
- events->push_back(SynthesizeKeyEvent(window, false, gdk_key, state));
-
- if (alt) {
- guint state = (control ? GDK_CONTROL_MASK : 0) |
- (shift ? GDK_SHIFT_MASK : 0) | GDK_MOD1_MASK;
- events->push_back(
- SynthesizeKeyEvent(window, false, GDK_Alt_L, state));
- }
-
- if (shift) {
- events->push_back(
- SynthesizeKeyEvent(window, false, GDK_Shift_L,
- (control ? GDK_CONTROL_MASK : 0) | GDK_SHIFT_MASK));
- }
-
- if (control) {
- events->push_back(
- SynthesizeKeyEvent(window, false, GDK_Control_L, GDK_CONTROL_MASK));
- }
-}
-
-} // namespace ui
diff --git a/ui/base/gtk/event_synthesis_gtk.h b/ui/base/gtk/event_synthesis_gtk.h
deleted file mode 100644
index 0994f9f..0000000
--- a/ui/base/gtk/event_synthesis_gtk.h
+++ /dev/null
@@ -1,38 +0,0 @@
-// Copyright (c) 2011 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.
-//
-// This file declares routines for creating fake GDK events (at the moment,
-// only keyboard events). This is useful for a variety of testing purposes.
-// NOTE: This should not be used outside of testing.
-
-#ifndef UI_BASE_GTK_EVENT_SYNTHESIS_GTK_
-#define UI_BASE_GTK_EVENT_SYNTHESIS_GTK_
-
-#include <gdk/gdk.h>
-#include <gdk/gdkkeysyms.h>
-#include <vector>
-
-#include "ui/base/ui_base_export.h"
-#include "ui/events/keycodes/keyboard_codes.h"
-
-namespace ui {
-
-// Creates and returns a key event. Passes ownership to the caller.
-UI_BASE_EXPORT GdkEvent* SynthesizeKeyEvent(GdkWindow* event_window,
- bool press,
- guint gdk_key,
- guint state);
-
-// Creates the proper sequence of key events for a key press + release.
-// Ownership of the events in the vector is passed to the caller.
-UI_BASE_EXPORT void SynthesizeKeyPressEvents(GdkWindow* window,
- KeyboardCode key,
- bool control,
- bool shift,
- bool alt,
- std::vector<GdkEvent*>* events);
-
-} // namespace ui
-
-#endif // UI_BASE_GTK_EVENT_SYNTHESIS_GTK_
diff --git a/ui/base/gtk/focus_store_gtk.cc b/ui/base/gtk/focus_store_gtk.cc
deleted file mode 100644
index 3af039d..0000000
--- a/ui/base/gtk/focus_store_gtk.cc
+++ /dev/null
@@ -1,55 +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/base/gtk/focus_store_gtk.h"
-
-#include <gtk/gtk.h>
-
-namespace ui {
-
-FocusStoreGtk::FocusStoreGtk()
- : widget_(NULL),
- destroy_handler_id_(0) {
-}
-
-FocusStoreGtk::~FocusStoreGtk() {
- DisconnectDestroyHandler();
-}
-
-void FocusStoreGtk::Store(GtkWidget* widget) {
- GtkWidget* focus_widget = NULL;
- if (widget) {
- // A detached widget won't have a toplevel window as an ancestor, so we
- // can't assume that the query for toplevel will return a window.
- GtkWidget* toplevel = gtk_widget_get_ancestor(widget, GTK_TYPE_WINDOW);
- GtkWindow* window = GTK_IS_WINDOW(toplevel) ? GTK_WINDOW(toplevel) : NULL;
- if (window)
- focus_widget = gtk_window_get_focus(window);
- }
-
- SetWidget(focus_widget);
-}
-
-void FocusStoreGtk::SetWidget(GtkWidget* widget) {
- DisconnectDestroyHandler();
-
- // We don't add a ref. The signal handler below effectively gives us a weak
- // reference.
- widget_ = widget;
- if (widget_) {
- // When invoked, |gtk_widget_destroyed| will set |widget_| to NULL.
- destroy_handler_id_ = g_signal_connect(widget_, "destroy",
- G_CALLBACK(gtk_widget_destroyed),
- &widget_);
- }
-}
-
-void FocusStoreGtk::DisconnectDestroyHandler() {
- if (widget_) {
- g_signal_handler_disconnect(widget_, destroy_handler_id_);
- widget_ = NULL;
- }
-}
-
-} // namespace ui
diff --git a/ui/base/gtk/focus_store_gtk.h b/ui/base/gtk/focus_store_gtk.h
deleted file mode 100644
index 3274c01..0000000
--- a/ui/base/gtk/focus_store_gtk.h
+++ /dev/null
@@ -1,46 +0,0 @@
-// Copyright (c) 2011 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_BASE_GTK_FOCUS_STORE_GTK_H_
-#define UI_BASE_GTK_FOCUS_STORE_GTK_H_
-
-#include "base/basictypes.h"
-#include "ui/base/ui_base_export.h"
-
-typedef struct _GtkWidget GtkWidget;
-
-namespace ui {
-
-class UI_BASE_EXPORT FocusStoreGtk {
- public:
- FocusStoreGtk();
- ~FocusStoreGtk();
-
- GtkWidget* widget() const { return widget_; }
-
- // Save the widget that is currently focused for |widget|'s toplevel (NOT
- // |widget|).
- void Store(GtkWidget* widget);
-
- // Save |widget| as the focus widget. Call with NULL to clear |widget_|.
- void SetWidget(GtkWidget* widget);
-
- private:
- // Disconnect the previous destroy handler (if any).
- void DisconnectDestroyHandler();
-
- // The widget which last had focus.
- GtkWidget* widget_;
-
- // The widget for which we've stored focus might be destroyed by the time we
- // want to restore focus. Thus we connect to the "destroy" signal on that
- // widget. This is the ID for the destroy handler.
- unsigned int destroy_handler_id_;
-
- DISALLOW_COPY_AND_ASSIGN(FocusStoreGtk);
-};
-
-} // namespace ui
-
-#endif // UI_BASE_GTK_FOCUS_STORE_GTK_H_
diff --git a/ui/base/gtk/g_object_destructor_filo.cc b/ui/base/gtk/g_object_destructor_filo.cc
deleted file mode 100644
index fe253c7..0000000
--- a/ui/base/gtk/g_object_destructor_filo.cc
+++ /dev/null
@@ -1,89 +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/base/gtk/g_object_destructor_filo.h"
-
-#include <glib-object.h>
-
-#include "base/logging.h"
-#include "base/memory/singleton.h"
-
-namespace ui {
-
-GObjectDestructorFILO::GObjectDestructorFILO() {
-}
-
-GObjectDestructorFILO::~GObjectDestructorFILO() {
- // Probably CHECK(handler_map_.empty()) would look natural here. But
- // some tests (some views_unittests) violate this assertion.
-}
-
-// static
-GObjectDestructorFILO* GObjectDestructorFILO::GetInstance() {
- return Singleton<GObjectDestructorFILO>::get();
-}
-
-void GObjectDestructorFILO::Connect(
- GObject* object, DestructorHook callback, void* context) {
- const Hook hook(object, callback, context);
- HandlerMap::iterator iter = handler_map_.find(object);
- if (iter == handler_map_.end()) {
- g_object_weak_ref(object, WeakNotifyThunk, this);
- handler_map_[object].push_front(hook);
- } else {
- iter->second.push_front(hook);
- }
-}
-
-void GObjectDestructorFILO::Disconnect(
- GObject* object, DestructorHook callback, void* context) {
- HandlerMap::iterator iter = handler_map_.find(object);
- if (iter == handler_map_.end()) {
- LOG(DFATAL) << "Unable to disconnect destructor hook for object " << object
- << ": hook not found (" << callback << ", " << context << ").";
- return;
- }
- HandlerList& dtors = iter->second;
- if (dtors.empty()) {
- LOG(DFATAL) << "Destructor list is empty for specified object " << object
- << " Maybe it is being executed?";
- return;
- }
- if (!dtors.front().equal(object, callback, context)) {
- // Reenable this warning once this bug is fixed:
- // http://code.google.com/p/chromium/issues/detail?id=85603
- DVLOG(1) << "Destructors should be unregistered the reverse order they "
- << "were registered. But for object " << object << " "
- << "deleted hook is "<< context << ", the last queued hook is "
- << dtors.front().context;
- }
- for (HandlerList::iterator i = dtors.begin(); i != dtors.end(); ++i) {
- if (i->equal(object, callback, context)) {
- dtors.erase(i);
- break;
- }
- }
- if (dtors.empty()) {
- g_object_weak_unref(object, WeakNotifyThunk, this);
- handler_map_.erase(iter);
- }
-}
-
-void GObjectDestructorFILO::WeakNotify(GObject* where_the_object_was) {
- HandlerMap::iterator iter = handler_map_.find(where_the_object_was);
- DCHECK(iter != handler_map_.end());
- DCHECK(!iter->second.empty());
-
- // Save destructor list for given object into local copy to avoid reentrancy
- // problem: if callee wants to modify the caller list.
- HandlerList dtors;
- iter->second.swap(dtors);
- handler_map_.erase(iter);
-
- // Execute hooks in local list in FILO order.
- for (HandlerList::iterator i = dtors.begin(); i != dtors.end(); ++i)
- i->callback(i->context, where_the_object_was);
-}
-
-} // napespace ui
diff --git a/ui/base/gtk/g_object_destructor_filo.h b/ui/base/gtk/g_object_destructor_filo.h
deleted file mode 100644
index 14c9e5f..0000000
--- a/ui/base/gtk/g_object_destructor_filo.h
+++ /dev/null
@@ -1,91 +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 UI_BASE_GTK_G_OBJECT_DESTRUCTOR_FILO_H_
-#define UI_BASE_GTK_G_OBJECT_DESTRUCTOR_FILO_H_
-
-#include <glib.h>
-#include <list>
-#include <map>
-
-#include "base/basictypes.h"
-#include "ui/base/ui_base_export.h"
-
-template <typename T> struct DefaultSingletonTraits;
-
-typedef struct _GObject GObject;
-
-namespace ui {
-
-// This class hooks calls to g_object_weak_ref()/unref() and executes them in
-// FILO order. This is important if there are several hooks to the single object
-// (set up at different levels of class hierarchy) and the lowest hook (set up
-// first) is deleting self - it must be called last (among hooks for the given
-// object). Unfortunately Glib does not provide this guarantee.
-//
-// Use it as follows:
-//
-// static void OnDestroyedThunk(gpointer data, GObject *where_the_object_was) {
-// reinterpret_cast<MyClass*>(data)->OnDestroyed(where_the_object_was);
-// }
-// void MyClass::OnDestroyed(GObject *where_the_object_was) {
-// destroyed_ = true;
-// delete this;
-// }
-// MyClass::Init() {
-// ...
-// ui::GObjectDestructorFILO::GetInstance()->Connect(
-// G_OBJECT(my_widget), &OnDestroyedThunk, this);
-// }
-// MyClass::~MyClass() {
-// if (!destroyed_) {
-// ui::GObjectDestructorFILO::GetInstance()->Disconnect(
-// G_OBJECT(my_widget), &OnDestroyedThunk, this);
-// }
-// }
-//
-// TODO(glotov): Probably worth adding ScopedGObjectDtor<T>.
-//
-// This class is a singleton. Not thread safe. Must be called within UI thread.
-class UI_BASE_EXPORT GObjectDestructorFILO {
- public:
- typedef void (*DestructorHook)(void* context, GObject* where_the_object_was);
-
- static GObjectDestructorFILO* GetInstance();
- void Connect(GObject* object, DestructorHook callback, void* context);
- void Disconnect(GObject* object, DestructorHook callback, void* context);
-
- private:
- struct Hook {
- Hook(GObject* o, DestructorHook cb, void* ctx)
- : object(o), callback(cb), context(ctx) {
- }
- bool equal(GObject* o, DestructorHook cb, void* ctx) const {
- return object == o && callback == cb && context == ctx;
- }
- GObject* object;
- DestructorHook callback;
- void* context;
- };
- typedef std::list<Hook> HandlerList;
- typedef std::map<GObject*, HandlerList> HandlerMap;
-
- GObjectDestructorFILO();
- ~GObjectDestructorFILO();
- friend struct DefaultSingletonTraits<GObjectDestructorFILO>;
-
- void WeakNotify(GObject* where_the_object_was);
- static void WeakNotifyThunk(gpointer data, GObject* where_the_object_was) {
- reinterpret_cast<GObjectDestructorFILO*>(data)->WeakNotify(
- where_the_object_was);
- }
-
- HandlerMap handler_map_;
-
- DISALLOW_COPY_AND_ASSIGN(GObjectDestructorFILO);
-};
-
-} // namespace ui
-
-#endif // UI_BASE_GTK_G_OBJECT_DESTRUCTOR_FILO_H_
diff --git a/ui/base/gtk/gtk_expanded_container.cc b/ui/base/gtk/gtk_expanded_container.cc
deleted file mode 100644
index 6b39821..0000000
--- a/ui/base/gtk/gtk_expanded_container.cc
+++ /dev/null
@@ -1,195 +0,0 @@
-// Copyright (c) 2011 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/base/gtk/gtk_expanded_container.h"
-
-#include <gtk/gtk.h>
-
-#include <algorithm>
-
-#include "ui/gfx/gtk_compat.h"
-
-namespace {
-
-enum {
- CHILD_SIZE_REQUEST,
- LAST_SIGNAL
-};
-
-guint expanded_container_signals[LAST_SIGNAL] = { 0 };
-
-struct SizeAllocateData {
- GtkWidget* container;
- GtkAllocation* allocation;
- int border_width;
-};
-
-void GetChildPosition(GtkWidget* container, GtkWidget* child, int* x, int* y) {
- GValue v = { 0 };
- g_value_init(&v, G_TYPE_INT);
- gtk_container_child_get_property(GTK_CONTAINER(container), child, "x", &v);
- *x = g_value_get_int(&v);
- gtk_container_child_get_property(GTK_CONTAINER(container), child, "y", &v);
- *y = g_value_get_int(&v);
- g_value_unset(&v);
-}
-
-void ChildSizeAllocate(GtkWidget* child, gpointer userdata) {
- if (!gtk_widget_get_visible(child))
- return;
-
- SizeAllocateData* data = reinterpret_cast<SizeAllocateData*>(userdata);
-
- GtkRequisition child_requisition;
- child_requisition.width = data->allocation->width - data->border_width * 2;
- child_requisition.height = data->allocation->height - data->border_width * 2;
-
- // We need to give whoever is pulling our strings a chance to adjust the
- // size of our children.
- g_signal_emit(data->container,
- expanded_container_signals[CHILD_SIZE_REQUEST], 0,
- child, &child_requisition);
-
- GtkAllocation child_allocation;
- child_allocation.width = child_requisition.width;
- child_allocation.height = child_requisition.height;
- if (child_allocation.width < 0 || child_allocation.height < 0) {
- gtk_widget_get_child_requisition(child, &child_requisition);
- if (child_allocation.width < 0)
- child_allocation.width = child_requisition.width;
- if (child_allocation.height < 0)
- child_allocation.height = child_requisition.height;
- }
-
- int x, y;
- GetChildPosition(data->container, child, &x, &y);
-
- child_allocation.x = x + data->border_width;
- child_allocation.y = y + data->border_width;
-
- if (!gtk_widget_get_has_window(data->container)) {
- child_allocation.x += data->allocation->x;
- child_allocation.y += data->allocation->y;
- }
- gtk_widget_size_allocate(child, &child_allocation);
-}
-
-void Marshal_VOID__OBJECT_BOXED(GClosure* closure,
- GValue* return_value G_GNUC_UNUSED,
- guint n_param_values,
- const GValue* param_values,
- gpointer invocation_hint G_GNUC_UNUSED,
- gpointer marshal_data) {
- typedef void (*GMarshalFunc_VOID__OBJECT_BOXED) (gpointer data1,
- gpointer arg_1,
- gpointer arg_2,
- gpointer data2);
- register GMarshalFunc_VOID__OBJECT_BOXED callback;
- register GCClosure *cc = reinterpret_cast<GCClosure*>(closure);
- register gpointer data1, data2;
-
- g_return_if_fail(n_param_values == 3);
-
- if (G_CCLOSURE_SWAP_DATA(closure)) {
- data1 = closure->data;
- data2 = g_value_peek_pointer(param_values + 0);
- } else {
- data1 = g_value_peek_pointer(param_values + 0);
- data2 = closure->data;
- }
-
- callback = reinterpret_cast<GMarshalFunc_VOID__OBJECT_BOXED>(
- marshal_data ? marshal_data : cc->callback);
-
- callback(data1,
- g_value_get_object(param_values + 1),
- g_value_get_boxed(param_values + 2),
- data2);
-}
-
-} // namespace
-
-G_BEGIN_DECLS
-
-static void gtk_expanded_container_size_allocate(GtkWidget* widget,
- GtkAllocation* allocation);
-
-G_DEFINE_TYPE(GtkExpandedContainer, gtk_expanded_container, GTK_TYPE_FIXED)
-
-static void gtk_expanded_container_class_init(
- GtkExpandedContainerClass *klass) {
- GtkObjectClass* object_class =
- reinterpret_cast<GtkObjectClass*>(klass);
-
- GtkWidgetClass* widget_class =
- reinterpret_cast<GtkWidgetClass*>(klass);
- widget_class->size_allocate = gtk_expanded_container_size_allocate;
-
- expanded_container_signals[CHILD_SIZE_REQUEST] =
- g_signal_new("child-size-request",
- G_OBJECT_CLASS_TYPE(object_class),
- static_cast<GSignalFlags>(G_SIGNAL_RUN_FIRST),
- 0,
- NULL, NULL,
- Marshal_VOID__OBJECT_BOXED,
- G_TYPE_NONE, 2,
- GTK_TYPE_WIDGET,
- GTK_TYPE_REQUISITION | G_SIGNAL_TYPE_STATIC_SCOPE);
-}
-
-static void gtk_expanded_container_init(GtkExpandedContainer* container) {
-}
-
-static void gtk_expanded_container_size_allocate(GtkWidget* widget,
- GtkAllocation* allocation) {
- gtk_widget_set_allocation(widget, allocation);
-
- if (gtk_widget_get_has_window(widget) && gtk_widget_get_realized(widget)) {
- gdk_window_move_resize(gtk_widget_get_window(widget),
- allocation->x,
- allocation->y,
- allocation->width,
- allocation->height);
- }
-
- SizeAllocateData data;
- data.container = widget;
- data.allocation = allocation;
- data.border_width = gtk_container_get_border_width(GTK_CONTAINER(widget));
-
- gtk_container_foreach(GTK_CONTAINER(widget), ChildSizeAllocate, &data);
-}
-
-GtkWidget* gtk_expanded_container_new() {
- return GTK_WIDGET(g_object_new(GTK_TYPE_EXPANDED_CONTAINER, NULL));
-}
-
-void gtk_expanded_container_put(GtkExpandedContainer* container,
- GtkWidget* widget, gint x, gint y) {
- g_return_if_fail(GTK_IS_EXPANDED_CONTAINER(container));
- g_return_if_fail(GTK_IS_WIDGET(widget));
- gtk_fixed_put(GTK_FIXED(container), widget, x, y);
-}
-
-void gtk_expanded_container_move(GtkExpandedContainer* container,
- GtkWidget* widget, gint x, gint y) {
- g_return_if_fail(GTK_IS_EXPANDED_CONTAINER(container));
- g_return_if_fail(GTK_IS_WIDGET(widget));
- gtk_fixed_move(GTK_FIXED(container), widget, x, y);
-}
-
-void gtk_expanded_container_set_has_window(GtkExpandedContainer* container,
- gboolean has_window) {
- g_return_if_fail(GTK_IS_EXPANDED_CONTAINER(container));
- g_return_if_fail(!gtk_widget_get_realized(GTK_WIDGET(container)));
- gtk_widget_set_has_window(GTK_WIDGET(container), has_window);
-}
-
-gboolean gtk_expanded_container_get_has_window(
- GtkExpandedContainer* container) {
- g_return_val_if_fail(GTK_IS_EXPANDED_CONTAINER(container), FALSE);
- return gtk_widget_get_has_window(GTK_WIDGET(container));
-}
-
-G_END_DECLS
diff --git a/ui/base/gtk/gtk_expanded_container.h b/ui/base/gtk/gtk_expanded_container.h
deleted file mode 100644
index c136151..0000000
--- a/ui/base/gtk/gtk_expanded_container.h
+++ /dev/null
@@ -1,78 +0,0 @@
-// Copyright (c) 2011 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_BASE_GTK_GTK_EXPANDED_CONTAINER_H_
-#define UI_BASE_GTK_GTK_EXPANDED_CONTAINER_H_
-
-#include <gdk/gdk.h>
-#include <gtk/gtk.h>
-
-#include "ui/base/ui_base_export.h"
-
-// A specialized container derived from GtkFixed, which expands the size of its
-// children to fill the container, in one or both directions. The usage of this
-// container is similar to GtkFixed.
-//
-// The "child-size-request" signal is optional, if you want to expand child
-// widgets to customized size other than the container's size. It should have
-// the following signature:
-//
-// void (*child_size_request)(GtkExpandedContainer* container,
-// GtkWidget* child,
-// GtkRequisition* requisition);
-//
-// This signal is emitted for each child with the requisition set to the size of
-// the container. Your handler may adjust the value of the requisition. If the
-// width or height is set to -1, then that direction will not be expanded, and
-// the original size request of the child will be used.
-
-G_BEGIN_DECLS
-
-#define GTK_TYPE_EXPANDED_CONTAINER \
- (gtk_expanded_container_get_type())
-#define GTK_EXPANDED_CONTAINER(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST((obj), GTK_TYPE_EXPANDED_CONTAINER, \
- GtkExpandedContainer))
-#define GTK_EXPANDED_CONTAINER_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST((klass), GTK_TYPE_EXPANDED_CONTAINER, \
- GtkExpandedContainerClass))
-#define GTK_IS_EXPANDED_CONTAINER(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE((obj), GTK_TYPE_EXPANDED_CONTAINER))
-#define GTK_IS_EXPANDED_CONTAINER_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_TYPE((klass), GTK_TYPE_EXPANDED_CONTAINER))
-#define GTK_EXPANDED_CONTAINER_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS((obj), GTK_TYPE_EXPANDED_CONTAINER, \
- GtkExpandedContainerClass))
-
-typedef struct _GtkExpandedContainer GtkExpandedContainer;
-typedef struct _GtkExpandedContainerClass GtkExpandedContainerClass;
-
-struct _GtkExpandedContainer {
- // Parent class.
- GtkFixed fixed;
-};
-
-struct _GtkExpandedContainerClass {
- GtkFixedClass parent_class;
-};
-
-UI_BASE_EXPORT GType gtk_expanded_container_get_type() G_GNUC_CONST;
-UI_BASE_EXPORT GtkWidget* gtk_expanded_container_new();
-UI_BASE_EXPORT void gtk_expanded_container_put(GtkExpandedContainer* container,
- GtkWidget* widget,
- gint x,
- gint y);
-UI_BASE_EXPORT void gtk_expanded_container_move(GtkExpandedContainer* container,
- GtkWidget* widget,
- gint x,
- gint y);
-UI_BASE_EXPORT void gtk_expanded_container_set_has_window(
- GtkExpandedContainer* container,
- gboolean has_window);
-UI_BASE_EXPORT gboolean gtk_expanded_container_get_has_window(
- GtkExpandedContainer* container);
-
-G_END_DECLS
-
-#endif // UI_BASE_GTK_GTK_EXPANDED_CONTAINER_H_
diff --git a/ui/base/gtk/gtk_expanded_container_unittest.cc b/ui/base/gtk/gtk_expanded_container_unittest.cc
deleted file mode 100644
index 532e58e..0000000
--- a/ui/base/gtk/gtk_expanded_container_unittest.cc
+++ /dev/null
@@ -1,164 +0,0 @@
-// Copyright (c) 2011 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/base/gtk/gtk_expanded_container.h"
-
-#include "testing/gtest/include/gtest/gtest.h"
-
-#define EXPECT_ALLOCATION_EQ(widget, x_, y_, width_, height_) \
-do { \
- GtkAllocation allocation; \
- gtk_widget_get_allocation(widget, &allocation); \
- EXPECT_EQ(x_, allocation.x); \
- EXPECT_EQ(y_, allocation.y); \
- EXPECT_EQ(width_, allocation.width); \
- EXPECT_EQ(height_, allocation.height); \
-} while(0);
-
-#define EXPECT_ALLOCATION_PARAM_EQ(widget, param, value) \
-do { \
- GtkAllocation allocation; \
- gtk_widget_get_allocation(widget, &allocation); \
- EXPECT_EQ(value,allocation.param); \
-} while(0);
-
-class GtkExpandedContainerTest : public testing::Test {
- protected:
- GtkExpandedContainerTest()
- : window_(gtk_window_new(GTK_WINDOW_TOPLEVEL)),
- expanded_(gtk_expanded_container_new()) {
- gtk_window_set_default_size(GTK_WINDOW(window_), 200, 200);
- gtk_container_add(GTK_CONTAINER(window_), expanded_);
- }
- virtual ~GtkExpandedContainerTest() {
- gtk_widget_destroy(window_);
- }
-
- bool FindChild(GtkWidget* widget) {
- GList* children = gtk_container_get_children(GTK_CONTAINER(expanded_));
- for (GList* child = children; child; child = child->next) {
- if (GTK_WIDGET(child->data) == widget) {
- g_list_free(children);
- return true;
- }
- }
- g_list_free(children);
- return false;
- }
-
- int GetChildX(GtkWidget* widget) {
- GValue x = { 0 };
- g_value_init(&x, G_TYPE_INT);
- gtk_container_child_get_property(GTK_CONTAINER(expanded_), widget, "x", &x);
- return g_value_get_int(&x);
- }
-
- int GetChildY(GtkWidget* widget) {
- GValue y = { 0 };
- g_value_init(&y, G_TYPE_INT);
- gtk_container_child_get_property(GTK_CONTAINER(expanded_), widget, "y", &y);
- return g_value_get_int(&y);
- }
-
- protected:
- GtkWidget* window_;
- GtkWidget* expanded_;
-};
-
-TEST_F(GtkExpandedContainerTest, AddRemove) {
- GtkWidget* child1 = gtk_fixed_new();
- GtkWidget* child2 = gtk_fixed_new();
- gtk_container_add(GTK_CONTAINER(expanded_), child1);
- ASSERT_TRUE(FindChild(child1));
-
- gtk_container_add(GTK_CONTAINER(expanded_), child2);
- ASSERT_TRUE(FindChild(child2));
- ASSERT_TRUE(FindChild(child1));
-
- gtk_container_remove(GTK_CONTAINER(expanded_), child1);
- ASSERT_FALSE(FindChild(child1));
- ASSERT_TRUE(FindChild(child2));
-
- gtk_container_remove(GTK_CONTAINER(expanded_), child2);
- ASSERT_FALSE(FindChild(child2));
-}
-
-TEST_F(GtkExpandedContainerTest, Expand) {
- GtkWidget* child1 = gtk_fixed_new();
- GtkWidget* child2 = gtk_fixed_new();
- gtk_container_add(GTK_CONTAINER(expanded_), child1);
- gtk_expanded_container_put(GTK_EXPANDED_CONTAINER(expanded_),
- child2, 10, 20);
- gtk_widget_show_all(window_);
-
- GtkAllocation allocation = { 0, 0, 50, 100 };
- gtk_widget_size_allocate(expanded_, &allocation);
-
- EXPECT_ALLOCATION_EQ(child1, 0, 0, 50, 100);
-
- EXPECT_ALLOCATION_EQ(child2, 10, 20, 50, 100);
-
- allocation.x = 10;
- allocation.y = 20;
- gtk_widget_size_allocate(expanded_, &allocation);
-
- EXPECT_ALLOCATION_PARAM_EQ(child1, x, 10);
- EXPECT_ALLOCATION_PARAM_EQ(child1, y, 20);
- EXPECT_ALLOCATION_PARAM_EQ(child2, x, 20);
- EXPECT_ALLOCATION_PARAM_EQ(child2, y, 40);
-}
-
-// Test if the size allocation for children still works when using own
-// GdkWindow. In this case, the children's origin starts from (0, 0) rather
-// than the container's origin.
-TEST_F(GtkExpandedContainerTest, HasWindow) {
- GtkWidget* child = gtk_fixed_new();
- gtk_container_add(GTK_CONTAINER(expanded_), child);
- gtk_expanded_container_set_has_window(GTK_EXPANDED_CONTAINER(expanded_),
- TRUE);
- gtk_widget_show_all(window_);
-
- GtkAllocation allocation = { 10, 10, 50, 100 };
- gtk_widget_size_allocate(expanded_, &allocation);
-
- EXPECT_ALLOCATION_EQ(child, 0, 0, 50, 100);
-}
-
-static void OnChildSizeRequest(GtkExpandedContainer* container,
- GtkWidget* child,
- GtkRequisition* requisition,
- gpointer userdata) {
- ASSERT_EQ(child, GTK_WIDGET(userdata));
- requisition->width = 250;
- requisition->height = -1;
-}
-
-TEST_F(GtkExpandedContainerTest, ChildSizeRequest) {
- GtkWidget* child = gtk_fixed_new();
- gtk_widget_set_size_request(child, 10, 25);
- g_signal_connect(expanded_, "child-size-request",
- G_CALLBACK(OnChildSizeRequest), child);
- gtk_container_add(GTK_CONTAINER(expanded_), child);
- gtk_widget_show_all(window_);
-
- GtkAllocation allocation = { 0, 0, 300, 100 };
- gtk_widget_size_allocate(expanded_, &allocation);
-
- EXPECT_ALLOCATION_EQ(child, 0, 0, 250, 25);
-}
-
-TEST_F(GtkExpandedContainerTest, ChildPosition) {
- GtkWidget* child = gtk_fixed_new();
- gtk_expanded_container_put(GTK_EXPANDED_CONTAINER(expanded_),
- child, 10, 20);
- gtk_widget_show_all(window_);
-
- EXPECT_EQ(10, GetChildX(child));
- EXPECT_EQ(20, GetChildY(child));
-
- gtk_expanded_container_move(GTK_EXPANDED_CONTAINER(expanded_),
- child, 40, 50);
- EXPECT_EQ(40, GetChildX(child));
- EXPECT_EQ(50, GetChildY(child));
-}
diff --git a/ui/base/gtk/gtk_floating_container.cc b/ui/base/gtk/gtk_floating_container.cc
deleted file mode 100644
index 6893746..0000000
--- a/ui/base/gtk/gtk_floating_container.cc
+++ /dev/null
@@ -1,322 +0,0 @@
-// Copyright (c) 2011 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/base/gtk/gtk_floating_container.h"
-
-#include <gtk/gtk.h>
-
-#include <algorithm>
-
-#include "ui/gfx/gtk_compat.h"
-
-namespace {
-
-enum {
- SET_FLOATING_POSITION,
- LAST_SIGNAL
-};
-
-enum {
- CHILD_PROP_0,
- CHILD_PROP_X,
- CHILD_PROP_Y
-};
-
-// Returns the GtkFloatingContainerChild associated with |widget| (or NULL if
-// |widget| not found).
-GtkFloatingContainerChild* GetChild(GtkFloatingContainer* container,
- GtkWidget* widget) {
- for (GList* floating_children = container->floating_children;
- floating_children; floating_children = g_list_next(floating_children)) {
- GtkFloatingContainerChild* child =
- reinterpret_cast<GtkFloatingContainerChild*>(floating_children->data);
-
- if (child->widget == widget)
- return child;
- }
-
- return NULL;
-}
-
-const GParamFlags kStaticReadWriteProp = static_cast<GParamFlags>(
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
-
-} // namespace
-
-G_BEGIN_DECLS
-
-static void gtk_floating_container_remove(GtkContainer* container,
- GtkWidget* widget);
-static void gtk_floating_container_forall(GtkContainer* container,
- gboolean include_internals,
- GtkCallback callback,
- gpointer callback_data);
-static void gtk_floating_container_size_request(GtkWidget* widget,
- GtkRequisition* requisition);
-static void gtk_floating_container_size_allocate(GtkWidget* widget,
- GtkAllocation* allocation);
-static void gtk_floating_container_set_child_property(GtkContainer* container,
- GtkWidget* child,
- guint property_id,
- const GValue* value,
- GParamSpec* pspec);
-static void gtk_floating_container_get_child_property(GtkContainer* container,
- GtkWidget* child,
- guint property_id,
- GValue* value,
- GParamSpec* pspec);
-
-static guint floating_container_signals[LAST_SIGNAL] = { 0 };
-
-G_DEFINE_TYPE(GtkFloatingContainer, gtk_floating_container, GTK_TYPE_BIN)
-
-static void gtk_floating_container_class_init(
- GtkFloatingContainerClass *klass) {
- GtkObjectClass* object_class =
- reinterpret_cast<GtkObjectClass*>(klass);
-
- GtkWidgetClass* widget_class =
- reinterpret_cast<GtkWidgetClass*>(klass);
- widget_class->size_request = gtk_floating_container_size_request;
- widget_class->size_allocate = gtk_floating_container_size_allocate;
-
- GtkContainerClass* container_class =
- reinterpret_cast<GtkContainerClass*>(klass);
- container_class->remove = gtk_floating_container_remove;
- container_class->forall = gtk_floating_container_forall;
-
- container_class->set_child_property =
- gtk_floating_container_set_child_property;
- container_class->get_child_property =
- gtk_floating_container_get_child_property;
-
- gtk_container_class_install_child_property(
- container_class,
- CHILD_PROP_X,
- g_param_spec_int("x",
- "X position",
- "X position of child widget",
- G_MININT,
- G_MAXINT,
- 0,
- kStaticReadWriteProp));
-
- gtk_container_class_install_child_property(
- container_class,
- CHILD_PROP_Y,
- g_param_spec_int("y",
- "Y position",
- "Y position of child widget",
- G_MININT,
- G_MAXINT,
- 0,
- kStaticReadWriteProp));
-
- floating_container_signals[SET_FLOATING_POSITION] =
- g_signal_new("set-floating-position",
- G_OBJECT_CLASS_TYPE(object_class),
- static_cast<GSignalFlags>(G_SIGNAL_RUN_FIRST |
- G_SIGNAL_ACTION),
- 0,
- NULL, NULL,
- g_cclosure_marshal_VOID__BOXED,
- G_TYPE_NONE, 1,
- GDK_TYPE_RECTANGLE | G_SIGNAL_TYPE_STATIC_SCOPE);
-}
-
-static void gtk_floating_container_init(GtkFloatingContainer* container) {
- gtk_widget_set_has_window(GTK_WIDGET(container), FALSE);
- container->floating_children = NULL;
-}
-
-static void gtk_floating_container_remove(GtkContainer* container,
- GtkWidget* widget) {
- g_return_if_fail(GTK_IS_WIDGET(widget));
-
- GtkBin* bin = GTK_BIN(container);
- if (gtk_bin_get_child(bin) == widget) {
- ((GTK_CONTAINER_CLASS(gtk_floating_container_parent_class))->remove)
- (container, widget);
- } else {
- // Handle the other case where it's in our |floating_children| list.
- GtkFloatingContainer* floating = GTK_FLOATING_CONTAINER(container);
- GList* children = floating->floating_children;
- gboolean removed_child = false;
- while (children) {
- GtkFloatingContainerChild* child =
- reinterpret_cast<GtkFloatingContainerChild*>(children->data);
-
- if (child->widget == widget) {
- removed_child = true;
- gboolean was_visible = gtk_widget_get_visible(GTK_WIDGET(widget));
-
- gtk_widget_unparent(widget);
-
- floating->floating_children =
- g_list_remove_link(floating->floating_children, children);
- g_list_free(children);
- g_free(child);
-
- if (was_visible && gtk_widget_get_visible(GTK_WIDGET(container)))
- gtk_widget_queue_resize(GTK_WIDGET(container));
-
- break;
- }
- children = children->next;
- }
-
- g_return_if_fail(removed_child);
- }
-}
-
-static void gtk_floating_container_forall(GtkContainer* container,
- gboolean include_internals,
- GtkCallback callback,
- gpointer callback_data) {
- g_return_if_fail(container != NULL);
- g_return_if_fail(callback != NULL);
-
- GtkFloatingContainer* floating = GTK_FLOATING_CONTAINER(container);
- GList* children = floating->floating_children;
- while (children) {
- GtkFloatingContainerChild* child =
- reinterpret_cast<GtkFloatingContainerChild*>(children->data);
- children = children->next;
-
- (*callback)(child->widget, callback_data);
- }
-
- // Let GtkBin do its part of the forall.
- ((GTK_CONTAINER_CLASS(gtk_floating_container_parent_class))->forall)
- (container, include_internals, callback, callback_data);
-}
-
-static void gtk_floating_container_size_request(GtkWidget* widget,
- GtkRequisition* requisition) {
- GtkBin* bin = GTK_BIN(widget);
- if (bin && gtk_bin_get_child(bin)) {
- gtk_widget_size_request(gtk_bin_get_child(bin), requisition);
- } else {
- requisition->width = 0;
- requisition->height = 0;
- }
-}
-
-static void gtk_floating_container_size_allocate(GtkWidget* widget,
- GtkAllocation* allocation) {
- gtk_widget_set_allocation(widget, allocation);
-
- if (gtk_widget_get_has_window(widget) && gtk_widget_get_realized(widget)) {
- gdk_window_move_resize(gtk_widget_get_window(widget),
- allocation->x,
- allocation->y,
- allocation->width,
- allocation->height);
- }
-
- // Give the same allocation to our GtkBin component.
- GtkBin* bin = GTK_BIN(widget);
- if (gtk_bin_get_child(bin)) {
- gtk_widget_size_allocate(gtk_bin_get_child(bin), allocation);
- }
-
- // We need to give whoever is pulling our strings a chance to set the "x" and
- // "y" properties on all of our children.
- g_signal_emit(widget, floating_container_signals[SET_FLOATING_POSITION], 0,
- allocation);
-
- // Our allocation has been set. We've asked our controller to place the other
- // widgets. Pass out allocations to all our children based on where they want
- // to be.
- GtkFloatingContainer* container = GTK_FLOATING_CONTAINER(widget);
- GList* children = container->floating_children;
- GtkAllocation child_allocation;
- GtkRequisition child_requisition;
- while (children) {
- GtkFloatingContainerChild* child =
- reinterpret_cast<GtkFloatingContainerChild*>(children->data);
- children = children->next;
-
- if (gtk_widget_get_visible(GTK_WIDGET(child->widget))) {
- gtk_widget_size_request(child->widget, &child_requisition);
- child_allocation.x = allocation->x + child->x;
- child_allocation.y = allocation->y + child->y;
- child_allocation.width = std::max(1, std::min(child_requisition.width,
- allocation->width));
- child_allocation.height = std::max(1, std::min(child_requisition.height,
- allocation->height));
- gtk_widget_size_allocate(child->widget, &child_allocation);
- }
- }
-}
-
-static void gtk_floating_container_set_child_property(GtkContainer* container,
- GtkWidget* child,
- guint property_id,
- const GValue* value,
- GParamSpec* pspec) {
- GtkFloatingContainerChild* floating_child =
- GetChild(GTK_FLOATING_CONTAINER(container), child);
- g_return_if_fail(floating_child);
-
- switch (property_id) {
- case CHILD_PROP_X:
- floating_child->x = g_value_get_int(value);
- gtk_widget_child_notify(child, "x");
- break;
- case CHILD_PROP_Y:
- floating_child->y = g_value_get_int(value);
- gtk_widget_child_notify(child, "y");
- break;
- default:
- GTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID(
- container, property_id, pspec);
- break;
- };
-}
-
-static void gtk_floating_container_get_child_property(GtkContainer* container,
- GtkWidget* child,
- guint property_id,
- GValue* value,
- GParamSpec* pspec) {
- GtkFloatingContainerChild* floating_child =
- GetChild(GTK_FLOATING_CONTAINER(container), child);
- g_return_if_fail(floating_child);
-
- switch (property_id) {
- case CHILD_PROP_X:
- g_value_set_int(value, floating_child->x);
- break;
- case CHILD_PROP_Y:
- g_value_set_int(value, floating_child->y);
- break;
- default:
- GTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID(
- container, property_id, pspec);
- break;
- };
-}
-
-GtkWidget* gtk_floating_container_new() {
- return GTK_WIDGET(g_object_new(GTK_TYPE_FLOATING_CONTAINER, NULL));
-}
-
-void gtk_floating_container_add_floating(GtkFloatingContainer* container,
- GtkWidget* widget) {
- g_return_if_fail(GTK_IS_FLOATING_CONTAINER(container));
- g_return_if_fail(GTK_IS_WIDGET(widget));
-
- GtkFloatingContainerChild* child_info = g_new(GtkFloatingContainerChild, 1);
- child_info->widget = widget;
- child_info->x = 0;
- child_info->y = 0;
-
- gtk_widget_set_parent(widget, GTK_WIDGET(container));
-
- container->floating_children =
- g_list_append(container->floating_children, child_info);
-}
-
-G_END_DECLS
diff --git a/ui/base/gtk/gtk_floating_container.h b/ui/base/gtk/gtk_floating_container.h
deleted file mode 100644
index 0d91a83..0000000
--- a/ui/base/gtk/gtk_floating_container.h
+++ /dev/null
@@ -1,89 +0,0 @@
-// Copyright (c) 2011 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_BASE_GTK_GTK_FLOATING_CONTAINER_H_
-#define UI_BASE_GTK_GTK_FLOATING_CONTAINER_H_
-
-#include <gdk/gdk.h>
-#include <gtk/gtk.h>
-
-#include "ui/base/ui_base_export.h"
-
-// A specialized container, which is a cross between a GtkBin and a
-// GtkFixed. This container dervies from GtkBin and the implementation of
-// gtk_container_add() is the same: only one GtkWidget can be added through
-// that interface. The GtkBin portion contains normal content and is given the
-// same allocation that this container has.
-//
-// In addition, any number of widgets can be added through the
-// gtk_floating_container_add_floating() method, which provides functionality
-// similar to a GtkFixed. Unlike a GtkFixed, coordinates are not set when you
-// gtk_fixed_put(). The location of the floating widgets is determined while
-// running the "set-floating-position" signal, which is emitted during this
-// container's "size-allocate" handler.
-//
-// The "set-floating-position" signal is (semi-)mandatory if you want widgets
-// placed anywhere other than the origin and should have the following
-// signature:
-//
-// void (*set_floating_position)(GtkFloatingContainer* container,
-// GtkAllocation* allocation,
-// gpointer userdata);
-//
-// Your handler should, for each floating widget, set the "x" and "y" child
-// properties.
-
-G_BEGIN_DECLS
-
-#define GTK_TYPE_FLOATING_CONTAINER \
- (gtk_floating_container_get_type())
-#define GTK_FLOATING_CONTAINER(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST((obj), GTK_TYPE_FLOATING_CONTAINER, \
- GtkFloatingContainer))
-#define GTK_FLOATING_CONTAINER_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST((klass), GTK_TYPE_FLOATING_CONTAINER, \
- GtkFloatingContainerClass))
-#define GTK_IS_FLOATING_CONTAINER(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE((obj), GTK_TYPE_FLOATING_CONTAINER))
-#define GTK_IS_FLOATING_CONTAINER_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_TYPE((klass), GTK_TYPE_FLOATING_CONTAINER))
-#define GTK_FLOATING_CONTAINER_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS((obj), GTK_TYPE_FLOATING_CONTAINER, \
- GtkFloatingContainerClass))
-
-typedef struct _GtkFloatingContainer GtkFloatingContainer;
-typedef struct _GtkFloatingContainerClass GtkFloatingContainerClass;
-typedef struct _GtkFloatingContainerChild GtkFloatingContainerChild;
-
-struct _GtkFloatingContainer {
- // Parent class.
- GtkBin bin;
-
- // A GList of all our floating children, in GtkFloatingContainerChild
- // structs. Owned by the GtkFloatingContainer.
- GList* floating_children;
-};
-
-struct _GtkFloatingContainerClass {
- GtkBinClass parent_class;
-};
-
-// Internal structure used to associate a widget and its x/y child properties.
-struct _GtkFloatingContainerChild {
- GtkWidget* widget;
- gint x;
- gint y;
-};
-
-UI_BASE_EXPORT GType gtk_floating_container_get_type() G_GNUC_CONST;
-UI_BASE_EXPORT GtkWidget* gtk_floating_container_new();
-UI_BASE_EXPORT void gtk_floating_container_add_floating(
- GtkFloatingContainer* container,
- GtkWidget* widget);
-// Use gtk_container_remove to remove all widgets; both widgets added with
-// gtk_container_add() and gtk_floating_container_add_floating().
-
-G_END_DECLS
-
-#endif // UI_BASE_GTK_GTK_FLOATING_CONTAINER_H_
diff --git a/ui/base/gtk/gtk_hig_constants.h b/ui/base/gtk/gtk_hig_constants.h
deleted file mode 100644
index a03db50..0000000
--- a/ui/base/gtk/gtk_hig_constants.h
+++ /dev/null
@@ -1,54 +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.
-//
-// A list of constants that are used in setting up GTK widgets.
-//
-// This contains named color constants, along with spacing constants from the
-// GNOME Human Interface Guide.
-
-#ifndef UI_BASE_GTK_GTK_HIG_CONSTANTS_H_
-#define UI_BASE_GTK_GTK_HIG_CONSTANTS_H_
-
-typedef struct _GdkColor GdkColor;
-
-// Define a macro for creating GdkColors from RGB values. This is a macro to
-// allow static construction of literals, etc. Use this like:
-// GdkColor white = GDK_COLOR_RGB(0xff, 0xff, 0xff);
-#define GDK_COLOR_RGB(r, g, b) {0, r * ::ui::kSkiaToGDKMultiplier, \
- g * ::ui::kSkiaToGDKMultiplier, b * ::ui::kSkiaToGDKMultiplier}
-
-namespace ui {
-
-// Multiply uint8 color components by this.
-const int kSkiaToGDKMultiplier = 257;
-
-// Common color constants.
-const GdkColor kGdkWhite = GDK_COLOR_RGB(0xFF, 0xFF, 0xFF);
-const GdkColor kGdkBlack = GDK_COLOR_RGB(0x00, 0x00, 0x00);
-const GdkColor kGdkGray = GDK_COLOR_RGB(0x7F, 0x7F, 0x7F);
-
-// Constants relating to the layout of dialog windows:
-// (See http://library.gnome.org/devel/hig-book/stable/design-window.html.en)
-
-// Spacing between controls of the same group.
-const int kControlSpacing = 6;
-
-// Horizontal spacing between a label and its control.
-const int kLabelSpacing = 12;
-
-// Indent of the controls within each group.
-const int kGroupIndent = 12;
-
-// Space around the outside of a dialog's contents.
-const int kContentAreaBorder = 12;
-
-// Spacing between groups of controls.
-const int kContentAreaSpacing = 18;
-
-// Horizontal Spacing between controls in a form.
-const int kFormControlSpacing = 10;
-
-} // namespace ui
-
-#endif // UI_BASE_GTK_GTK_HIG_CONSTANTS_H_
diff --git a/ui/base/gtk/gtk_screen_util.cc b/ui/base/gtk/gtk_screen_util.cc
deleted file mode 100644
index 000f950..0000000
--- a/ui/base/gtk/gtk_screen_util.cc
+++ /dev/null
@@ -1,58 +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/base/gtk/gtk_screen_util.h"
-
-#include "base/logging.h"
-
-namespace ui {
-
-bool IsScreenComposited() {
- GdkScreen* screen = gdk_screen_get_default();
- return gdk_screen_is_composited(screen) == TRUE;
-}
-
-gfx::Point ScreenPoint(GtkWidget* widget) {
- int x, y;
- gdk_display_get_pointer(gtk_widget_get_display(widget), NULL, &x, &y,
- NULL);
- return gfx::Point(x, y);
-}
-
-gfx::Point ClientPoint(GtkWidget* widget) {
- int x, y;
- gtk_widget_get_pointer(widget, &x, &y);
- return gfx::Point(x, y);
-}
-
-gfx::Vector2d GetWidgetScreenOffset(GtkWidget* widget) {
- GdkWindow* window = gtk_widget_get_window(widget);
-
- if (!window) {
- NOTREACHED() << "Must only be called on realized widgets.";
- return gfx::Vector2d(0, 0);
- }
-
- gint x, y;
- gdk_window_get_origin(window, &x, &y);
-
- if (!gtk_widget_get_has_window(widget)) {
- GtkAllocation allocation;
- gtk_widget_get_allocation(widget, &allocation);
- x += allocation.x;
- y += allocation.y;
- }
-
- return gfx::Vector2d(x, y);
-}
-
-gfx::Rect GetWidgetScreenBounds(GtkWidget* widget) {
- GtkAllocation allocation;
- gtk_widget_get_allocation(widget, &allocation);
-
- return gfx::Rect(PointAtOffsetFromOrigin(GetWidgetScreenOffset(widget)),
- gfx::Size(allocation.width, allocation.height));
-}
-
-} // namespace ui
diff --git a/ui/base/gtk/gtk_screen_util.h b/ui/base/gtk/gtk_screen_util.h
deleted file mode 100644
index c3a7f2c..0000000
--- a/ui/base/gtk/gtk_screen_util.h
+++ /dev/null
@@ -1,34 +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 UI_BASE_GTK_GTK_SCREEN_UTILS_H_
-#define UI_BASE_GTK_GTK_SCREEN_UTILS_H_
-
-#include <gtk/gtk.h>
-
-#include "ui/base/ui_base_export.h"
-#include "ui/gfx/point.h"
-#include "ui/gfx/rect.h"
-#include "ui/gfx/vector2d.h"
-
-namespace ui {
-
-// Returns true if the screen is composited, false otherwise.
-UI_BASE_EXPORT bool IsScreenComposited();
-
-// Get the current location of the mouse cursor relative to the screen.
-UI_BASE_EXPORT gfx::Point ScreenPoint(GtkWidget* widget);
-
-// Get the current location of the mouse cursor relative to the widget.
-UI_BASE_EXPORT gfx::Point ClientPoint(GtkWidget* widget);
-
-// Gets the offset of a gtk widget from the origin in screen coordinates.
-UI_BASE_EXPORT gfx::Vector2d GetWidgetScreenOffset(GtkWidget* widget);
-
-// Returns the bounds of the specified widget in screen coordinates.
-UI_BASE_EXPORT gfx::Rect GetWidgetScreenBounds(GtkWidget* widget);
-
-} // namespace ui
-
-#endif // UI_BASE_GTK_GTK_SCREEN_UTILS_H_
diff --git a/ui/base/gtk/gtk_windowing.cc b/ui/base/gtk/gtk_windowing.cc
deleted file mode 100644
index e378c84..0000000
--- a/ui/base/gtk/gtk_windowing.cc
+++ /dev/null
@@ -1,48 +0,0 @@
-// Copyright (c) 2011 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/base/gtk/gtk_windowing.h"
-
-#include <gdk/gdkx.h>
-
-#include "base/logging.h"
-#include "ui/base/x/x11_util.h"
-#include "ui/gfx/gtk_compat.h"
-
-namespace ui {
-
-void StackPopupWindow(GtkWidget* popup, GtkWidget* toplevel) {
- DCHECK(GTK_IS_WINDOW(popup) && gtk_widget_is_toplevel(popup) &&
- gtk_widget_get_realized(popup));
- DCHECK(GTK_IS_WINDOW(toplevel) && gtk_widget_is_toplevel(toplevel) &&
- gtk_widget_get_realized(toplevel));
-
- // Stack the |popup| window directly above the |toplevel| window.
- // The popup window is a direct child of the root window, so we need to
- // find a similar ancestor for the toplevel window (which might have been
- // reparented by a window manager). We grab the server while we're doing
- // this -- otherwise, we'll get an error if the window manager reparents the
- // toplevel window right after we call GetHighestAncestorWindow().
- gdk_x11_display_grab(gtk_widget_get_display(toplevel));
- XID toplevel_window_base = ui::GetHighestAncestorWindow(
- ui::GetX11WindowFromGtkWidget(toplevel),
- ui::GetX11RootWindow());
- if (toplevel_window_base) {
- XID window_xid = ui::GetX11WindowFromGtkWidget(popup);
- XID window_parent = ui::GetParentWindow(window_xid);
- if (window_parent == ui::GetX11RootWindow()) {
- ui::RestackWindow(window_xid, toplevel_window_base, true);
- } else {
- // The window manager shouldn't reparent override-redirect windows.
- DLOG(ERROR) << "override-redirect window " << window_xid
- << "'s parent is " << window_parent
- << ", rather than root window "
- << ui::GetX11RootWindow();
- }
- }
- gdk_x11_display_ungrab(gtk_widget_get_display(toplevel));
-}
-
-} // namespace ui
-
diff --git a/ui/base/gtk/gtk_windowing.h b/ui/base/gtk/gtk_windowing.h
deleted file mode 100644
index 8510779..0000000
--- a/ui/base/gtk/gtk_windowing.h
+++ /dev/null
@@ -1,19 +0,0 @@
-// Copyright (c) 2011 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_BASE_GTK_GTK_WINDOWING_H_
-#define UI_BASE_GTK_GTK_WINDOWING_H_
-
-#include <gtk/gtk.h>
-
-#include "ui/base/ui_base_export.h"
-
-namespace ui {
-
-// Stacks a |popup| window directly on top of a |toplevel| window.
-UI_BASE_EXPORT void StackPopupWindow(GtkWidget* popup, GtkWidget* toplevel);
-
-} // namespace ui
-
-#endif // UI_BASE_GTK_GTK_WINDOWING_H_
diff --git a/ui/base/gtk/owned_widget_gtk.cc b/ui/base/gtk/owned_widget_gtk.cc
deleted file mode 100644
index d8a1d0b..0000000
--- a/ui/base/gtk/owned_widget_gtk.cc
+++ /dev/null
@@ -1,47 +0,0 @@
-// Copyright (c) 2011 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/base/gtk/owned_widget_gtk.h"
-
-#include <gtk/gtk.h>
-
-#include "base/logging.h"
-
-#error "The GTK+ port will be deleted later this week. If you are seeing this, you are trying to compile it. Please check your gyp flags for 'use_aura=0' and remove them."
-
-namespace ui {
-
-OwnedWidgetGtk::~OwnedWidgetGtk() {
- Destroy();
-}
-
-void OwnedWidgetGtk::Own(GtkWidget* widget) {
- if (!widget)
- return;
-
- DCHECK(!widget_);
- // We want to make sure that Own() was called properly, right after the
- // widget was created. There should be a floating reference.
- DCHECK(g_object_is_floating(widget));
-
- // Sink the floating reference, we should now own this reference.
- g_object_ref_sink(widget);
- widget_ = widget;
-}
-
-void OwnedWidgetGtk::Destroy() {
- if (!widget_)
- return;
-
- GtkWidget* widget = widget_;
- widget_ = NULL;
- gtk_widget_destroy(widget);
-
- DCHECK(!g_object_is_floating(widget));
- // NOTE: Assumes some implementation details about glib internals.
- DCHECK_EQ(G_OBJECT(widget)->ref_count, 1U);
- g_object_unref(widget);
-}
-
-} // namespace ui
diff --git a/ui/base/gtk/owned_widget_gtk.h b/ui/base/gtk/owned_widget_gtk.h
deleted file mode 100644
index 9a1166b..0000000
--- a/ui/base/gtk/owned_widget_gtk.h
+++ /dev/null
@@ -1,95 +0,0 @@
-// Copyright (c) 2011 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.
-
-// This class assists you in dealing with a specific situation when managing
-// ownership between a C++ object and a GTK widget. It is common to have a
-// C++ object which encapsulates a GtkWidget, and that widget is exposed from
-// the object for use outside of the class. In this situation, you commonly
-// want the GtkWidget's lifetime to match its C++ object's lifetime. Using an
-// OwnedWigetGtk will take ownership over the initial reference of the
-// GtkWidget, so that it is "owned" by the C++ object. Example usage:
-//
-// class FooViewGtk() {
-// public:
-// FooViewGtk() { }
-// ~FooViewGtk() { }
-// void Init() { vbox_.Own(gtk_vbox_new()); }
-// GtkWidget* widget() { return vbox_.get() }; // Host my widget!
-// private:
-// OwnedWidgetGtk vbox_;
-// };
-//
-// This design will ensure that the widget stays alive from the call to Own()
-// until the call to Destroy().
-//
-// - Details of the problem and OwnedWidgetGtk's solution:
-// In order to make passing ownership more convenient for newly created
-// widgets, GTK has a concept of a "floating" reference. All GtkObjects (and
-// thus GtkWidgets) inherit from GInitiallyUnowned. When they are created, the
-// object starts with a reference count of 1, but has its floating flag set.
-// When it is put into a container for the first time, that container will
-// "sink" the floating reference, and the count will still be 1. Now the
-// container owns the widget, and if we remove the widget from the container,
-// the widget is destroyed. This style of ownership often causes problems when
-// you have an object encapsulating the widget. If we just use a raw
-// GtkObject* with no specific ownership management, we push the widget's
-// ownership onto the user of the class. Now the C++ object can't depend on
-// the widget being valid, since it doesn't manage its lifetime. If the widget
-// was removed from a container, removing its only reference, it would be
-// destroyed (from the C++ object's perspective) unexpectedly destroyed. The
-// solution is fairly simple, make sure that the C++ object owns the widget,
-// and thus it is also responsible for destroying it. This boils down to:
-// GtkWidget* widget = gtk_widget_new();
-// g_object_ref_sink(widget); // Claim the initial floating reference.
-// ...
-// gtk_destroy_widget(widget); // Ask all code to destroy their references.
-// g_object_unref(widget); // Destroy the initial reference we had claimed.
-
-#ifndef UI_BASE_GTK_OWNED_WIDGET_GTK_H_
-#define UI_BASE_GTK_OWNED_WIDGET_GTK_H_
-
-#include "base/basictypes.h"
-#include "ui/base/ui_base_export.h"
-
-typedef struct _GtkWidget GtkWidget;
-
-namespace ui {
-
-class UI_BASE_EXPORT OwnedWidgetGtk {
- public:
- // Create an instance that isn't managing any ownership.
- OwnedWidgetGtk() : widget_(NULL) { }
- // Create an instance that owns |widget|.
- explicit OwnedWidgetGtk(GtkWidget* widget) : widget_(NULL) { Own(widget); }
-
- ~OwnedWidgetGtk();
-
- // Return the currently owned widget, or NULL if no widget is owned.
- GtkWidget* get() const { return widget_; }
- GtkWidget* operator->() const { return widget_; }
-
- // Takes ownership of a widget, by taking the initial floating reference of
- // the GtkWidget. It is expected that Own() is called right after the widget
- // has been created, and before any other references to the widget might have
- // been added. It is valid to never call Own(), in which case Destroy() will
- // do nothing. If Own() has been called, you must explicitly call Destroy().
- void Own(GtkWidget* widget);
-
- // You may call Destroy() after you have called Own(). Calling Destroy()
- // will call gtk_widget_destroy(), and drop our reference to the widget.
- // Destroy() is also called in this object's destructor.
- // After a call to Destroy(), you may call Own() again. NOTE: It is expected
- // that after gtk_widget_destroy we will be holding the only reference left
- // on the object. We assert this in debug mode to help catch any leaks.
- void Destroy();
-
- private:
- GtkWidget* widget_;
-
- DISALLOW_COPY_AND_ASSIGN(OwnedWidgetGtk);
-};
-
-} // namespace ui
-
-#endif // UI_BASE_GTK_OWNED_WIDGET_GTK_H_
diff --git a/ui/base/gtk/scoped_region.cc b/ui/base/gtk/scoped_region.cc
deleted file mode 100644
index 729e3c3..0000000
--- a/ui/base/gtk/scoped_region.cc
+++ /dev/null
@@ -1,41 +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/base/gtk/scoped_region.h"
-
-#include <gdk/gdk.h>
-
-namespace ui {
-
-ScopedRegion::ScopedRegion() : region_(NULL) {}
-
-ScopedRegion::ScopedRegion(GdkRegion* region) : region_(region) {}
-
-ScopedRegion::~ScopedRegion() {
- Close();
-}
-
-void ScopedRegion::Set(GdkRegion* region) {
- Close();
- region_ = region;
-}
-
-GdkRegion* ScopedRegion::Get() {
- return region_;
-}
-
-GdkRegion* ScopedRegion::release() {
- GdkRegion* region = region_;
- region_ = NULL;
- return region;
-}
-
-void ScopedRegion::Close() {
- if (region_) {
- gdk_region_destroy(region_);
- region_ = NULL;
- }
-}
-
-} // namespace ui
diff --git a/ui/base/gtk/scoped_region.h b/ui/base/gtk/scoped_region.h
deleted file mode 100644
index e7a690f..0000000
--- a/ui/base/gtk/scoped_region.h
+++ /dev/null
@@ -1,40 +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 UI_BASE_GTK_SCOPED_REGION_H_
-#define UI_BASE_GTK_SCOPED_REGION_H_
-
-#include "base/basictypes.h"
-#include "ui/base/ui_base_export.h"
-
-typedef struct _GdkRegion GdkRegion;
-
-namespace ui {
-
-// Wraps a GdkRegion. This class provides the same methods as ScopedGDIObject in
-// base/win/scoped_gdi_object.h.
-class UI_BASE_EXPORT ScopedRegion {
- public:
- ScopedRegion();
- explicit ScopedRegion(GdkRegion* region);
-
- ~ScopedRegion();
-
- void Set(GdkRegion* region);
-
- GdkRegion* Get();
-
- GdkRegion* release();
-
- private:
- void Close();
-
- GdkRegion* region_;
-
- DISALLOW_COPY_AND_ASSIGN(ScopedRegion);
-};
-
-} // namespace ui
-
-#endif // UI_BASE_GTK_SCOPED_REGION_H_
diff --git a/ui/base/resource/resource_bundle_gtk.cc b/ui/base/resource/resource_bundle_gtk.cc
deleted file mode 100644
index 871f9a4..0000000
--- a/ui/base/resource/resource_bundle_gtk.cc
+++ /dev/null
@@ -1,112 +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/base/resource/resource_bundle.h"
-
-#include "base/i18n/rtl.h"
-#include "base/logging.h"
-#include "base/memory/ref_counted_memory.h"
-#include "base/path_service.h"
-#include "base/synchronization/lock.h"
-#include "third_party/skia/include/core/SkBitmap.h"
-#include "ui/base/layout.h"
-#include "ui/base/resource/resource_handle.h"
-#include "ui/base/ui_base_paths.h"
-#include "ui/gfx/image/image.h"
-#include "ui/gfx/scoped_gobject.h"
-
-#include <gtk/gtk.h>
-
-namespace ui {
-
-namespace {
-
-// Convert the raw image data into a GdkPixbuf. The GdkPixbuf that is returned
-// has a ref count of 1 so the caller must call g_object_unref to free the
-// memory.
-GdkPixbuf* LoadPixbuf(base::RefCountedStaticMemory* data, bool rtl_enabled) {
- ScopedGObject<GdkPixbufLoader>::Type loader(gdk_pixbuf_loader_new());
- bool ok = data && gdk_pixbuf_loader_write(loader.get(),
- data->front_as<guint8>(), data->size(), NULL);
- if (!ok)
- return NULL;
- // Calling gdk_pixbuf_loader_close forces the data to be parsed by the
- // loader. We must do this before calling gdk_pixbuf_loader_get_pixbuf.
- ok = gdk_pixbuf_loader_close(loader.get(), NULL);
- if (!ok)
- return NULL;
- GdkPixbuf* pixbuf = gdk_pixbuf_loader_get_pixbuf(loader.get());
- if (!pixbuf)
- return NULL;
-
- if (base::i18n::IsRTL() && rtl_enabled) {
- // |pixbuf| will get unreffed and destroyed (see below). The returned value
- // has ref count 1.
- return gdk_pixbuf_flip(pixbuf, TRUE);
- } else {
- // The pixbuf is owned by the loader, so add a ref so when we delete the
- // loader (when the ScopedGObject goes out of scope), the pixbuf still
- // exists.
- g_object_ref(pixbuf);
- return pixbuf;
- }
-}
-
-base::FilePath GetResourcesPakFilePath(const std::string& pak_name) {
- base::FilePath path;
- if (PathService::Get(base::DIR_MODULE, &path))
- return path.AppendASCII(pak_name.c_str());
-
- // Return just the name of the pack file.
- return base::FilePath(pak_name.c_str());
-}
-
-} // namespace
-
-void ResourceBundle::LoadCommonResources() {
- AddDataPackFromPath(GetResourcesPakFilePath(
- "chrome_100_percent.pak"),
- SCALE_FACTOR_100P);
-}
-
-gfx::Image& ResourceBundle::GetNativeImageNamed(int resource_id, ImageRTL rtl) {
- // Use the negative |resource_id| for the key for BIDI-aware images.
- int key = rtl == RTL_ENABLED ? -resource_id : resource_id;
-
- // Check to see if the image is already in the cache.
- {
- base::AutoLock lock_scope(*images_and_fonts_lock_);
- if (images_.count(key))
- return images_[key];
- }
-
- gfx::Image image;
- if (delegate_)
- image = delegate_->GetNativeImageNamed(resource_id, rtl);
-
- if (image.IsEmpty()) {
- scoped_refptr<base::RefCountedStaticMemory> data(
- LoadDataResourceBytesForScale(resource_id, SCALE_FACTOR_100P));
- GdkPixbuf* pixbuf = LoadPixbuf(data.get(), rtl == RTL_ENABLED);
-
- if (!pixbuf) {
- LOG(WARNING) << "Unable to load pixbuf with id " << resource_id;
- NOTREACHED(); // Want to assert in debug mode.
- return GetEmptyImage();
- }
-
- image = gfx::Image(pixbuf); // Takes ownership.
- }
-
- base::AutoLock lock_scope(*images_and_fonts_lock_);
-
- // Another thread raced the load and has already cached the image.
- if (images_.count(key))
- return images_[key];
-
- images_[key] = image;
- return images_[key];
-}
-
-} // namespace ui
diff --git a/ui/base/test/ui_controls_gtk.cc b/ui/base/test/ui_controls_gtk.cc
deleted file mode 100644
index 3342a3d..0000000
--- a/ui/base/test/ui_controls_gtk.cc
+++ /dev/null
@@ -1,261 +0,0 @@
-// 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/base/test/ui_controls.h"
-
-#include <gdk/gdkkeysyms.h>
-#include <gtk/gtk.h>
-
-#include "base/bind.h"
-#include "base/logging.h"
-#include "base/message_loop/message_loop.h"
-#include "ui/base/gtk/event_synthesis_gtk.h"
-#include "ui/base/gtk/gtk_screen_util.h"
-#include "ui/gfx/rect.h"
-
-namespace {
-bool g_ui_controls_enabled = false;
-
-// static
-guint32 XTimeNow() {
- struct timespec ts;
- clock_gettime(CLOCK_MONOTONIC, &ts);
- return ts.tv_sec * 1000 + ts.tv_nsec / 1000000;
-}
-
-class EventWaiter : public base::MessageLoopForUI::Observer {
- public:
- EventWaiter(const base::Closure& task, GdkEventType type, int count)
- : task_(task),
- type_(type),
- count_(count) {
- base::MessageLoopForUI::current()->AddObserver(this);
- }
-
- virtual ~EventWaiter() {
- base::MessageLoopForUI::current()->RemoveObserver(this);
- }
-
- // MessageLoop::Observer implementation:
- virtual void WillProcessEvent(GdkEvent* event) OVERRIDE {
- if ((event->type == type_) && (--count_ == 0)) {
- // At the time we're invoked the event has not actually been processed.
- // Use PostTask to make sure the event has been processed before
- // notifying.
- // NOTE: if processing a message results in running a nested message
- // loop, then DidProcessEvent isn't immediately sent. As such, we do
- // the processing in WillProcessEvent rather than DidProcessEvent.
- base::MessageLoop::current()->PostTask(FROM_HERE, task_);
- delete this;
- }
- }
-
- virtual void DidProcessEvent(GdkEvent* event) OVERRIDE {
- // No-op.
- }
-
- private:
- base::Closure task_;
- GdkEventType type_;
- // The number of events of this type to wait for.
- int count_;
-};
-
-void FakeAMouseMotionEvent(gint x, gint y) {
- GdkEvent* event = gdk_event_new(GDK_MOTION_NOTIFY);
-
- event->motion.send_event = false;
- event->motion.time = XTimeNow();
-
- GtkWidget* grab_widget = gtk_grab_get_current();
- if (grab_widget) {
- // If there is a grab, we need to target all events at it regardless of
- // what widget the mouse is over.
- event->motion.window = gtk_widget_get_window(grab_widget);
- } else {
- event->motion.window = gdk_window_at_pointer(&x, &y);
- }
- g_object_ref(event->motion.window);
- gint window_x, window_y;
- gdk_window_get_origin(event->motion.window, &window_x, &window_y);
- event->motion.x = x - window_x;
- event->motion.y = y - window_y;
- event->motion.x_root = x;
- event->motion.y_root = y;
-
- event->motion.device = gdk_device_get_core_pointer();
- event->type = GDK_MOTION_NOTIFY;
-
- gdk_event_put(event);
- gdk_event_free(event);
-}
-
-} // namespace
-
-namespace ui_controls {
-
-void EnableUIControls() {
- g_ui_controls_enabled = true;
-}
-
-bool SendKeyPress(gfx::NativeWindow window,
- ui::KeyboardCode key,
- bool control,
- bool shift,
- bool alt,
- bool command) {
- CHECK(g_ui_controls_enabled);
- DCHECK(!command); // No command key on Linux
- GdkWindow* event_window = NULL;
- GtkWidget* grab_widget = gtk_grab_get_current();
- if (grab_widget) {
- // If there is a grab, send all events to the grabbed widget.
- event_window = gtk_widget_get_window(grab_widget);
- } else if (window) {
- event_window = gtk_widget_get_window(GTK_WIDGET(window));
- } else {
- // No target was specified. Send the events to the active toplevel.
- GList* windows = gtk_window_list_toplevels();
- for (GList* element = windows; element; element = g_list_next(element)) {
- GtkWindow* this_window = GTK_WINDOW(element->data);
- if (gtk_window_is_active(this_window)) {
- event_window = gtk_widget_get_window(GTK_WIDGET(this_window));
- break;
- }
- }
- g_list_free(windows);
- }
- if (!event_window) {
- NOTREACHED() << "Window not specified and none is active";
- return false;
- }
-
- std::vector<GdkEvent*> events;
- ui::SynthesizeKeyPressEvents(event_window, key, control, shift, alt, &events);
- for (std::vector<GdkEvent*>::iterator iter = events.begin();
- iter != events.end(); ++iter) {
- gdk_event_put(*iter);
- // gdk_event_put appends a copy of the event.
- gdk_event_free(*iter);
- }
-
- return true;
-}
-
-bool SendKeyPressNotifyWhenDone(gfx::NativeWindow window,
- ui::KeyboardCode key,
- bool control,
- bool shift,
- bool alt,
- bool command,
- const base::Closure& task) {
- CHECK(g_ui_controls_enabled);
- DCHECK(!command); // No command key on Linux
- int release_count = 1;
- if (control)
- release_count++;
- if (shift)
- release_count++;
- if (alt)
- release_count++;
- // This object will delete itself after running |task|.
- new EventWaiter(task, GDK_KEY_RELEASE, release_count);
- return SendKeyPress(window, key, control, shift, alt, command);
-}
-
-bool SendMouseMove(long x, long y) {
- CHECK(g_ui_controls_enabled);
- gdk_display_warp_pointer(gdk_display_get_default(), gdk_screen_get_default(),
- x, y);
- // Sometimes gdk_display_warp_pointer fails to send back any indication of
- // the move, even though it succesfully moves the server cursor. We fake it in
- // order to get drags to work.
- FakeAMouseMotionEvent(x, y);
- return true;
-}
-
-bool SendMouseMoveNotifyWhenDone(long x, long y, const base::Closure& task) {
- CHECK(g_ui_controls_enabled);
- bool rv = SendMouseMove(x, y);
- new EventWaiter(task, GDK_MOTION_NOTIFY, 1);
- return rv;
-}
-
-bool SendMouseEvents(MouseButton type, int state) {
- CHECK(g_ui_controls_enabled);
- GdkEvent* event = gdk_event_new(GDK_BUTTON_PRESS);
-
- event->button.send_event = false;
- event->button.time = XTimeNow();
-
- gint x, y;
- GtkWidget* grab_widget = gtk_grab_get_current();
- if (grab_widget) {
- // If there is a grab, we need to target all events at it regardless of
- // what widget the mouse is over.
- event->button.window = gtk_widget_get_window(grab_widget);
- gdk_window_get_pointer(event->button.window, &x, &y, NULL);
- } else {
- event->button.window = gdk_window_at_pointer(&x, &y);
- CHECK(event->button.window);
- }
-
- g_object_ref(event->button.window);
- event->button.x = x;
- event->button.y = y;
- gint origin_x, origin_y;
- gdk_window_get_origin(event->button.window, &origin_x, &origin_y);
- event->button.x_root = x + origin_x;
- event->button.y_root = y + origin_y;
-
- event->button.axes = NULL;
- GdkModifierType modifier;
- gdk_window_get_pointer(event->button.window, NULL, NULL, &modifier);
- event->button.state = modifier;
- event->button.button = type == LEFT ? 1 : (type == MIDDLE ? 2 : 3);
- event->button.device = gdk_device_get_core_pointer();
-
- event->button.type = GDK_BUTTON_PRESS;
- if (state & DOWN)
- gdk_event_put(event);
-
- // Also send a release event.
- GdkEvent* release_event = gdk_event_copy(event);
- release_event->button.type = GDK_BUTTON_RELEASE;
- release_event->button.time++;
- if (state & UP)
- gdk_event_put(release_event);
-
- gdk_event_free(event);
- gdk_event_free(release_event);
-
- return false;
-}
-
-bool SendMouseEventsNotifyWhenDone(MouseButton type,
- int state,
- const base::Closure& task) {
- CHECK(g_ui_controls_enabled);
- bool rv = SendMouseEvents(type, state);
- GdkEventType wait_type;
- if (state & UP) {
- wait_type = GDK_BUTTON_RELEASE;
- } else {
- if (type == LEFT)
- wait_type = GDK_BUTTON_PRESS;
- else if (type == MIDDLE)
- wait_type = GDK_2BUTTON_PRESS;
- else
- wait_type = GDK_3BUTTON_PRESS;
- }
- new EventWaiter(task, wait_type, 1);
- return rv;
-}
-
-bool SendMouseClick(MouseButton type) {
- CHECK(g_ui_controls_enabled);
- return SendMouseEvents(type, UP | DOWN);
-}
-
-} // namespace ui_controls
diff --git a/ui/base/ui_base.gyp b/ui/base/ui_base.gyp
index 16737cb..afe3c9f 100644
--- a/ui/base/ui_base.gyp
+++ b/ui/base/ui_base.gyp
@@ -43,8 +43,6 @@
'accelerators/platform_accelerator.h',
'accelerators/platform_accelerator_cocoa.h',
'accelerators/platform_accelerator_cocoa.mm',
- 'accelerators/platform_accelerator_gtk.cc',
- 'accelerators/platform_accelerator_gtk.h',
'android/ui_base_jni_registrar.cc',
'android/ui_base_jni_registrar.h',
'android/view_android.cc',
@@ -62,7 +60,6 @@
'clipboard/clipboard_aura.cc',
'clipboard/clipboard_aurax11.cc',
'clipboard/clipboard_constants.cc',
- 'clipboard/clipboard_gtk.cc',
'clipboard/clipboard_mac.mm',
'clipboard/clipboard_types.h',
'clipboard/clipboard_util_win.cc',
@@ -172,28 +169,6 @@
'dragdrop/os_exchange_data_provider_aurax11.h',
'dragdrop/os_exchange_data_provider_win.cc',
'dragdrop/os_exchange_data_provider_win.h',
- 'gtk/event_synthesis_gtk.cc',
- 'gtk/event_synthesis_gtk.h',
- 'gtk/focus_store_gtk.cc',
- 'gtk/focus_store_gtk.h',
- 'gtk/g_object_destructor_filo.cc',
- 'gtk/g_object_destructor_filo.h',
- 'gtk/gtk_expanded_container.cc',
- 'gtk/gtk_expanded_container.h',
- 'gtk/gtk_floating_container.cc',
- 'gtk/gtk_floating_container.h',
- 'gtk/gtk_hig_constants.h',
- 'gtk/gtk_screen_util.cc',
- 'gtk/gtk_screen_util.h',
- 'gtk/gtk_signal.h',
- 'gtk/gtk_signal_registrar.cc',
- 'gtk/gtk_signal_registrar.h',
- 'gtk/gtk_windowing.cc',
- 'gtk/gtk_windowing.h',
- 'gtk/owned_widget_gtk.cc',
- 'gtk/owned_widget_gtk.h',
- 'gtk/scoped_region.cc',
- 'gtk/scoped_region.h',
'hit_test.h',
'l10n/formatter.cc',
'l10n/formatter.h',
@@ -248,7 +223,6 @@
'resource/resource_bundle.h',
'resource/resource_bundle_android.cc',
'resource/resource_bundle_auralinux.cc',
- 'resource/resource_bundle_gtk.cc',
'resource/resource_bundle_ios.mm',
'resource/resource_bundle_mac.mm',
'resource/resource_bundle_win.cc',
diff --git a/ui/base/webui/web_ui_util.cc b/ui/base/webui/web_ui_util.cc
index d901491..aba0009 100644
--- a/ui/base/webui/web_ui_util.cc
+++ b/ui/base/webui/web_ui_util.cc
@@ -140,13 +140,6 @@ void SetFontAndTextDirection(base::DictionaryValue* localized_strings) {
std::string font_family = l10n_util::GetStringUTF8(web_font_family_id);
-#if defined(TOOLKIT_GTK)
- // Use the system font on Linux/GTK. Keep the hard-coded font families as
- // backup in case for some crazy reason this one isn't available.
- font_family = ui::ResourceBundle::GetSharedInstance().GetFont(
- ui::ResourceBundle::BaseFont).GetFontName() + ", " + font_family;
-#endif
-
localized_strings->SetString("fontfamily", font_family);
localized_strings->SetString("fontsize",
l10n_util::GetStringUTF8(web_font_size_id));
diff --git a/ui/base/x/x11_util.cc b/ui/base/x/x11_util.cc
index 668c787..0f16be7 100644
--- a/ui/base/x/x11_util.cc
+++ b/ui/base/x/x11_util.cc
@@ -61,13 +61,6 @@
#include "ui/gfx/skia_util.h"
#endif
-#if defined(TOOLKIT_GTK)
-#include <gdk/gdk.h>
-#include <gtk/gtk.h>
-#include "ui/gfx/gdk_compat.h"
-#include "ui/gfx/gtk_compat.h"
-#endif
-
namespace ui {
namespace {
@@ -530,33 +523,6 @@ bool GetCurrentDesktop(int* desktop) {
return GetIntProperty(GetX11RootWindow(), "_NET_CURRENT_DESKTOP", desktop);
}
-#if defined(TOOLKIT_GTK)
-XID GetX11WindowFromGtkWidget(GtkWidget* widget) {
- return GDK_WINDOW_XID(gtk_widget_get_window(widget));
-}
-
-XID GetX11WindowFromGdkWindow(GdkWindow* window) {
- return GDK_WINDOW_XID(window);
-}
-
-GtkWindow* GetGtkWindowFromX11Window(XID xid) {
- GdkWindow* gdk_window =
- gdk_x11_window_lookup_for_display(gdk_display_get_default(), xid);
- if (!gdk_window)
- return NULL;
- GtkWindow* gtk_window = NULL;
- gdk_window_get_user_data(gdk_window,
- reinterpret_cast<gpointer*>(&gtk_window));
- if (!gtk_window)
- return NULL;
- return gtk_window;
-}
-
-void* GetVisualFromGtkWidget(GtkWidget* widget) {
- return GDK_VISUAL_XVISUAL(gtk_widget_get_visual(widget));
-}
-#endif // defined(TOOLKIT_GTK)
-
void SetHideTitlebarWhenMaximizedProperty(XID window,
HideTitlebarWhenMaximized property) {
// XChangeProperty() expects "hide" to be long.
@@ -973,13 +939,8 @@ bool SetStringProperty(XID window,
}
Atom GetAtom(const char* name) {
-#if defined(TOOLKIT_GTK)
- return gdk_x11_get_xatom_by_name_for_display(
- gdk_display_get_default(), name);
-#else
// TODO(derat): Cache atoms to avoid round-trips to the server.
return XInternAtom(gfx::GetXDisplay(), name, false);
-#endif
}
void SetWindowClassHint(XDisplay* display,
@@ -1394,17 +1355,6 @@ bool IsX11WindowFullScreen(XID window) {
if (!ui::GetWindowRect(window, &window_rect))
return false;
-#if defined(TOOLKIT_GTK)
- // As the last resort, check if the window size is as large as the main
- // screen.
- GdkRectangle monitor_rect;
- gdk_screen_get_monitor_geometry(gdk_screen_get_default(), 0, &monitor_rect);
-
- return monitor_rect.x == window_rect.x() &&
- monitor_rect.y == window_rect.y() &&
- monitor_rect.width == window_rect.width() &&
- monitor_rect.height == window_rect.height();
-#else
// We can't use gfx::Screen here because we don't have an aura::Window. So
// instead just look at the size of the default display.
//
@@ -1415,7 +1365,6 @@ bool IsX11WindowFullScreen(XID window) {
int width = WidthOfScreen(screen);
int height = HeightOfScreen(screen);
return window_rect.size() == gfx::Size(width, height);
-#endif
}
const unsigned char* XRefcountedMemory::front() const {
diff --git a/ui/base/x/x11_util.h b/ui/base/x/x11_util.h
index d87635f9..0f7c12e 100644
--- a/ui/base/x/x11_util.h
+++ b/ui/base/x/x11_util.h
@@ -29,12 +29,6 @@ typedef unsigned long Cursor;
typedef struct _XcursorImage XcursorImage;
typedef union _XEvent XEvent;
-#if defined(TOOLKIT_GTK)
-typedef struct _GdkDrawable GdkWindow;
-typedef struct _GtkWidget GtkWidget;
-typedef struct _GtkWindow GtkWindow;
-#endif
-
namespace gfx {
class Canvas;
class Point;
@@ -119,21 +113,6 @@ UI_BASE_EXPORT XID GetX11RootWindow();
// Returns the user's current desktop.
bool GetCurrentDesktop(int* desktop);
-#if defined(TOOLKIT_GTK)
-// Get the X window id for the given GTK widget.
-UI_BASE_EXPORT XID GetX11WindowFromGtkWidget(GtkWidget* widget);
-XID GetX11WindowFromGdkWindow(GdkWindow* window);
-
-// Get the GtkWindow* wrapping a given XID, if any.
-// Returns NULL if there isn't already a GtkWindow* wrapping this XID;
-// see gdk_window_foreign_new() etc. to wrap arbitrary XIDs.
-UI_BASE_EXPORT GtkWindow* GetGtkWindowFromX11Window(XID xid);
-
-// Get a Visual from the given widget. Since we don't include the Xlib
-// headers, this is returned as a void*.
-UI_BASE_EXPORT void* GetVisualFromGtkWidget(GtkWidget* widget);
-#endif // defined(TOOLKIT_GTK)
-
enum HideTitlebarWhenMaximized {
SHOW_TITLEBAR_WHEN_MAXIMIZED = 0,
HIDE_TITLEBAR_WHEN_MAXIMIZED = 1,
diff --git a/ui/events/events.gyp b/ui/events/events.gyp
index 2a67d77..ec07daa 100644
--- a/ui/events/events.gyp
+++ b/ui/events/events.gyp
@@ -42,8 +42,6 @@
'keycodes/keyboard_code_conversion.h',
'keycodes/keyboard_code_conversion_android.cc',
'keycodes/keyboard_code_conversion_android.h',
- 'keycodes/keyboard_code_conversion_gtk.cc',
- 'keycodes/keyboard_code_conversion_gtk.h',
'keycodes/keyboard_code_conversion_mac.h',
'keycodes/keyboard_code_conversion_mac.mm',
'keycodes/keyboard_code_conversion_win.cc',
diff --git a/ui/events/keycodes/keyboard_code_conversion_gtk.cc b/ui/events/keycodes/keyboard_code_conversion_gtk.cc
deleted file mode 100644
index 9a39653..0000000
--- a/ui/events/keycodes/keyboard_code_conversion_gtk.cc
+++ /dev/null
@@ -1,85 +0,0 @@
-// Copyright (c) 2011 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.
-
-/*
- * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
- * Copyright (C) 2006 Michael Emmel mike.emmel@gmail.com
- * Copyright (C) 2007 Holger Hans Peter Freyther
- * Copyright (C) 2008 Collabora, Ltd. All rights reserved.
- * Copyright (C) 2008, 2009 Google Inc.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-// WindowsKeyCodeForGdkKeyCode is copied from platform/gtk/KeyEventGtk.cpp
-
-#include "ui/events/keycodes/keyboard_code_conversion_gtk.h"
-
-#include <gdk/gdk.h>
-#include <gdk/gdkkeysyms.h>
-#include <X11/keysym.h>
-
-#include "base/basictypes.h"
-#include "build/build_config.h"
-#include "ui/events/keycodes/keyboard_code_conversion_x.h"
-#include "ui/events/keycodes/keyboard_codes_posix.h"
-
-namespace ui {
-
-KeyboardCode WindowsKeyCodeForGdkKeyCode(int keycode) {
- // Gdk key codes (e.g. GDK_BackSpace) and X keysyms (e.g. XK_BackSpace) share
- // the same values.
- return KeyboardCodeFromXKeysym(keycode);
-}
-
-int GdkKeyCodeForWindowsKeyCode(KeyboardCode keycode, bool shift) {
- // Gdk key codes and X keysyms share the same values.
- return XKeysymForWindowsKeyCode(keycode, shift);
-}
-
-// Just in case, test whether Gdk key codes match X ones.
-COMPILE_ASSERT(GDK_KP_0 == XK_KP_0, keycode_check);
-COMPILE_ASSERT(GDK_A == XK_A, keycode_check);
-COMPILE_ASSERT(GDK_Escape == XK_Escape, keycode_check);
-COMPILE_ASSERT(GDK_F1 == XK_F1, keycode_check);
-COMPILE_ASSERT(GDK_Kanji == XK_Kanji, keycode_check);
-COMPILE_ASSERT(GDK_Page_Up == XK_Page_Up, keycode_check);
-COMPILE_ASSERT(GDK_Tab == XK_Tab, keycode_check);
-COMPILE_ASSERT(GDK_a == XK_a, keycode_check);
-COMPILE_ASSERT(GDK_space == XK_space, keycode_check);
-
-int GdkNativeKeyCodeForWindowsKeyCode(KeyboardCode keycode, bool shift) {
- int keyval = GdkKeyCodeForWindowsKeyCode(keycode, shift);
- GdkKeymapKey* keys;
- gint n_keys;
-
- int native_keycode = 0;
- if (keyval && gdk_keymap_get_entries_for_keyval(0, keyval, &keys, &n_keys)) {
- native_keycode = keys[0].keycode;
- g_free(keys);
- }
-
- return native_keycode;
-}
-
-} // namespace ui
diff --git a/ui/events/keycodes/keyboard_code_conversion_gtk.h b/ui/events/keycodes/keyboard_code_conversion_gtk.h
deleted file mode 100644
index 6258f41..0000000
--- a/ui/events/keycodes/keyboard_code_conversion_gtk.h
+++ /dev/null
@@ -1,58 +0,0 @@
-// Copyright (c) 2011 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.
-
-/*
- * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
- * Copyright (C) 2006 Michael Emmel mike.emmel@gmail.com
- * Copyright (C) 2007 Holger Hans Peter Freyther
- * Copyright (C) 2008 Collabora, Ltd. All rights reserved.
- * Copyright (C) 2008, 2009 Google Inc.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-// WindowsKeyCodeForGdkKeyCode is copied from platform/gtk/KeyEventGtk.cpp
-
-#ifndef UI_EVENTS_KEYCODES_KEYBOARD_CODE_CONVERSION_GTK_H_
-#define UI_EVENTS_KEYCODES_KEYBOARD_CODE_CONVERSION_GTK_H_
-
-#include "ui/events/events_base_export.h"
-#include "ui/events/keycodes/keyboard_codes_posix.h"
-
-typedef struct _GdkEventKey GdkEventKey;
-
-namespace ui {
-
-EVENTS_BASE_EXPORT KeyboardCode WindowsKeyCodeForGdkKeyCode(int keycode);
-
-EVENTS_BASE_EXPORT int GdkKeyCodeForWindowsKeyCode(KeyboardCode keycode,
- bool shift);
-
-// For WebKit DRT testing: simulate the native keycode for the given
-// input |keycode|. Return the native keycode.
-EVENTS_BASE_EXPORT int GdkNativeKeyCodeForWindowsKeyCode(KeyboardCode keycode,
- bool shift);
-
-} // namespace ui
-
-#endif // UI_EVENTS_KEYCODES_KEYBOARD_CODE_CONVERSION_GTK_H_
diff --git a/ui/events/keycodes/keyboard_code_conversion_x.cc b/ui/events/keycodes/keyboard_code_conversion_x.cc
index ffda952..b21164e 100644
--- a/ui/events/keycodes/keyboard_code_conversion_x.cc
+++ b/ui/events/keycodes/keyboard_code_conversion_x.cc
@@ -371,20 +371,6 @@ KeyboardCode KeyboardCodeFromXKeysym(unsigned int keysym) {
case XF86XK_Launch9:
return VKEY_F18;
-#if defined(TOOLKIT_GTK)
- case XF86XK_Refresh:
- case XF86XK_History:
- case XF86XK_OpenURL:
- case XF86XK_AddFavorite:
- case XF86XK_Go:
- case XF86XK_ZoomIn:
- case XF86XK_ZoomOut:
- // ui::AcceleratorGtk tries to convert the XF86XK_ keysyms on Chrome
- // startup. It's safe to return VKEY_UNKNOWN here since ui::AcceleratorGtk
- // also checks a Gdk keysym. http://crbug.com/109843
- return VKEY_UNKNOWN;
-#endif
-
// For supporting multimedia buttons on a USB keyboard.
case XF86XK_Back:
return VKEY_BROWSER_BACK;
diff --git a/ui/gfx/canvas_paint_gtk.cc b/ui/gfx/canvas_paint_gtk.cc
deleted file mode 100644
index aef6fc9..0000000
--- a/ui/gfx/canvas_paint_gtk.cc
+++ /dev/null
@@ -1,107 +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 "base/basictypes.h"
-#include "base/compiler_specific.h"
-#include "ui/gfx/canvas.h"
-#include "ui/gfx/canvas_skia_paint.h"
-#include "ui/gfx/rect.h"
-
-namespace gfx {
-
-// CanvasSkiaPaint
-
-CanvasSkiaPaint::CanvasSkiaPaint(GdkEventExpose* event)
- : context_(NULL),
- window_(event->window),
- region_(gdk_region_copy(event->region)),
- composite_alpha_(false) {
- Init(true);
-}
-
-CanvasSkiaPaint::CanvasSkiaPaint(GdkEventExpose* event, bool opaque)
- : context_(NULL),
- window_(event->window),
- region_(gdk_region_copy(event->region)),
- composite_alpha_(false) {
- Init(opaque);
-}
-
-CanvasSkiaPaint::~CanvasSkiaPaint() {
- if (!is_empty()) {
- platform_canvas()->restoreToCount(1);
-
- // Blit the dirty rect to the window.
- CHECK(window_);
- cairo_t* cr = gdk_cairo_create(window_);
- CHECK(cr);
- if (composite_alpha_)
- cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
- cairo_surface_t* source_surface = cairo_get_target(context_);
- CHECK(source_surface);
- // Flush cairo's cache of the surface.
- cairo_surface_mark_dirty(source_surface);
- GdkRectangle bounds = rectangle();
- cairo_set_source_surface(cr, source_surface, bounds.x, bounds.y);
- gdk_cairo_region(cr, region_);
- cairo_fill(cr);
- cairo_destroy(cr);
- }
-
- gdk_region_destroy(region_);
-}
-
-void CanvasSkiaPaint::Init(bool opaque) {
- GdkRectangle bounds = rectangle();
- RecreateBackingCanvas(Size(bounds.width, bounds.height), 1.0f, opaque);
-
- skia::PlatformCanvas* canvas = platform_canvas();
-
- // Need to translate so that the dirty region appears at the origin of the
- // surface.
- canvas->translate(-SkIntToScalar(bounds.x), -SkIntToScalar(bounds.y));
-
- context_ = skia::BeginPlatformPaint(canvas);
-}
-
-// CanvasSkiaPaintCairo
-
-CanvasSkiaPaintCairo::CanvasSkiaPaintCairo(cairo_t* cairo,
- Size size,
- bool opaque)
- : context_(NULL),
- dest_(cairo),
- size_(size),
- composite_alpha_(false) {
- CHECK(dest_);
- Init(opaque);
-}
-
-CanvasSkiaPaintCairo::~CanvasSkiaPaintCairo() {
- if (!is_empty()) {
- platform_canvas()->restoreToCount(1);
-
- // Blit the dirty rect to the window.
- if (composite_alpha_)
- cairo_set_operator(dest_, CAIRO_OPERATOR_SOURCE);
- cairo_surface_t* source_surface = cairo_get_target(context_);
- CHECK(source_surface);
- // Flush cairo's cache of the surface.
- cairo_surface_mark_dirty(source_surface);
- cairo_set_source_surface(dest_, source_surface, 0, 0);
- GdkRectangle bounds = {0, 0, size_.width(), size_.height()};
- gdk_cairo_rectangle(dest_, &bounds);
- cairo_fill(dest_);
- }
-}
-
-void CanvasSkiaPaintCairo::Init(bool opaque) {
- RecreateBackingCanvas(size_, 1.0f, opaque);
-
- context_ = skia::BeginPlatformPaint(platform_canvas());
-}
-
-} // namespace gfx
-
-
diff --git a/ui/gfx/canvas_paint_gtk.h b/ui/gfx/canvas_paint_gtk.h
deleted file mode 100644
index 487db79f..0000000
--- a/ui/gfx/canvas_paint_gtk.h
+++ /dev/null
@@ -1,102 +0,0 @@
-
-// Copyright (c) 2011 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_GFX_CANVAS_PAINT_LINUX_H_
-#define UI_GFX_CANVAS_PAINT_LINUX_H_
-
-#include "base/logging.h"
-#include "skia/ext/platform_canvas.h"
-#include "ui/gfx/canvas.h"
-#include <gdk/gdk.h>
-
-namespace gfx {
-
-// A class designed to translate skia painting into a region in a GdkWindow.
-// On construction, it will set up a context for painting into, and on
-// destruction, it will commit it to the GdkWindow.
-// Note: The created context is always inialized to (0, 0, 0, 0).
-class GFX_EXPORT CanvasSkiaPaint : public Canvas {
- public:
- // This constructor assumes the result is opaque.
- explicit CanvasSkiaPaint(GdkEventExpose* event);
- CanvasSkiaPaint(GdkEventExpose* event, bool opaque);
- virtual ~CanvasSkiaPaint();
-
- // Sets whether the bitmap is composited in such a way that the alpha channel
- // is honored. This is only useful if you've enabled an RGBA colormap on the
- // widget. The default is false.
- void set_composite_alpha(bool composite_alpha) {
- composite_alpha_ = composite_alpha;
- }
-
- // Returns true if the invalid region is empty. The caller should call this
- // function to determine if anything needs painting.
- bool is_empty() const {
- return gdk_region_empty(region_);
- }
-
- GdkRectangle rectangle() const {
- GdkRectangle bounds;
- gdk_region_get_clipbox(region_, &bounds);
- return bounds;
- }
-
- private:
- void Init(bool opaque);
-
- cairo_t* context_;
- GdkWindow* window_;
- GdkRegion* region_;
- // See description above setter.
- bool composite_alpha_;
-
- // Disallow copy and assign.
- CanvasSkiaPaint(const CanvasSkiaPaint&);
- CanvasSkiaPaint& operator=(const CanvasSkiaPaint&);
-};
-
-// A class designed to translate skia painting into a region in a Cairo context.
-// On construction, it will set up a context for painting into, and on
-// destruction, it will commit it to the Cairo context. If there are any
-// transformations applied to the Cairo context, they will affect the drawing.
-class GFX_EXPORT CanvasSkiaPaintCairo : public Canvas {
- public:
- CanvasSkiaPaintCairo(cairo_t* cairo, Size size, bool opaque);
- virtual ~CanvasSkiaPaintCairo();
-
- // Sets whether the bitmap is composited in such a way that the alpha channel
- // is honored. This is only useful if you've enabled an RGBA colormap on the
- // widget. The default is false.
- void set_composite_alpha(bool composite_alpha) {
- composite_alpha_ = composite_alpha;
- }
-
- // Returns true if size of the drawing region is empty. The caller should call
- // this function to determine if anything needs painting.
- bool is_empty() const {
- return size_.IsEmpty();
- }
-
- Size size() const {
- return size_;
- }
-
- private:
- void Init(bool opaque);
-
- cairo_t* context_;
- cairo_t* dest_;
- Size size_;
- // See description above setter.
- bool composite_alpha_;
-
- // Disallow copy and assign.
- CanvasSkiaPaintCairo(const CanvasSkiaPaintCairo&);
- CanvasSkiaPaintCairo& operator=(const CanvasSkiaPaintCairo&);
-};
-
-} // namespace gfx
-
-#endif // UI_GFX_CANVAS_PAINT_LINUX_H_
diff --git a/ui/gfx/canvas_skia_paint.h b/ui/gfx/canvas_skia_paint.h
index 3f21f5c..e9e22ff 100644
--- a/ui/gfx/canvas_skia_paint.h
+++ b/ui/gfx/canvas_skia_paint.h
@@ -12,12 +12,8 @@
#include "ui/gfx/canvas_paint_win.h"
#elif defined(__APPLE__)
#include "ui/gfx/canvas_paint_mac.h"
-#elif defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__sun)
-#if defined(TOOLKIT_GTK)
-#include "ui/gfx/canvas_paint_gtk.h"
#else
#error "No canvas paint for this platform"
#endif
-#endif
#endif // UI_GFX_CANVAS_SKIA_PAINT_H_
diff --git a/ui/gfx/font_render_params_linux.cc b/ui/gfx/font_render_params_linux.cc
index 0c157d5..fdef6a9 100644
--- a/ui/gfx/font_render_params_linux.cc
+++ b/ui/gfx/font_render_params_linux.cc
@@ -9,11 +9,7 @@
#include "ui/gfx/display.h"
#include "ui/gfx/switches.h"
-#if defined(TOOLKIT_GTK)
-#include <gtk/gtk.h>
-#else
#include <fontconfig/fontconfig.h>
-#endif
#if defined(OS_LINUX) && defined(USE_AURA) && !defined(OS_CHROMEOS)
#include "ui/gfx/linux_font_delegate.h"
@@ -39,58 +35,6 @@ bool SubpixelPositioningRequested(bool renderer) {
// Initializes |params| with the system's default settings. |renderer| is true
// when setting WebKit renderer defaults.
void LoadDefaults(FontRenderParams* params, bool renderer) {
-#if defined(TOOLKIT_GTK)
- params->antialiasing = true;
- // TODO(wangxianzhu): autohinter is now true to keep original behavior
- // of WebKit, but it might not be the best value.
- params->autohinter = true;
- params->use_bitmaps = true;
- params->hinting = FontRenderParams::HINTING_SLIGHT;
- params->subpixel_rendering = FontRenderParams::SUBPIXEL_RENDERING_NONE;
-
- GtkSettings* gtk_settings = gtk_settings_get_default();
- CHECK(gtk_settings);
- gint gtk_antialias = 0;
- gint gtk_hinting = 0;
- gchar* gtk_hint_style = NULL;
- gchar* gtk_rgba = NULL;
- g_object_get(gtk_settings,
- "gtk-xft-antialias", &gtk_antialias,
- "gtk-xft-hinting", &gtk_hinting,
- "gtk-xft-hintstyle", &gtk_hint_style,
- "gtk-xft-rgba", &gtk_rgba,
- NULL);
-
- // g_object_get() doesn't tell us whether the properties were present or not,
- // but if they aren't (because gnome-settings-daemon isn't running), we'll get
- // NULL values for the strings.
- if (gtk_hint_style && gtk_rgba) {
- params->antialiasing = gtk_antialias;
-
- if (gtk_hinting == 0 || strcmp(gtk_hint_style, "hintnone") == 0)
- params->hinting = FontRenderParams::HINTING_NONE;
- else if (strcmp(gtk_hint_style, "hintslight") == 0)
- params->hinting = FontRenderParams::HINTING_SLIGHT;
- else if (strcmp(gtk_hint_style, "hintmedium") == 0)
- params->hinting = FontRenderParams::HINTING_MEDIUM;
- else if (strcmp(gtk_hint_style, "hintfull") == 0)
- params->hinting = FontRenderParams::HINTING_FULL;
-
- if (strcmp(gtk_rgba, "none") == 0)
- params->subpixel_rendering = FontRenderParams::SUBPIXEL_RENDERING_NONE;
- else if (strcmp(gtk_rgba, "rgb") == 0)
- params->subpixel_rendering = FontRenderParams::SUBPIXEL_RENDERING_RGB;
- else if (strcmp(gtk_rgba, "bgr") == 0)
- params->subpixel_rendering = FontRenderParams::SUBPIXEL_RENDERING_BGR;
- else if (strcmp(gtk_rgba, "vrgb") == 0)
- params->subpixel_rendering = FontRenderParams::SUBPIXEL_RENDERING_VRGB;
- else if (strcmp(gtk_rgba, "vbgr") == 0)
- params->subpixel_rendering = FontRenderParams::SUBPIXEL_RENDERING_VBGR;
- }
-
- g_free(gtk_hint_style);
- g_free(gtk_rgba);
-#else
// For non-GTK builds (read: Aura), just use reasonable hardcoded values.
params->antialiasing = true;
params->autohinter = true;
@@ -134,7 +78,6 @@ void LoadDefaults(FontRenderParams* params, bool renderer) {
params->subpixel_rendering = delegate->GetSubpixelRenderingStyle();
}
#endif
-#endif
params->subpixel_positioning = SubpixelPositioningRequested(renderer);
diff --git a/ui/gfx/geometry/insets.cc b/ui/gfx/geometry/insets.cc
index 300de45..c29368e 100644
--- a/ui/gfx/geometry/insets.cc
+++ b/ui/gfx/geometry/insets.cc
@@ -4,10 +4,6 @@
#include "ui/gfx/geometry/insets.h"
-#if defined(TOOLKIT_GTK)
-#include <gtk/gtk.h>
-#endif
-
#include "base/strings/stringprintf.h"
namespace gfx {
@@ -19,15 +15,6 @@ Insets::Insets() : InsetsBase<Insets, int>(0, 0, 0, 0) {}
Insets::Insets(int top, int left, int bottom, int right)
: InsetsBase<Insets, int>(top, left, bottom, right) {}
-#if defined(TOOLKIT_GTK)
-Insets::Insets(const GtkBorder& border)
- : InsetsBase<Insets, int>(border.top,
- border.left,
- border.bottom,
- border.right) {
-}
-#endif
-
Insets::~Insets() {}
std::string Insets::ToString() const {
diff --git a/ui/gfx/geometry/insets.h b/ui/gfx/geometry/insets.h
index d9eaed4..00b6125 100644
--- a/ui/gfx/geometry/insets.h
+++ b/ui/gfx/geometry/insets.h
@@ -12,10 +12,6 @@
#include "ui/gfx/geometry/insets_f.h"
#include "ui/gfx/gfx_export.h"
-#if defined(TOOLKIT_GTK)
-typedef struct _GtkBorder GtkBorder;
-#endif
-
namespace gfx {
// An integer version of gfx::Insets.
@@ -23,9 +19,6 @@ class GFX_EXPORT Insets : public InsetsBase<Insets, int> {
public:
Insets();
Insets(int top, int left, int bottom, int right);
-#if defined(TOOLKIT_GTK)
- explicit Insets(const GtkBorder& border);
-#endif
~Insets();
diff --git a/ui/gfx/geometry/rect.cc b/ui/gfx/geometry/rect.cc
index 4b1c6e9..f418e175 100644
--- a/ui/gfx/geometry/rect.cc
+++ b/ui/gfx/geometry/rect.cc
@@ -8,8 +8,6 @@
#if defined(OS_WIN)
#include <windows.h>
-#elif defined(TOOLKIT_GTK)
-#include <gdk/gdk.h>
#endif
#include "base/logging.h"
@@ -35,12 +33,6 @@ Rect::Rect(const CGRect& r)
set_width(r.size.width);
set_height(r.size.height);
}
-#elif defined(TOOLKIT_GTK)
-Rect::Rect(const GdkRectangle& r)
- : RectBaseT(gfx::Point(r.x, r.y)) {
- set_width(r.width);
- set_height(r.height);
-}
#endif
#if defined(OS_WIN)
@@ -56,11 +48,6 @@ RECT Rect::ToRECT() const {
CGRect Rect::ToCGRect() const {
return CGRectMake(x(), y(), width(), height());
}
-#elif defined(TOOLKIT_GTK)
-GdkRectangle Rect::ToGdkRectangle() const {
- GdkRectangle r = {x(), y(), width(), height()};
- return r;
-}
#endif
std::string Rect::ToString() const {
diff --git a/ui/gfx/geometry/rect.h b/ui/gfx/geometry/rect.h
index 7272a1c..28d37bc 100644
--- a/ui/gfx/geometry/rect.h
+++ b/ui/gfx/geometry/rect.h
@@ -23,8 +23,6 @@
#if defined(OS_WIN)
typedef struct tagRECT RECT;
-#elif defined(TOOLKIT_GTK)
-typedef struct _GdkRectangle GdkRectangle;
#elif defined(OS_IOS)
#include <CoreGraphics/CoreGraphics.h>
#elif defined(OS_MACOSX)
@@ -52,8 +50,6 @@ class GFX_EXPORT Rect
explicit Rect(const RECT& r);
#elif defined(OS_MACOSX)
explicit Rect(const CGRect& r);
-#elif defined(TOOLKIT_GTK)
- explicit Rect(const GdkRectangle& r);
#endif
explicit Rect(const gfx::Size& size)
@@ -67,8 +63,6 @@ class GFX_EXPORT Rect
#if defined(OS_WIN)
// Construct an equivalent Win32 RECT object.
RECT ToRECT() const;
-#elif defined(TOOLKIT_GTK)
- GdkRectangle ToGdkRectangle() const;
#elif defined(OS_MACOSX)
// Construct an equivalent CoreGraphics object.
CGRect ToCGRect() const;
diff --git a/ui/gfx/gfx.gyp b/ui/gfx/gfx.gyp
index 8c6ca19..7c4e8bf 100644
--- a/ui/gfx/gfx.gyp
+++ b/ui/gfx/gfx.gyp
@@ -125,8 +125,6 @@
'canvas.cc',
'canvas.h',
'canvas_android.cc',
- 'canvas_paint_gtk.cc',
- 'canvas_paint_gtk.h',
'canvas_paint_mac.h',
'canvas_paint_mac.mm',
'canvas_paint_win.cc',
@@ -228,7 +226,6 @@
'path.cc',
'path.h',
'path_aura.cc',
- 'path_gtk.cc',
'path_win.cc',
'path_win.h',
'path_x11.cc',
@@ -267,7 +264,6 @@
'screen.h',
'screen_android.cc',
'screen_aura.cc',
- 'screen_gtk.cc',
'screen_ios.mm',
'screen_mac.mm',
'screen_win.cc',
@@ -284,8 +280,6 @@
'skbitmap_operations.h',
'skia_util.cc',
'skia_util.h',
- 'skia_utils_gtk.cc',
- 'skia_utils_gtk.h',
'switches.cc',
'switches.h',
'sys_color_change_listener.cc',
diff --git a/ui/gfx/gtk_compat.h b/ui/gfx/gtk_compat.h
deleted file mode 100644
index ca14a27..0000000
--- a/ui/gfx/gtk_compat.h
+++ /dev/null
@@ -1,97 +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 UI_GFX_GTK_COMPAT_H_
-#define UI_GFX_GTK_COMPAT_H_
-
-#include <gtk/gtk.h>
-
-// Google Chrome must depend on GTK 2.18, at least until the next LTS drops
-// (and we might have to extend which version of GTK we want to target due to
-// RHEL). To make our porting job for GTK3 easier, we define all the methods
-// that replace deprecated APIs in this file and then include it everywhere.
-//
-// This file is organized first by version, and then with each version,
-// alphabetically by method.
-//
-// For Google Chrome builds, we want to support RHEL 6, which uses GTK 2.18,
-// but the official builder is Ubuntu Lucid with GTK 2.20. Thus for Google
-// Chrome builds, we define the GTK 2.20.0 compatibility functions even though
-// the system GTK provides the functions.
-
-#if !GTK_CHECK_VERSION(2, 20, 0) || defined(GOOGLE_CHROME_BUILD)
-inline gboolean gtk_widget_get_mapped(GtkWidget* widget) {
- return GTK_WIDGET_MAPPED(widget);
-}
-
-inline gboolean gtk_widget_get_realized(GtkWidget* widget) {
- return GTK_WIDGET_REALIZED(widget);
-}
-
-inline gboolean gtk_widget_is_toplevel(GtkWidget* widget) {
- return GTK_WIDGET_TOPLEVEL(widget);
-}
-
-inline void gtk_widget_set_mapped(GtkWidget* widget,
- gboolean mapped) {
- if (mapped)
- GTK_WIDGET_SET_FLAGS(widget, GTK_MAPPED);
- else
- GTK_WIDGET_UNSET_FLAGS(widget, GTK_MAPPED);
-}
-
-inline void gtk_widget_set_realized(GtkWidget* widget,
- gboolean realized) {
- if (realized)
- GTK_WIDGET_SET_FLAGS(widget, GTK_REALIZED);
- else
- GTK_WIDGET_UNSET_FLAGS(widget, GTK_REALIZED);
-}
-
-inline void gtk_widget_style_attach(GtkWidget* widget) {
- widget->style = gtk_style_attach(widget->style, widget->window);
-}
-#endif // !GTK_CHECK_VERSION(2, 20, 0) || defined(GOOGLE_CHROME_BUILD)
-
-#if !GTK_CHECK_VERSION(2, 22, 0)
-inline GdkWindow* gdk_drag_context_get_source_window(GdkDragContext *context) {
- return context->source_window;
-}
-
-inline gint gdk_visual_get_depth(GdkVisual* visual) {
- return visual->depth;
-}
-
-inline GdkWindow* gtk_button_get_event_window(GtkButton* button) {
- return button->event_window;
-}
-#endif // !GTK_CHECK_VERSION(2, 22, 0)
-
-#if !GTK_CHECK_VERSION(2, 24, 0)
-inline void gdk_pixmap_get_size(GdkPixmap* pixmap, gint* width, gint* height) {
- gdk_drawable_get_size(GDK_DRAWABLE(pixmap), width, height);
-}
-
-inline GdkDisplay* gdk_window_get_display(GdkWindow* window) {
- return gdk_drawable_get_display(GDK_DRAWABLE(window));
-}
-
-inline int gdk_window_get_height(GdkWindow* window) {
- int height;
- gdk_drawable_get_size(GDK_DRAWABLE(window), NULL, &height);
- return height;
-}
-
-inline GdkScreen* gdk_window_get_screen(GdkWindow* window) {
- return gdk_drawable_get_screen(GDK_DRAWABLE(window));
-}
-
-inline int gdk_window_get_width(GdkWindow* window) {
- int width;
- gdk_drawable_get_size(GDK_DRAWABLE(window), &width, NULL);
- return width;
-}
-#endif // !GTK_CHECK_VERSION(2, 24, 0)
-
-#endif // UI_GFX_GTK_COMPAT_H_
diff --git a/ui/gfx/gtk_native_view_id_manager.cc b/ui/gfx/gtk_native_view_id_manager.cc
deleted file mode 100644
index 0844b190..0000000
--- a/ui/gfx/gtk_native_view_id_manager.cc
+++ /dev/null
@@ -1,254 +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/gfx/gtk_native_view_id_manager.h"
-
-#include <gdk/gdkx.h>
-#include <gtk/gtk.h>
-
-#include "base/logging.h"
-#include "base/memory/singleton.h"
-#include "base/rand_util.h"
-#include "ui/gfx/gdk_compat.h"
-#include "ui/gfx/gtk_compat.h"
-#include "ui/gfx/gtk_preserve_window.h"
-
-// -----------------------------------------------------------------------------
-// Bounce functions for GTK to callback into a C++ object...
-
-void OnRealize(gfx::NativeView widget, void* arg) {
- GtkNativeViewManager* manager = reinterpret_cast<GtkNativeViewManager*>(arg);
- manager->OnRealize(widget);
-}
-
-void OnUnrealize(gfx::NativeView widget, void *arg) {
- GtkNativeViewManager* manager = reinterpret_cast<GtkNativeViewManager*>(arg);
- manager->OnUnrealize(widget);
-}
-
-static void OnDestroy(GtkObject* obj, void* arg) {
- GtkNativeViewManager* manager = reinterpret_cast<GtkNativeViewManager*>(arg);
- manager->OnDestroy(reinterpret_cast<GtkWidget*>(obj));
-}
-
-// -----------------------------------------------------------------------------
-
-
-// -----------------------------------------------------------------------------
-// Public functions...
-
-GtkNativeViewManager::GtkNativeViewManager() {
-}
-
-GtkNativeViewManager::~GtkNativeViewManager() {
-}
-
-// static
-GtkNativeViewManager* GtkNativeViewManager::GetInstance() {
- return Singleton<GtkNativeViewManager>::get();
-}
-
-gfx::NativeViewId GtkNativeViewManager::GetIdForWidget(gfx::NativeView widget) {
- // This is just for unit tests:
- if (!widget)
- return 0;
-
- base::AutoLock locked(lock_);
-
- std::map<gfx::NativeView, gfx::NativeViewId>::const_iterator i =
- native_view_to_id_.find(widget);
-
- if (i != native_view_to_id_.end())
- return i->second;
-
- gfx::NativeViewId new_id =
- static_cast<gfx::NativeViewId>(base::RandUint64());
- while (id_to_info_.find(new_id) != id_to_info_.end())
- new_id = static_cast<gfx::NativeViewId>(base::RandUint64());
-
- NativeViewInfo info;
- info.widget = widget;
- if (gtk_widget_get_realized(widget)) {
- GdkWindow *gdk_window = gtk_widget_get_window(widget);
- DCHECK(gdk_window);
- info.x_window_id = GDK_WINDOW_XID(gdk_window);
- }
-
- native_view_to_id_[widget] = new_id;
- id_to_info_[new_id] = info;
-
- g_signal_connect(widget, "realize", G_CALLBACK(::OnRealize), this);
- g_signal_connect(widget, "unrealize", G_CALLBACK(::OnUnrealize), this);
- g_signal_connect(widget, "destroy", G_CALLBACK(::OnDestroy), this);
-
- return new_id;
-}
-
-bool GtkNativeViewManager::GetXIDForId(XID* output, gfx::NativeViewId id) {
- base::AutoLock locked(lock_);
-
- std::map<gfx::NativeViewId, NativeViewInfo>::const_iterator i =
- id_to_info_.find(id);
-
- if (i == id_to_info_.end())
- return false;
-
- *output = i->second.x_window_id;
- return true;
-}
-
-bool GtkNativeViewManager::GetNativeViewForId(gfx::NativeView* output,
- gfx::NativeViewId id) {
- base::AutoLock locked(lock_);
-
- std::map<gfx::NativeViewId, NativeViewInfo>::const_iterator i =
- id_to_info_.find(id);
-
- if (i == id_to_info_.end())
- return false;
-
- *output = i->second.widget;
- return true;
-}
-
-bool GtkNativeViewManager::GetPermanentXIDForId(XID* output,
- gfx::NativeViewId id) {
- base::AutoLock locked(lock_);
-
- std::map<gfx::NativeViewId, NativeViewInfo>::iterator i =
- id_to_info_.find(id);
-
- if (i == id_to_info_.end())
- return false;
-
- // We only return permanent XIDs for widgets that allow us to guarantee that
- // the XID will not change.
- DCHECK(GTK_IS_PRESERVE_WINDOW(i->second.widget));
- GtkPreserveWindow* widget =
- reinterpret_cast<GtkPreserveWindow*>(i->second.widget);
- gtk_preserve_window_set_preserve(widget, TRUE);
-
- *output = GDK_WINDOW_XID(gtk_widget_get_window(i->second.widget));
-
- // Update the reference count on the permanent XID.
- PermanentXIDInfo info;
- info.widget = widget;
- info.ref_count = 1;
- std::pair<std::map<XID, PermanentXIDInfo>::iterator, bool> ret =
- perm_xid_to_info_.insert(std::make_pair(*output, info));
-
- if (!ret.second) {
- DCHECK(ret.first->second.widget == widget);
- ret.first->second.ref_count++;
- }
-
- return true;
-}
-
-bool GtkNativeViewManager::AddRefPermanentXID(XID xid) {
- base::AutoLock locked(lock_);
-
- std::map<XID, PermanentXIDInfo>::iterator i =
- perm_xid_to_info_.find(xid);
-
- if (i == perm_xid_to_info_.end())
- return false;
-
- i->second.ref_count++;
-
- return true;
-}
-
-void GtkNativeViewManager::ReleasePermanentXID(XID xid) {
- base::AutoLock locked(lock_);
-
- std::map<XID, PermanentXIDInfo>::iterator i =
- perm_xid_to_info_.find(xid);
-
- if (i == perm_xid_to_info_.end())
- return;
-
- if (i->second.ref_count > 1) {
- i->second.ref_count--;
- } else {
- if (i->second.widget) {
- gtk_preserve_window_set_preserve(i->second.widget, FALSE);
- } else {
- GdkWindow* window = reinterpret_cast<GdkWindow*>(
- gdk_x11_window_lookup_for_display(gdk_display_get_default(), xid));
- DCHECK(window);
- gdk_window_destroy(window);
- }
- perm_xid_to_info_.erase(i);
- }
-}
-
-// -----------------------------------------------------------------------------
-
-
-// -----------------------------------------------------------------------------
-// Private functions...
-
-gfx::NativeViewId GtkNativeViewManager::GetWidgetId(gfx::NativeView widget) {
- lock_.AssertAcquired();
-
- std::map<gfx::NativeView, gfx::NativeViewId>::const_iterator i =
- native_view_to_id_.find(widget);
-
- CHECK(i != native_view_to_id_.end());
- return i->second;
-}
-
-void GtkNativeViewManager::OnRealize(gfx::NativeView widget) {
- base::AutoLock locked(lock_);
-
- const gfx::NativeViewId id = GetWidgetId(widget);
- std::map<gfx::NativeViewId, NativeViewInfo>::iterator i =
- id_to_info_.find(id);
-
- CHECK(i != id_to_info_.end());
-
- GdkWindow* gdk_window = gtk_widget_get_window(widget);
- CHECK(gdk_window);
- i->second.x_window_id = GDK_WINDOW_XID(gdk_window);
-}
-
-void GtkNativeViewManager::OnUnrealize(gfx::NativeView widget) {
- base::AutoLock locked(lock_);
-
- const gfx::NativeViewId id = GetWidgetId(widget);
- std::map<gfx::NativeViewId, NativeViewInfo>::iterator i =
- id_to_info_.find(id);
-
- CHECK(i != id_to_info_.end());
-}
-
-void GtkNativeViewManager::OnDestroy(gfx::NativeView widget) {
- base::AutoLock locked(lock_);
-
- std::map<gfx::NativeView, gfx::NativeViewId>::iterator i =
- native_view_to_id_.find(widget);
- CHECK(i != native_view_to_id_.end());
-
- std::map<gfx::NativeViewId, NativeViewInfo>::iterator j =
- id_to_info_.find(i->second);
- CHECK(j != id_to_info_.end());
-
- // If the XID is supposed to outlive the widget, mark it
- // in the lookup table.
- if (GTK_IS_PRESERVE_WINDOW(widget) &&
- gtk_preserve_window_get_preserve(
- reinterpret_cast<GtkPreserveWindow*>(widget))) {
- std::map<XID, PermanentXIDInfo>::iterator k =
- perm_xid_to_info_.find(GDK_WINDOW_XID(gtk_widget_get_window(widget)));
-
- if (k != perm_xid_to_info_.end())
- k->second.widget = NULL;
- }
-
- native_view_to_id_.erase(i);
- id_to_info_.erase(j);
-}
-
-// -----------------------------------------------------------------------------
diff --git a/ui/gfx/gtk_native_view_id_manager.h b/ui/gfx/gtk_native_view_id_manager.h
deleted file mode 100644
index 4421920..0000000
--- a/ui/gfx/gtk_native_view_id_manager.h
+++ /dev/null
@@ -1,138 +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 UI_GFX_GTK_NATIVE_VIEW_ID_MANAGER_H_
-#define UI_GFX_GTK_NATIVE_VIEW_ID_MANAGER_H_
-
-#include <map>
-
-#include "base/synchronization/lock.h"
-#include "ui/gfx/gfx_export.h"
-#include "ui/gfx/native_widget_types.h"
-
-template <typename T> struct DefaultSingletonTraits;
-
-typedef unsigned long XID;
-struct _GtkPreserveWindow;
-
-// NativeViewIds are the opaque values which the renderer holds as a reference
-// to a window.
-//
-// We could make NativeViewIds be the X id of the window. However, at the
-// time when we need to tell the renderer about its NativeViewId, an XID isn't
-// availible and it goes very much against the grain of the code to make it so.
-// Also, we worry that GTK might choose to change the underlying X window id
-// when, say, the widget is hidden or repacked. Finally, if we used XIDs then a
-// compromised renderer could start asking questions about any X windows on the
-// system.
-//
-// Thus, we have this object. It produces random NativeViewIds from GtkWidget
-// pointers and observes the various signals from the widget for when an X
-// window is created, destroyed etc. Thus it provides a thread safe mapping
-// from NativeViewIds to the current XID for that widget.
-class GFX_EXPORT GtkNativeViewManager {
- public:
- // Returns the singleton instance.
- static GtkNativeViewManager* GetInstance();
-
- // Must be called from the UI thread:
- //
- // Return a NativeViewId for the given widget and attach to the various
- // signals emitted by that widget. The NativeViewId is pseudo-randomly
- // allocated so that a compromised renderer trying to guess values will fail
- // with high probability. The NativeViewId will not be reused for the
- // lifetime of the GtkWidget.
- gfx::NativeViewId GetIdForWidget(gfx::NativeView widget);
-
- // May be called from any thread:
- //
- // xid: (output) the resulting X window ID, or 0
- // id: a value previously returned from GetIdForWidget
- // returns: true if |id| is a valid id, false otherwise.
- //
- // If the widget referenced by |id| does not current have an X window id,
- // |*xid| is set to 0.
- bool GetXIDForId(XID* xid, gfx::NativeViewId id);
-
- // May be called from the UI thread:
- //
- // Same as GetXIDForId except it returns the NativeView (GtkWidget*).
- bool GetNativeViewForId(gfx::NativeView* xid, gfx::NativeViewId id);
-
- // Must be called from the UI thread because we may need the associated
- // widget to create a window.
- //
- // Keeping the XID permanent requires a bit of overhead, so it must
- // be explicitly requested.
- //
- // xid: (output) the resulting X window
- // id: a value previously returned from GetIdForWidget
- // returns: true if |id| is a valid id, false otherwise.
- bool GetPermanentXIDForId(XID* xid, gfx::NativeViewId id);
-
- // Can be called from any thread.
- // Will return false if the given XID isn't permanent or has already been
- // released.
- bool AddRefPermanentXID(XID xid);
-
- // Must be called from the UI thread because we may need to access a
- // GtkWidget or destroy a GdkWindow.
- //
- // If the widget associated with the XID is still alive, allow the widget
- // to destroy the associated XID when it wants. Otherwise, destroy the
- // GdkWindow associated with the XID.
- void ReleasePermanentXID(XID xid);
-
- // These are actually private functions, but need to be called from statics.
- void OnRealize(gfx::NativeView widget);
- void OnUnrealize(gfx::NativeView widget);
- void OnDestroy(gfx::NativeView widget);
-
- private:
- // This object is a singleton:
- GtkNativeViewManager();
- ~GtkNativeViewManager();
- friend struct DefaultSingletonTraits<GtkNativeViewManager>;
-
- struct NativeViewInfo {
- NativeViewInfo() : widget(NULL), x_window_id(0) {
- }
- gfx::NativeView widget;
- XID x_window_id;
- };
-
- gfx::NativeViewId GetWidgetId(gfx::NativeView id);
-
- // protects native_view_to_id_ and id_to_info_
- base::Lock lock_;
-
- // If asked for an id for the same widget twice, we want to return the same
- // id. So this records the current mapping.
- std::map<gfx::NativeView, gfx::NativeViewId> native_view_to_id_;
- std::map<gfx::NativeViewId, NativeViewInfo> id_to_info_;
-
- struct PermanentXIDInfo {
- PermanentXIDInfo() : widget(NULL), ref_count(0) {
- }
- _GtkPreserveWindow* widget;
- int ref_count;
- };
-
- // Used to maintain the reference count for permanent XIDs
- // (referenced by GetPermanentXIDForId and dereferenced by
- // ReleasePermanentXID). Only those XIDs with a positive reference count
- // will be in the table.
- //
- // In general, several GTK widgets may share the same X window. We assume
- // that is not true of the widgets stored in this registry.
- //
- // An XID will map to NULL, if there is an outstanding reference but the
- // widget was destroyed. In this case, the destruction of the X window
- // is deferred to the dropping of all references.
- std::map<XID, PermanentXIDInfo> perm_xid_to_info_;
-
- DISALLOW_COPY_AND_ASSIGN(GtkNativeViewManager);
-};
-
-#endif // UI_GFX_GTK_NATIVE_VIEW_ID_MANAGER_H_
diff --git a/ui/gfx/gtk_preserve_window.cc b/ui/gfx/gtk_preserve_window.cc
deleted file mode 100644
index 78a49c2..0000000
--- a/ui/gfx/gtk_preserve_window.cc
+++ /dev/null
@@ -1,264 +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/gfx/gtk_preserve_window.h"
-
-#include <gdk/gdk.h>
-#include <gtk/gtk.h>
-
-#include "ui/gfx/gtk_compat.h"
-
-G_BEGIN_DECLS
-
-#define GTK_PRESERVE_WINDOW_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), \
- GTK_TYPE_PRESERVE_WINDOW, \
- GtkPreserveWindowPrivate))
-
-typedef struct _GtkPreserveWindowPrivate GtkPreserveWindowPrivate;
-
-struct _GtkPreserveWindowPrivate {
- // If true, don't create/destroy windows on realize/unrealize.
- gboolean preserve_window;
-
- // Whether or not we delegate the resize of the GdkWindow
- // to someone else.
- gboolean delegate_resize;
-
- // Accessible factory and userdata.
- AtkObject* (*accessible_factory)(void* userdata);
- void* accessible_factory_userdata;
-};
-
-G_DEFINE_TYPE(GtkPreserveWindow, gtk_preserve_window, GTK_TYPE_FIXED)
-
-static void gtk_preserve_window_destroy(GtkObject* object);
-static void gtk_preserve_window_realize(GtkWidget* widget);
-static void gtk_preserve_window_unrealize(GtkWidget* widget);
-static void gtk_preserve_window_size_allocate(GtkWidget* widget,
- GtkAllocation* allocation);
-static AtkObject* gtk_preserve_window_get_accessible(GtkWidget* widget);
-
-static void gtk_preserve_window_class_init(GtkPreserveWindowClass *klass) {
- GtkWidgetClass* widget_class = reinterpret_cast<GtkWidgetClass*>(klass);
- widget_class->realize = gtk_preserve_window_realize;
- widget_class->unrealize = gtk_preserve_window_unrealize;
- widget_class->size_allocate = gtk_preserve_window_size_allocate;
- widget_class->get_accessible = gtk_preserve_window_get_accessible;
-
- GtkObjectClass* object_class = reinterpret_cast<GtkObjectClass*>(klass);
- object_class->destroy = gtk_preserve_window_destroy;
-
- GObjectClass* gobject_class = G_OBJECT_CLASS(klass);
- g_type_class_add_private(gobject_class, sizeof(GtkPreserveWindowPrivate));
-}
-
-static void gtk_preserve_window_init(GtkPreserveWindow* widget) {
- GtkPreserveWindowPrivate* priv = GTK_PRESERVE_WINDOW_GET_PRIVATE(widget);
- priv->preserve_window = FALSE;
- priv->accessible_factory = NULL;
- priv->accessible_factory_userdata = NULL;
-
- // These widgets always have their own window.
- gtk_widget_set_has_window(GTK_WIDGET(widget), TRUE);
-}
-
-GtkWidget* gtk_preserve_window_new() {
- return GTK_WIDGET(g_object_new(GTK_TYPE_PRESERVE_WINDOW, NULL));
-}
-
-static void gtk_preserve_window_destroy(GtkObject* object) {
- GtkWidget* widget = reinterpret_cast<GtkWidget*>(object);
- GtkPreserveWindowPrivate* priv = GTK_PRESERVE_WINDOW_GET_PRIVATE(widget);
-
- GdkWindow* gdk_window = gtk_widget_get_window(widget);
- if (gdk_window) {
- gdk_window_set_user_data(gdk_window, NULL);
- // If the window is preserved, someone else must destroy it.
- if (!priv->preserve_window)
- gdk_window_destroy(gdk_window);
- gtk_widget_set_window(widget, NULL);
- }
-
- GTK_OBJECT_CLASS(gtk_preserve_window_parent_class)->destroy(object);
-}
-
-static void gtk_preserve_window_realize(GtkWidget* widget) {
- g_return_if_fail(GTK_IS_PRESERVE_WINDOW(widget));
-
- GdkWindow* gdk_window = gtk_widget_get_window(widget);
- if (gdk_window) {
- GtkAllocation allocation;
- gtk_widget_get_allocation(widget, &allocation);
-
- gdk_window_reparent(gdk_window,
- gtk_widget_get_parent_window(widget),
- allocation.x,
- allocation.y);
- GtkPreserveWindowPrivate* priv = GTK_PRESERVE_WINDOW_GET_PRIVATE(widget);
- if (!priv->delegate_resize) {
- gdk_window_resize(gdk_window,
- allocation.width,
- allocation.height);
- }
- gint event_mask = gtk_widget_get_events(widget);
- event_mask |= GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK;
- gdk_window_set_events(gdk_window, (GdkEventMask) event_mask);
- gdk_window_set_user_data(gdk_window, widget);
-
- gtk_widget_set_realized(widget, TRUE);
-
- gtk_widget_style_attach(widget);
- gtk_style_set_background(gtk_widget_get_style(widget),
- gdk_window, GTK_STATE_NORMAL);
- } else {
- GTK_WIDGET_CLASS(gtk_preserve_window_parent_class)->realize(widget);
- }
-}
-
-static void gtk_preserve_window_unrealize(GtkWidget* widget) {
- g_return_if_fail(GTK_IS_PRESERVE_WINDOW(widget));
-
- GtkPreserveWindowPrivate* priv = GTK_PRESERVE_WINDOW_GET_PRIVATE(widget);
- if (priv->preserve_window) {
- GtkWidgetClass* widget_class =
- GTK_WIDGET_CLASS(gtk_preserve_window_parent_class);
- GtkContainerClass* container_class =
- GTK_CONTAINER_CLASS(gtk_preserve_window_parent_class);
-
- if (gtk_widget_get_mapped(widget)) {
- widget_class->unmap(widget);
-
- gtk_widget_set_mapped(widget, FALSE);
- }
-
- // This is the behavior from GtkWidget, inherited by GtkFixed.
- // It is unclear why we should not call the potentially overridden
- // unrealize method (via the callback), but doing so causes errors.
- container_class->forall(
- GTK_CONTAINER(widget), FALSE,
- reinterpret_cast<GtkCallback>(gtk_widget_unrealize), NULL);
-
- GdkWindow* gdk_window = gtk_widget_get_window(widget);
-
- // TODO(erg): Almost all style handling will need to be overhauled in GTK3.
- gtk_style_detach(gtk_widget_get_style(widget));
- gdk_window_reparent(gdk_window, gdk_get_default_root_window(), 0, 0);
- gtk_selection_remove_all(widget);
- gdk_window_set_user_data(gdk_window, NULL);
-
- gtk_widget_set_realized(widget, FALSE);
- } else {
- GTK_WIDGET_CLASS(gtk_preserve_window_parent_class)->unrealize(widget);
- }
-}
-
-gboolean gtk_preserve_window_get_preserve(GtkPreserveWindow* window) {
- g_return_val_if_fail(GTK_IS_PRESERVE_WINDOW(window), FALSE);
- GtkPreserveWindowPrivate* priv = GTK_PRESERVE_WINDOW_GET_PRIVATE(window);
-
- return priv->preserve_window;
-}
-
-void gtk_preserve_window_set_preserve(GtkPreserveWindow* window,
- gboolean value) {
- g_return_if_fail(GTK_IS_PRESERVE_WINDOW(window));
- GtkPreserveWindowPrivate* priv = GTK_PRESERVE_WINDOW_GET_PRIVATE(window);
- priv->preserve_window = value;
-
- GtkWidget* widget = GTK_WIDGET(window);
- GdkWindow* gdk_window = gtk_widget_get_window(widget);
- if (value && !gdk_window) {
- GdkWindowAttr attributes;
- gint attributes_mask;
-
- // We may not know the width and height, so we rely on the fact
- // that a size-allocation will resize it later.
- attributes.width = 1;
- attributes.height = 1;
-
- attributes.window_type = GDK_WINDOW_CHILD;
- attributes.wclass = GDK_INPUT_OUTPUT;
- attributes.override_redirect = TRUE;
-
- attributes.visual = gtk_widget_get_visual(widget);
- attributes.colormap = gtk_widget_get_colormap(widget);
-
- attributes.event_mask = gtk_widget_get_events(widget);
- attributes.event_mask |= GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK;
-
- attributes_mask = GDK_WA_VISUAL | GDK_WA_COLORMAP | GDK_WA_NOREDIR;
- gdk_window = gdk_window_new(
- gdk_get_default_root_window(), &attributes, attributes_mask);
- gtk_widget_set_window(widget, gdk_window);
- } else if (!value && gdk_window && !gtk_widget_get_realized(widget)) {
- gdk_window_destroy(gdk_window);
- gtk_widget_set_window(widget, NULL);
- }
-}
-
-void gtk_preserve_window_size_allocate(GtkWidget* widget,
- GtkAllocation* allocation) {
- g_return_if_fail(GTK_IS_PRESERVE_WINDOW(widget));
-
- gtk_widget_set_allocation(widget, allocation);
-
- if (gtk_widget_get_realized(widget)) {
- GtkPreserveWindowPrivate* priv = GTK_PRESERVE_WINDOW_GET_PRIVATE(widget);
- GdkWindow* gdk_window = gtk_widget_get_window(widget);
- if (priv->delegate_resize) {
- gdk_window_move(gdk_window, allocation->x, allocation->y);
- } else {
- gdk_window_move_resize(
- gdk_window, allocation->x, allocation->y,
- allocation->width, allocation->height);
- }
- }
-
- // Propagate resize to children
- guint16 border_width = gtk_container_get_border_width(GTK_CONTAINER(widget));
- GList *children = GTK_FIXED(widget)->children;
- while (children) {
- GtkFixedChild *child = reinterpret_cast<GtkFixedChild*>(children->data);
- if (gtk_widget_get_visible(child->widget)) {
- GtkRequisition child_requisition;
- gtk_widget_get_child_requisition(child->widget, &child_requisition);
-
- GtkAllocation child_allocation;
- child_allocation.x = child->x + border_width;
- child_allocation.y = child->y + border_width;
- child_allocation.width = child_requisition.width;
- child_allocation.height = child_requisition.height;
-
- gtk_widget_size_allocate(child->widget, &child_allocation);
- }
- children = children->next;
- }
-}
-
-void gtk_preserve_window_delegate_resize(GtkPreserveWindow* widget,
- gboolean delegate) {
- GtkPreserveWindowPrivate* priv = GTK_PRESERVE_WINDOW_GET_PRIVATE(widget);
- priv->delegate_resize = delegate;
-}
-
-void gtk_preserve_window_set_accessible_factory(
- GtkPreserveWindow* widget,
- AtkObject* (*factory)(void* userdata),
- gpointer userdata) {
- GtkPreserveWindowPrivate* priv = GTK_PRESERVE_WINDOW_GET_PRIVATE(widget);
- priv->accessible_factory = factory;
- priv->accessible_factory_userdata = userdata;
-}
-
-AtkObject* gtk_preserve_window_get_accessible(GtkWidget* widget) {
- GtkPreserveWindowPrivate* priv = GTK_PRESERVE_WINDOW_GET_PRIVATE(widget);
- if (priv->accessible_factory) {
- return priv->accessible_factory(priv->accessible_factory_userdata);
- } else {
- return GTK_WIDGET_CLASS(gtk_preserve_window_parent_class)
- ->get_accessible(widget);
- }
-}
-
-G_END_DECLS
diff --git a/ui/gfx/gtk_preserve_window.h b/ui/gfx/gtk_preserve_window.h
deleted file mode 100644
index 5b5198b..0000000
--- a/ui/gfx/gtk_preserve_window.h
+++ /dev/null
@@ -1,74 +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 UI_GFX_GTK_PRESERVE_WINDOW_H_
-#define UI_GFX_GTK_PRESERVE_WINDOW_H_
-
-#include <atk/atk.h>
-#include <gdk/gdk.h>
-#include <gtk/gtk.h>
-
-#include "ui/gfx/gfx_export.h"
-
-// GtkFixed creates an X window when realized and destroys an X window
-// when unrealized. GtkPreserveWindow allows overrides this
-// behaviour. When preserve is set (via gtk_preserve_window_set_preserve),
-// the X window is only destroyed when the widget is destroyed.
-
-G_BEGIN_DECLS
-
-#define GTK_TYPE_PRESERVE_WINDOW \
- (gtk_preserve_window_get_type())
-#define GTK_PRESERVE_WINDOW(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST((obj), GTK_TYPE_PRESERVE_WINDOW, \
- GtkPreserveWindow))
-#define GTK_PRESERVE_WINDOW_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST((klass), GTK_TYPE_PRESERVE_WINDOW, \
- GtkPreserveWindowClass))
-#define GTK_IS_PRESERVE_WINDOW(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE((obj), GTK_TYPE_PRESERVE_WINDOW))
-#define GTK_IS_PRESERVE_WINDOW_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_TYPE((klass), GTK_TYPE_PRESERVE_WINDOW))
-#define GTK_PRESERVE_WINDOW_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS((obj), GTK_TYPE_PRESERVE_WINDOW, \
- GtkPreserveWindowClass))
-
-typedef struct _GtkPreserveWindow GtkPreserveWindow;
-typedef struct _GtkPreserveWindowClass GtkPreserveWindowClass;
-
-struct _GtkPreserveWindow {
- // Parent class.
- GtkFixed fixed;
-};
-
-struct _GtkPreserveWindowClass {
- GtkFixedClass parent_class;
-};
-
-GFX_EXPORT GType gtk_preserve_window_get_type() G_GNUC_CONST;
-GFX_EXPORT GtkWidget* gtk_preserve_window_new();
-
-// Whether or not we should preserve associated windows as the widget
-// is realized or unrealized.
-GFX_EXPORT gboolean gtk_preserve_window_get_preserve(GtkPreserveWindow* widget);
-GFX_EXPORT void gtk_preserve_window_set_preserve(GtkPreserveWindow* widget,
- gboolean value);
-
-// Whether or not someone else will gdk_window_resize the GdkWindow associated
-// with this widget (needed by the GPU process to synchronize resizing
-// with swapped between front and back buffer).
-GFX_EXPORT void gtk_preserve_window_delegate_resize(GtkPreserveWindow* widget,
- gboolean delegate);
-
-// Provide a function to return an AtkObject* when calls to get_accessible
-// are made on this widget. The parameter |userdata| will be passed to the
-// factory function.
-GFX_EXPORT void gtk_preserve_window_set_accessible_factory(
- GtkPreserveWindow* widget,
- AtkObject* (*factory)(void* userdata),
- gpointer userdata);
-
-G_END_DECLS
-
-#endif // UI_GFX_GTK_PRESERVE_WINDOW_H_
diff --git a/ui/gfx/gtk_util.cc b/ui/gfx/gtk_util.cc
deleted file mode 100644
index 0c11168..0000000
--- a/ui/gfx/gtk_util.cc
+++ /dev/null
@@ -1,190 +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/gfx/gtk_util.h"
-
-#include <gdk/gdk.h>
-#include <gtk/gtk.h>
-#include <stdlib.h>
-
-#include "base/basictypes.h"
-#include "base/command_line.h"
-#include "base/memory/scoped_ptr.h"
-#include "third_party/skia/include/core/SkBitmap.h"
-#include "third_party/skia/include/core/SkUnPreMultiply.h"
-#include "ui/gfx/rect.h"
-
-namespace {
-
-// A process wide singleton that manages our usage of gdk cursors.
-// gdk_cursor_new() hits the disk in several places and GdkCursor instances can
-// be reused throughout the process.
-class GdkCursorCache {
- public:
- GdkCursorCache() {}
- ~GdkCursorCache() {
- for (GdkCursorMap::iterator i(cursors_.begin()); i != cursors_.end(); ++i) {
- gdk_cursor_unref(i->second);
- }
- cursors_.clear();
- }
-
- GdkCursor* GetCursorImpl(GdkCursorType type) {
- GdkCursorMap::iterator it = cursors_.find(type);
- GdkCursor* cursor = NULL;
- if (it == cursors_.end()) {
- cursor = gdk_cursor_new(type);
- cursors_.insert(std::make_pair(type, cursor));
- } else {
- cursor = it->second;
- }
-
- // It is not necessary to add a reference here. The callers can ref the
- // cursor if they need it for something.
- return cursor;
- }
-
- private:
- typedef std::map<GdkCursorType, GdkCursor*> GdkCursorMap;
- GdkCursorMap cursors_;
-
- DISALLOW_COPY_AND_ASSIGN(GdkCursorCache);
-};
-
-} // namespace
-
-namespace gfx {
-
-static void CommonInitFromCommandLine(const CommandLine& command_line,
- void (*init_func)(gint*, gchar***)) {
- const std::vector<std::string>& args = command_line.argv();
- int argc = args.size();
- scoped_ptr<char *[]> argv(new char *[argc + 1]);
- for (size_t i = 0; i < args.size(); ++i) {
- // TODO(piman@google.com): can gtk_init modify argv? Just being safe
- // here.
- argv[i] = strdup(args[i].c_str());
- }
- argv[argc] = NULL;
- char **argv_pointer = argv.get();
-
- init_func(&argc, &argv_pointer);
- for (size_t i = 0; i < args.size(); ++i) {
- free(argv[i]);
- }
-}
-
-void GtkInitFromCommandLine(const CommandLine& command_line) {
- CommonInitFromCommandLine(command_line, gtk_init);
-}
-
-void GdkInitFromCommandLine(const CommandLine& command_line) {
- CommonInitFromCommandLine(command_line, gdk_init);
-}
-
-GdkPixbuf* GdkPixbufFromSkBitmap(const SkBitmap& bitmap) {
- if (bitmap.isNull())
- return NULL;
-
- SkAutoLockPixels lock_pixels(bitmap);
-
- int width = bitmap.width();
- int height = bitmap.height();
-
- GdkPixbuf* pixbuf = gdk_pixbuf_new(
- GDK_COLORSPACE_RGB, // The only colorspace gtk supports.
- TRUE, // There is an alpha channel.
- 8,
- width, height);
-
- // SkBitmaps are premultiplied, we need to unpremultiply them.
- const int kBytesPerPixel = 4;
- uint8* divided = gdk_pixbuf_get_pixels(pixbuf);
-
- for (int y = 0, i = 0; y < height; y++) {
- for (int x = 0; x < width; x++) {
- uint32 pixel = bitmap.getAddr32(0, y)[x];
-
- int alpha = SkColorGetA(pixel);
- if (alpha != 0 && alpha != 255) {
- SkColor unmultiplied = SkUnPreMultiply::PMColorToColor(pixel);
- divided[i + 0] = SkColorGetR(unmultiplied);
- divided[i + 1] = SkColorGetG(unmultiplied);
- divided[i + 2] = SkColorGetB(unmultiplied);
- divided[i + 3] = alpha;
- } else {
- divided[i + 0] = SkColorGetR(pixel);
- divided[i + 1] = SkColorGetG(pixel);
- divided[i + 2] = SkColorGetB(pixel);
- divided[i + 3] = alpha;
- }
- i += kBytesPerPixel;
- }
- }
-
- return pixbuf;
-}
-
-void SubtractRectanglesFromRegion(GdkRegion* region,
- const std::vector<Rect>& cutouts) {
- for (size_t i = 0; i < cutouts.size(); ++i) {
- GdkRectangle rect = cutouts[i].ToGdkRectangle();
- GdkRegion* rect_region = gdk_region_rectangle(&rect);
- gdk_region_subtract(region, rect_region);
- // TODO(deanm): It would be nice to be able to reuse the GdkRegion here.
- gdk_region_destroy(rect_region);
- }
-}
-
-GdkCursor* GetCursor(int type) {
- CR_DEFINE_STATIC_LOCAL(GdkCursorCache, impl, ());
- return impl.GetCursorImpl(static_cast<GdkCursorType>(type));
-}
-
-void InitRCStyles() {
- static const char kRCText[] =
- // Make our dialogs styled like the GNOME HIG.
- //
- // TODO(evanm): content-area-spacing was introduced in a later
- // version of GTK, so we need to set that manually on all dialogs.
- // Perhaps it would make sense to have a shared FixupDialog() function.
- "style \"gnome-dialog\" {\n"
- " xthickness = 12\n"
- " GtkDialog::action-area-border = 0\n"
- " GtkDialog::button-spacing = 6\n"
- " GtkDialog::content-area-spacing = 18\n"
- " GtkDialog::content-area-border = 12\n"
- "}\n"
- // Note we set it at the "application" priority, so users can override.
- "widget \"GtkDialog\" style : application \"gnome-dialog\"\n"
-
- // Make our about dialog special, so the image is flush with the edge.
- "style \"about-dialog\" {\n"
- " GtkDialog::action-area-border = 12\n"
- " GtkDialog::button-spacing = 6\n"
- " GtkDialog::content-area-spacing = 18\n"
- " GtkDialog::content-area-border = 0\n"
- "}\n"
- "widget \"about-dialog\" style : application \"about-dialog\"\n";
-
- gtk_rc_parse_string(kRCText);
-}
-
-base::TimeDelta GetCursorBlinkCycle() {
- // From http://library.gnome.org/devel/gtk/unstable/GtkSettings.html, this is
- // the default value for gtk-cursor-blink-time.
- static const gint kGtkDefaultCursorBlinkTime = 1200;
-
- gint cursor_blink_time = kGtkDefaultCursorBlinkTime;
- gboolean cursor_blink = TRUE;
- g_object_get(gtk_settings_get_default(),
- "gtk-cursor-blink-time", &cursor_blink_time,
- "gtk-cursor-blink", &cursor_blink,
- NULL);
- return cursor_blink ?
- base::TimeDelta::FromMilliseconds(cursor_blink_time) :
- base::TimeDelta();
-}
-
-} // namespace gfx
diff --git a/ui/gfx/gtk_util.h b/ui/gfx/gtk_util.h
deleted file mode 100644
index 7607603..0000000
--- a/ui/gfx/gtk_util.h
+++ /dev/null
@@ -1,55 +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 UI_GFX_GTK_UTIL_H_
-#define UI_GFX_GTK_UTIL_H_
-
-#include <vector>
-
-#include "base/time/time.h"
-#include "ui/gfx/gfx_export.h"
-
-typedef struct _GdkPixbuf GdkPixbuf;
-typedef struct _GdkRegion GdkRegion;
-typedef struct _GdkCursor GdkCursor;
-
-class SkBitmap;
-
-namespace base {
-class CommandLine;
-}
-
-namespace gfx {
-
-class Rect;
-
-// Call gtk_init() / gdk_init() using the argc and argv from command_line.
-// These init functions want an argc and argv that they can mutate; we provide
-// those, but leave the original CommandLine unaltered.
-GFX_EXPORT void GtkInitFromCommandLine(const base::CommandLine& command_line);
-GFX_EXPORT void GdkInitFromCommandLine(const base::CommandLine& command_line);
-
-// Convert and copy a SkBitmap to a GdkPixbuf. NOTE: this uses BGRAToRGBA, so
-// it is an expensive operation. The returned GdkPixbuf will have a refcount of
-// 1, and the caller is responsible for unrefing it when done.
-GFX_EXPORT GdkPixbuf* GdkPixbufFromSkBitmap(const SkBitmap& bitmap);
-
-// Modify the given region by subtracting the given rectangles.
-GFX_EXPORT void SubtractRectanglesFromRegion(GdkRegion* region,
- const std::vector<Rect>& cutouts);
-
-// Returns a static instance of a GdkCursor* object, sharable across the
-// process. Caller must gdk_cursor_ref() it if they want to assume ownership.
-GFX_EXPORT GdkCursor* GetCursor(int type);
-
-// Initialize some GTK settings so that our dialogs are consistent.
-GFX_EXPORT void InitRCStyles();
-
-// Queries GtkSettings for the cursor blink cycle time. Returns a 0 duration if
-// blinking is disabled.
-GFX_EXPORT base::TimeDelta GetCursorBlinkCycle();
-
-} // namespace gfx
-
-#endif // UI_GFX_GTK_UTIL_H_
diff --git a/ui/gfx/image/image.cc b/ui/gfx/image/image.cc
index 21fc7fb..6ee817b 100644
--- a/ui/gfx/image/image.cc
+++ b/ui/gfx/image/image.cc
@@ -18,15 +18,7 @@
#include "ui/gfx/codec/png_codec.h"
#endif
-#if defined(TOOLKIT_GTK)
-#include <gdk-pixbuf/gdk-pixbuf.h>
-#include <gdk/gdk.h>
-#include <glib-object.h>
-#include "ui/gfx/canvas.h"
-#include "ui/gfx/gtk_util.h"
-#include "ui/gfx/image/cairo_cached_surface.h"
-#include "ui/gfx/scoped_gobject.h"
-#elif defined(OS_IOS)
+#if defined(OS_IOS)
#include "base/mac/foundation_util.h"
#include "ui/gfx/image/image_skia_util_ios.h"
#elif defined(OS_MACOSX)
@@ -38,81 +30,6 @@ namespace gfx {
namespace internal {
-#if defined(TOOLKIT_GTK)
-const ImageSkia ImageSkiaFromGdkPixbuf(GdkPixbuf* pixbuf) {
- CHECK(pixbuf);
- gfx::Canvas canvas(gfx::Size(gdk_pixbuf_get_width(pixbuf),
- gdk_pixbuf_get_height(pixbuf)),
- 1.0f,
- false);
- skia::ScopedPlatformPaint scoped_platform_paint(canvas.sk_canvas());
- cairo_t* cr = scoped_platform_paint.GetPlatformSurface();
- gdk_cairo_set_source_pixbuf(cr, pixbuf, 0, 0);
- cairo_paint(cr);
- return ImageSkia(canvas.ExtractImageRep());
-}
-
-// Returns a 16x16 red pixbuf to visually show error in decoding PNG.
-// Also logs error to console.
-GdkPixbuf* GetErrorPixbuf() {
- LOG(ERROR) << "Unable to decode PNG.";
- GdkPixbuf* pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, 16, 16);
- gdk_pixbuf_fill(pixbuf, 0xff0000ff);
- return pixbuf;
-}
-
-GdkPixbuf* GdkPixbufFromPNG(
- const std::vector<gfx::ImagePNGRep>& image_png_reps) {
- scoped_refptr<base::RefCountedMemory> png_bytes(NULL);
- for (size_t i = 0; i < image_png_reps.size(); ++i) {
- if (image_png_reps[i].scale == 1.0f)
- png_bytes = image_png_reps[i].raw_data;
- }
-
- if (!png_bytes.get())
- return GetErrorPixbuf();
-
- GdkPixbuf* pixbuf = NULL;
- ui::ScopedGObject<GdkPixbufLoader>::Type loader(gdk_pixbuf_loader_new());
-
- bool ok = gdk_pixbuf_loader_write(loader.get(),
- reinterpret_cast<const guint8*>(png_bytes->front()), png_bytes->size(),
- NULL);
-
- // Calling gdk_pixbuf_loader_close forces the data to be parsed by the
- // loader. This must be done before calling gdk_pixbuf_loader_get_pixbuf.
- if (ok)
- ok = gdk_pixbuf_loader_close(loader.get(), NULL);
- if (ok)
- pixbuf = gdk_pixbuf_loader_get_pixbuf(loader.get());
-
- if (pixbuf) {
- // The pixbuf is owned by the scoped loader which will delete its ref when
- // it goes out of scope. Add a ref so that the pixbuf still exists.
- g_object_ref(pixbuf);
- } else {
- return GetErrorPixbuf();
- }
-
- return pixbuf;
-}
-
-scoped_refptr<base::RefCountedMemory> Get1xPNGBytesFromPixbuf(
- GdkPixbuf* pixbuf) {
- gchar* image = NULL;
- gsize image_size;
- GError* error = NULL;
- CHECK(gdk_pixbuf_save_to_buffer(
- pixbuf, &image, &image_size, "png", &error, NULL));
- scoped_refptr<base::RefCountedBytes> png_bytes(
- new base::RefCountedBytes());
- png_bytes->data().assign(image, image + image_size);
- g_free(image);
- return png_bytes;
-}
-
-#endif // defined(TOOLKIT_GTK)
-
#if defined(OS_IOS)
scoped_refptr<base::RefCountedMemory> Get1xPNGBytesFromUIImage(
UIImage* uiimage);
@@ -213,18 +130,6 @@ class ImageRep {
return reinterpret_cast<ImageRepSkia*>(this);
}
-#if defined(TOOLKIT_GTK)
- ImageRepGdk* AsImageRepGdk() {
- CHECK_EQ(type_, Image::kImageRepGdk);
- return reinterpret_cast<ImageRepGdk*>(this);
- }
-
- ImageRepCairo* AsImageRepCairo() {
- CHECK_EQ(type_, Image::kImageRepCairo);
- return reinterpret_cast<ImageRepCairo*>(this);
- }
-#endif
-
#if defined(OS_IOS)
ImageRepCocoaTouch* AsImageRepCocoaTouch() {
CHECK_EQ(type_, Image::kImageRepCocoaTouch);
@@ -326,77 +231,6 @@ class ImageRepSkia : public ImageRep {
DISALLOW_COPY_AND_ASSIGN(ImageRepSkia);
};
-#if defined(TOOLKIT_GTK)
-class ImageRepGdk : public ImageRep {
- public:
- explicit ImageRepGdk(GdkPixbuf* pixbuf)
- : ImageRep(Image::kImageRepGdk),
- pixbuf_(pixbuf) {
- CHECK(pixbuf);
- }
-
- virtual ~ImageRepGdk() {
- if (pixbuf_) {
- g_object_unref(pixbuf_);
- pixbuf_ = NULL;
- }
- }
-
- virtual int Width() const OVERRIDE {
- return gdk_pixbuf_get_width(pixbuf_);
- }
-
- virtual int Height() const OVERRIDE {
- return gdk_pixbuf_get_height(pixbuf_);
- }
-
- virtual gfx::Size Size() const OVERRIDE {
- return gfx::Size(Width(), Height());
- }
-
- GdkPixbuf* pixbuf() const { return pixbuf_; }
-
- private:
- GdkPixbuf* pixbuf_;
-
- DISALLOW_COPY_AND_ASSIGN(ImageRepGdk);
-};
-
-// Represents data that lives on the display server instead of in the client.
-class ImageRepCairo : public ImageRep {
- public:
- explicit ImageRepCairo(GdkPixbuf* pixbuf)
- : ImageRep(Image::kImageRepCairo),
- cairo_cache_(new CairoCachedSurface) {
- CHECK(pixbuf);
- cairo_cache_->UsePixbuf(pixbuf);
- }
-
- virtual ~ImageRepCairo() {
- delete cairo_cache_;
- }
-
- virtual int Width() const OVERRIDE {
- return cairo_cache_->Width();
- }
-
- virtual int Height() const OVERRIDE {
- return cairo_cache_->Height();
- }
-
- virtual gfx::Size Size() const OVERRIDE {
- return gfx::Size(Width(), Height());
- }
-
- CairoCachedSurface* surface() const { return cairo_cache_; }
-
- private:
- CairoCachedSurface* cairo_cache_;
-
- DISALLOW_COPY_AND_ASSIGN(ImageRepCairo);
-};
-#endif // defined(TOOLKIT_GTK)
-
#if defined(OS_IOS)
class ImageRepCocoaTouch : public ImageRep {
public:
@@ -550,16 +384,6 @@ Image::Image(const ImageSkia& image) {
}
}
-#if defined(TOOLKIT_GTK)
-Image::Image(GdkPixbuf* pixbuf) {
- if (pixbuf) {
- storage_ = new internal::ImageStorage(Image::kImageRepGdk);
- internal::ImageRepGdk* rep = new internal::ImageRepGdk(pixbuf);
- AddRepresentation(rep);
- }
-}
-#endif
-
#if defined(OS_IOS)
Image::Image(UIImage* image)
: storage_(new internal::ImageStorage(Image::kImageRepCocoaTouch)) {
@@ -632,15 +456,7 @@ const ImageSkia* Image::ToImageSkia() const {
internal::ImageSkiaFromPNG(png_rep->image_reps()));
break;
}
-#if defined(TOOLKIT_GTK)
- case kImageRepGdk: {
- internal::ImageRepGdk* native_rep =
- GetRepresentation(kImageRepGdk, true)->AsImageRepGdk();
- rep = new internal::ImageRepSkia(new ImageSkia(
- internal::ImageSkiaFromGdkPixbuf(native_rep->pixbuf())));
- break;
- }
-#elif defined(OS_IOS)
+#if defined(OS_IOS)
case kImageRepCocoaTouch: {
internal::ImageRepCocoaTouch* native_rep =
GetRepresentation(kImageRepCocoaTouch, true)
@@ -667,47 +483,6 @@ const ImageSkia* Image::ToImageSkia() const {
return rep->AsImageRepSkia()->image();
}
-#if defined(TOOLKIT_GTK)
-GdkPixbuf* Image::ToGdkPixbuf() const {
- internal::ImageRep* rep = GetRepresentation(kImageRepGdk, false);
- if (!rep) {
- switch (DefaultRepresentationType()) {
- case kImageRepPNG: {
- internal::ImageRepPNG* png_rep =
- GetRepresentation(kImageRepPNG, true)->AsImageRepPNG();
- rep = new internal::ImageRepGdk(internal::GdkPixbufFromPNG(
- png_rep->image_reps()));
- break;
- }
- case kImageRepSkia: {
- internal::ImageRepSkia* skia_rep =
- GetRepresentation(kImageRepSkia, true)->AsImageRepSkia();
- rep = new internal::ImageRepGdk(gfx::GdkPixbufFromSkBitmap(
- *skia_rep->image()->bitmap()));
- break;
- }
- default:
- NOTREACHED();
- }
- CHECK(rep);
- AddRepresentation(rep);
- }
- return rep->AsImageRepGdk()->pixbuf();
-}
-
-CairoCachedSurface* const Image::ToCairo() const {
- internal::ImageRep* rep = GetRepresentation(kImageRepCairo, false);
- if (!rep) {
- // Handle any-to-Cairo conversion. This may create and cache an intermediate
- // pixbuf before sending the data to the display server.
- rep = new internal::ImageRepCairo(ToGdkPixbuf());
- CHECK(rep);
- AddRepresentation(rep);
- }
- return rep->AsImageRepCairo()->surface();
-}
-#endif
-
#if defined(OS_IOS)
UIImage* Image::ToUIImage() const {
internal::ImageRep* rep = GetRepresentation(kImageRepCocoaTouch, false);
@@ -788,14 +563,7 @@ scoped_refptr<base::RefCountedMemory> Image::As1xPNGBytes() const {
scoped_refptr<base::RefCountedMemory> png_bytes(NULL);
switch (DefaultRepresentationType()) {
-#if defined(TOOLKIT_GTK)
- case kImageRepGdk: {
- internal::ImageRepGdk* gdk_rep =
- GetRepresentation(kImageRepGdk, true)->AsImageRepGdk();
- png_bytes = internal::Get1xPNGBytesFromPixbuf(gdk_rep->pixbuf());
- break;
- }
-#elif defined(OS_IOS)
+#if defined(OS_IOS)
case kImageRepCocoaTouch: {
internal::ImageRepCocoaTouch* cocoa_touch_rep =
GetRepresentation(kImageRepCocoaTouch, true)
@@ -870,14 +638,6 @@ SkBitmap* Image::CopySkBitmap() const {
return new SkBitmap(*ToSkBitmap());
}
-#if defined(TOOLKIT_GTK)
-GdkPixbuf* Image::CopyGdkPixbuf() const {
- GdkPixbuf* pixbuf = ToGdkPixbuf();
- g_object_ref(pixbuf);
- return pixbuf;
-}
-#endif
-
#if defined(OS_IOS)
UIImage* Image::CopyUIImage() const {
UIImage* image = ToUIImage();
diff --git a/ui/gfx/image/image_unittest.cc b/ui/gfx/image/image_unittest.cc
index 2ff88c7..1e137e0 100644
--- a/ui/gfx/image/image_unittest.cc
+++ b/ui/gfx/image/image_unittest.cc
@@ -10,10 +10,7 @@
#include "ui/gfx/image/image_skia.h"
#include "ui/gfx/image/image_unittest_util.h"
-#if defined(TOOLKIT_GTK)
-#include <gtk/gtk.h>
-#include "ui/gfx/gtk_util.h"
-#elif defined(OS_IOS)
+#if defined(OS_IOS)
#include "base/mac/foundation_util.h"
#include "skia/ext/skia_utils_ios.h"
#elif defined(OS_MACOSX)
@@ -75,7 +72,7 @@ TEST_F(ImageTest, EmptyImage) {
// Test constructing a gfx::Image from an empty PlatformImage.
TEST_F(ImageTest, EmptyImageFromEmptyPlatformImage) {
-#if defined(OS_IOS) || defined(OS_MACOSX) || defined(TOOLKIT_GTK)
+#if defined(OS_IOS) || defined(OS_MACOSX)
gfx::Image image1(NULL);
EXPECT_TRUE(image1.IsEmpty());
EXPECT_EQ(0, image1.Width());
@@ -436,27 +433,6 @@ TEST_F(ImageTest, PlatformToSkiaToCopy) {
delete bitmap;
}
-#if defined(TOOLKIT_GTK)
-TEST_F(ImageTest, SkiaToGdkCopy) {
- GdkPixbuf* pixbuf;
-
- {
- gfx::Image image(gt::CreateImageSkia(25, 25));
- pixbuf = image.CopyGdkPixbuf();
- }
-
- EXPECT_TRUE(pixbuf);
- g_object_unref(pixbuf);
-}
-
-TEST_F(ImageTest, SkiaToCairoCreatesGdk) {
- gfx::Image image(gt::CreateImageSkia(25, 25));
- EXPECT_FALSE(image.HasRepresentation(gfx::Image::kImageRepGdk));
- EXPECT_TRUE(image.ToCairo());
- EXPECT_TRUE(image.HasRepresentation(gfx::Image::kImageRepGdk));
-}
-#endif
-
#if defined(OS_IOS)
TEST_F(ImageTest, SkiaToCocoaTouchCopy) {
UIImage* ui_image;
diff --git a/ui/gfx/image/image_unittest_util.cc b/ui/gfx/image/image_unittest_util.cc
index 4baf30a..aa7094c 100644
--- a/ui/gfx/image/image_unittest_util.cc
+++ b/ui/gfx/image/image_unittest_util.cc
@@ -15,10 +15,7 @@
#include "ui/gfx/codec/png_codec.h"
#include "ui/gfx/image/image_skia.h"
-#if defined(TOOLKIT_GTK)
-#include <gtk/gtk.h>
-#include "ui/gfx/gtk_util.h"
-#elif defined(OS_IOS)
+#if defined(OS_IOS)
#include "base/mac/foundation_util.h"
#include "base/mac/scoped_cftyperef.h"
#include "skia/ext/skia_utils_ios.h"
@@ -192,8 +189,6 @@ PlatformImage CreatePlatformImage() {
NSImage* image = gfx::SkBitmapToNSImage(bitmap);
base::mac::NSObjectRetain(image);
return image;
-#elif defined(TOOLKIT_GTK)
- return gfx::GdkPixbufFromSkBitmap(bitmap);
#else
return gfx::ImageSkia::CreateFrom1xBitmap(bitmap);
#endif
@@ -204,8 +199,6 @@ gfx::Image::RepresentationType GetPlatformRepresentationType() {
return gfx::Image::kImageRepCocoaTouch;
#elif defined(OS_MACOSX)
return gfx::Image::kImageRepCocoa;
-#elif defined(TOOLKIT_GTK)
- return gfx::Image::kImageRepGdk;
#else
return gfx::Image::kImageRepSkia;
#endif
@@ -216,8 +209,6 @@ PlatformImage ToPlatformType(const gfx::Image& image) {
return image.ToUIImage();
#elif defined(OS_MACOSX)
return image.ToNSImage();
-#elif defined(TOOLKIT_GTK)
- return image.ToGdkPixbuf();
#else
return image.AsImageSkia();
#endif
@@ -228,8 +219,6 @@ PlatformImage CopyPlatformType(const gfx::Image& image) {
return image.CopyUIImage();
#elif defined(OS_MACOSX)
return image.CopyNSImage();
-#elif defined(TOOLKIT_GTK)
- return image.CopyGdkPixbuf();
#else
return image.AsImageSkia();
#endif
@@ -237,16 +226,6 @@ PlatformImage CopyPlatformType(const gfx::Image& image) {
#if defined(OS_MACOSX)
// Defined in image_unittest_util_mac.mm.
-#elif defined(TOOLKIT_GTK)
-SkColor GetPlatformImageColor(PlatformImage image, int x, int y) {
- int n_channels = gdk_pixbuf_get_n_channels(image);
- int rowstride = gdk_pixbuf_get_rowstride(image);
- guchar* gdk_pixels = gdk_pixbuf_get_pixels(image);
-
- guchar* pixel = gdk_pixels + (y * rowstride) + (x * n_channels);
- guchar alpha = gdk_pixbuf_get_has_alpha(image) ? pixel[3] : 255;
- return SkColorSetARGB(alpha, pixel[0], pixel[1], pixel[2]);
-}
#else
SkColor GetPlatformImageColor(PlatformImage image, int x, int y) {
SkBitmap bitmap = *image.bitmap();
@@ -264,7 +243,7 @@ void CheckIsTransparent(SkColor color) {
}
bool IsPlatformImageValid(PlatformImage image) {
-#if defined(OS_MACOSX) || defined(TOOLKIT_GTK)
+#if defined(OS_MACOSX)
return image != NULL;
#else
return !image.isNull();
@@ -272,7 +251,7 @@ bool IsPlatformImageValid(PlatformImage image) {
}
bool PlatformImagesEqual(PlatformImage image1, PlatformImage image2) {
-#if defined(OS_MACOSX) || defined(TOOLKIT_GTK)
+#if defined(OS_MACOSX)
return image1 == image2;
#else
return image1.BackedBySameObjectAs(image2);
diff --git a/ui/gfx/image/image_unittest_util.h b/ui/gfx/image/image_unittest_util.h
index 4788e4e..cac8015 100644
--- a/ui/gfx/image/image_unittest_util.h
+++ b/ui/gfx/image/image_unittest_util.h
@@ -18,8 +18,6 @@ namespace test {
typedef UIImage* PlatformImage;
#elif defined(OS_MACOSX)
typedef NSImage* PlatformImage;
-#elif defined(TOOLKIT_GTK)
-typedef GdkPixbuf* PlatformImage;
#else
typedef gfx::ImageSkia PlatformImage;
#endif
diff --git a/ui/gfx/native_widget_types.h b/ui/gfx/native_widget_types.h
index 2c3e196..f79670d 100644
--- a/ui/gfx/native_widget_types.h
+++ b/ui/gfx/native_widget_types.h
@@ -98,14 +98,7 @@ typedef struct _PangoFontDescription PangoFontDescription;
typedef struct _cairo cairo_t;
#endif
-#if defined(TOOLKIT_GTK)
-typedef struct _GdkCursor GdkCursor;
-typedef union _GdkEvent GdkEvent;
-typedef struct _GdkPixbuf GdkPixbuf;
-typedef struct _GdkRegion GdkRegion;
-typedef struct _GtkWidget GtkWidget;
-typedef struct _GtkWindow GtkWindow;
-#elif defined(OS_ANDROID)
+#if defined(OS_ANDROID)
struct ANativeWindow;
namespace ui {
class WindowAndroid;
@@ -132,12 +125,6 @@ typedef NSCursor* NativeCursor;
typedef NSView* NativeView;
typedef NSWindow* NativeWindow;
typedef NSEvent* NativeEvent;
-#elif defined(TOOLKIT_GTK)
-typedef GdkCursor* NativeCursor;
-typedef GtkWidget* NativeView;
-typedef GtkWindow* NativeWindow;
-typedef GdkRegion* NativeRegion;
-typedef GdkEvent* NativeEvent;
#elif defined(OS_ANDROID)
typedef void* NativeCursor;
typedef ui::ViewAndroid* NativeView;
@@ -160,11 +147,6 @@ typedef NSFont* NativeFont;
typedef NSTextField* NativeEditView;
typedef CGContext* NativeDrawingContext;
typedef void* NativeViewAccessible;
-#elif defined(TOOLKIT_GTK)
-typedef PangoFontDescription* NativeFont;
-typedef GtkWidget* NativeEditView;
-typedef cairo_t* NativeDrawingContext;
-typedef void* NativeViewAccessible;
#elif defined(USE_CAIRO)
typedef PangoFontDescription* NativeFont;
typedef void* NativeEditView;
@@ -188,8 +170,6 @@ const gfx::NativeCursor kNullCursor = static_cast<gfx::NativeCursor>(NULL);
typedef UIImage NativeImageType;
#elif defined(OS_MACOSX)
typedef NSImage NativeImageType;
-#elif defined(TOOLKIT_GTK)
-typedef GdkPixbuf NativeImageType;
#else
typedef SkBitmap NativeImageType;
#endif
diff --git a/ui/gfx/pango_util.cc b/ui/gfx/pango_util.cc
index 3716cf1..56503c6 100644
--- a/ui/gfx/pango_util.cc
+++ b/ui/gfx/pango_util.cc
@@ -23,10 +23,6 @@
#include "ui/gfx/rect.h"
#include "ui/gfx/text_utils.h"
-#if defined(TOOLKIT_GTK)
-#include <gdk/gdk.h>
-#endif
-
namespace gfx {
namespace {
@@ -116,12 +112,8 @@ float GetPixelsInPoint() {
} // namespace
PangoContext* GetPangoContext() {
-#if defined(TOOLKIT_GTK)
- return gdk_pango_context_get();
-#else
PangoFontMap* font_map = pango_cairo_font_map_get_default();
return pango_font_map_create_context(font_map);
-#endif
}
double GetPangoResolution() {
diff --git a/ui/gfx/path_gtk.cc b/ui/gfx/path_gtk.cc
deleted file mode 100644
index d5c376d..0000000
--- a/ui/gfx/path_gtk.cc
+++ /dev/null
@@ -1,57 +0,0 @@
-// Copyright (c) 2011 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/gfx/path.h"
-
-#include <gdk/gdk.h>
-
-#include "base/command_line.h"
-#include "base/memory/scoped_ptr.h"
-
-#error "The GTK+ port will be deleted later this week. If you are seeing this, you are trying to compile it. Please check your gyp flags for 'use_aura=0' and remove them."
-
-namespace gfx {
-
-GdkRegion* Path::CreateNativeRegion() const {
- int point_count = getPoints(NULL, 0);
- if (point_count <= 1) {
- // NOTE: ideally this would return gdk_empty_region, but that returns a
- // region with nothing in it.
- return NULL;
- }
-
- scoped_ptr<SkPoint[]> points(new SkPoint[point_count]);
- getPoints(points.get(), point_count);
-
- scoped_ptr<GdkPoint[]> gdk_points(new GdkPoint[point_count]);
- for (int i = 0; i < point_count; ++i) {
- gdk_points[i].x = SkScalarRoundToInt(points[i].fX);
- gdk_points[i].y = SkScalarRoundToInt(points[i].fY);
- }
-
- return gdk_region_polygon(gdk_points.get(), point_count, GDK_EVEN_ODD_RULE);
-}
-
-// static
-NativeRegion Path::IntersectRegions(NativeRegion r1, NativeRegion r2) {
- GdkRegion* copy = gdk_region_copy(r1);
- gdk_region_intersect(copy, r2);
- return copy;
-}
-
-// static
-NativeRegion Path::CombineRegions(NativeRegion r1, NativeRegion r2) {
- GdkRegion* copy = gdk_region_copy(r1);
- gdk_region_union(copy, r2);
- return copy;
-}
-
-// static
-NativeRegion Path::SubtractRegion(NativeRegion r1, NativeRegion r2) {
- GdkRegion* copy = gdk_region_copy(r1);
- gdk_region_subtract(copy, r2);
- return copy;
-}
-
-} // namespace gfx
diff --git a/ui/gfx/render_text_unittest.cc b/ui/gfx/render_text_unittest.cc
index 977cea4..cbe3dd5 100644
--- a/ui/gfx/render_text_unittest.cc
+++ b/ui/gfx/render_text_unittest.cc
@@ -24,10 +24,6 @@
#include "ui/gfx/render_text_pango.h"
#endif
-#if defined(TOOLKIT_GTK)
-#include <gtk/gtk.h>
-#endif
-
using base::ASCIIToUTF16;
using base::UTF8ToUTF16;
using base::WideToUTF16;
@@ -63,10 +59,6 @@ base::string16 GetSelectedText(RenderText* render_text) {
void SetRTL(bool rtl) {
// Override the current locale/direction.
base::i18n::SetICUDefaultLocale(rtl ? "he" : "en");
-#if defined(TOOLKIT_GTK)
- // Do the same for GTK, which does not rely on the ICU default locale.
- gtk_widget_set_default_direction(rtl ? GTK_TEXT_DIR_RTL : GTK_TEXT_DIR_LTR);
-#endif
EXPECT_EQ(rtl, base::i18n::IsRTL());
}
diff --git a/ui/gfx/screen_gtk.cc b/ui/gfx/screen_gtk.cc
deleted file mode 100644
index ac2464b..0000000
--- a/ui/gfx/screen_gtk.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 "ui/gfx/screen.h"
-
-#include <gdk/gdkx.h>
-#include <gtk/gtk.h>
-
-#include "base/logging.h"
-#include "ui/gfx/display.h"
-
-namespace {
-
-bool GetScreenWorkArea(gfx::Rect* out_rect) {
- gboolean ok;
- guchar* raw_data = NULL;
- gint data_len = 0;
- ok = gdk_property_get(gdk_get_default_root_window(), // a gdk window
- gdk_atom_intern("_NET_WORKAREA", FALSE), // property
- gdk_atom_intern("CARDINAL", FALSE), // property type
- 0, // byte offset into property
- 0xff, // property length to retrieve
- false, // delete property after retrieval?
- NULL, // returned property type
- NULL, // returned data format
- &data_len, // returned data len
- &raw_data); // returned data
- if (!ok)
- return false;
-
- // We expect to get four longs back: x, y, width, height.
- if (data_len < static_cast<gint>(4 * sizeof(glong))) {
- NOTREACHED();
- g_free(raw_data);
- return false;
- }
-
- glong* data = reinterpret_cast<glong*>(raw_data);
- gint x = data[0];
- gint y = data[1];
- gint width = data[2];
- gint height = data[3];
- g_free(raw_data);
-
- out_rect->SetRect(x, y, width, height);
- return true;
-}
-
-gfx::Display GetDisplayForMonitorNum(GdkScreen* screen, gint monitor_num) {
- GdkRectangle bounds;
- gdk_screen_get_monitor_geometry(screen, monitor_num, &bounds);
- // Use |monitor_num| as display id.
- gfx::Display display(monitor_num, gfx::Rect(bounds));
- if (gdk_screen_get_primary_monitor(screen) == monitor_num) {
- gfx::Rect rect;
- if (GetScreenWorkArea(&rect))
- display.set_work_area(gfx::IntersectRects(rect, display.bounds()));
- }
- return display;
-}
-
-gfx::Display GetMonitorAreaNearestWindow(gfx::NativeView view) {
- GdkScreen* screen = gdk_screen_get_default();
- gint monitor_num = 0;
- if (view && GTK_IS_WINDOW(view)) {
- GtkWidget* top_level = gtk_widget_get_toplevel(view);
- DCHECK(GTK_IS_WINDOW(top_level));
- GtkWindow* window = GTK_WINDOW(top_level);
- screen = gtk_window_get_screen(window);
- monitor_num = gdk_screen_get_monitor_at_window(
- screen,
- gtk_widget_get_window(top_level));
- }
- return GetDisplayForMonitorNum(screen, monitor_num);
-}
-
-class ScreenGtk : public gfx::Screen {
- public:
- ScreenGtk() {
- }
-
- virtual ~ScreenGtk() {
- }
-
- virtual bool IsDIPEnabled() OVERRIDE {
- return false;
- }
-
- virtual gfx::Point GetCursorScreenPoint() OVERRIDE {
- gint x, y;
- gdk_display_get_pointer(gdk_display_get_default(), NULL, &x, &y, NULL);
- return gfx::Point(x, y);
- }
-
- // Returns the window under the cursor.
- virtual gfx::NativeWindow GetWindowUnderCursor() OVERRIDE {
- GdkWindow* window = gdk_window_at_pointer(NULL, NULL);
- if (!window)
- return NULL;
-
- gpointer data = NULL;
- gdk_window_get_user_data(window, &data);
- GtkWidget* widget = reinterpret_cast<GtkWidget*>(data);
- if (!widget)
- return NULL;
- widget = gtk_widget_get_toplevel(widget);
- return GTK_IS_WINDOW(widget) ? GTK_WINDOW(widget) : NULL;
- }
-
- virtual gfx::NativeWindow GetWindowAtScreenPoint(const gfx::Point& point)
- OVERRIDE {
- NOTIMPLEMENTED();
- return NULL;
- }
-
- // Returns the number of displays.
- // Mirrored displays are excluded; this method is intended to return the
- // number of distinct, usable displays.
- virtual int GetNumDisplays() const OVERRIDE {
- // This query is kinda bogus for Linux -- do we want number of X screens?
- // The number of monitors Xinerama has? We'll just use whatever GDK uses.
- GdkScreen* screen = gdk_screen_get_default();
- return gdk_screen_get_n_monitors(screen);
- }
-
- virtual std::vector<gfx::Display> GetAllDisplays() const OVERRIDE {
- GdkScreen* screen = gdk_screen_get_default();
- gint num_of_displays = gdk_screen_get_n_monitors(screen);
- std::vector<gfx::Display> all_displays;
- for (gint i = 0; i < num_of_displays; ++i)
- all_displays.push_back(GetDisplayForMonitorNum(screen, i));
- return all_displays;
- }
-
- // Returns the display nearest the specified window.
- virtual gfx::Display GetDisplayNearestWindow(
- gfx::NativeView view) const OVERRIDE {
- // Do not use the _NET_WORKAREA here, this is supposed to be an area on a
- // specific monitor, and _NET_WORKAREA is a hint from the WM that
- // generally spans across all monitors. This would make the work area
- // larger than the monitor.
- // TODO(danakj) This is a work-around as there is no standard way to get
- // this area, but it is a rect that we should be computing. The standard
- // means to compute this rect would be to watch all windows with
- // _NET_WM_STRUT(_PARTIAL) hints, and subtract their space from the
- // physical area of the display to construct a work area.
- // TODO(oshima): Implement Observer.
- return GetMonitorAreaNearestWindow(view);
- }
-
- // Returns the the display nearest the specified point.
- virtual gfx::Display GetDisplayNearestPoint(
- const gfx::Point& point) const OVERRIDE {
- GdkScreen* screen = gdk_screen_get_default();
- gint monitor = gdk_screen_get_monitor_at_point(
- screen, point.x(), point.y());
- // TODO(oshima): Implement Observer.
- return GetDisplayForMonitorNum(screen, monitor);
- }
-
- // Returns the display that most closely intersects the provided bounds.
- virtual gfx::Display GetDisplayMatching(
- const gfx::Rect& match_rect) const OVERRIDE {
- std::vector<gfx::Display> displays = GetAllDisplays();
- gfx::Display maxIntersectDisplay;
- gfx::Rect maxIntersection;
- for (std::vector<gfx::Display>::iterator it = displays.begin();
- it != displays.end(); ++it) {
- gfx::Rect displayIntersection = it->bounds();
- displayIntersection.Intersect(match_rect);
- if (displayIntersection.size().GetArea() >
- maxIntersection.size().GetArea()) {
- maxIntersectDisplay = *it;
- maxIntersection = displayIntersection;
- }
- }
- return maxIntersectDisplay.is_valid() ?
- maxIntersectDisplay : GetPrimaryDisplay();
- }
-
- // Returns the primary display.
- virtual gfx::Display GetPrimaryDisplay() const OVERRIDE {
- GdkScreen* screen = gdk_screen_get_default();
- gint primary_monitor_index = gdk_screen_get_primary_monitor(screen);
- // TODO(oshima): Implement Observer.
- return GetDisplayForMonitorNum(screen, primary_monitor_index);
- }
-
- virtual void AddObserver(gfx::DisplayObserver* observer) OVERRIDE {
- // TODO(oshima): crbug.com/122863.
- }
-
- virtual void RemoveObserver(gfx::DisplayObserver* observer) OVERRIDE {
- // TODO(oshima): crbug.com/122863.
- }
-
- private:
- DISALLOW_COPY_AND_ASSIGN(ScreenGtk);
-};
-
-} // namespace
-
-namespace gfx {
-
-Screen* CreateNativeScreen() {
- return new ScreenGtk;
-}
-
-} // namespace gfx
diff --git a/ui/gfx/skia_utils_gtk.cc b/ui/gfx/skia_utils_gtk.cc
deleted file mode 100644
index f7f3a0a..0000000
--- a/ui/gfx/skia_utils_gtk.cc
+++ /dev/null
@@ -1,32 +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/gfx/skia_utils_gtk.h"
-
-#include <gdk/gdk.h>
-
-namespace gfx {
-
-const int kSkiaToGDKMultiplier = 257;
-
-// GDK_COLOR_RGB multiplies by 257 (= 0x10001) to distribute the bits evenly
-// See: http://www.mindcontrol.org/~hplus/graphics/expand-bits.html
-// To get back, we can just right shift by eight
-// (or, formulated differently, i == (i*257)/256 for all i < 256).
-
-SkColor GdkColorToSkColor(GdkColor color) {
- return SkColorSetRGB(color.red >> 8, color.green >> 8, color.blue >> 8);
-}
-
-GdkColor SkColorToGdkColor(SkColor color) {
- GdkColor gdk_color = {
- 0,
- static_cast<guint16>(SkColorGetR(color) * kSkiaToGDKMultiplier),
- static_cast<guint16>(SkColorGetG(color) * kSkiaToGDKMultiplier),
- static_cast<guint16>(SkColorGetB(color) * kSkiaToGDKMultiplier)
- };
- return gdk_color;
-}
-
-} // namespace gfx
diff --git a/ui/gfx/skia_utils_gtk.h b/ui/gfx/skia_utils_gtk.h
deleted file mode 100644
index 6b74da2..0000000
--- a/ui/gfx/skia_utils_gtk.h
+++ /dev/null
@@ -1,23 +0,0 @@
-// Copyright (c) 2011 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_GFX_SKIA_UTILS_GTK_H_
-#define UI_GFX_SKIA_UTILS_GTK_H_
-
-#include "third_party/skia/include/core/SkColor.h"
-#include "ui/gfx/gfx_export.h"
-
-typedef struct _GdkColor GdkColor;
-
-namespace gfx {
-
-// Converts GdkColors to the ARGB layout Skia expects.
-GFX_EXPORT SkColor GdkColorToSkColor(GdkColor color);
-
-// Converts ARGB to GdkColor.
-GFX_EXPORT GdkColor SkColorToGdkColor(SkColor color);
-
-} // namespace gfx
-
-#endif // UI_GFX_SKIA_UTILS_GTK_H_
diff --git a/ui/native_theme/fallback_theme.cc b/ui/native_theme/fallback_theme.cc
index 918a5b3..ffb15fd 100644
--- a/ui/native_theme/fallback_theme.cc
+++ b/ui/native_theme/fallback_theme.cc
@@ -7,7 +7,6 @@
#include "base/basictypes.h"
#include "base/logging.h"
#include "ui/gfx/color_utils.h"
-#include "ui/gfx/skia_utils_gtk.h"
#include "ui/native_theme/common_theme.h"
namespace ui {
diff --git a/ui/native_theme/native_theme.gyp b/ui/native_theme/native_theme.gyp
index a50a532..269bc06 100644
--- a/ui/native_theme/native_theme.gyp
+++ b/ui/native_theme/native_theme.gyp
@@ -37,8 +37,6 @@
'native_theme_aurawin.h',
'native_theme_base.cc',
'native_theme_base.h',
- 'native_theme_gtk.cc',
- 'native_theme_gtk.h',
'native_theme_mac.h',
'native_theme_mac.mm',
'native_theme_switches.cc',
diff --git a/ui/native_theme/native_theme_gtk.cc b/ui/native_theme/native_theme_gtk.cc
deleted file mode 100644
index 4049363..0000000
--- a/ui/native_theme/native_theme_gtk.cc
+++ /dev/null
@@ -1,110 +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/native_theme/native_theme_gtk.h"
-
-#include <gtk/gtk.h>
-
-#include "base/basictypes.h"
-#include "base/logging.h"
-#include "ui/gfx/skia_utils_gtk.h"
-
-#error "The GTK+ port will be deleted later this week. If you are seeing this, you are trying to compile it. Please check your gyp flags for 'use_aura=0' and remove them."
-
-namespace {
-
-const SkColor kInvalidColorIdColor = SkColorSetRGB(255, 0, 128);
-
-// Theme colors returned by GetSystemColor().
-
-// FocusableBorder:
-const SkColor kFocusedBorderColor = SkColorSetRGB(0x4D, 0x90, 0xFE);
-const SkColor kUnfocusedBorderColor = SkColorSetRGB(0xD9, 0xD9, 0xD9);
-
-// MenuItem
-const SkColor kFocusedMenuItemBackgroundColor = SkColorSetARGB(13, 0, 0, 0);
-const SkColor kHoverMenuItemBackgroundColor = SkColorSetRGB(204, 204, 204);
-
-// MenuButton
-const SkColor kEnabledMenuButtonBorderColor = SkColorSetARGB(36, 0, 0, 0);
-const SkColor kFocusedMenuButtonBorderColor = SkColorSetARGB(72, 0, 0, 0);
-const SkColor kHoverMenuButtonBorderColor = SkColorSetARGB(72, 0, 0, 0);
-
-// Button:
-const SkColor kButtonBackgroundColor = SkColorSetRGB(0xde, 0xde, 0xde);
-const SkColor kButtonEnabledColor = SkColorSetRGB(6, 45, 117);
-const SkColor kButtonDisabledColor = SkColorSetRGB(161, 161, 146);
-const SkColor kButtonHighlightColor = SkColorSetARGB(200, 255, 255, 255);
-const SkColor kButtonHoverColor = kButtonEnabledColor;
-
-} // namespace
-
-namespace ui {
-
-// static
-NativeTheme* NativeTheme::instance() {
- return NativeThemeGtk::instance();
-}
-
-// static
-NativeThemeGtk* NativeThemeGtk::instance() {
- CR_DEFINE_STATIC_LOCAL(NativeThemeGtk, s_native_theme, ());
- return &s_native_theme;
-}
-
-SkColor NativeThemeGtk::GetSystemColor(ColorId color_id) const {
- switch (color_id) {
- case kColorId_DialogBackground:
- // TODO(benrg): This code used to call gtk_widget_get_style() on the
- // widget being styled. After refactoring, that widget is not available
- // and we have to call gtk_widget_get_default_style(). Unfortunately,
- // it turns out that this breaks everything (chromium bug 105609,
- // chromium-os bug 23461). Need to figure out the right thing and do it.
- return gfx::GdkColorToSkColor(
- gtk_widget_get_default_style()->bg[GTK_STATE_NORMAL]);
-
- // FocusableBorder:
- case kColorId_FocusedBorderColor:
- return kFocusedBorderColor;
- case kColorId_UnfocusedBorderColor:
- return kUnfocusedBorderColor;
-
- // MenuItem
- case kColorId_FocusedMenuItemBackgroundColor:
- return kFocusedMenuItemBackgroundColor;
- case kColorId_HoverMenuItemBackgroundColor:
- return kHoverMenuItemBackgroundColor;
- case kColorId_EnabledMenuButtonBorderColor:
- return kEnabledMenuButtonBorderColor;
- case kColorId_FocusedMenuButtonBorderColor:
- return kFocusedMenuButtonBorderColor;
- case kColorId_HoverMenuButtonBorderColor:
- return kHoverMenuButtonBorderColor;
-
- // Button:
- case kColorId_ButtonBackgroundColor:
- return kButtonBackgroundColor;
- case kColorId_ButtonEnabledColor:
- return kButtonEnabledColor;
- case kColorId_ButtonDisabledColor:
- return kButtonDisabledColor;
- case kColorId_ButtonHighlightColor:
- return kButtonHighlightColor;
- case kColorId_ButtonHoverColor:
- return kButtonHoverColor;
-
- default:
- NOTREACHED() << "Invalid color_id: " << color_id;
- break;
- }
- return kInvalidColorIdColor;
-}
-
-NativeThemeGtk::NativeThemeGtk() {
-}
-
-NativeThemeGtk::~NativeThemeGtk() {
-}
-
-} // namespace ui
diff --git a/ui/native_theme/native_theme_gtk.h b/ui/native_theme/native_theme_gtk.h
deleted file mode 100644
index 05f5a8c..0000000
--- a/ui/native_theme/native_theme_gtk.h
+++ /dev/null
@@ -1,28 +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 UI_NATIVE_THEME_NATIVE_THEME_GTK_H_
-#define UI_NATIVE_THEME_NATIVE_THEME_GTK_H_
-
-#include "ui/native_theme/native_theme_base.h"
-
-namespace ui {
-
-// GTK implementation of native theme support.
-class NativeThemeGtk : public NativeThemeBase {
- public:
- static NativeThemeGtk* instance();
-
- virtual SkColor GetSystemColor(ColorId color_id) const OVERRIDE;
-
- private:
- NativeThemeGtk();
- virtual ~NativeThemeGtk();
-
- DISALLOW_COPY_AND_ASSIGN(NativeThemeGtk);
-};
-
-} // namespace ui
-
-#endif // UI_NATIVE_THEME_NATIVE_THEME_GTK_H_
diff --git a/ui/shell_dialogs/gtk/OWNERS b/ui/shell_dialogs/gtk/OWNERS
deleted file mode 100644
index 0573e6b..0000000
--- a/ui/shell_dialogs/gtk/OWNERS
+++ /dev/null
@@ -1,2 +0,0 @@
-erg@chromium.org
-estade@chromium.org
diff --git a/ui/shell_dialogs/gtk/select_file_dialog_impl.cc b/ui/shell_dialogs/gtk/select_file_dialog_impl.cc
deleted file mode 100644
index c7e80c1..0000000
--- a/ui/shell_dialogs/gtk/select_file_dialog_impl.cc
+++ /dev/null
@@ -1,92 +0,0 @@
-// Copyright (c) 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.
-//
-// This file implements common select dialog functionality between GTK and KDE.
-
-#include "ui/shell_dialogs/gtk/select_file_dialog_impl.h"
-
-#include "base/environment.h"
-#include "base/file_util.h"
-#include "base/nix/xdg_util.h"
-#include "base/threading/thread_restrictions.h"
-
-namespace {
-
-enum UseKdeFileDialogStatus {
- UNKNOWN,
- NO_KDE,
- YES_KDE
-};
-
-UseKdeFileDialogStatus use_kde_ = UNKNOWN;
-
-} // namespace
-
-namespace ui {
-
-base::FilePath* SelectFileDialogImpl::last_saved_path_ = NULL;
-base::FilePath* SelectFileDialogImpl::last_opened_path_ = NULL;
-
-// static
-SelectFileDialog* CreateLinuxSelectFileDialog(
- SelectFileDialog::Listener* listener,
- SelectFilePolicy* policy) {
- if (use_kde_ == UNKNOWN) {
- // Start out assumimg we are not going to use KDE.
- use_kde_ = NO_KDE;
-
- // Check to see if KDE is the desktop environment.
- scoped_ptr<base::Environment> env(base::Environment::Create());
- base::nix::DesktopEnvironment desktop =
- base::nix::GetDesktopEnvironment(env.get());
- if (desktop == base::nix::DESKTOP_ENVIRONMENT_KDE3 ||
- desktop == base::nix::DESKTOP_ENVIRONMENT_KDE4) {
- // Check to see if the user dislikes the KDE file dialog.
- if (!env->HasVar("NO_CHROME_KDE_FILE_DIALOG")) {
- // Check to see if the KDE dialog works.
- if (SelectFileDialogImpl::CheckKDEDialogWorksOnUIThread()) {
- use_kde_ = YES_KDE;
- }
- }
- }
- }
-
- if (use_kde_ == NO_KDE)
- return SelectFileDialogImpl::NewSelectFileDialogImplGTK(listener, policy);
-
- scoped_ptr<base::Environment> env(base::Environment::Create());
- base::nix::DesktopEnvironment desktop =
- base::nix::GetDesktopEnvironment(env.get());
- return SelectFileDialogImpl::NewSelectFileDialogImplKDE(
- listener, policy, desktop);
-}
-
-SelectFileDialogImpl::SelectFileDialogImpl(Listener* listener,
- ui::SelectFilePolicy* policy)
- : SelectFileDialog(listener, policy),
- file_type_index_(0),
- type_(SELECT_NONE) {
- if (!last_saved_path_) {
- last_saved_path_ = new base::FilePath();
- last_opened_path_ = new base::FilePath();
- }
-}
-
-SelectFileDialogImpl::~SelectFileDialogImpl() { }
-
-void SelectFileDialogImpl::ListenerDestroyed() {
- listener_ = NULL;
-}
-
-bool SelectFileDialogImpl::IsRunning(gfx::NativeWindow parent_window) const {
- return parents_.find(parent_window) != parents_.end();
-}
-
-bool SelectFileDialogImpl::CallDirectoryExistsOnUIThread(
- const base::FilePath& path) {
- base::ThreadRestrictions::ScopedAllowIO allow_io;
- return base::DirectoryExists(path);
-}
-
-} // namespace ui
diff --git a/ui/shell_dialogs/gtk/select_file_dialog_impl.h b/ui/shell_dialogs/gtk/select_file_dialog_impl.h
deleted file mode 100644
index ebe497f..0000000
--- a/ui/shell_dialogs/gtk/select_file_dialog_impl.h
+++ /dev/null
@@ -1,89 +0,0 @@
-// Copyright (c) 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.
-//
-// This file implements common select dialog functionality between GTK and KDE.
-
-#ifndef UI_SHELL_DIALOGS_GTK_SELECT_FILE_DIALOG_IMPL_H_
-#define UI_SHELL_DIALOGS_GTK_SELECT_FILE_DIALOG_IMPL_H_
-
-#include <set>
-
-#include "base/compiler_specific.h"
-#include "base/nix/xdg_util.h"
-#include "ui/shell_dialogs/select_file_dialog.h"
-
-namespace ui {
-
-// Shared implementation SelectFileDialog used by SelectFileDialogImplGTK
-class SelectFileDialogImpl : public SelectFileDialog {
- public:
- // Factory method for creating a GTK-styled SelectFileDialogImpl
- static SelectFileDialogImpl* NewSelectFileDialogImplGTK(
- Listener* listener,
- ui::SelectFilePolicy* policy);
- // Factory method for creating a KDE-styled SelectFileDialogImpl
- static SelectFileDialogImpl* NewSelectFileDialogImplKDE(
- Listener* listener,
- ui::SelectFilePolicy* policy,
- base::nix::DesktopEnvironment desktop);
-
- // Returns true if the SelectFileDialog class returned by
- // NewSelectFileDialogImplKDE will actually work.
- static bool CheckKDEDialogWorksOnUIThread();
-
- // BaseShellDialog implementation.
- virtual bool IsRunning(gfx::NativeWindow parent_window) const OVERRIDE;
- virtual void ListenerDestroyed() OVERRIDE;
-
- protected:
- explicit SelectFileDialogImpl(Listener* listener,
- ui::SelectFilePolicy* policy);
- virtual ~SelectFileDialogImpl();
-
- // SelectFileDialog implementation.
- // |params| is user data we pass back via the Listener interface.
- virtual void SelectFileImpl(
- Type type,
- const base::string16& title,
- const base::FilePath& default_path,
- const FileTypeInfo* file_types,
- int file_type_index,
- const base::FilePath::StringType& default_extension,
- gfx::NativeWindow owning_window,
- void* params) = 0;
-
- // Wrapper for base::DirectoryExists() that allow access on the UI
- // thread. Use this only in the file dialog functions, where it's ok
- // because the file dialog has to do many stats anyway. One more won't
- // hurt too badly and it's likely already cached.
- bool CallDirectoryExistsOnUIThread(const base::FilePath& path);
-
- // The file filters.
- FileTypeInfo file_types_;
-
- // The index of the default selected file filter.
- // Note: This starts from 1, not 0.
- size_t file_type_index_;
-
- // The set of all parent windows for which we are currently running dialogs.
- std::set<GtkWindow*> parents_;
-
- // The type of dialog we are showing the user.
- Type type_;
-
- // These two variables track where the user last saved a file or opened a
- // file so that we can display future dialogs with the same starting path.
- static base::FilePath* last_saved_path_;
- static base::FilePath* last_opened_path_;
-
- DISALLOW_COPY_AND_ASSIGN(SelectFileDialogImpl);
-};
-
-SelectFileDialog* CreateLinuxSelectFileDialog(
- SelectFileDialog::Listener* listener,
- SelectFilePolicy* policy);
-
-} // namespace ui
-
-#endif // UI_SHELL_DIALOGS_GTK_SELECT_FILE_DIALOG_IMPL_H_
diff --git a/ui/shell_dialogs/gtk/select_file_dialog_impl_gtk.cc b/ui/shell_dialogs/gtk/select_file_dialog_impl_gtk.cc
deleted file mode 100644
index 67f35ed..0000000
--- a/ui/shell_dialogs/gtk/select_file_dialog_impl_gtk.cc
+++ /dev/null
@@ -1,596 +0,0 @@
-// Copyright (c) 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 <gtk/gtk.h>
-#include <map>
-#include <set>
-#include <vector>
-
-#include "base/file_util.h"
-#include "base/logging.h"
-#include "base/memory/scoped_ptr.h"
-#include "base/message_loop/message_loop.h"
-#include "base/strings/string_util.h"
-#include "base/strings/sys_string_conversions.h"
-#include "base/strings/utf_string_conversions.h"
-#include "base/threading/thread.h"
-#include "base/threading/thread_restrictions.h"
-#include "grit/ui_strings.h"
-#include "ui/base/gtk/gtk_signal.h"
-#include "ui/base/l10n/l10n_util.h"
-#include "ui/shell_dialogs/gtk/select_file_dialog_impl.h"
-#include "ui/shell_dialogs/select_file_dialog.h"
-
-namespace {
-
-// Makes sure that .jpg also shows .JPG.
-gboolean FileFilterCaseInsensitive(const GtkFileFilterInfo* file_info,
- std::string* file_extension) {
- return EndsWith(file_info->filename, *file_extension, false);
-}
-
-// Deletes |data| when gtk_file_filter_add_custom() is done with it.
-void OnFileFilterDataDestroyed(std::string* file_extension) {
- delete file_extension;
-}
-
-// Implementation of SelectFileDialog that shows a Gtk common dialog for
-// choosing a file or folder. This acts as a modal dialog.
-class SelectFileDialogImplGTK : public ui::SelectFileDialogImpl {
- public:
- explicit SelectFileDialogImplGTK(Listener* listener,
- ui::SelectFilePolicy* policy);
-
- protected:
- virtual ~SelectFileDialogImplGTK();
-
- // SelectFileDialog implementation.
- // |params| is user data we pass back via the Listener interface.
- virtual void SelectFileImpl(
- Type type,
- const base::string16& title,
- const base::FilePath& default_path,
- const FileTypeInfo* file_types,
- int file_type_index,
- const base::FilePath::StringType& default_extension,
- gfx::NativeWindow owning_window,
- void* params) OVERRIDE;
-
- private:
- virtual bool HasMultipleFileTypeChoicesImpl() OVERRIDE;
-
- // Add the filters from |file_types_| to |chooser|.
- void AddFilters(GtkFileChooser* chooser);
-
- // Notifies the listener that a single file was chosen.
- void FileSelected(GtkWidget* dialog, const base::FilePath& path);
-
- // Notifies the listener that multiple files were chosen.
- void MultiFilesSelected(GtkWidget* dialog,
- const std::vector<base::FilePath>& files);
-
- // Notifies the listener that no file was chosen (the action was canceled).
- // Dialog is passed so we can find that |params| pointer that was passed to
- // us when we were told to show the dialog.
- void FileNotSelected(GtkWidget* dialog);
-
- GtkWidget* CreateSelectFolderDialog(
- Type type,
- const std::string& title,
- const base::FilePath& default_path,
- gfx::NativeWindow parent);
-
- GtkWidget* CreateFileOpenDialog(const std::string& title,
- const base::FilePath& default_path, gfx::NativeWindow parent);
-
- GtkWidget* CreateMultiFileOpenDialog(const std::string& title,
- const base::FilePath& default_path, gfx::NativeWindow parent);
-
- GtkWidget* CreateSaveAsDialog(const std::string& title,
- const base::FilePath& default_path, gfx::NativeWindow parent);
-
- // Removes and returns the |params| associated with |dialog| from
- // |params_map_|.
- void* PopParamsForDialog(GtkWidget* dialog);
-
- // Take care of internal data structures when a file dialog is destroyed.
- void FileDialogDestroyed(GtkWidget* dialog);
-
- // Check whether response_id corresponds to the user cancelling/closing the
- // dialog. Used as a helper for the below callbacks.
- bool IsCancelResponse(gint response_id);
-
- // Common function for OnSelectSingleFileDialogResponse and
- // OnSelectSingleFolderDialogResponse.
- void SelectSingleFileHelper(GtkWidget* dialog,
- gint response_id,
- bool allow_folder);
-
- // Common function for CreateFileOpenDialog and CreateMultiFileOpenDialog.
- GtkWidget* CreateFileOpenHelper(const std::string& title,
- const base::FilePath& default_path,
- gfx::NativeWindow parent);
-
- // Callback for when the user responds to a Save As or Open File dialog.
- CHROMEGTK_CALLBACK_1(SelectFileDialogImplGTK, void,
- OnSelectSingleFileDialogResponse, int);
-
- // Callback for when the user responds to a Select Folder dialog.
- CHROMEGTK_CALLBACK_1(SelectFileDialogImplGTK, void,
- OnSelectSingleFolderDialogResponse, int);
-
- // Callback for when the user responds to a Open Multiple Files dialog.
- CHROMEGTK_CALLBACK_1(SelectFileDialogImplGTK, void,
- OnSelectMultiFileDialogResponse, int);
-
- // Callback for when the file chooser gets destroyed.
- CHROMEGTK_CALLBACK_0(SelectFileDialogImplGTK, void, OnFileChooserDestroy);
-
- // Callback for when we update the preview for the selection.
- CHROMEGTK_CALLBACK_0(SelectFileDialogImplGTK, void, OnUpdatePreview);
-
- // A map from dialog windows to the |params| user data associated with them.
- std::map<GtkWidget*, void*> params_map_;
-
- // The GtkImage widget for showing previews of selected images.
- GtkWidget* preview_;
-
- // All our dialogs.
- std::set<GtkWidget*> dialogs_;
-
- DISALLOW_COPY_AND_ASSIGN(SelectFileDialogImplGTK);
-};
-
-// The size of the preview we display for selected image files. We set height
-// larger than width because generally there is more free space vertically
-// than horiztonally (setting the preview image will alway expand the width of
-// the dialog, but usually not the height). The image's aspect ratio will always
-// be preserved.
-static const int kPreviewWidth = 256;
-static const int kPreviewHeight = 512;
-
-SelectFileDialogImplGTK::SelectFileDialogImplGTK(Listener* listener,
- ui::SelectFilePolicy* policy)
- : SelectFileDialogImpl(listener, policy),
- preview_(NULL) {
-}
-
-SelectFileDialogImplGTK::~SelectFileDialogImplGTK() {
- while (dialogs_.begin() != dialogs_.end()) {
- gtk_widget_destroy(*(dialogs_.begin()));
- }
-}
-
-bool SelectFileDialogImplGTK::HasMultipleFileTypeChoicesImpl() {
- return file_types_.extensions.size() > 1;
-}
-
-// We ignore |default_extension|.
-void SelectFileDialogImplGTK::SelectFileImpl(
- Type type,
- const base::string16& title,
- const base::FilePath& default_path,
- const FileTypeInfo* file_types,
- int file_type_index,
- const base::FilePath::StringType& default_extension,
- gfx::NativeWindow owning_window,
- void* params) {
- type_ = type;
- // |owning_window| can be null when user right-clicks on a downloadable item
- // and chooses 'Open Link in New Tab' when 'Ask where to save each file
- // before downloading.' preference is turned on. (http://crbug.com/29213)
- if (owning_window)
- parents_.insert(owning_window);
-
- std::string title_string = base::UTF16ToUTF8(title);
-
- file_type_index_ = file_type_index;
- if (file_types)
- file_types_ = *file_types;
- else
- file_types_.include_all_files = true;
-
- GtkWidget* dialog = NULL;
- switch (type) {
- case SELECT_FOLDER:
- case SELECT_UPLOAD_FOLDER:
- dialog = CreateSelectFolderDialog(type, title_string, default_path,
- owning_window);
- break;
- case SELECT_OPEN_FILE:
- dialog = CreateFileOpenDialog(title_string, default_path, owning_window);
- break;
- case SELECT_OPEN_MULTI_FILE:
- dialog = CreateMultiFileOpenDialog(title_string, default_path,
- owning_window);
- break;
- case SELECT_SAVEAS_FILE:
- dialog = CreateSaveAsDialog(title_string, default_path, owning_window);
- break;
- default:
- NOTREACHED();
- return;
- }
- g_signal_connect(dialog, "delete-event",
- G_CALLBACK(gtk_widget_hide_on_delete), NULL);
- dialogs_.insert(dialog);
-
- preview_ = gtk_image_new();
- g_signal_connect(dialog, "destroy",
- G_CALLBACK(OnFileChooserDestroyThunk), this);
- g_signal_connect(dialog, "update-preview",
- G_CALLBACK(OnUpdatePreviewThunk), this);
- gtk_file_chooser_set_preview_widget(GTK_FILE_CHOOSER(dialog), preview_);
-
- params_map_[dialog] = params;
-
- // Set window-to-parent modality by adding the dialog to the same window
- // group as the parent.
- gtk_window_group_add_window(gtk_window_get_group(owning_window),
- GTK_WINDOW(dialog));
- gtk_window_set_modal(GTK_WINDOW(dialog), TRUE);
-
- gtk_widget_show_all(dialog);
-}
-
-void SelectFileDialogImplGTK::AddFilters(GtkFileChooser* chooser) {
- for (size_t i = 0; i < file_types_.extensions.size(); ++i) {
- GtkFileFilter* filter = NULL;
- std::set<std::string> fallback_labels;
-
- for (size_t j = 0; j < file_types_.extensions[i].size(); ++j) {
- const std::string& current_extension = file_types_.extensions[i][j];
- if (!current_extension.empty()) {
- if (!filter)
- filter = gtk_file_filter_new();
- scoped_ptr<std::string> file_extension(
- new std::string("." + current_extension));
- fallback_labels.insert(std::string("*").append(*file_extension));
- gtk_file_filter_add_custom(
- filter,
- GTK_FILE_FILTER_FILENAME,
- reinterpret_cast<GtkFileFilterFunc>(FileFilterCaseInsensitive),
- file_extension.release(),
- reinterpret_cast<GDestroyNotify>(OnFileFilterDataDestroyed));
- }
- }
- // We didn't find any non-empty extensions to filter on.
- if (!filter)
- continue;
-
- // The description vector may be blank, in which case we are supposed to
- // use some sort of default description based on the filter.
- if (i < file_types_.extension_description_overrides.size()) {
- gtk_file_filter_set_name(filter, base::UTF16ToUTF8(
- file_types_.extension_description_overrides[i]).c_str());
- } else {
- // There is no system default filter description so we use
- // the extensions themselves if the description is blank.
- std::vector<std::string> fallback_labels_vector(fallback_labels.begin(),
- fallback_labels.end());
- std::string fallback_label = JoinString(fallback_labels_vector, ',');
- gtk_file_filter_set_name(filter, fallback_label.c_str());
- }
-
- gtk_file_chooser_add_filter(chooser, filter);
- if (i == file_type_index_ - 1)
- gtk_file_chooser_set_filter(chooser, filter);
- }
-
- // Add the *.* filter, but only if we have added other filters (otherwise it
- // is implied).
- if (file_types_.include_all_files && !file_types_.extensions.empty()) {
- GtkFileFilter* filter = gtk_file_filter_new();
- gtk_file_filter_add_pattern(filter, "*");
- gtk_file_filter_set_name(filter,
- l10n_util::GetStringUTF8(IDS_SAVEAS_ALL_FILES).c_str());
- gtk_file_chooser_add_filter(chooser, filter);
- }
-}
-
-void SelectFileDialogImplGTK::FileSelected(GtkWidget* dialog,
- const base::FilePath& path) {
- if (type_ == SELECT_SAVEAS_FILE) {
- *last_saved_path_ = path.DirName();
- } else if (type_ == SELECT_OPEN_FILE || type_ == SELECT_FOLDER ||
- type_ == SELECT_UPLOAD_FOLDER) {
- *last_opened_path_ = path.DirName();
- } else {
- NOTREACHED();
- }
-
- if (listener_) {
- GtkFileFilter* selected_filter =
- gtk_file_chooser_get_filter(GTK_FILE_CHOOSER(dialog));
- GSList* filters = gtk_file_chooser_list_filters(GTK_FILE_CHOOSER(dialog));
- int idx = g_slist_index(filters, selected_filter);
- g_slist_free(filters);
- listener_->FileSelected(path, idx + 1, PopParamsForDialog(dialog));
- }
- gtk_widget_destroy(dialog);
-}
-
-void SelectFileDialogImplGTK::MultiFilesSelected(GtkWidget* dialog,
- const std::vector<base::FilePath>& files) {
- *last_opened_path_ = files[0].DirName();
-
- if (listener_)
- listener_->MultiFilesSelected(files, PopParamsForDialog(dialog));
- gtk_widget_destroy(dialog);
-}
-
-void SelectFileDialogImplGTK::FileNotSelected(GtkWidget* dialog) {
- void* params = PopParamsForDialog(dialog);
- if (listener_)
- listener_->FileSelectionCanceled(params);
- gtk_widget_destroy(dialog);
-}
-
-GtkWidget* SelectFileDialogImplGTK::CreateFileOpenHelper(
- const std::string& title,
- const base::FilePath& default_path,
- gfx::NativeWindow parent) {
- GtkWidget* dialog =
- gtk_file_chooser_dialog_new(title.c_str(), parent,
- GTK_FILE_CHOOSER_ACTION_OPEN,
- GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
- GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
- NULL);
- AddFilters(GTK_FILE_CHOOSER(dialog));
-
- if (!default_path.empty()) {
- if (CallDirectoryExistsOnUIThread(default_path)) {
- gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog),
- default_path.value().c_str());
- } else {
- // If the file doesn't exist, this will just switch to the correct
- // directory. That's good enough.
- gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(dialog),
- default_path.value().c_str());
- }
- } else if (!last_opened_path_->empty()) {
- gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog),
- last_opened_path_->value().c_str());
- }
- return dialog;
-}
-
-GtkWidget* SelectFileDialogImplGTK::CreateSelectFolderDialog(
- Type type,
- const std::string& title,
- const base::FilePath& default_path,
- gfx::NativeWindow parent) {
- std::string title_string = title;
- if (title_string.empty()) {
- title_string = (type == SELECT_UPLOAD_FOLDER) ?
- l10n_util::GetStringUTF8(IDS_SELECT_UPLOAD_FOLDER_DIALOG_TITLE) :
- l10n_util::GetStringUTF8(IDS_SELECT_FOLDER_DIALOG_TITLE);
- }
- std::string accept_button_label = (type == SELECT_UPLOAD_FOLDER) ?
- l10n_util::GetStringUTF8(IDS_SELECT_UPLOAD_FOLDER_DIALOG_UPLOAD_BUTTON) :
- GTK_STOCK_OPEN;
-
- GtkWidget* dialog =
- gtk_file_chooser_dialog_new(title_string.c_str(), parent,
- GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
- GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
- accept_button_label.c_str(),
- GTK_RESPONSE_ACCEPT,
- NULL);
-
- if (!default_path.empty()) {
- gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(dialog),
- default_path.value().c_str());
- } else if (!last_opened_path_->empty()) {
- gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog),
- last_opened_path_->value().c_str());
- }
- gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(dialog), FALSE);
- g_signal_connect(dialog, "response",
- G_CALLBACK(OnSelectSingleFolderDialogResponseThunk), this);
- return dialog;
-}
-
-GtkWidget* SelectFileDialogImplGTK::CreateFileOpenDialog(
- const std::string& title,
- const base::FilePath& default_path,
- gfx::NativeWindow parent) {
- std::string title_string = !title.empty() ? title :
- l10n_util::GetStringUTF8(IDS_OPEN_FILE_DIALOG_TITLE);
-
- GtkWidget* dialog = CreateFileOpenHelper(title_string, default_path, parent);
- gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(dialog), FALSE);
- g_signal_connect(dialog, "response",
- G_CALLBACK(OnSelectSingleFileDialogResponseThunk), this);
- return dialog;
-}
-
-GtkWidget* SelectFileDialogImplGTK::CreateMultiFileOpenDialog(
- const std::string& title,
- const base::FilePath& default_path,
- gfx::NativeWindow parent) {
- std::string title_string = !title.empty() ? title :
- l10n_util::GetStringUTF8(IDS_OPEN_FILES_DIALOG_TITLE);
-
- GtkWidget* dialog = CreateFileOpenHelper(title_string, default_path, parent);
- gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(dialog), TRUE);
- g_signal_connect(dialog, "response",
- G_CALLBACK(OnSelectMultiFileDialogResponseThunk), this);
- return dialog;
-}
-
-GtkWidget* SelectFileDialogImplGTK::CreateSaveAsDialog(const std::string& title,
- const base::FilePath& default_path, gfx::NativeWindow parent) {
- std::string title_string = !title.empty() ? title :
- l10n_util::GetStringUTF8(IDS_SAVE_AS_DIALOG_TITLE);
-
- GtkWidget* dialog =
- gtk_file_chooser_dialog_new(title_string.c_str(), parent,
- GTK_FILE_CHOOSER_ACTION_SAVE,
- GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
- GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT,
- NULL);
-
- AddFilters(GTK_FILE_CHOOSER(dialog));
- if (!default_path.empty()) {
- // Since the file may not already exist, we use
- // set_current_folder() followed by set_current_name(), as per the
- // recommendation of the GTK docs.
- if (CallDirectoryExistsOnUIThread(default_path)) {
- gtk_file_chooser_set_current_folder(
- GTK_FILE_CHOOSER(dialog), default_path.value().c_str());
- gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(dialog), "");
- } else {
- gtk_file_chooser_set_current_folder(
- GTK_FILE_CHOOSER(dialog), default_path.DirName().value().c_str());
- gtk_file_chooser_set_current_name(
- GTK_FILE_CHOOSER(dialog), default_path.BaseName().value().c_str());
- }
- } else if (!last_saved_path_->empty()) {
- gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog),
- last_saved_path_->value().c_str());
- }
- gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(dialog), FALSE);
- gtk_file_chooser_set_do_overwrite_confirmation(GTK_FILE_CHOOSER(dialog),
- TRUE);
- g_signal_connect(dialog, "response",
- G_CALLBACK(OnSelectSingleFileDialogResponseThunk), this);
- return dialog;
-}
-
-void* SelectFileDialogImplGTK::PopParamsForDialog(GtkWidget* dialog) {
- std::map<GtkWidget*, void*>::iterator iter = params_map_.find(dialog);
- DCHECK(iter != params_map_.end());
- void* params = iter->second;
- params_map_.erase(iter);
- return params;
-}
-
-void SelectFileDialogImplGTK::FileDialogDestroyed(GtkWidget* dialog) {
- dialogs_.erase(dialog);
-
- // Parent may be NULL in a few cases: 1) on shutdown when
- // AllBrowsersClosed() trigger this handler after all the browser
- // windows got destroyed, or 2) when the parent tab has been opened by
- // 'Open Link in New Tab' context menu on a downloadable item and
- // the tab has no content (see the comment in SelectFile as well).
- GtkWindow* parent = gtk_window_get_transient_for(GTK_WINDOW(dialog));
- if (!parent)
- return;
- std::set<GtkWindow*>::iterator iter = parents_.find(parent);
- if (iter != parents_.end())
- parents_.erase(iter);
- else
- NOTREACHED();
-}
-
-bool SelectFileDialogImplGTK::IsCancelResponse(gint response_id) {
- bool is_cancel = response_id == GTK_RESPONSE_CANCEL ||
- response_id == GTK_RESPONSE_DELETE_EVENT;
- if (is_cancel)
- return true;
-
- DCHECK(response_id == GTK_RESPONSE_ACCEPT);
- return false;
-}
-
-void SelectFileDialogImplGTK::SelectSingleFileHelper(GtkWidget* dialog,
- gint response_id,
- bool allow_folder) {
- if (IsCancelResponse(response_id)) {
- FileNotSelected(dialog);
- return;
- }
-
- gchar* filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
- if (!filename) {
- FileNotSelected(dialog);
- return;
- }
-
- base::FilePath path(filename);
- g_free(filename);
-
- if (allow_folder) {
- FileSelected(dialog, path);
- return;
- }
-
- if (CallDirectoryExistsOnUIThread(path))
- FileNotSelected(dialog);
- else
- FileSelected(dialog, path);
-}
-
-void SelectFileDialogImplGTK::OnSelectSingleFileDialogResponse(
- GtkWidget* dialog, int response_id) {
- SelectSingleFileHelper(dialog, response_id, false);
-}
-
-void SelectFileDialogImplGTK::OnSelectSingleFolderDialogResponse(
- GtkWidget* dialog, int response_id) {
- SelectSingleFileHelper(dialog, response_id, true);
-}
-
-void SelectFileDialogImplGTK::OnSelectMultiFileDialogResponse(GtkWidget* dialog,
- int response_id) {
- if (IsCancelResponse(response_id)) {
- FileNotSelected(dialog);
- return;
- }
-
- GSList* filenames = gtk_file_chooser_get_filenames(GTK_FILE_CHOOSER(dialog));
- if (!filenames) {
- FileNotSelected(dialog);
- return;
- }
-
- std::vector<base::FilePath> filenames_fp;
- for (GSList* iter = filenames; iter != NULL; iter = g_slist_next(iter)) {
- base::FilePath path(static_cast<char*>(iter->data));
- g_free(iter->data);
- if (CallDirectoryExistsOnUIThread(path))
- continue;
- filenames_fp.push_back(path);
- }
- g_slist_free(filenames);
-
- if (filenames_fp.empty()) {
- FileNotSelected(dialog);
- return;
- }
- MultiFilesSelected(dialog, filenames_fp);
-}
-
-void SelectFileDialogImplGTK::OnFileChooserDestroy(GtkWidget* dialog) {
- FileDialogDestroyed(dialog);
-}
-
-void SelectFileDialogImplGTK::OnUpdatePreview(GtkWidget* chooser) {
- gchar* filename = gtk_file_chooser_get_preview_filename(
- GTK_FILE_CHOOSER(chooser));
- if (!filename)
- return;
- // This will preserve the image's aspect ratio.
- GdkPixbuf* pixbuf = gdk_pixbuf_new_from_file_at_size(filename, kPreviewWidth,
- kPreviewHeight, NULL);
- g_free(filename);
- if (pixbuf) {
- gtk_image_set_from_pixbuf(GTK_IMAGE(preview_), pixbuf);
- g_object_unref(pixbuf);
- }
- gtk_file_chooser_set_preview_widget_active(GTK_FILE_CHOOSER(chooser),
- pixbuf ? TRUE : FALSE);
-}
-
-} // namespace
-
-namespace ui {
-
-SelectFileDialogImpl* SelectFileDialogImpl::NewSelectFileDialogImplGTK(
- Listener* listener, ui::SelectFilePolicy* policy) {
- return new SelectFileDialogImplGTK(listener, policy);
-}
-
-} // namespace ui
diff --git a/ui/shell_dialogs/gtk/select_file_dialog_impl_kde.cc b/ui/shell_dialogs/gtk/select_file_dialog_impl_kde.cc
deleted file mode 100644
index e0e52b5..0000000
--- a/ui/shell_dialogs/gtk/select_file_dialog_impl_kde.cc
+++ /dev/null
@@ -1,485 +0,0 @@
-// Copyright (c) 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 <set>
-
-#include "base/bind.h"
-#include "base/bind_helpers.h"
-#include "base/command_line.h"
-#include "base/logging.h"
-#include "base/message_loop/message_loop.h"
-#include "base/message_loop/message_loop_proxy.h"
-#include "base/nix/mime_util_xdg.h"
-#include "base/nix/xdg_util.h"
-#include "base/process/launch.h"
-#include "base/strings/string_number_conversions.h"
-#include "base/strings/string_util.h"
-#include "base/strings/utf_string_conversions.h"
-#include "base/threading/thread_restrictions.h"
-#include "base/threading/worker_pool.h"
-#include "grit/ui_strings.h"
-#include "ui/base/l10n/l10n_util.h"
-#include "ui/shell_dialogs/gtk/select_file_dialog_impl.h"
-
-// These conflict with base/tracked_objects.h, so need to come last.
-#include <gdk/gdkx.h>
-#include <gtk/gtk.h>
-
-namespace {
-
-std::string GetTitle(const std::string& title, int message_id) {
- return title.empty() ? l10n_util::GetStringUTF8(message_id) : title;
-}
-
-const char kKdialogBinary[] = "kdialog";
-
-// Implementation of SelectFileDialog that shows a KDE common dialog for
-// choosing a file or folder. This acts as a modal dialog.
-class SelectFileDialogImplKDE : public ui::SelectFileDialogImpl {
- public:
- SelectFileDialogImplKDE(Listener* listener,
- ui::SelectFilePolicy* policy,
- base::nix::DesktopEnvironment desktop);
-
- protected:
- virtual ~SelectFileDialogImplKDE();
-
- // SelectFileDialog implementation.
- // |params| is user data we pass back via the Listener interface.
- virtual void SelectFileImpl(
- Type type,
- const base::string16& title,
- const base::FilePath& default_path,
- const FileTypeInfo* file_types,
- int file_type_index,
- const base::FilePath::StringType& default_extension,
- gfx::NativeWindow owning_window,
- void* params) OVERRIDE;
-
- private:
- virtual bool HasMultipleFileTypeChoicesImpl() OVERRIDE;
-
- struct KDialogParams {
- // This constructor can only be run from the UI thread.
- KDialogParams(const std::string& type,
- const std::string& title,
- const base::FilePath& default_path,
- gfx::NativeWindow parent,
- bool file_operation,
- bool multiple_selection,
- void* kdialog_params,
- void(SelectFileDialogImplKDE::* callback)(const std::string&,
- int,
- void*))
- : type(type),
- title(title),
- default_path(default_path),
- parent(parent),
- file_operation(file_operation),
- multiple_selection(multiple_selection),
- kdialog_params(kdialog_params),
- ui_loop_proxy(
- base::MessageLoopForUI::current()->message_loop_proxy()),
- callback(callback) {}
-
- std::string type;
- std::string title;
- base::FilePath default_path;
- gfx::NativeWindow parent;
- bool file_operation;
- bool multiple_selection;
- void* kdialog_params;
- scoped_refptr<base::MessageLoopProxy> ui_loop_proxy;
-
- void (SelectFileDialogImplKDE::*callback)(const std::string&, int, void*);
- };
-
- // Get the filters from |file_types_| and concatenate them into
- // |filter_string|.
- std::string GetMimeTypeFilterString();
-
- // Get KDialog command line representing the Argv array for KDialog.
- void GetKDialogCommandLine(const std::string& type, const std::string& title,
- const base::FilePath& default_path, gfx::NativeWindow parent,
- bool file_operation, bool multiple_selection, CommandLine* command_line);
-
- // Call KDialog on a worker thread and post results back to the caller
- // thread.
- void CallKDialogOutput(const KDialogParams& params);
-
- // Notifies the listener that a single file was chosen.
- void FileSelected(const base::FilePath& path, void* params);
-
- // Notifies the listener that multiple files were chosen.
- void MultiFilesSelected(const std::vector<base::FilePath>& files,
- void* params);
-
- // Notifies the listener that no file was chosen (the action was canceled).
- // Dialog is passed so we can find that |params| pointer that was passed to
- // us when we were told to show the dialog.
- void FileNotSelected(void *params);
-
- void CreateSelectFolderDialog(Type type,
- const std::string& title,
- const base::FilePath& default_path,
- gfx::NativeWindow parent, void* params);
-
- void CreateFileOpenDialog(const std::string& title,
- const base::FilePath& default_path,
- gfx::NativeWindow parent, void* params);
-
- void CreateMultiFileOpenDialog(const std::string& title,
- const base::FilePath& default_path,
- gfx::NativeWindow parent, void* params);
-
- void CreateSaveAsDialog(const std::string& title,
- const base::FilePath& default_path,
- gfx::NativeWindow parent, void* params);
-
- // Common function for OnSelectSingleFileDialogResponse and
- // OnSelectSingleFolderDialogResponse.
- void SelectSingleFileHelper(const std::string& output, int exit_code,
- void* params, bool allow_folder);
-
- void OnSelectSingleFileDialogResponse(const std::string& output,
- int exit_code, void* params);
- void OnSelectMultiFileDialogResponse(const std::string& output,
- int exit_code, void* params);
- void OnSelectSingleFolderDialogResponse(const std::string& output,
- int exit_code, void* params);
-
- // Should be either DESKTOP_ENVIRONMENT_KDE3 or DESKTOP_ENVIRONMENT_KDE4.
- base::nix::DesktopEnvironment desktop_;
-
- DISALLOW_COPY_AND_ASSIGN(SelectFileDialogImplKDE);
-};
-
-SelectFileDialogImplKDE::SelectFileDialogImplKDE(
- Listener* listener,
- ui::SelectFilePolicy* policy,
- base::nix::DesktopEnvironment desktop)
- : SelectFileDialogImpl(listener, policy),
- desktop_(desktop) {
- DCHECK(desktop_ == base::nix::DESKTOP_ENVIRONMENT_KDE3 ||
- desktop_ == base::nix::DESKTOP_ENVIRONMENT_KDE4);
-}
-
-SelectFileDialogImplKDE::~SelectFileDialogImplKDE() {
-}
-
-// We ignore |default_extension|.
-void SelectFileDialogImplKDE::SelectFileImpl(
- Type type,
- const base::string16& title,
- const base::FilePath& default_path,
- const FileTypeInfo* file_types,
- int file_type_index,
- const base::FilePath::StringType& default_extension,
- gfx::NativeWindow owning_window,
- void* params) {
- type_ = type;
- // |owning_window| can be null when user right-clicks on a downloadable item
- // and chooses 'Open Link in New Tab' when 'Ask where to save each file
- // before downloading.' preference is turned on. (http://crbug.com/29213)
- if (owning_window)
- parents_.insert(owning_window);
-
- std::string title_string = base::UTF16ToUTF8(title);
-
- file_type_index_ = file_type_index;
- if (file_types)
- file_types_ = *file_types;
- else
- file_types_.include_all_files = true;
-
- switch (type) {
- case SELECT_FOLDER:
- case SELECT_UPLOAD_FOLDER:
- CreateSelectFolderDialog(type, title_string, default_path,
- owning_window, params);
- return;
- case SELECT_OPEN_FILE:
- CreateFileOpenDialog(title_string, default_path, owning_window,
- params);
- return;
- case SELECT_OPEN_MULTI_FILE:
- CreateMultiFileOpenDialog(title_string, default_path,
- owning_window, params);
- return;
- case SELECT_SAVEAS_FILE:
- CreateSaveAsDialog(title_string, default_path, owning_window,
- params);
- return;
- default:
- NOTREACHED();
- return;
- }
-}
-
-bool SelectFileDialogImplKDE::HasMultipleFileTypeChoicesImpl() {
- return file_types_.extensions.size() > 1;
-}
-
-std::string SelectFileDialogImplKDE::GetMimeTypeFilterString() {
- std::string filter_string;
- // We need a filter set because the same mime type can appear multiple times.
- std::set<std::string> filter_set;
- for (size_t i = 0; i < file_types_.extensions.size(); ++i) {
- for (size_t j = 0; j < file_types_.extensions[i].size(); ++j) {
- if (!file_types_.extensions[i][j].empty()) {
- std::string mime_type = base::nix::GetFileMimeType(
- base::FilePath("name").ReplaceExtension(
- file_types_.extensions[i][j]));
- filter_set.insert(mime_type);
- }
- }
- }
- // Add the *.* filter, but only if we have added other filters (otherwise it
- // is implied).
- if (file_types_.include_all_files && !file_types_.extensions.empty())
- filter_set.insert("application/octet-stream");
- // Create the final output string.
- filter_string.clear();
- for (std::set<std::string>::iterator it = filter_set.begin();
- it != filter_set.end(); ++it) {
- filter_string.append(*it + " ");
- }
- return filter_string;
-}
-
-void SelectFileDialogImplKDE::CallKDialogOutput(const KDialogParams& params) {
- CommandLine::StringVector cmd_vector;
- cmd_vector.push_back(kKdialogBinary);
- CommandLine command_line(cmd_vector);
- GetKDialogCommandLine(params.type, params.title, params.default_path,
- params.parent, params.file_operation,
- params.multiple_selection, &command_line);
- std::string output;
- int exit_code;
- // Get output from KDialog
- base::GetAppOutputWithExitCode(command_line, &output, &exit_code);
- if (!output.empty())
- output.erase(output.size() - 1);
- // Now the dialog is no longer showing. We can erase its parent from the
- // parent set.
- std::set<GtkWindow*>::iterator iter = parents_.find(params.parent);
- if (iter != parents_.end())
- parents_.erase(iter);
- params.ui_loop_proxy->PostTask(FROM_HERE,
- base::Bind(params.callback, this, output, exit_code,
- params.kdialog_params));
-}
-
-void SelectFileDialogImplKDE::GetKDialogCommandLine(const std::string& type,
- const std::string& title, const base::FilePath& path,
- gfx::NativeWindow parent, bool file_operation, bool multiple_selection,
- CommandLine* command_line) {
- CHECK(command_line);
-
- // Attach to the current Chrome window.
- GdkWindow* gdk_window = gtk_widget_get_window(GTK_WIDGET((parent)));
- int window_id = GDK_DRAWABLE_XID(gdk_window);
- command_line->AppendSwitchNative(
- desktop_ == base::nix::DESKTOP_ENVIRONMENT_KDE3 ? "--embed" : "--attach",
- base::IntToString(window_id));
- // Set the correct title for the dialog.
- if (!title.empty())
- command_line->AppendSwitchNative("--title", title);
- // Enable multiple file selection if we need to.
- if (multiple_selection) {
- command_line->AppendSwitch("--multiple");
- command_line->AppendSwitch("--separate-output");
- }
- command_line->AppendSwitch(type);
- // The path should never be empty. If it is, set it to PWD.
- if (path.empty())
- command_line->AppendArgPath(base::FilePath("."));
- else
- command_line->AppendArgPath(path);
- // Depending on the type of the operation we need, get the path to the
- // file/folder and set up mime type filters.
- if (file_operation)
- command_line->AppendArg(GetMimeTypeFilterString());
- VLOG(1) << "KDialog command line: " << command_line->GetCommandLineString();
-}
-
-void SelectFileDialogImplKDE::FileSelected(const base::FilePath& path,
- void* params) {
- if (type_ == SELECT_SAVEAS_FILE)
- *last_saved_path_ = path.DirName();
- else if (type_ == SELECT_OPEN_FILE)
- *last_opened_path_ = path.DirName();
- else if (type_ == SELECT_FOLDER)
- *last_opened_path_ = path;
- else
- NOTREACHED();
- if (listener_) { // What does the filter index actually do?
- // TODO(dfilimon): Get a reasonable index value from somewhere.
- listener_->FileSelected(path, 1, params);
- }
-}
-
-void SelectFileDialogImplKDE::MultiFilesSelected(
- const std::vector<base::FilePath>& files, void* params) {
- *last_opened_path_ = files[0].DirName();
- if (listener_)
- listener_->MultiFilesSelected(files, params);
-}
-
-void SelectFileDialogImplKDE::FileNotSelected(void* params) {
- if (listener_)
- listener_->FileSelectionCanceled(params);
-}
-
-void SelectFileDialogImplKDE::CreateSelectFolderDialog(
- Type type, const std::string& title, const base::FilePath& default_path,
- gfx::NativeWindow parent, void *params) {
- int title_message_id = (type == SELECT_UPLOAD_FOLDER) ?
- IDS_SELECT_UPLOAD_FOLDER_DIALOG_TITLE :
- IDS_SELECT_FOLDER_DIALOG_TITLE;
- base::WorkerPool::PostTask(FROM_HERE,
- base::Bind(
- &SelectFileDialogImplKDE::CallKDialogOutput,
- this,
- KDialogParams(
- "--getexistingdirectory",
- GetTitle(title, title_message_id),
- default_path.empty() ? *last_opened_path_ : default_path,
- parent, false, false, params,
- &SelectFileDialogImplKDE::OnSelectSingleFolderDialogResponse)),
- true);
-}
-
-void SelectFileDialogImplKDE::CreateFileOpenDialog(
- const std::string& title, const base::FilePath& default_path,
- gfx::NativeWindow parent, void* params) {
- base::WorkerPool::PostTask(FROM_HERE,
- base::Bind(
- &SelectFileDialogImplKDE::CallKDialogOutput,
- this,
- KDialogParams(
- "--getopenfilename",
- GetTitle(title, IDS_OPEN_FILE_DIALOG_TITLE),
- default_path.empty() ? *last_opened_path_ : default_path,
- parent, true, false, params,
- &SelectFileDialogImplKDE::OnSelectSingleFileDialogResponse)),
- true);
-}
-
-void SelectFileDialogImplKDE::CreateMultiFileOpenDialog(
- const std::string& title, const base::FilePath& default_path,
- gfx::NativeWindow parent, void* params) {
- base::WorkerPool::PostTask(FROM_HERE,
- base::Bind(
- &SelectFileDialogImplKDE::CallKDialogOutput,
- this,
- KDialogParams(
- "--getopenfilename",
- GetTitle(title, IDS_OPEN_FILES_DIALOG_TITLE),
- default_path.empty() ? *last_opened_path_ : default_path,
- parent, true, true, params,
- &SelectFileDialogImplKDE::OnSelectMultiFileDialogResponse)),
- true);
-}
-
-void SelectFileDialogImplKDE::CreateSaveAsDialog(
- const std::string& title, const base::FilePath& default_path,
- gfx::NativeWindow parent, void* params) {
- base::WorkerPool::PostTask(FROM_HERE,
- base::Bind(
- &SelectFileDialogImplKDE::CallKDialogOutput,
- this,
- KDialogParams(
- "--getsavefilename",
- GetTitle(title, IDS_SAVE_AS_DIALOG_TITLE),
- default_path.empty() ? *last_saved_path_ : default_path,
- parent, true, false, params,
- &SelectFileDialogImplKDE::OnSelectSingleFileDialogResponse)),
- true);
-}
-
-void SelectFileDialogImplKDE::SelectSingleFileHelper(const std::string& output,
- int exit_code, void* params, bool allow_folder) {
- VLOG(1) << "[kdialog] SingleFileResponse: " << output;
- if (exit_code != 0 || output.empty()) {
- FileNotSelected(params);
- return;
- }
-
- base::FilePath path(output);
- if (allow_folder) {
- FileSelected(path, params);
- return;
- }
-
- if (CallDirectoryExistsOnUIThread(path))
- FileNotSelected(params);
- else
- FileSelected(path, params);
-}
-
-void SelectFileDialogImplKDE::OnSelectSingleFileDialogResponse(
- const std::string& output, int exit_code, void* params) {
- SelectSingleFileHelper(output, exit_code, params, false);
-}
-
-void SelectFileDialogImplKDE::OnSelectSingleFolderDialogResponse(
- const std::string& output, int exit_code, void* params) {
- SelectSingleFileHelper(output, exit_code, params, true);
-}
-
-void SelectFileDialogImplKDE::OnSelectMultiFileDialogResponse(
- const std::string& output, int exit_code, void* params) {
- VLOG(1) << "[kdialog] MultiFileResponse: " << output;
-
- if (exit_code != 0 || output.empty()) {
- FileNotSelected(params);
- return;
- }
-
- std::vector<std::string> filenames;
- Tokenize(output, "\n", &filenames);
- std::vector<base::FilePath> filenames_fp;
- for (std::vector<std::string>::iterator iter = filenames.begin();
- iter != filenames.end(); ++iter) {
- base::FilePath path(*iter);
- if (CallDirectoryExistsOnUIThread(path))
- continue;
- filenames_fp.push_back(path);
- }
-
- if (filenames_fp.empty()) {
- FileNotSelected(params);
- return;
- }
- MultiFilesSelected(filenames_fp, params);
-}
-
-} // namespace
-
-namespace ui {
-
-// static
-bool SelectFileDialogImpl::CheckKDEDialogWorksOnUIThread() {
- // No choice. UI thread can't continue without an answer here. Fortunately we
- // only do this once, the first time a file dialog is displayed.
- base::ThreadRestrictions::ScopedAllowIO allow_io;
-
- CommandLine::StringVector cmd_vector;
- cmd_vector.push_back(kKdialogBinary);
- cmd_vector.push_back("--version");
- CommandLine command_line(cmd_vector);
- std::string dummy;
- return base::GetAppOutput(command_line, &dummy);
-}
-
-// static
-SelectFileDialogImpl* SelectFileDialogImpl::NewSelectFileDialogImplKDE(
- Listener* listener,
- ui::SelectFilePolicy* policy,
- base::nix::DesktopEnvironment desktop) {
- return new SelectFileDialogImplKDE(listener, policy, desktop);
-}
-
-} // namespace ui
diff --git a/ui/shell_dialogs/shell_dialogs.gyp b/ui/shell_dialogs/shell_dialogs.gyp
index 7cd262d..0d9181f 100644
--- a/ui/shell_dialogs/shell_dialogs.gyp
+++ b/ui/shell_dialogs/shell_dialogs.gyp
@@ -27,10 +27,6 @@
'base_shell_dialog.h',
'base_shell_dialog_win.cc',
'base_shell_dialog_win.h',
- 'gtk/select_file_dialog_impl.cc',
- 'gtk/select_file_dialog_impl.h',
- 'gtk/select_file_dialog_impl_gtk.cc',
- 'gtk/select_file_dialog_impl_kde.cc',
'linux_shell_dialog.cc',
'linux_shell_dialog.h',
'select_file_dialog.cc',
diff --git a/ui/snapshot/snapshot.gyp b/ui/snapshot/snapshot.gyp
index 9dd9322..1f0c645 100644
--- a/ui/snapshot/snapshot.gyp
+++ b/ui/snapshot/snapshot.gyp
@@ -25,7 +25,6 @@
'snapshot_android.cc',
'snapshot_aura.cc',
'snapshot_export.h',
- 'snapshot_gtk.cc',
'snapshot_ios.mm',
'snapshot_mac.mm',
'snapshot_win.cc',
diff --git a/ui/snapshot/snapshot_gtk.cc b/ui/snapshot/snapshot_gtk.cc
deleted file mode 100644
index 2ec86f3..0000000
--- a/ui/snapshot/snapshot_gtk.cc
+++ /dev/null
@@ -1,112 +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/snapshot/snapshot.h"
-
-#include <gdk/gdkx.h>
-#include <gtk/gtk.h>
-
-#include "base/callback.h"
-#include "base/logging.h"
-#include "ui/base/x/x11_util.h"
-#include "ui/gfx/image/image.h"
-#include "ui/gfx/rect.h"
-
-namespace {
-
-cairo_status_t SnapshotCallback(void* closure,
- const unsigned char* data,
- unsigned int length) {
- std::vector<unsigned char>* png_representation =
- static_cast<std::vector<unsigned char>*>(closure);
-
- size_t old_size = png_representation->size();
- png_representation->resize(old_size + length);
- memcpy(&(*png_representation)[old_size], data, length);
- return CAIRO_STATUS_SUCCESS;
-}
-
-} // namespace
-
-namespace ui {
-
-bool GrabViewSnapshot(gfx::NativeView view_handle,
- std::vector<unsigned char>* png_representation,
- const gfx::Rect& snapshot_bounds) {
- GdkWindow* gdk_window = gtk_widget_get_window(view_handle);
- Display* display = GDK_WINDOW_XDISPLAY(gdk_window);
- XID win = GDK_WINDOW_XID(gdk_window);
-
- gfx::Rect window_bounds;
- if (ui::GetWindowRect(win, &window_bounds) == 0) {
- LOG(ERROR) << "Couldn't get window bounds";
- return false;
- }
-
- DCHECK_LE(snapshot_bounds.right(), window_bounds.width());
- DCHECK_LE(snapshot_bounds.bottom(), window_bounds.height());
-
- ui::XScopedImage image(XGetImage(
- display, win, snapshot_bounds.x(), snapshot_bounds.y(),
- snapshot_bounds.width(), snapshot_bounds.height(), AllPlanes, ZPixmap));
- if (!image.get()) {
- LOG(ERROR) << "Couldn't get image";
- return false;
- }
- if (image->depth != 24) {
- LOG(ERROR)<< "Unsupported image depth " << image->depth;
- return false;
- }
- cairo_surface_t* surface =
- cairo_image_surface_create_for_data(
- reinterpret_cast<unsigned char*>(image->data),
- CAIRO_FORMAT_RGB24,
- image->width,
- image->height,
- image->bytes_per_line);
-
- if (!surface) {
- LOG(ERROR) << "Unable to create Cairo surface from XImage data";
- return false;
- }
- cairo_surface_write_to_png_stream(
- surface, SnapshotCallback, png_representation);
- cairo_surface_destroy(surface);
-
- return true;
-}
-
-bool GrabWindowSnapshot(gfx::NativeWindow window_handle,
- std::vector<unsigned char>* png_representation,
- const gfx::Rect& snapshot_bounds) {
- return GrabViewSnapshot(GTK_WIDGET(window_handle), png_representation,
- snapshot_bounds);
-}
-
-void GrabWindowSnapshotAndScaleAsync(
- gfx::NativeWindow window,
- const gfx::Rect& snapshot_bounds,
- const gfx::Size& target_size,
- scoped_refptr<base::TaskRunner> background_task_runner,
- GrabWindowSnapshotAsyncCallback callback) {
- callback.Run(gfx::Image());
-}
-
-void GrabViewSnapshotAsync(
- gfx::NativeView view,
- const gfx::Rect& source_rect,
- scoped_refptr<base::TaskRunner> background_task_runner,
- const GrabWindowSnapshotAsyncPNGCallback& callback) {
- callback.Run(scoped_refptr<base::RefCountedBytes>());
-}
-
-void GrabWindowSnapshotAsync(
- gfx::NativeWindow window,
- const gfx::Rect& source_rect,
- scoped_refptr<base::TaskRunner> background_task_runner,
- const GrabWindowSnapshotAsyncPNGCallback& callback) {
- callback.Run(scoped_refptr<base::RefCountedBytes>());
-}
-
-} // namespace ui
diff --git a/ui/surface/surface.gyp b/ui/surface/surface.gyp
index cc76b69..5729565 100644
--- a/ui/surface/surface.gyp
+++ b/ui/surface/surface.gyp
@@ -37,7 +37,6 @@
'surface_export.h',
'transport_dib.h',
'transport_dib.cc',
- 'transport_dib_gtk.cc',
'transport_dib_posix.cc',
'transport_dib_win.cc',
],
diff --git a/ui/surface/transport_dib_gtk.cc b/ui/surface/transport_dib_gtk.cc
deleted file mode 100644
index 0d075a1..0000000
--- a/ui/surface/transport_dib_gtk.cc
+++ /dev/null
@@ -1,160 +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/surface/transport_dib.h"
-
-// Desktop GTK Linux builds use the old-style SYSV SHM based DIBs.
-
-#include <errno.h>
-#include <stdlib.h>
-#include <sys/ipc.h>
-#include <sys/shm.h>
-
-#include "base/logging.h"
-#include "base/memory/scoped_ptr.h"
-#include "skia/ext/platform_canvas.h"
-#include "ui/base/x/x11_util.h"
-#include "ui/gfx/size.h"
-
-#error "The GTK+ port will be deleted later this week. If you are seeing this, you are trying to compile it. Please check your gyp flags for 'use_aura=0' and remove them."
-
-// The shmat system call uses this as it's invalid return address
-static void *const kInvalidAddress = (void*) -1;
-
-TransportDIB::TransportDIB()
- : address_(kInvalidAddress),
- x_shm_(0),
- display_(NULL),
- inflight_counter_(0),
- detached_(false),
- size_(0) {
-}
-
-TransportDIB::~TransportDIB() {
- if (address_ != kInvalidAddress) {
- shmdt(address_);
- address_ = kInvalidAddress;
- }
-
- if (x_shm_) {
- DCHECK(display_);
- ui::DetachSharedMemory(display_, x_shm_);
- }
-}
-
-// static
-TransportDIB* TransportDIB::Create(size_t size, uint32 sequence_num) {
- const int shmkey = shmget(IPC_PRIVATE, size, 0600);
- if (shmkey == -1) {
- DLOG(ERROR) << "Failed to create SysV shared memory region"
- << " errno:" << errno;
- return NULL;
- } else {
- VLOG(1) << "Created SysV shared memory region " << shmkey;
- }
-
- void* address = shmat(shmkey, NULL /* desired address */, 0 /* flags */);
- // Here we mark the shared memory for deletion. Since we attached it in the
- // line above, it doesn't actually get deleted but, if we crash, this means
- // that the kernel will automatically clean it up for us.
- shmctl(shmkey, IPC_RMID, 0);
- if (address == kInvalidAddress)
- return NULL;
-
- TransportDIB* dib = new TransportDIB;
-
- dib->key_.shmkey = shmkey;
- dib->address_ = address;
- dib->size_ = size;
- return dib;
-}
-
-// static
-TransportDIB* TransportDIB::Map(Handle handle) {
- scoped_ptr<TransportDIB> dib(CreateWithHandle(handle));
- if (!dib->Map())
- return NULL;
- return dib.release();
-}
-
-// static
-TransportDIB* TransportDIB::CreateWithHandle(Handle shmkey) {
- TransportDIB* dib = new TransportDIB;
- dib->key_.shmkey = shmkey;
- return dib;
-}
-
-// static
-bool TransportDIB::is_valid_handle(Handle dib) {
- return dib >= 0;
-}
-
-// static
-bool TransportDIB::is_valid_id(Id id) {
- return id.shmkey != -1;
-}
-
-skia::PlatformCanvas* TransportDIB::GetPlatformCanvas(int w, int h) {
- if ((address_ == kInvalidAddress && !Map()) || !VerifyCanvasSize(w, h))
- return NULL;
- return skia::CreatePlatformCanvas(w, h, true,
- reinterpret_cast<uint8_t*>(memory()),
- skia::RETURN_NULL_ON_FAILURE);
-}
-
-bool TransportDIB::Map() {
- if (!is_valid_id(key_))
- return false;
- if (address_ != kInvalidAddress)
- return true;
-
- struct shmid_ds shmst;
- if (shmctl(key_.shmkey, IPC_STAT, &shmst) == -1)
- return false;
-
- void* address = shmat(key_.shmkey, NULL /* desired address */, 0 /* flags */);
- if (address == kInvalidAddress)
- return false;
-
- address_ = address;
- size_ = shmst.shm_segsz;
- return true;
-}
-
-void* TransportDIB::memory() const {
- DCHECK_NE(address_, kInvalidAddress);
- return address_;
-}
-
-TransportDIB::Id TransportDIB::id() const {
- return key_;
-}
-
-TransportDIB::Handle TransportDIB::handle() const {
- return key_.shmkey;
-}
-
-XID TransportDIB::MapToX(XDisplay* display) {
- if (!x_shm_) {
- x_shm_ = ui::AttachSharedMemory(display, key_.shmkey);
- display_ = display;
- }
-
- return x_shm_;
-}
-
-void TransportDIB::DecreaseInFlightCounter() {
- CHECK(inflight_counter_);
- inflight_counter_--;
- if (!inflight_counter_ && detached_)
- delete this;
-}
-
-void TransportDIB::Detach() {
- CHECK(!detached_);
- detached_ = true;
- if (!inflight_counter_)
- delete this;
-}
-
diff --git a/ui/ui_unittests.gyp b/ui/ui_unittests.gyp
index 7b7d3e4..c89733e 100644
--- a/ui/ui_unittests.gyp
+++ b/ui/ui_unittests.gyp
@@ -19,7 +19,6 @@
'sources': [
'base/test/ui_controls.h',
'base/test/ui_controls_aura.cc',
- 'base/test/ui_controls_gtk.cc',
'base/test/ui_controls_internal_win.cc',
'base/test/ui_controls_internal_win.h',
'base/test/ui_controls_mac.mm',