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

Side by Side Diff: ui/base/dragdrop/os_exchange_data_provider_aurax11.cc

Issue 207013003: Mark drags starting in web content as tainted to avoid file path forgery (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: More fixes and comment Created 6 years, 9 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 | Annotate | Revision Log
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/dragdrop/os_exchange_data_provider_aurax11.h" 5 #include "ui/base/dragdrop/os_exchange_data_provider_aurax11.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/memory/ref_counted_memory.h" 8 #include "base/memory/ref_counted_memory.h"
9 #include "base/message_loop/message_pump_x11.h" 9 #include "base/message_loop/message_pump_x11.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
11 #include "base/strings/utf_string_conversions.h" 11 #include "base/strings/utf_string_conversions.h"
12 #include "net/base/net_util.h" 12 #include "net/base/net_util.h"
13 #include "ui/base/clipboard/clipboard.h" 13 #include "ui/base/clipboard/clipboard.h"
14 #include "ui/base/clipboard/scoped_clipboard_writer.h" 14 #include "ui/base/clipboard/scoped_clipboard_writer.h"
15 #include "ui/base/x/selection_utils.h" 15 #include "ui/base/x/selection_utils.h"
16 #include "ui/base/x/x11_util.h" 16 #include "ui/base/x/x11_util.h"
17 17
18 // Note: the GetBlah() methods are used immediately by the 18 // Note: the GetBlah() methods are used immediately by the
19 // web_contents_view_aura.cc:PrepareDropData(), while the omnibox is a 19 // web_contents_view_aura.cc:PrepareDropData(), while the omnibox is a
20 // little more discriminating and calls HasBlah() before trying to get the 20 // little more discriminating and calls HasBlah() before trying to get the
21 // information. 21 // information.
22 22
23 namespace ui { 23 namespace ui {
24 24
25 namespace { 25 namespace {
26 26
27 const char kDndSelection[] = "XdndSelection"; 27 const char kDndSelection[] = "XdndSelection";
28 const char kRendererTaint[] = "chromium/x-renderer-taint";
28 29
29 const char* kAtomsToCache[] = { 30 const char* kAtomsToCache[] = {
30 kString, 31 kString,
31 kText, 32 kText,
32 kUtf8String, 33 kUtf8String,
33 kDndSelection, 34 kDndSelection,
34 Clipboard::kMimeTypeURIList, 35 Clipboard::kMimeTypeURIList,
35 kMimeTypeMozillaURL, 36 kMimeTypeMozillaURL,
36 Clipboard::kMimeTypeText, 37 Clipboard::kMimeTypeText,
38 kRendererTaint,
37 NULL 39 NULL
38 }; 40 };
39 41
40 } // namespace 42 } // namespace
41 43
42 OSExchangeDataProviderAuraX11::OSExchangeDataProviderAuraX11( 44 OSExchangeDataProviderAuraX11::OSExchangeDataProviderAuraX11(
43 ::Window x_window, 45 ::Window x_window,
44 const SelectionFormatMap& selection) 46 const SelectionFormatMap& selection)
45 : x_display_(gfx::GetXDisplay()), 47 : x_display_(gfx::GetXDisplay()),
46 x_root_window_(DefaultRootWindow(x_display_)), 48 x_root_window_(DefaultRootWindow(x_display_)),
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 // ours has been modified since TakeOwnershipOfSelection() was called. 103 // ours has been modified since TakeOwnershipOfSelection() was called.
102 return selection_owner_.selection_format_map(); 104 return selection_owner_.selection_format_map();
103 } 105 }
104 106
105 OSExchangeData::Provider* OSExchangeDataProviderAuraX11::Clone() const { 107 OSExchangeData::Provider* OSExchangeDataProviderAuraX11::Clone() const {
106 OSExchangeDataProviderAuraX11* ret = new OSExchangeDataProviderAuraX11(); 108 OSExchangeDataProviderAuraX11* ret = new OSExchangeDataProviderAuraX11();
107 ret->format_map_ = format_map_; 109 ret->format_map_ = format_map_;
108 return ret; 110 return ret;
109 } 111 }
110 112
113 void OSExchangeDataProviderAuraX11::MarkRendererTainted() {
114 std::string empty;
115 format_map_.Insert(atom_cache_.GetAtom(kRendererTaint),
116 scoped_refptr<base::RefCountedMemory>(
117 base::RefCountedString::TakeString(&empty)));
118 }
119
120 bool OSExchangeDataProviderAuraX11::IsRendererTainted() const {
121 return format_map_.find(atom_cache_.GetAtom(kRendererTaint)) !=
122 format_map_.end();
tony 2014/03/21 23:09:00 Nit: Is this the correct indent? I thought it was
dcheng 2014/03/21 23:57:07 This is what clang-format said. I didn't clang for
123 }
124
111 void OSExchangeDataProviderAuraX11::SetString(const base::string16& text_data) { 125 void OSExchangeDataProviderAuraX11::SetString(const base::string16& text_data) {
112 std::string utf8 = base::UTF16ToUTF8(text_data); 126 std::string utf8 = base::UTF16ToUTF8(text_data);
113 scoped_refptr<base::RefCountedMemory> mem( 127 scoped_refptr<base::RefCountedMemory> mem(
114 base::RefCountedString::TakeString(&utf8)); 128 base::RefCountedString::TakeString(&utf8));
115 129
116 format_map_.Insert(atom_cache_.GetAtom(Clipboard::kMimeTypeText), mem); 130 format_map_.Insert(atom_cache_.GetAtom(Clipboard::kMimeTypeText), mem);
117 format_map_.Insert(atom_cache_.GetAtom(kText), mem); 131 format_map_.Insert(atom_cache_.GetAtom(kText), mem);
118 format_map_.Insert(atom_cache_.GetAtom(kString), mem); 132 format_map_.Insert(atom_cache_.GetAtom(kString), mem);
119 format_map_.Insert(atom_cache_.GetAtom(kUtf8String), mem); 133 format_map_.Insert(atom_cache_.GetAtom(kUtf8String), mem);
120 } 134 }
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
461 475
462 /////////////////////////////////////////////////////////////////////////////// 476 ///////////////////////////////////////////////////////////////////////////////
463 // OSExchangeData, public: 477 // OSExchangeData, public:
464 478
465 // static 479 // static
466 OSExchangeData::Provider* OSExchangeData::CreateProvider() { 480 OSExchangeData::Provider* OSExchangeData::CreateProvider() {
467 return new OSExchangeDataProviderAuraX11(); 481 return new OSExchangeDataProviderAuraX11();
468 } 482 }
469 483
470 } // namespace ui 484 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698