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

Side by Side Diff: chrome/common/os_exchange_data.cc

Issue 11247: Remove cf_html from webdropdata.h. This is windows (Closed)
Patch Set: fix feedback Created 12 years, 1 month 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
« no previous file with comments | « chrome/common/os_exchange_data.h ('k') | chrome/common/os_exchange_data_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 <shlobj.h> 5 #include <shlobj.h>
6 6
7 #include "chrome/common/os_exchange_data.h" 7 #include "chrome/common/os_exchange_data.h"
8 8
9 #include "base/clipboard_util.h" 9 #include "base/clipboard_util.h"
10 #include "base/file_util.h" 10 #include "base/file_util.h"
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 STGMEDIUM* storage = GetStorageForFileDescriptor(filename); 328 STGMEDIUM* storage = GetStorageForFileDescriptor(filename);
329 contents_.push_back(new StoredDataInfo( 329 contents_.push_back(new StoredDataInfo(
330 ClipboardUtil::GetFileDescriptorFormat()->cfFormat, storage)); 330 ClipboardUtil::GetFileDescriptorFormat()->cfFormat, storage));
331 331
332 // Add CFSTR_FILECONTENTS 332 // Add CFSTR_FILECONTENTS
333 storage = GetStorageForBytes(file_contents.data(), file_contents.length()); 333 storage = GetStorageForBytes(file_contents.data(), file_contents.length());
334 contents_.push_back(new StoredDataInfo( 334 contents_.push_back(new StoredDataInfo(
335 ClipboardUtil::GetFileContentFormatZero()->cfFormat, storage)); 335 ClipboardUtil::GetFileContentFormatZero()->cfFormat, storage));
336 } 336 }
337 337
338 void OSExchangeData::SetCFHtml(const std::wstring& cf_html) { 338 void OSExchangeData::SetHtml(const std::wstring& html, const GURL& base_url) {
339 std::string utf8 = WideToUTF8(cf_html); 339 // Add both MS CF_HTML and text/html format. CF_HTML should be in utf-8.
340 STGMEDIUM* storage = GetStorageForBytes(utf8.c_str(), utf8.size()); 340 std::string utf8_html = WideToUTF8(html);
341 std::string url = base_url.is_valid() ? base_url.spec() : std::string();
342
343 std::string cf_html = ClipboardUtil::HtmlToCFHtml(utf8_html, url);
344 STGMEDIUM* storage = GetStorageForBytes(cf_html.c_str(), cf_html.size());
341 contents_.push_back(new StoredDataInfo( 345 contents_.push_back(new StoredDataInfo(
342 ClipboardUtil::GetHtmlFormat()->cfFormat, storage)); 346 ClipboardUtil::GetHtmlFormat()->cfFormat, storage));
347
348 STGMEDIUM* storage_plain = GetStorageForBytes(utf8_html.c_str(),
349 utf8_html.size());
350 contents_.push_back(new StoredDataInfo(
351 ClipboardUtil::GetTextHtmlFormat()->cfFormat, storage_plain));
343 } 352 }
344 353
345 bool OSExchangeData::GetString(std::wstring* data) const { 354 bool OSExchangeData::GetString(std::wstring* data) const {
346 return ClipboardUtil::GetPlainText(source_object_, data); 355 return ClipboardUtil::GetPlainText(source_object_, data);
347 } 356 }
348 357
349 bool OSExchangeData::GetURLAndTitle(GURL* url, std::wstring* title) const { 358 bool OSExchangeData::GetURLAndTitle(GURL* url, std::wstring* title) const {
350 std::wstring url_str; 359 std::wstring url_str;
351 bool success = ClipboardUtil::GetUrl(source_object_, &url_str, title); 360 bool success = ClipboardUtil::GetUrl(source_object_, &url_str, title);
352 if (success) { 361 if (success) {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 } 397 }
389 return success; 398 return success;
390 } 399 }
391 400
392 bool OSExchangeData::GetFileContents(std::wstring* filename, 401 bool OSExchangeData::GetFileContents(std::wstring* filename,
393 std::string* file_contents) const { 402 std::string* file_contents) const {
394 return ClipboardUtil::GetFileContents(source_object_, filename, 403 return ClipboardUtil::GetFileContents(source_object_, filename,
395 file_contents); 404 file_contents);
396 } 405 }
397 406
398 bool OSExchangeData::GetCFHtml(std::wstring* cf_html) const { 407 bool OSExchangeData::GetHtml(std::wstring* html, GURL* base_url) const {
399 return ClipboardUtil::GetCFHtml(source_object_, cf_html); 408 std::string url;
409 bool success = ClipboardUtil::GetHtml(source_object_, html, &url);
410 if (success)
411 *base_url = GURL(url);
412 return success;
400 } 413 }
401 414
402 bool OSExchangeData::HasString() const { 415 bool OSExchangeData::HasString() const {
403 return ClipboardUtil::HasPlainText(source_object_); 416 return ClipboardUtil::HasPlainText(source_object_);
404 } 417 }
405 418
406 bool OSExchangeData::HasURL() const { 419 bool OSExchangeData::HasURL() const {
407 return (ClipboardUtil::HasUrl(source_object_) || 420 return (ClipboardUtil::HasUrl(source_object_) ||
408 HasPlainTextURL(source_object_)); 421 HasPlainTextURL(source_object_));
409 } 422 }
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
686 699
687 GlobalUnlock(handle); 700 GlobalUnlock(handle);
688 701
689 STGMEDIUM* storage = new STGMEDIUM; 702 STGMEDIUM* storage = new STGMEDIUM;
690 storage->hGlobal = handle; 703 storage->hGlobal = handle;
691 storage->tymed = TYMED_HGLOBAL; 704 storage->tymed = TYMED_HGLOBAL;
692 storage->pUnkForRelease = NULL; 705 storage->pUnkForRelease = NULL;
693 return storage; 706 return storage;
694 } 707 }
695 708
OLDNEW
« no previous file with comments | « chrome/common/os_exchange_data.h ('k') | chrome/common/os_exchange_data_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698