| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/x/selection_requestor.h" | 5 #include "ui/base/x/selection_requestor.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <X11/Xlib.h> | 8 #include <X11/Xlib.h> |
| 9 | 9 |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| 11 #include "base/run_loop.h" | 11 #include "base/run_loop.h" |
| 12 #include "ui/base/x/selection_utils.h" | 12 #include "ui/base/x/selection_utils.h" |
| 13 #include "ui/base/x/x11_util.h" | 13 #include "ui/base/x/x11_util.h" |
| 14 #include "ui/events/platform/platform_event_dispatcher.h" | 14 #include "ui/events/platform/platform_event_dispatcher.h" |
| 15 #include "ui/events/platform/platform_event_source.h" | 15 #include "ui/events/platform/platform_event_source.h" |
| 16 #include "ui/gfx/x/x11_atom_cache.h" |
| 16 #include "ui/gfx/x/x11_types.h" | 17 #include "ui/gfx/x/x11_types.h" |
| 17 | 18 |
| 18 namespace ui { | 19 namespace ui { |
| 19 | 20 |
| 20 namespace { | 21 namespace { |
| 21 | 22 |
| 22 const char kChromeSelection[] = "CHROME_SELECTION"; | 23 const char kChromeSelection[] = "CHROME_SELECTION"; |
| 23 const char kIncr[] = "INCR"; | 24 const char kIncr[] = "INCR"; |
| 24 | 25 |
| 25 // The period of |abort_timer_|. Arbitrary but must be <= than | 26 // The period of |abort_timer_|. Arbitrary but must be <= than |
| (...skipping 29 matching lines...) Expand all Loading... |
| 55 } // namespace | 56 } // namespace |
| 56 | 57 |
| 57 SelectionRequestor::SelectionRequestor(XDisplay* x_display, | 58 SelectionRequestor::SelectionRequestor(XDisplay* x_display, |
| 58 XID x_window, | 59 XID x_window, |
| 59 PlatformEventDispatcher* dispatcher) | 60 PlatformEventDispatcher* dispatcher) |
| 60 : x_display_(x_display), | 61 : x_display_(x_display), |
| 61 x_window_(x_window), | 62 x_window_(x_window), |
| 62 x_property_(None), | 63 x_property_(None), |
| 63 dispatcher_(dispatcher), | 64 dispatcher_(dispatcher), |
| 64 current_request_index_(0u) { | 65 current_request_index_(0u) { |
| 65 x_property_ = GetAtom(kChromeSelection); | 66 x_property_ = gfx::GetAtom(kChromeSelection); |
| 66 } | 67 } |
| 67 | 68 |
| 68 SelectionRequestor::~SelectionRequestor() {} | 69 SelectionRequestor::~SelectionRequestor() {} |
| 69 | 70 |
| 70 bool SelectionRequestor::PerformBlockingConvertSelection( | 71 bool SelectionRequestor::PerformBlockingConvertSelection( |
| 71 XAtom selection, | 72 XAtom selection, |
| 72 XAtom target, | 73 XAtom target, |
| 73 scoped_refptr<base::RefCountedMemory>* out_data, | 74 scoped_refptr<base::RefCountedMemory>* out_data, |
| 74 size_t* out_data_items, | 75 size_t* out_data_items, |
| 75 XAtom* out_type) { | 76 XAtom* out_type) { |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 &request->out_data_items, | 156 &request->out_data_items, |
| 156 &request->out_type); | 157 &request->out_type); |
| 157 if (success) { | 158 if (success) { |
| 158 request->out_data.clear(); | 159 request->out_data.clear(); |
| 159 request->out_data.push_back(out_data); | 160 request->out_data.push_back(out_data); |
| 160 } | 161 } |
| 161 } | 162 } |
| 162 if (event_property != None) | 163 if (event_property != None) |
| 163 XDeleteProperty(x_display_, x_window_, event_property); | 164 XDeleteProperty(x_display_, x_window_, event_property); |
| 164 | 165 |
| 165 if (request->out_type == GetAtom(kIncr)) { | 166 if (request->out_type == gfx::GetAtom(kIncr)) { |
| 166 request->data_sent_incrementally = true; | 167 request->data_sent_incrementally = true; |
| 167 request->out_data.clear(); | 168 request->out_data.clear(); |
| 168 request->out_data_items = 0u; | 169 request->out_data_items = 0u; |
| 169 request->out_type = None; | 170 request->out_type = None; |
| 170 request->timeout = base::TimeTicks::Now() + | 171 request->timeout = base::TimeTicks::Now() + |
| 171 base::TimeDelta::FromMilliseconds(kRequestTimeoutMs); | 172 base::TimeDelta::FromMilliseconds(kRequestTimeoutMs); |
| 172 } else { | 173 } else { |
| 173 CompleteRequest(current_request_index_, success); | 174 CompleteRequest(current_request_index_, success); |
| 174 } | 175 } |
| 175 } | 176 } |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 out_type(None), | 306 out_type(None), |
| 306 success(false), | 307 success(false), |
| 307 timeout(timeout), | 308 timeout(timeout), |
| 308 completed(false) { | 309 completed(false) { |
| 309 } | 310 } |
| 310 | 311 |
| 311 SelectionRequestor::Request::~Request() { | 312 SelectionRequestor::Request::~Request() { |
| 312 } | 313 } |
| 313 | 314 |
| 314 } // namespace ui | 315 } // namespace ui |
| OLD | NEW |