| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ui/base/clipboard/clipboard.h" | 5 #include "ui/base/clipboard/clipboard.h" |
| 6 | 6 |
| 7 #include <X11/extensions/Xfixes.h> | 7 #include <X11/extensions/Xfixes.h> |
| 8 #include <X11/Xatom.h> | 8 #include <X11/Xatom.h> |
| 9 #include <list> | 9 #include <list> |
| 10 #include <set> | 10 #include <set> |
| 11 | 11 |
| 12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
| 13 #include "base/files/file_path.h" | 13 #include "base/files/file_path.h" |
| 14 #include "base/logging.h" | 14 #include "base/logging.h" |
| 15 #include "base/memory/ref_counted_memory.h" | 15 #include "base/memory/ref_counted_memory.h" |
| 16 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
| 17 #include "base/memory/singleton.h" | 17 #include "base/memory/singleton.h" |
| 18 #include "base/message_loop/message_pump_aurax11.h" | |
| 19 #include "base/message_loop/message_pump_observer.h" | 18 #include "base/message_loop/message_pump_observer.h" |
| 19 #include "base/message_loop/message_pump_x11.h" |
| 20 #include "base/stl_util.h" | 20 #include "base/stl_util.h" |
| 21 #include "base/strings/utf_string_conversions.h" | 21 #include "base/strings/utf_string_conversions.h" |
| 22 #include "third_party/skia/include/core/SkBitmap.h" | 22 #include "third_party/skia/include/core/SkBitmap.h" |
| 23 #include "ui/base/clipboard/custom_data_helper.h" | 23 #include "ui/base/clipboard/custom_data_helper.h" |
| 24 #include "ui/base/x/selection_owner.h" | 24 #include "ui/base/x/selection_owner.h" |
| 25 #include "ui/base/x/selection_requestor.h" | 25 #include "ui/base/x/selection_requestor.h" |
| 26 #include "ui/base/x/selection_utils.h" | 26 #include "ui/base/x/selection_utils.h" |
| 27 #include "ui/base/x/x11_atom_cache.h" | 27 #include "ui/base/x/x11_atom_cache.h" |
| 28 #include "ui/base/x/x11_util.h" | 28 #include "ui/base/x/x11_util.h" |
| 29 #include "ui/gfx/codec/png_codec.h" | 29 #include "ui/gfx/codec/png_codec.h" |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 XFixesSelectionClientCloseNotifyMask); | 99 XFixesSelectionClientCloseNotifyMask); |
| 100 // This seems to be semi-optional. For some reason, registering for any | 100 // This seems to be semi-optional. For some reason, registering for any |
| 101 // selection notify events seems to subscribe us to events for both the | 101 // selection notify events seems to subscribe us to events for both the |
| 102 // primary and the clipboard buffers. Register anyway just to be safe. | 102 // primary and the clipboard buffers. Register anyway just to be safe. |
| 103 XFixesSelectSelectionInput(GetXDisplay(), GetX11RootWindow(), | 103 XFixesSelectSelectionInput(GetXDisplay(), GetX11RootWindow(), |
| 104 XA_PRIMARY, | 104 XA_PRIMARY, |
| 105 XFixesSetSelectionOwnerNotifyMask | | 105 XFixesSetSelectionOwnerNotifyMask | |
| 106 XFixesSelectionWindowDestroyNotifyMask | | 106 XFixesSelectionWindowDestroyNotifyMask | |
| 107 XFixesSelectionClientCloseNotifyMask); | 107 XFixesSelectionClientCloseNotifyMask); |
| 108 | 108 |
| 109 base::MessagePumpAuraX11::Current()->AddObserver(this); | 109 base::MessagePumpX11::Current()->AddObserver(this); |
| 110 } | 110 } |
| 111 } | 111 } |
| 112 | 112 |
| 113 SelectionChangeObserver::~SelectionChangeObserver() { | 113 SelectionChangeObserver::~SelectionChangeObserver() { |
| 114 // We are a singleton; we will outlive our message pump. | 114 // We are a singleton; we will outlive our message pump. |
| 115 } | 115 } |
| 116 | 116 |
| 117 SelectionChangeObserver* SelectionChangeObserver::GetInstance() { | 117 SelectionChangeObserver* SelectionChangeObserver::GetInstance() { |
| 118 return Singleton<SelectionChangeObserver>::get(); | 118 return Singleton<SelectionChangeObserver>::get(); |
| 119 } | 119 } |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 atom_cache_.GetAtom(kClipboard)), | 325 atom_cache_.GetAtom(kClipboard)), |
| 326 primary_requestor_(x_display_, x_window_, XA_PRIMARY), | 326 primary_requestor_(x_display_, x_window_, XA_PRIMARY), |
| 327 clipboard_owner_(x_display_, x_window_, atom_cache_.GetAtom(kClipboard)), | 327 clipboard_owner_(x_display_, x_window_, atom_cache_.GetAtom(kClipboard)), |
| 328 primary_owner_(x_display_, x_window_, XA_PRIMARY) { | 328 primary_owner_(x_display_, x_window_, XA_PRIMARY) { |
| 329 // We don't know all possible MIME types at compile time. | 329 // We don't know all possible MIME types at compile time. |
| 330 atom_cache_.allow_uncached_atoms(); | 330 atom_cache_.allow_uncached_atoms(); |
| 331 | 331 |
| 332 XStoreName(x_display_, x_window_, "Chromium clipboard"); | 332 XStoreName(x_display_, x_window_, "Chromium clipboard"); |
| 333 XSelectInput(x_display_, x_window_, PropertyChangeMask); | 333 XSelectInput(x_display_, x_window_, PropertyChangeMask); |
| 334 | 334 |
| 335 base::MessagePumpAuraX11::Current()->AddDispatcherForWindow(this, x_window_); | 335 base::MessagePumpX11::Current()->AddDispatcherForWindow(this, x_window_); |
| 336 } | 336 } |
| 337 | 337 |
| 338 Clipboard::AuraX11Details::~AuraX11Details() { | 338 Clipboard::AuraX11Details::~AuraX11Details() { |
| 339 base::MessagePumpAuraX11::Current()->RemoveDispatcherForWindow(x_window_); | 339 base::MessagePumpX11::Current()->RemoveDispatcherForWindow(x_window_); |
| 340 | 340 |
| 341 XDestroyWindow(x_display_, x_window_); | 341 XDestroyWindow(x_display_, x_window_); |
| 342 } | 342 } |
| 343 | 343 |
| 344 ::Atom Clipboard::AuraX11Details::LookupSelectionForBuffer( | 344 ::Atom Clipboard::AuraX11Details::LookupSelectionForBuffer( |
| 345 Buffer buffer) const { | 345 Buffer buffer) const { |
| 346 if (buffer == BUFFER_STANDARD) | 346 if (buffer == BUFFER_STANDARD) |
| 347 return atom_cache_.GetAtom(kClipboard); | 347 return atom_cache_.GetAtom(kClipboard); |
| 348 | 348 |
| 349 return XA_PRIMARY; | 349 return XA_PRIMARY; |
| (...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 858 return type; | 858 return type; |
| 859 } | 859 } |
| 860 | 860 |
| 861 // static | 861 // static |
| 862 const Clipboard::FormatType& Clipboard::GetPepperCustomDataFormatType() { | 862 const Clipboard::FormatType& Clipboard::GetPepperCustomDataFormatType() { |
| 863 CR_DEFINE_STATIC_LOCAL(FormatType, type, (kMimeTypePepperCustomData)); | 863 CR_DEFINE_STATIC_LOCAL(FormatType, type, (kMimeTypePepperCustomData)); |
| 864 return type; | 864 return type; |
| 865 } | 865 } |
| 866 | 866 |
| 867 } // namespace ui | 867 } // namespace ui |
| OLD | NEW |