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

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

Issue 12041078: Clear the clipboard closing Incognito window (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Merge with master Created 7 years, 10 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
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.h" 5 #include "ui/base/clipboard/clipboard.h"
6 6
7 #include <gtk/gtk.h> 7 #include <gtk/gtk.h>
8 #include <X11/extensions/Xfixes.h> 8 #include <X11/extensions/Xfixes.h>
9 #include <X11/Xatom.h> 9 #include <X11/Xatom.h>
10 #include <map> 10 #include <map>
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 DLOG(ERROR) << "Unexpected selection atom: " << ev->selection; 103 DLOG(ERROR) << "Unexpected selection atom: " << ev->selection;
104 } 104 }
105 } 105 }
106 return GDK_FILTER_CONTINUE; 106 return GDK_FILTER_CONTINUE;
107 } 107 }
108 108
109 const char kMimeTypeBitmap[] = "image/bmp"; 109 const char kMimeTypeBitmap[] = "image/bmp";
110 const char kMimeTypeMozillaURL[] = "text/x-moz-url"; 110 const char kMimeTypeMozillaURL[] = "text/x-moz-url";
111 const char kMimeTypePepperCustomData[] = "chromium/x-pepper-custom-data"; 111 const char kMimeTypePepperCustomData[] = "chromium/x-pepper-custom-data";
112 const char kMimeTypeWebkitSmartPaste[] = "chromium/x-webkit-paste"; 112 const char kMimeTypeWebkitSmartPaste[] = "chromium/x-webkit-paste";
113 const char kIncognitoMarkerType[] = "org.chromium.incognito-marker";
113 114
114 std::string GdkAtomToString(const GdkAtom& atom) { 115 std::string GdkAtomToString(const GdkAtom& atom) {
115 gchar* name = gdk_atom_name(atom); 116 gchar* name = gdk_atom_name(atom);
116 std::string rv(name); 117 std::string rv(name);
117 g_free(name); 118 g_free(name);
118 return rv; 119 return rv;
119 } 120 }
120 121
121 GdkAtom StringToGdkAtom(const std::string& str) { 122 GdkAtom StringToGdkAtom(const std::string& str) {
122 return gdk_atom_intern(str.c_str(), FALSE); 123 return gdk_atom_intern(str.c_str(), FALSE);
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 DCHECK(CalledOnValidThread()); 211 DCHECK(CalledOnValidThread());
211 clipboard_ = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD); 212 clipboard_ = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD);
212 primary_selection_ = gtk_clipboard_get(GDK_SELECTION_PRIMARY); 213 primary_selection_ = gtk_clipboard_get(GDK_SELECTION_PRIMARY);
213 } 214 }
214 215
215 Clipboard::~Clipboard() { 216 Clipboard::~Clipboard() {
216 DCHECK(CalledOnValidThread()); 217 DCHECK(CalledOnValidThread());
217 gtk_clipboard_store(clipboard_); 218 gtk_clipboard_store(clipboard_);
218 } 219 }
219 220
220 void Clipboard::WriteObjects(Buffer buffer, const ObjectMap& objects) { 221 void Clipboard::WriteObjectsImpl(Buffer buffer, const ObjectMap& objects) {
221 DCHECK(CalledOnValidThread()); 222 DCHECK(CalledOnValidThread());
222 clipboard_data_ = new TargetMap(); 223 clipboard_data_ = new TargetMap();
223 224
224 for (ObjectMap::const_iterator iter = objects.begin(); 225 for (ObjectMap::const_iterator iter = objects.begin();
225 iter != objects.end(); ++iter) { 226 iter != objects.end(); ++iter) {
226 DispatchObject(static_cast<ObjectType>(iter->first), iter->second); 227 DispatchObject(static_cast<ObjectType>(iter->first), iter->second);
227 } 228 }
228 229
229 SetGtkClipboard(buffer); 230 SetGtkClipboard(buffer);
230 } 231 }
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after
652 CR_DEFINE_STATIC_LOCAL(FormatType, type, (kMimeTypeWebCustomData)); 653 CR_DEFINE_STATIC_LOCAL(FormatType, type, (kMimeTypeWebCustomData));
653 return type; 654 return type;
654 } 655 }
655 656
656 // static 657 // static
657 const Clipboard::FormatType& Clipboard::GetPepperCustomDataFormatType() { 658 const Clipboard::FormatType& Clipboard::GetPepperCustomDataFormatType() {
658 CR_DEFINE_STATIC_LOCAL(FormatType, type, (kMimeTypePepperCustomData)); 659 CR_DEFINE_STATIC_LOCAL(FormatType, type, (kMimeTypePepperCustomData));
659 return type; 660 return type;
660 } 661 }
661 662
663 // static
664 const Clipboard::FormatType& Clipboard::GetIncognitoMarkerFormatType() {
665 CR_DEFINE_STATIC_LOCAL(FormatType, type, (kIncognitoMarkerType));
666 return type;
667 }
668
662 void Clipboard::InsertMapping(const char* key, 669 void Clipboard::InsertMapping(const char* key,
663 char* data, 670 char* data,
664 size_t data_len) { 671 size_t data_len) {
665 DCHECK(clipboard_data_->find(key) == clipboard_data_->end()); 672 DCHECK(clipboard_data_->find(key) == clipboard_data_->end());
666 (*clipboard_data_)[key] = std::make_pair(data, data_len); 673 (*clipboard_data_)[key] = std::make_pair(data, data_len);
667 } 674 }
668 675
669 GtkClipboard* Clipboard::LookupBackingClipboard(Buffer clipboard) const { 676 GtkClipboard* Clipboard::LookupBackingClipboard(Buffer clipboard) const {
670 switch (clipboard) { 677 switch (clipboard) {
671 case BUFFER_STANDARD: 678 case BUFFER_STANDARD:
672 return clipboard_; 679 return clipboard_;
673 case BUFFER_SELECTION: 680 case BUFFER_SELECTION:
674 return primary_selection_; 681 return primary_selection_;
675 default: 682 default:
676 NOTREACHED(); 683 NOTREACHED();
677 return NULL; 684 return NULL;
678 } 685 }
679 } 686 }
680 687
681 } // namespace ui 688 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698