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

Side by Side Diff: ui/base/clipboard/clipboard.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 <iterator> 7 #include <iterator>
8 8
9 #include "base/lazy_instance.h" 9 #include "base/lazy_instance.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 146
147 ClipboardMap* clipboard_map = g_clipboard_map.Pointer(); 147 ClipboardMap* clipboard_map = g_clipboard_map.Pointer();
148 base::PlatformThreadId id = base::PlatformThread::CurrentId(); 148 base::PlatformThreadId id = base::PlatformThread::CurrentId();
149 ClipboardMap::iterator it = clipboard_map->find(id); 149 ClipboardMap::iterator it = clipboard_map->find(id);
150 if (it != clipboard_map->end()) { 150 if (it != clipboard_map->end()) {
151 delete it->second; 151 delete it->second;
152 clipboard_map->erase(it); 152 clipboard_map->erase(it);
153 } 153 }
154 } 154 }
155 155
156 void Clipboard::WriteObjects(Buffer buffer, const ObjectMap& objects) {
157 WriteObjectsImpl(buffer, objects);
158 FOR_EACH_OBSERVER(ClipboardObserver, observer_list_, OnWriteObjects(buffer));
159 }
160
156 void Clipboard::DispatchObject(ObjectType type, const ObjectMapParams& params) { 161 void Clipboard::DispatchObject(ObjectType type, const ObjectMapParams& params) {
157 // All types apart from CBF_WEBKIT need at least 1 non-empty param. 162 // All types apart from CBF_WEBKIT need at least 1 non-empty param.
158 if (type != CBF_WEBKIT && (params.empty() || params[0].empty())) 163 if (type != CBF_WEBKIT && (params.empty() || params[0].empty()))
159 return; 164 return;
160 // Some other types need a non-empty 2nd param. 165 // Some other types need a non-empty 2nd param.
161 if ((type == CBF_BOOKMARK || type == CBF_BITMAP || 166 if ((type == CBF_BOOKMARK || type == CBF_BITMAP ||
162 type == CBF_SMBITMAP || type == CBF_DATA) && 167 type == CBF_SMBITMAP || type == CBF_DATA) &&
163 (params.size() != 2 || params[1].empty())) 168 (params.size() != 2 || params[1].empty()))
164 return; 169 return;
165 switch (type) { 170 switch (type) {
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 } 226 }
222 227
223 case CBF_DATA: 228 case CBF_DATA:
224 WriteData( 229 WriteData(
225 FormatType::Deserialize( 230 FormatType::Deserialize(
226 std::string(&(params[0].front()), params[0].size())), 231 std::string(&(params[0].front()), params[0].size())),
227 &(params[1].front()), 232 &(params[1].front()),
228 params[1].size()); 233 params[1].size());
229 break; 234 break;
230 235
236 case CBF_INCOGNITO_MARKER:
237 #if defined(TOOLKIT_GTK) // TODO(vasilii): support other platforms.
238 WriteData(GetIncognitoMarkerFormatType(),
239 &params[0].front(), params[0].size());
240 #endif
241 break;
242
231 default: 243 default:
232 NOTREACHED(); 244 NOTREACHED();
233 } 245 }
234 } 246 }
235 247
236 // static 248 // static
237 void Clipboard::ReplaceSharedMemHandle(ObjectMap* objects, 249 void Clipboard::ReplaceSharedMemHandle(ObjectMap* objects,
238 base::SharedMemoryHandle bitmap_handle, 250 base::SharedMemoryHandle bitmap_handle,
239 base::ProcessHandle process) { 251 base::ProcessHandle process) {
240 using base::SharedMemory; 252 using base::SharedMemory;
(...skipping 17 matching lines...) Expand all
258 // UI thread (see DispatchObject()). 270 // UI thread (see DispatchObject()).
259 iter->second[0].clear(); 271 iter->second[0].clear();
260 for (size_t i = 0; i < sizeof(SharedMemory*); ++i) 272 for (size_t i = 0; i < sizeof(SharedMemory*); ++i)
261 iter->second[0].push_back(reinterpret_cast<char*>(&bitmap)[i]); 273 iter->second[0].push_back(reinterpret_cast<char*>(&bitmap)[i]);
262 has_shared_bitmap = true; 274 has_shared_bitmap = true;
263 } 275 }
264 } 276 }
265 } 277 }
266 278
267 } // namespace ui 279 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698