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

Unified 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: Moved incogito marker to BrowserContext 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 side-by-side diff with in-line comments
Download patch
Index: ui/base/clipboard/clipboard_gtk.cc
diff --git a/ui/base/clipboard/clipboard_gtk.cc b/ui/base/clipboard/clipboard_gtk.cc
index 7473f31097289eb0b7bc716711c256392a2fd88f..1f705907b83f595120dc5e83e704a616186b85be 100644
--- a/ui/base/clipboard/clipboard_gtk.cc
+++ b/ui/base/clipboard/clipboard_gtk.cc
@@ -106,6 +106,7 @@ GdkFilterReturn SelectionChangeObserver::OnXEvent(GdkXEvent* xevent,
return GDK_FILTER_CONTINUE;
}
+const char kSourceTagType[] = "org.chromium.source-tag";
const char kMimeTypeBitmap[] = "image/bmp";
const char kMimeTypeMozillaURL[] = "text/x-moz-url";
const char kMimeTypePepperCustomData[] = "chromium/x-pepper-custom-data";
@@ -217,7 +218,9 @@ Clipboard::~Clipboard() {
gtk_clipboard_store(clipboard_);
}
-void Clipboard::WriteObjects(Buffer buffer, const ObjectMap& objects) {
+void Clipboard::WriteObjectsImpl(Buffer buffer,
+ const ObjectMap& objects,
+ SourceTag tag) {
DCHECK(CalledOnValidThread());
clipboard_data_ = new TargetMap();
@@ -225,6 +228,7 @@ void Clipboard::WriteObjects(Buffer buffer, const ObjectMap& objects) {
iter != objects.end(); ++iter) {
DispatchObject(static_cast<ObjectType>(iter->first), iter->second);
}
+ WriteSourceTag(tag);
SetGtkClipboard(buffer);
}
@@ -350,6 +354,13 @@ void Clipboard::WriteData(const FormatType& format,
InsertMapping(GdkAtomToString(format.ToGdkAtom()).c_str(), data, data_len);
}
+void Clipboard::WriteSourceTag(SourceTag tag) {
+ if (tag != SourceTag()) {
+ ObjectMapParam binary = SourceTag2Binary(tag);
+ WriteData(GetSourceTagFormatType(), &binary[0], binary.size());
+ }
+}
+
// We do not use gtk_clipboard_wait_is_target_available because of
// a bug with the gtk clipboard. It caches the available targets
// and does not always refresh the cache when it is appropriate.
@@ -587,6 +598,12 @@ void Clipboard::ReadData(const FormatType& format, std::string* result) const {
gtk_selection_data_free(data);
}
+Clipboard::SourceTag Clipboard::ReadSourceTag() const {
+ std::string result;
+ ReadData(GetSourceTagFormatType(), &result);
+ return Binary2SourceTag(result);
+}
+
uint64 Clipboard::GetSequenceNumber(Buffer buffer) {
DCHECK(CalledOnValidThread());
if (buffer == BUFFER_STANDARD)
@@ -659,6 +676,12 @@ const Clipboard::FormatType& Clipboard::GetPepperCustomDataFormatType() {
return type;
}
+// static
+const Clipboard::FormatType& Clipboard::GetSourceTagFormatType() {
+ CR_DEFINE_STATIC_LOCAL(FormatType, type, (kSourceTagType));
+ return type;
+}
+
void Clipboard::InsertMapping(const char* key,
char* data,
size_t data_len) {

Powered by Google App Engine
This is Rietveld 408576698