summaryrefslogtreecommitdiffstats
path: root/app/os_exchange_data_provider_gtk.h
diff options
context:
space:
mode:
authorsky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-12 21:58:18 +0000
committersky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-12 21:58:18 +0000
commit8c3dc79bc13ba84f418d3c135e1bf296a3e29722 (patch)
tree32eb9688d500a90eb74a7c4f8cb5a97e507dd0fc /app/os_exchange_data_provider_gtk.h
parentabaccb2cb8cff8138e5ea9daf420645e5852c9eb (diff)
downloadchromium_src-8c3dc79bc13ba84f418d3c135e1bf296a3e29722.zip
chromium_src-8c3dc79bc13ba84f418d3c135e1bf296a3e29722.tar.gz
chromium_src-8c3dc79bc13ba84f418d3c135e1bf296a3e29722.tar.bz2
Refactors OSExchangeData for easier portability.
BUG=none TEST=none Review URL: http://codereview.chromium.org/164401 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@23230 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'app/os_exchange_data_provider_gtk.h')
-rw-r--r--app/os_exchange_data_provider_gtk.h106
1 files changed, 106 insertions, 0 deletions
diff --git a/app/os_exchange_data_provider_gtk.h b/app/os_exchange_data_provider_gtk.h
new file mode 100644
index 0000000..dd9c009
--- /dev/null
+++ b/app/os_exchange_data_provider_gtk.h
@@ -0,0 +1,106 @@
+// Copyright (c) 2009 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.
+
+#ifndef APP_OS_EXCHANGE_DATA_PROVIDER_GTK_H_
+#define APP_OS_EXCHANGE_DATA_PROVIDER_GTK_H_
+
+#include <gtk/gtk.h>
+#include <map>
+#include <set>
+#include <string>
+#include <vector>
+
+#include "app/os_exchange_data.h"
+#include "base/pickle.h"
+#include "base/string16.h"
+#include "googleurl/src/gurl.h"
+
+// OSExchangeData::Provider implementation for Gtk. OSExchangeDataProviderGtk
+// is created with a set of known data types. In addition specific data
+// types can be set on OSExchangeDataProviderGtk by way of the various setters.
+// The various has methods return true if the format was supplied to the
+// constructor, or explicitly set.
+class OSExchangeDataProviderGtk : public OSExchangeData::Provider {
+ public:
+ OSExchangeDataProviderGtk(int known_formats,
+ const std::set<GdkAtom>& known_custom_formats_);
+ OSExchangeDataProviderGtk();
+
+ virtual ~OSExchangeDataProviderGtk();
+
+ int known_formats() const { return known_formats_; }
+ const std::set<GdkAtom>& known_custom_formats() const {
+ return known_custom_formats_;
+ }
+
+ // Returns true if all the formats and custom formats identified by |formats|
+ // and |custom_formats| have been set in this provider.
+ //
+ // NOTE: this is NOT the same as whether a format may be provided (as is
+ // returned by the various HasXXX methods), but rather if the data for the
+ // formats has been set on this provider by way of the various Setter
+ // methods.
+ bool HasDataForAllFormats(int formats,
+ const std::set<GdkAtom>& custom_formats) const;
+
+ // Provider methods.
+ virtual void SetString(const std::wstring& data);
+ virtual void SetURL(const GURL& url, const std::wstring& title);
+ virtual void SetFilename(const std::wstring& full_path);
+ virtual void SetPickledData(OSExchangeData::CustomFormat format,
+ const Pickle& data);
+ virtual void SetFileContents(const std::wstring& filename,
+ const std::string& file_contents);
+ virtual void SetHtml(const std::wstring& html, const GURL& base_url);
+ virtual bool GetString(std::wstring* data) const;
+ virtual bool GetURLAndTitle(GURL* url, std::wstring* title) const;
+ virtual bool GetFilename(std::wstring* full_path) const;
+ virtual bool GetPickledData(OSExchangeData::CustomFormat format,
+ Pickle* data) const;
+ virtual bool GetFileContents(std::wstring* filename,
+ std::string* file_contents) const;
+ virtual bool GetHtml(std::wstring* html, GURL* base_url) const;
+ virtual bool HasString() const;
+ virtual bool HasURL() const;
+ virtual bool HasFile() const;
+ virtual bool HasFileContents() const;
+ virtual bool HasHtml() const;
+ virtual bool HasCustomFormat(OSExchangeData::CustomFormat format) const;
+
+ private:
+ typedef std::map<OSExchangeData::CustomFormat, Pickle> PickleData;
+
+ // These are the possible formats the OSExchangeData may contain. Don't
+ // confuse this with the actual formats that have been set, which are
+ // |formats_| and |custom_formats_|.
+ const int known_formats_;
+ const std::set<GdkAtom> known_custom_formats_;
+
+ // Actual formats that have been set. See comment above |known_formats_|
+ // for details.
+ int formats_;
+ std::set<GdkAtom> custom_formats_;
+
+ // String contents.
+ string16 string_;
+
+ // URL contents.
+ GURL url_;
+ string16 title_;
+
+ // File contents.
+ string16 filename_;
+ std::string file_contents_;
+
+ // HTML contents.
+ string16 html_;
+ GURL base_url_;
+
+ // PICKLED_DATA contents.
+ PickleData pickle_data_;
+
+ DISALLOW_COPY_AND_ASSIGN(OSExchangeDataProviderGtk);
+};
+
+#endif // APP_OS_EXCHANGE_DATA_PROVIDER_GTK_H_