diff options
author | rbyers@chromium.org <rbyers@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-20 17:28:48 +0000 |
---|---|---|
committer | rbyers@chromium.org <rbyers@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-20 17:28:48 +0000 |
commit | 6722815ca4295ba65dcd646af28ebba6fa1eb480 (patch) | |
tree | 6d1b7885a32a90ef182088ffb46004c9f28281ee /ui | |
parent | 56f3a81b5f1131223aac9175e8fbe5c13ef843e2 (diff) | |
download | chromium_src-6722815ca4295ba65dcd646af28ebba6fa1eb480.zip chromium_src-6722815ca4295ba65dcd646af28ebba6fa1eb480.tar.gz chromium_src-6722815ca4295ba65dcd646af28ebba6fa1eb480.tar.bz2 |
Revert 127706 - Add drag and drop support for custom and html data types on Aura
Also unifies OSExchangeData::CustomFormat and Clipboard::FormatType on Aura so we don't need two separate code paths and mime type lists for getting specific custom formats.
BUG=118416
TEST=none yet
Review URL: http://codereview.chromium.org/9705072
TBR=rbyers@chromium.org
Review URL: https://chromiumcodereview.appspot.com/9751013
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@127713 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r-- | ui/base/clipboard/clipboard.h | 7 | ||||
-rw-r--r-- | ui/base/dragdrop/os_exchange_data.cc | 24 | ||||
-rw-r--r-- | ui/base/dragdrop/os_exchange_data.h | 34 | ||||
-rw-r--r-- | ui/base/dragdrop/os_exchange_data_provider_aura.cc | 44 | ||||
-rw-r--r-- | ui/base/dragdrop/os_exchange_data_provider_aura.h | 11 | ||||
-rw-r--r-- | ui/views/controls/textfield/native_textfield_views_unittest.cc | 7 |
6 files changed, 40 insertions, 87 deletions
diff --git a/ui/base/clipboard/clipboard.h b/ui/base/clipboard/clipboard.h index a268512..5020882 100644 --- a/ui/base/clipboard/clipboard.h +++ b/ui/base/clipboard/clipboard.h @@ -65,13 +65,6 @@ class UI_EXPORT Clipboard : NON_EXPORTED_BASE(public base::ThreadChecker) { std::string Serialize() const; static FormatType Deserialize(const std::string& serialization); - // FormatType can be used as the key in a map on some platforms. -#if defined(OS_WIN) || defined(USE_AURA) - bool operator<(const FormatType& other) const { - return data_ < other.data_; - } -#endif - private: friend class Clipboard; diff --git a/ui/base/dragdrop/os_exchange_data.cc b/ui/base/dragdrop/os_exchange_data.cc index a1de420..a81f8e7 100644 --- a/ui/base/dragdrop/os_exchange_data.cc +++ b/ui/base/dragdrop/os_exchange_data.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -85,8 +85,6 @@ bool OSExchangeData::HasAllFormats( #if defined(OS_WIN) if ((formats & FILE_CONTENTS) != 0 && !provider_->HasFileContents()) return false; -#endif -#if defined(OS_WIN) || defined(USE_AURA) if ((formats & HTML) != 0 && !provider_->HasHtml()) return false; #endif @@ -110,8 +108,6 @@ bool OSExchangeData::HasAnyFormat( #if defined(OS_WIN) if ((formats & FILE_CONTENTS) != 0 && provider_->HasFileContents()) return true; -#endif -#if defined(OS_WIN) || defined(USE_AURA) if ((formats & HTML) != 0 && provider_->HasHtml()) return true; #endif @@ -131,24 +127,22 @@ void OSExchangeData::SetFileContents(const FilePath& filename, provider_->SetFileContents(filename, file_contents); } +void OSExchangeData::SetHtml(const string16& html, const GURL& base_url) { + provider_->SetHtml(html, base_url); +} + bool OSExchangeData::GetFileContents(FilePath* filename, std::string* file_contents) const { return provider_->GetFileContents(filename, file_contents); } -void OSExchangeData::SetDownloadFileInfo(const DownloadFileInfo& download) { - return provider_->SetDownloadFileInfo(download); -} -#endif - -#if defined(OS_WIN) || defined(USE_AURA) -void OSExchangeData::SetHtml(const string16& html, const GURL& base_url) { - provider_->SetHtml(html, base_url); -} - bool OSExchangeData::GetHtml(string16* html, GURL* base_url) const { return provider_->GetHtml(html, base_url); } + +void OSExchangeData::SetDownloadFileInfo(const DownloadFileInfo& download) { + return provider_->SetDownloadFileInfo(download); +} #endif } // namespace ui diff --git a/ui/base/dragdrop/os_exchange_data.h b/ui/base/dragdrop/os_exchange_data.h index f0b5745..9888b3f 100644 --- a/ui/base/dragdrop/os_exchange_data.h +++ b/ui/base/dragdrop/os_exchange_data.h @@ -1,4 +1,4 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -23,10 +23,6 @@ #include "ui/base/dragdrop/download_file_interface.h" #include "ui/base/ui_export.h" -#if defined(USE_AURA) -#include "ui/base/clipboard/clipboard.h" -#endif - class GURL; class Pickle; @@ -50,11 +46,7 @@ class UI_EXPORT OSExchangeData { public: // CustomFormats are used for non-standard data types. For example, bookmark // nodes are written using a CustomFormat. -#if defined(USE_AURA) - // Use the same type as the clipboard (why do we want two different - // definitions of this on other platforms?). - typedef Clipboard::FormatType CustomFormat; -#elif defined(OS_WIN) +#if defined(OS_WIN) typedef CLIPFORMAT CustomFormat; #elif defined(TOOLKIT_USES_GTK) typedef GdkAtom CustomFormat; @@ -70,8 +62,6 @@ class UI_EXPORT OSExchangeData { PICKLED_DATA = 1 << 3, #if defined(OS_WIN) FILE_CONTENTS = 1 << 4, -#endif -#if defined(OS_WIN) || defined(USE_AURA) HTML = 1 << 5, #endif }; @@ -112,16 +102,13 @@ class UI_EXPORT OSExchangeData { #if defined(OS_WIN) virtual void SetFileContents(const FilePath& filename, const std::string& file_contents) = 0; + virtual void SetHtml(const string16& html, const GURL& base_url) = 0; virtual bool GetFileContents(FilePath* filename, std::string* file_contents) const = 0; - virtual bool HasFileContents() const = 0; - virtual void SetDownloadFileInfo(const DownloadFileInfo& download) = 0; -#endif - -#if defined(OS_WIN) || defined(USE_AURA) - virtual void SetHtml(const string16& html, const GURL& base_url) = 0; virtual bool GetHtml(string16* html, GURL* base_url) const = 0; + virtual bool HasFileContents() const = 0; virtual bool HasHtml() const = 0; + virtual void SetDownloadFileInfo(const DownloadFileInfo& download) = 0; #endif }; @@ -188,20 +175,17 @@ class UI_EXPORT OSExchangeData { // Adds the bytes of a file (CFSTR_FILECONTENTS and CFSTR_FILEDESCRIPTOR). void SetFileContents(const FilePath& filename, const std::string& file_contents); + // Adds a snippet of HTML. |html| is just raw html but this sets both + // text/html and CF_HTML. + void SetHtml(const string16& html, const GURL& base_url); bool GetFileContents(FilePath* filename, std::string* file_contents) const; + bool GetHtml(string16* html, GURL* base_url) const; // Adds a download file with full path (CF_HDROP). void SetDownloadFileInfo(const DownloadFileInfo& download); #endif -#if defined(OS_WIN) || defined(USE_AURA) - // Adds a snippet of HTML. |html| is just raw html but this sets both - // text/html and CF_HTML. - void SetHtml(const string16& html, const GURL& base_url); - bool GetHtml(string16* html, GURL* base_url) const; -#endif - private: // Creates the platform specific Provider. static Provider* CreateProvider(); diff --git a/ui/base/dragdrop/os_exchange_data_provider_aura.cc b/ui/base/dragdrop/os_exchange_data_provider_aura.cc index e10e0e2..238cb47 100644 --- a/ui/base/dragdrop/os_exchange_data_provider_aura.cc +++ b/ui/base/dragdrop/os_exchange_data_provider_aura.cc @@ -7,7 +7,6 @@ #include "base/logging.h" #include "base/utf_string_conversions.h" #include "net/base/net_util.h" -#include "ui/base/clipboard/clipboard.h" #include "ui/base/clipboard/scoped_clipboard_writer.h" namespace ui { @@ -123,6 +122,11 @@ bool OSExchangeDataProviderAura::HasCustomFormat( NOTIMPLEMENTED(); } + void OSExchangeDataProviderAura::SetHtml(const string16& html, + const GURL& base_url) { + NOTIMPLEMENTED(); + } + bool OSExchangeDataProviderAura::GetFileContents( FilePath* filename, std::string* file_contents) const { @@ -130,37 +134,28 @@ bool OSExchangeDataProviderAura::HasCustomFormat( return false; } + bool OSExchangeDataProviderAura::GetHtml(string16* html, + GURL* base_url) const { + NOTIMPLEMENTED(); + return false; + } + bool OSExchangeDataProviderAura::HasFileContents() const { NOTIMPLEMENTED(); return false; } + bool OSExchangeDataProviderAura::HasHtml() const { + NOTIMPLEMENTED(); + return false; + } + void OSExchangeDataProviderAura::SetDownloadFileInfo( const OSExchangeData::DownloadFileInfo& download) { NOTIMPLEMENTED(); } #endif -void OSExchangeDataProviderAura::SetHtml(const string16& html, - const GURL& base_url) { - formats_ |= OSExchangeData::HTML; - html_ = html; - base_url_ = base_url; -} - -bool OSExchangeDataProviderAura::GetHtml(string16* html, - GURL* base_url) const { - if ((formats_ & OSExchangeData::HTML) == 0) - return false; - *html = html_; - *base_url = base_url_; - return true; -} - -bool OSExchangeDataProviderAura::HasHtml() const { - return ((formats_ & OSExchangeData::HTML) != 0); -} - bool OSExchangeDataProviderAura::GetPlainTextURL(GURL* url) const { if ((formats_ & OSExchangeData::STRING) == 0) return false; @@ -185,11 +180,8 @@ OSExchangeData::Provider* OSExchangeData::CreateProvider() { // static OSExchangeData::CustomFormat OSExchangeData::RegisterCustomFormat(const std::string& type) { - // On Aura you probably want to just use the Clipboard::Get*FormatType APIs - // instead. But we can also dynamically generate new CustomFormat objects - // here too if really necessary. - return Clipboard::FormatType::Deserialize(type); + // TODO(davemoore) Implement this for aura. + return NULL; } - } // namespace ui diff --git a/ui/base/dragdrop/os_exchange_data_provider_aura.h b/ui/base/dragdrop/os_exchange_data_provider_aura.h index f7903c3..0e0dfe4 100644 --- a/ui/base/dragdrop/os_exchange_data_provider_aura.h +++ b/ui/base/dragdrop/os_exchange_data_provider_aura.h @@ -46,17 +46,16 @@ class UI_EXPORT OSExchangeDataProviderAura : public OSExchangeData::Provider { #if defined(OS_WIN) virtual void SetFileContents(const FilePath& filename, const std::string& file_contents) OVERRIDE; + virtual void SetHtml(const string16& html, const GURL& base_url) OVERRIDE; virtual bool GetFileContents(FilePath* filename, std::string* file_contents) const OVERRIDE; + virtual bool GetHtml(string16* html, GURL* base_url) const OVERRIDE; virtual bool HasFileContents() const OVERRIDE; + virtual bool HasHtml() const OVERRIDE; virtual void SetDownloadFileInfo( const OSExchangeData::DownloadFileInfo& download) OVERRIDE; #endif - virtual void SetHtml(const string16& html, const GURL& base_url) OVERRIDE; - virtual bool GetHtml(string16* html, GURL* base_url) const OVERRIDE; - virtual bool HasHtml() const OVERRIDE; - void set_drag_image(const SkBitmap& drag_image) { drag_image_ = drag_image; } const SkBitmap& drag_image() const { return drag_image_; } @@ -87,10 +86,6 @@ class UI_EXPORT OSExchangeDataProviderAura : public OSExchangeData::Provider { // Drag image and offset data. SkBitmap drag_image_; - // For HTML format - string16 html_; - GURL base_url_; - DISALLOW_COPY_AND_ASSIGN(OSExchangeDataProviderAura); }; diff --git a/ui/views/controls/textfield/native_textfield_views_unittest.cc b/ui/views/controls/textfield/native_textfield_views_unittest.cc index ed5e425..37a7e6a 100644 --- a/ui/views/controls/textfield/native_textfield_views_unittest.cc +++ b/ui/views/controls/textfield/native_textfield_views_unittest.cc @@ -789,12 +789,7 @@ TEST_F(NativeTextfieldViewsTest, DragAndDrop_AcceptDrop) { ui::OSExchangeData bad_data; bad_data.SetFilename(FilePath(FILE_PATH_LITERAL("x"))); #if defined(OS_WIN) -#if defined(USE_AURA) - ui::OSExchangeData::CustomFormat fmt = ui::Clipboard::GetBitmapFormatType(); -#else - ui::OSExchangeData::CustomFormat fmt = CF_BITMAP; -#endif - bad_data.SetPickledData(fmt, Pickle()); + bad_data.SetPickledData(CF_BITMAP, Pickle()); bad_data.SetFileContents(FilePath(L"x"), "x"); bad_data.SetHtml(string16(ASCIIToUTF16("x")), GURL("x.org")); ui::OSExchangeData::DownloadFileInfo download(FilePath(), NULL); |