Home | History | Annotate | Download | only in renderer
      1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 #ifndef CONTENT_RENDERER_CLIPBOARD_CLIENT_H_
      6 #define CONTENT_RENDERER_CLIPBOARD_CLIENT_H_
      7 
      8 #include "content/common/clipboard_format.h"
      9 #include "ui/base/clipboard/clipboard.h"
     10 
     11 class GURL;
     12 
     13 namespace content {
     14 
     15 // Interface for the content embedder to implement to support clipboard.
     16 class ClipboardClient {
     17  public:
     18   class WriteContext {
     19    public:
     20     virtual ~WriteContext() { }
     21 
     22     // Writes bitmap data into the context, updating the ObjectMap.
     23     virtual void WriteBitmapFromPixels(ui::Clipboard::ObjectMap* objects,
     24                                        const void* pixels,
     25                                        const gfx::Size& size) = 0;
     26 
     27     // Flushes all gathered data.
     28     virtual void Flush(const ui::Clipboard::ObjectMap& objects) = 0;
     29   };
     30 
     31   virtual ~ClipboardClient() { }
     32 
     33   // Get a clipboard that can be used to construct a ScopedClipboardWriterGlue.
     34   virtual ui::Clipboard* GetClipboard() = 0;
     35 
     36   // Get a sequence number which uniquely identifies clipboard state.
     37   virtual uint64 GetSequenceNumber(ui::ClipboardType type) = 0;
     38 
     39   // Tests whether the clipboard contains a certain format
     40   virtual bool IsFormatAvailable(ClipboardFormat format,
     41                                  ui::ClipboardType type) = 0;
     42 
     43   // Clear the contents of the clipboard.
     44   virtual void Clear(ui::ClipboardType type) = 0;
     45 
     46   // Reads the available types from the clipboard, if available.
     47   virtual void ReadAvailableTypes(ui::ClipboardType type,
     48                                   std::vector<base::string16>* types,
     49                                   bool* contains_filenames) = 0;
     50 
     51   // Reads text from the clipboard, trying UNICODE first, then falling back to
     52   // ASCII.
     53   virtual void ReadText(ui::ClipboardType type,
     54                         base::string16* result) = 0;
     55 
     56   // Reads HTML from the clipboard, if available.
     57   virtual void ReadHTML(ui::ClipboardType type,
     58                         base::string16* markup,
     59                         GURL* url,
     60                         uint32* fragment_start,
     61                         uint32* fragment_end) = 0;
     62 
     63   // Reads RTF from the clipboard, if available.
     64   virtual void ReadRTF(ui::ClipboardType type, std::string* result) = 0;
     65 
     66   // Reads and image from the clipboard, if available.
     67   virtual void ReadImage(ui::ClipboardType type, std::string* data) = 0;
     68 
     69   // Reads a custom data type from the clipboard, if available.
     70   virtual void ReadCustomData(ui::ClipboardType clipboard_type,
     71                               const base::string16& type,
     72                               base::string16* data) = 0;
     73 
     74   // Creates a context to write clipboard data. May return NULL.
     75   virtual WriteContext* CreateWriteContext() = 0;
     76 };
     77 
     78 }  // namespace content
     79 
     80 #endif  // CONTENT_RENDERER_CLIPBOARD_CLIENT_H_
     81 
     82