Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(173)

Side by Side Diff: ui/base/clipboard/clipboard_aurax11.cc

Issue 2914103002: Remove usages of XInternAtom (Closed)
Patch Set: Address sadrul and sergeyu comments Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/aura/window_tree_host_x11.cc ('k') | ui/base/dragdrop/os_exchange_data_provider_aurax11.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_aurax11.h" 5 #include "ui/base/clipboard/clipboard_aurax11.h"
6 6
7 #include <X11/Xatom.h> 7 #include <X11/Xatom.h>
8 #include <X11/extensions/Xfixes.h> 8 #include <X11/extensions/Xfixes.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
(...skipping 16 matching lines...) Expand all
27 #include "ui/base/x/selection_owner.h" 27 #include "ui/base/x/selection_owner.h"
28 #include "ui/base/x/selection_requestor.h" 28 #include "ui/base/x/selection_requestor.h"
29 #include "ui/base/x/selection_utils.h" 29 #include "ui/base/x/selection_utils.h"
30 #include "ui/base/x/x11_util.h" 30 #include "ui/base/x/x11_util.h"
31 #include "ui/base/x/x11_window_event_manager.h" 31 #include "ui/base/x/x11_window_event_manager.h"
32 #include "ui/events/platform/platform_event_dispatcher.h" 32 #include "ui/events/platform/platform_event_dispatcher.h"
33 #include "ui/events/platform/platform_event_observer.h" 33 #include "ui/events/platform/platform_event_observer.h"
34 #include "ui/events/platform/platform_event_source.h" 34 #include "ui/events/platform/platform_event_source.h"
35 #include "ui/gfx/codec/png_codec.h" 35 #include "ui/gfx/codec/png_codec.h"
36 #include "ui/gfx/geometry/size.h" 36 #include "ui/gfx/geometry/size.h"
37 #include "ui/gfx/x/x11_atom_cache.h"
38 37
39 namespace ui { 38 namespace ui {
40 39
41 namespace { 40 namespace {
42 41
43 const char kClipboard[] = "CLIPBOARD"; 42 const char kClipboard[] = "CLIPBOARD";
44 const char kClipboardManager[] = "CLIPBOARD_MANAGER"; 43 const char kClipboardManager[] = "CLIPBOARD_MANAGER";
45 const char kMimeTypeFilename[] = "chromium/filename"; 44 const char kMimeTypeFilename[] = "chromium/filename";
46 const char kSaveTargets[] = "SAVE_TARGETS"; 45 const char kSaveTargets[] = "SAVE_TARGETS";
47 const char kTargets[] = "TARGETS"; 46 const char kTargets[] = "TARGETS";
48 47
49 const char* kAtomsToCache[] = {kClipboard,
50 kClipboardManager,
51 Clipboard::kMimeTypePNG,
52 kMimeTypeFilename,
53 Clipboard::kMimeTypeMozillaURL,
54 Clipboard::kMimeTypeWebkitSmartPaste,
55 kSaveTargets,
56 kString,
57 kTargets,
58 kText,
59 kUtf8String,
60 nullptr};
61
62 /////////////////////////////////////////////////////////////////////////////// 48 ///////////////////////////////////////////////////////////////////////////////
63 49
64 // Uses the XFixes API to provide sequence numbers for GetSequenceNumber(). 50 // Uses the XFixes API to provide sequence numbers for GetSequenceNumber().
65 class SelectionChangeObserver : public ui::PlatformEventObserver { 51 class SelectionChangeObserver : public ui::PlatformEventObserver {
66 public: 52 public:
67 static SelectionChangeObserver* GetInstance(); 53 static SelectionChangeObserver* GetInstance();
68 54
69 uint64_t clipboard_sequence_number() const { 55 uint64_t clipboard_sequence_number() const {
70 return clipboard_sequence_number_; 56 return clipboard_sequence_number_;
71 } 57 }
(...skipping 17 matching lines...) Expand all
89 DISALLOW_COPY_AND_ASSIGN(SelectionChangeObserver); 75 DISALLOW_COPY_AND_ASSIGN(SelectionChangeObserver);
90 }; 76 };
91 77
92 SelectionChangeObserver::SelectionChangeObserver() 78 SelectionChangeObserver::SelectionChangeObserver()
93 : event_base_(-1), 79 : event_base_(-1),
94 clipboard_atom_(None), 80 clipboard_atom_(None),
95 clipboard_sequence_number_(0), 81 clipboard_sequence_number_(0),
96 primary_sequence_number_(0) { 82 primary_sequence_number_(0) {
97 int ignored; 83 int ignored;
98 if (XFixesQueryExtension(gfx::GetXDisplay(), &event_base_, &ignored)) { 84 if (XFixesQueryExtension(gfx::GetXDisplay(), &event_base_, &ignored)) {
99 clipboard_atom_ = XInternAtom(gfx::GetXDisplay(), kClipboard, false); 85 clipboard_atom_ = GetAtom(kClipboard);
100 XFixesSelectSelectionInput(gfx::GetXDisplay(), GetX11RootWindow(), 86 XFixesSelectSelectionInput(gfx::GetXDisplay(), GetX11RootWindow(),
101 clipboard_atom_, 87 clipboard_atom_,
102 XFixesSetSelectionOwnerNotifyMask | 88 XFixesSetSelectionOwnerNotifyMask |
103 XFixesSelectionWindowDestroyNotifyMask | 89 XFixesSelectionWindowDestroyNotifyMask |
104 XFixesSelectionClientCloseNotifyMask); 90 XFixesSelectionClientCloseNotifyMask);
105 // This seems to be semi-optional. For some reason, registering for any 91 // This seems to be semi-optional. For some reason, registering for any
106 // selection notify events seems to subscribe us to events for both the 92 // selection notify events seems to subscribe us to events for both the
107 // primary and the clipboard buffers. Register anyway just to be safe. 93 // primary and the clipboard buffers. Register anyway just to be safe.
108 XFixesSelectSelectionInput(gfx::GetXDisplay(), GetX11RootWindow(), 94 XFixesSelectSelectionInput(gfx::GetXDisplay(), GetX11RootWindow(),
109 XA_PRIMARY, 95 XA_PRIMARY,
(...skipping 28 matching lines...) Expand all
138 } 124 }
139 } 125 }
140 126
141 /////////////////////////////////////////////////////////////////////////////// 127 ///////////////////////////////////////////////////////////////////////////////
142 128
143 // Represents a list of possible return types. Copy constructable. 129 // Represents a list of possible return types. Copy constructable.
144 class TargetList { 130 class TargetList {
145 public: 131 public:
146 typedef std::vector< ::Atom> AtomVector; 132 typedef std::vector< ::Atom> AtomVector;
147 133
148 TargetList(const AtomVector& target_list, X11AtomCache* atom_cache); 134 explicit TargetList(const AtomVector& target_list);
149 135
150 const AtomVector& target_list() { return target_list_; } 136 const AtomVector& target_list() { return target_list_; }
151 137
152 bool ContainsText() const; 138 bool ContainsText() const;
153 bool ContainsFormat(const Clipboard::FormatType& format_type) const; 139 bool ContainsFormat(const Clipboard::FormatType& format_type) const;
154 bool ContainsAtom(::Atom atom) const; 140 bool ContainsAtom(::Atom atom) const;
155 141
156 private: 142 private:
157 AtomVector target_list_; 143 AtomVector target_list_;
158 X11AtomCache* atom_cache_;
159 }; 144 };
160 145
161 TargetList::TargetList(const AtomVector& target_list, 146 TargetList::TargetList(const AtomVector& target_list)
162 X11AtomCache* atom_cache) 147 : target_list_(target_list) {}
163 : target_list_(target_list),
164 atom_cache_(atom_cache) {
165 }
166 148
167 bool TargetList::ContainsText() const { 149 bool TargetList::ContainsText() const {
168 std::vector< ::Atom> atoms = GetTextAtomsFrom(atom_cache_); 150 std::vector<::Atom> atoms = GetTextAtomsFrom();
169 for (std::vector< ::Atom>::const_iterator it = atoms.begin(); 151 for (std::vector< ::Atom>::const_iterator it = atoms.begin();
170 it != atoms.end(); ++it) { 152 it != atoms.end(); ++it) {
171 if (ContainsAtom(*it)) 153 if (ContainsAtom(*it))
172 return true; 154 return true;
173 } 155 }
174 156
175 return false; 157 return false;
176 } 158 }
177 159
178 bool TargetList::ContainsFormat( 160 bool TargetList::ContainsFormat(
179 const Clipboard::FormatType& format_type) const { 161 const Clipboard::FormatType& format_type) const {
180 ::Atom atom = atom_cache_->GetAtom(format_type.ToString().c_str()); 162 ::Atom atom = GetAtom(format_type.ToString().c_str());
181 return ContainsAtom(atom); 163 return ContainsAtom(atom);
182 } 164 }
183 165
184 bool TargetList::ContainsAtom(::Atom atom) const { 166 bool TargetList::ContainsAtom(::Atom atom) const {
185 return find(target_list_.begin(), target_list_.end(), atom) 167 return find(target_list_.begin(), target_list_.end(), atom)
186 != target_list_.end(); 168 != target_list_.end();
187 } 169 }
188 170
189 } // namespace 171 } // namespace
190 172
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 /////////////////////////////////////////////////////////////////////////////// 208 ///////////////////////////////////////////////////////////////////////////////
227 // ClipboardAuraX11::AuraX11Details 209 // ClipboardAuraX11::AuraX11Details
228 210
229 // Private implementation of our X11 integration. Keeps X11 headers out of the 211 // Private implementation of our X11 integration. Keeps X11 headers out of the
230 // majority of chrome, which break badly. 212 // majority of chrome, which break badly.
231 class ClipboardAuraX11::AuraX11Details : public PlatformEventDispatcher { 213 class ClipboardAuraX11::AuraX11Details : public PlatformEventDispatcher {
232 public: 214 public:
233 AuraX11Details(); 215 AuraX11Details();
234 ~AuraX11Details() override; 216 ~AuraX11Details() override;
235 217
236 X11AtomCache* atom_cache() { return &atom_cache_; }
237
238 // Returns the X11 type that we pass to various XSelection functions for the 218 // Returns the X11 type that we pass to various XSelection functions for the
239 // given type. 219 // given type.
240 ::Atom LookupSelectionForClipboardType(ClipboardType type) const; 220 ::Atom LookupSelectionForClipboardType(ClipboardType type) const;
241 221
242 // Returns the X11 type that we pass to various XSelection functions for 222 // Returns the X11 type that we pass to various XSelection functions for
243 // CLIPBOARD_TYPE_COPY_PASTE. 223 // CLIPBOARD_TYPE_COPY_PASTE.
244 ::Atom GetCopyPasteSelection() const; 224 ::Atom GetCopyPasteSelection() const;
245 225
246 // Finds the SelectionFormatMap for the incoming selection atom. 226 // Finds the SelectionFormatMap for the incoming selection atom.
247 const SelectionFormatMap& LookupStorageForAtom(::Atom atom); 227 const SelectionFormatMap& LookupStorageForAtom(::Atom atom);
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 // Our X11 state. 278 // Our X11 state.
299 Display* x_display_; 279 Display* x_display_;
300 ::Window x_root_window_; 280 ::Window x_root_window_;
301 281
302 // Input-only window used as a selection owner. 282 // Input-only window used as a selection owner.
303 ::Window x_window_; 283 ::Window x_window_;
304 284
305 // Events selected on |x_window_|. 285 // Events selected on |x_window_|.
306 std::unique_ptr<XScopedEventSelector> x_window_events_; 286 std::unique_ptr<XScopedEventSelector> x_window_events_;
307 287
308 X11AtomCache atom_cache_;
309
310 // Object which requests and receives selection data. 288 // Object which requests and receives selection data.
311 SelectionRequestor selection_requestor_; 289 SelectionRequestor selection_requestor_;
312 290
313 // Temporary target map that we write to during DispatchObects. 291 // Temporary target map that we write to during DispatchObects.
314 SelectionFormatMap clipboard_data_; 292 SelectionFormatMap clipboard_data_;
315 293
316 // Objects which offer selection data to other windows. 294 // Objects which offer selection data to other windows.
317 SelectionOwner clipboard_owner_; 295 SelectionOwner clipboard_owner_;
318 SelectionOwner primary_owner_; 296 SelectionOwner primary_owner_;
319 297
320 DISALLOW_COPY_AND_ASSIGN(AuraX11Details); 298 DISALLOW_COPY_AND_ASSIGN(AuraX11Details);
321 }; 299 };
322 300
323 ClipboardAuraX11::AuraX11Details::AuraX11Details() 301 ClipboardAuraX11::AuraX11Details::AuraX11Details()
324 : x_display_(gfx::GetXDisplay()), 302 : x_display_(gfx::GetXDisplay()),
325 x_root_window_(DefaultRootWindow(x_display_)), 303 x_root_window_(DefaultRootWindow(x_display_)),
326 x_window_(XCreateWindow(x_display_, 304 x_window_(XCreateWindow(x_display_,
327 x_root_window_, 305 x_root_window_,
328 -100, 306 -100,
329 -100, 307 -100,
330 10, 308 10,
331 10, // x, y, width, height 309 10, // x, y, width, height
332 0, // border width 310 0, // border width
333 CopyFromParent, // depth 311 CopyFromParent, // depth
334 InputOnly, 312 InputOnly,
335 CopyFromParent, // visual 313 CopyFromParent, // visual
336 0, 314 0,
337 NULL)), 315 NULL)),
338 atom_cache_(x_display_, kAtomsToCache),
339 selection_requestor_(x_display_, x_window_, this), 316 selection_requestor_(x_display_, x_window_, this),
340 clipboard_owner_(x_display_, x_window_, atom_cache_.GetAtom(kClipboard)), 317 clipboard_owner_(x_display_, x_window_, GetAtom(kClipboard)),
341 primary_owner_(x_display_, x_window_, XA_PRIMARY) { 318 primary_owner_(x_display_, x_window_, XA_PRIMARY) {
342 // We don't know all possible MIME types at compile time.
343 atom_cache_.allow_uncached_atoms();
344
345 XStoreName(x_display_, x_window_, "Chromium clipboard"); 319 XStoreName(x_display_, x_window_, "Chromium clipboard");
346 x_window_events_.reset( 320 x_window_events_.reset(
347 new XScopedEventSelector(x_window_, PropertyChangeMask)); 321 new XScopedEventSelector(x_window_, PropertyChangeMask));
348 322
349 if (PlatformEventSource::GetInstance()) 323 if (PlatformEventSource::GetInstance())
350 PlatformEventSource::GetInstance()->AddPlatformEventDispatcher(this); 324 PlatformEventSource::GetInstance()->AddPlatformEventDispatcher(this);
351 } 325 }
352 326
353 ClipboardAuraX11::AuraX11Details::~AuraX11Details() { 327 ClipboardAuraX11::AuraX11Details::~AuraX11Details() {
354 if (PlatformEventSource::GetInstance()) 328 if (PlatformEventSource::GetInstance())
355 PlatformEventSource::GetInstance()->RemovePlatformEventDispatcher(this); 329 PlatformEventSource::GetInstance()->RemovePlatformEventDispatcher(this);
356 330
357 XDestroyWindow(x_display_, x_window_); 331 XDestroyWindow(x_display_, x_window_);
358 } 332 }
359 333
360 ::Atom ClipboardAuraX11::AuraX11Details::LookupSelectionForClipboardType( 334 ::Atom ClipboardAuraX11::AuraX11Details::LookupSelectionForClipboardType(
361 ClipboardType type) const { 335 ClipboardType type) const {
362 if (type == CLIPBOARD_TYPE_COPY_PASTE) 336 if (type == CLIPBOARD_TYPE_COPY_PASTE)
363 return GetCopyPasteSelection(); 337 return GetCopyPasteSelection();
364 338
365 return XA_PRIMARY; 339 return XA_PRIMARY;
366 } 340 }
367 341
368 ::Atom ClipboardAuraX11::AuraX11Details::GetCopyPasteSelection() const { 342 ::Atom ClipboardAuraX11::AuraX11Details::GetCopyPasteSelection() const {
369 return atom_cache_.GetAtom(kClipboard); 343 return GetAtom(kClipboard);
370 } 344 }
371 345
372 const SelectionFormatMap& 346 const SelectionFormatMap&
373 ClipboardAuraX11::AuraX11Details::LookupStorageForAtom(::Atom atom) { 347 ClipboardAuraX11::AuraX11Details::LookupStorageForAtom(::Atom atom) {
374 if (atom == XA_PRIMARY) 348 if (atom == XA_PRIMARY)
375 return primary_owner_.selection_format_map(); 349 return primary_owner_.selection_format_map();
376 350
377 DCHECK_EQ(GetCopyPasteSelection(), atom); 351 DCHECK_EQ(GetCopyPasteSelection(), atom);
378 return clipboard_owner_.selection_format_map(); 352 return clipboard_owner_.selection_format_map();
379 } 353 }
380 354
381 void ClipboardAuraX11::AuraX11Details::CreateNewClipboardData() { 355 void ClipboardAuraX11::AuraX11Details::CreateNewClipboardData() {
382 clipboard_data_ = SelectionFormatMap(); 356 clipboard_data_ = SelectionFormatMap();
383 } 357 }
384 358
385 void ClipboardAuraX11::AuraX11Details::InsertMapping( 359 void ClipboardAuraX11::AuraX11Details::InsertMapping(
386 const std::string& key, 360 const std::string& key,
387 const scoped_refptr<base::RefCountedMemory>& memory) { 361 const scoped_refptr<base::RefCountedMemory>& memory) {
388 ::Atom atom_key = atom_cache_.GetAtom(key.c_str()); 362 ::Atom atom_key = GetAtom(key.c_str());
389 clipboard_data_.Insert(atom_key, memory); 363 clipboard_data_.Insert(atom_key, memory);
390 } 364 }
391 365
392 void ClipboardAuraX11::AuraX11Details::TakeOwnershipOfSelection( 366 void ClipboardAuraX11::AuraX11Details::TakeOwnershipOfSelection(
393 ClipboardType type) { 367 ClipboardType type) {
394 if (type == CLIPBOARD_TYPE_COPY_PASTE) 368 if (type == CLIPBOARD_TYPE_COPY_PASTE)
395 return clipboard_owner_.TakeOwnershipOfSelection(clipboard_data_); 369 return clipboard_owner_.TakeOwnershipOfSelection(clipboard_data_);
396 else 370 else
397 return primary_owner_.TakeOwnershipOfSelection(clipboard_data_); 371 return primary_owner_.TakeOwnershipOfSelection(clipboard_data_);
398 } 372 }
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 for (SelectionFormatMap::const_iterator it = format_map.begin(); 410 for (SelectionFormatMap::const_iterator it = format_map.begin();
437 it != format_map.end(); ++it) { 411 it != format_map.end(); ++it) {
438 out.push_back(it->first); 412 out.push_back(it->first);
439 } 413 }
440 } else { 414 } else {
441 scoped_refptr<base::RefCountedMemory> data; 415 scoped_refptr<base::RefCountedMemory> data;
442 size_t out_data_items = 0; 416 size_t out_data_items = 0;
443 ::Atom out_type = None; 417 ::Atom out_type = None;
444 418
445 if (selection_requestor_.PerformBlockingConvertSelection( 419 if (selection_requestor_.PerformBlockingConvertSelection(
446 selection_name, 420 selection_name, GetAtom(kTargets), &data, &out_data_items,
447 atom_cache_.GetAtom(kTargets),
448 &data,
449 &out_data_items,
450 &out_type)) { 421 &out_type)) {
451 // Some apps return an |out_type| of "TARGETS". (crbug.com/377893) 422 // Some apps return an |out_type| of "TARGETS". (crbug.com/377893)
452 if (out_type == XA_ATOM || out_type == atom_cache_.GetAtom(kTargets)) { 423 if (out_type == XA_ATOM || out_type == GetAtom(kTargets)) {
453 const ::Atom* atom_array = 424 const ::Atom* atom_array =
454 reinterpret_cast<const ::Atom*>(data->front()); 425 reinterpret_cast<const ::Atom*>(data->front());
455 for (size_t i = 0; i < out_data_items; ++i) 426 for (size_t i = 0; i < out_data_items; ++i)
456 out.push_back(atom_array[i]); 427 out.push_back(atom_array[i]);
457 } 428 }
458 } else { 429 } else {
459 // There was no target list. Most Java apps doesn't offer a TARGETS list, 430 // There was no target list. Most Java apps doesn't offer a TARGETS list,
460 // even though they AWT to. They will offer individual text types if you 431 // even though they AWT to. They will offer individual text types if you
461 // ask. If this is the case we attempt to make sense of the contents as 432 // ask. If this is the case we attempt to make sense of the contents as
462 // text. This is pretty unfortunate since it means we have to actually 433 // text. This is pretty unfortunate since it means we have to actually
463 // copy the data to see if it is available, but at least this path 434 // copy the data to see if it is available, but at least this path
464 // shouldn't be hit for conforming programs. 435 // shouldn't be hit for conforming programs.
465 std::vector< ::Atom> types = GetTextAtoms(); 436 std::vector< ::Atom> types = GetTextAtoms();
466 for (std::vector< ::Atom>::const_iterator it = types.begin(); 437 for (std::vector< ::Atom>::const_iterator it = types.begin();
467 it != types.end(); ++it) { 438 it != types.end(); ++it) {
468 ::Atom type = None; 439 ::Atom type = None;
469 if (selection_requestor_.PerformBlockingConvertSelection(selection_name, 440 if (selection_requestor_.PerformBlockingConvertSelection(selection_name,
470 *it, 441 *it,
471 NULL, 442 NULL,
472 NULL, 443 NULL,
473 &type) && 444 &type) &&
474 type == *it) { 445 type == *it) {
475 out.push_back(*it); 446 out.push_back(*it);
476 } 447 }
477 } 448 }
478 } 449 }
479 } 450 }
480 451
481 return TargetList(out, &atom_cache_); 452 return TargetList(out);
482 } 453 }
483 454
484 std::vector<::Atom> ClipboardAuraX11::AuraX11Details::GetTextAtoms() const { 455 std::vector<::Atom> ClipboardAuraX11::AuraX11Details::GetTextAtoms() const {
485 return GetTextAtomsFrom(&atom_cache_); 456 return GetTextAtomsFrom();
486 } 457 }
487 458
488 std::vector<::Atom> ClipboardAuraX11::AuraX11Details::GetAtomsForFormat( 459 std::vector<::Atom> ClipboardAuraX11::AuraX11Details::GetAtomsForFormat(
489 const Clipboard::FormatType& format) { 460 const Clipboard::FormatType& format) {
490 std::vector< ::Atom> atoms; 461 std::vector< ::Atom> atoms;
491 atoms.push_back(atom_cache_.GetAtom(format.ToString().c_str())); 462 atoms.push_back(GetAtom(format.ToString().c_str()));
492 return atoms; 463 return atoms;
493 } 464 }
494 465
495 void ClipboardAuraX11::AuraX11Details::Clear(ClipboardType type) { 466 void ClipboardAuraX11::AuraX11Details::Clear(ClipboardType type) {
496 if (type == CLIPBOARD_TYPE_COPY_PASTE) 467 if (type == CLIPBOARD_TYPE_COPY_PASTE)
497 clipboard_owner_.ClearSelectionOwner(); 468 clipboard_owner_.ClearSelectionOwner();
498 else 469 else
499 primary_owner_.ClearSelectionOwner(); 470 primary_owner_.ClearSelectionOwner();
500 } 471 }
501 472
502 void ClipboardAuraX11::AuraX11Details::StoreCopyPasteDataAndWait() { 473 void ClipboardAuraX11::AuraX11Details::StoreCopyPasteDataAndWait() {
503 ::Atom selection = GetCopyPasteSelection(); 474 ::Atom selection = GetCopyPasteSelection();
504 if (XGetSelectionOwner(x_display_, selection) != x_window_) 475 if (XGetSelectionOwner(x_display_, selection) != x_window_)
505 return; 476 return;
506 477
507 ::Atom clipboard_manager_atom = atom_cache_.GetAtom(kClipboardManager); 478 ::Atom clipboard_manager_atom = GetAtom(kClipboardManager);
508 if (XGetSelectionOwner(x_display_, clipboard_manager_atom) == None) 479 if (XGetSelectionOwner(x_display_, clipboard_manager_atom) == None)
509 return; 480 return;
510 481
511 const SelectionFormatMap& format_map = LookupStorageForAtom(selection); 482 const SelectionFormatMap& format_map = LookupStorageForAtom(selection);
512 if (format_map.size() == 0) 483 if (format_map.size() == 0)
513 return; 484 return;
514 std::vector<Atom> targets = format_map.GetTypes(); 485 std::vector<Atom> targets = format_map.GetTypes();
515 486
516 base::TimeTicks start = base::TimeTicks::Now(); 487 base::TimeTicks start = base::TimeTicks::Now();
517 selection_requestor_.PerformBlockingConvertSelectionWithParameter( 488 selection_requestor_.PerformBlockingConvertSelectionWithParameter(
518 atom_cache_.GetAtom(kClipboardManager), 489 GetAtom(kClipboardManager), GetAtom(kSaveTargets), targets);
519 atom_cache_.GetAtom(kSaveTargets),
520 targets);
521 UMA_HISTOGRAM_TIMES("Clipboard.X11StoreCopyPasteDuration", 490 UMA_HISTOGRAM_TIMES("Clipboard.X11StoreCopyPasteDuration",
522 base::TimeTicks::Now() - start); 491 base::TimeTicks::Now() - start);
523 } 492 }
524 493
525 bool ClipboardAuraX11::AuraX11Details::CanDispatchEvent( 494 bool ClipboardAuraX11::AuraX11Details::CanDispatchEvent(
526 const PlatformEvent& event) { 495 const PlatformEvent& event) {
527 if (event->xany.window == x_window_) 496 if (event->xany.window == x_window_)
528 return true; 497 return true;
529 498
530 if (event->type == PropertyNotify) { 499 if (event->type == PropertyNotify) {
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after
945 if (format.Equals(GetBitmapFormatType())) 914 if (format.Equals(GetBitmapFormatType()))
946 return; 915 return;
947 916
948 std::vector<unsigned char> bytes(data_data, data_data + data_len); 917 std::vector<unsigned char> bytes(data_data, data_data + data_len);
949 scoped_refptr<base::RefCountedMemory> mem( 918 scoped_refptr<base::RefCountedMemory> mem(
950 base::RefCountedBytes::TakeVector(&bytes)); 919 base::RefCountedBytes::TakeVector(&bytes));
951 aurax11_details_->InsertMapping(format.ToString(), mem); 920 aurax11_details_->InsertMapping(format.ToString(), mem);
952 } 921 }
953 922
954 } // namespace ui 923 } // namespace ui
OLDNEW
« no previous file with comments | « ui/aura/window_tree_host_x11.cc ('k') | ui/base/dragdrop/os_exchange_data_provider_aurax11.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698