Home | History | Annotate | Download | only in extensions
      1 // Copyright (c) 2010 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 CHROME_BROWSER_UI_VIEWS_EXTENSIONS_BROWSER_ACTION_DRAG_DATA_H_
      6 #define CHROME_BROWSER_UI_VIEWS_EXTENSIONS_BROWSER_ACTION_DRAG_DATA_H_
      7 #pragma once
      8 
      9 #include <string>
     10 
     11 #include "base/basictypes.h"
     12 #include "chrome/browser/profiles/profile.h"
     13 
     14 #if defined(TOOLKIT_VIEWS)
     15 #include "ui/base/dragdrop/os_exchange_data.h"
     16 #endif
     17 
     18 class BrowserActionButton;
     19 class FilePath;
     20 class Pickle;
     21 
     22 class BrowserActionDragData {
     23  public:
     24   BrowserActionDragData();
     25   BrowserActionDragData(const std::string& id, int index);
     26 
     27   const std::string& id() const { return id_; }
     28 
     29   size_t index() const { return index_; }
     30 
     31   // Returns true if this data is from the specified profile.
     32   bool IsFromProfile(Profile* profile) const;
     33 
     34 #if defined(TOOLKIT_VIEWS)
     35   void Write(Profile* profile, ui::OSExchangeData* data) const;
     36 
     37   // Restores this data from the clipboard, returning true on success.
     38   bool Read(const ui::OSExchangeData& data);
     39 
     40   // Returns the Custom Format this class supports (for Browser Actions).
     41   static ui::OSExchangeData::CustomFormat GetBrowserActionCustomFormat();
     42 #endif
     43 
     44  private:
     45   void WriteToPickle(Profile* profile, Pickle* pickle) const;
     46   bool ReadFromPickle(Pickle* pickle);
     47 
     48   // ID of the profile we originated from.
     49   ProfileId profile_id_;
     50 
     51   // The id of the view being dragged.
     52   std::string id_;
     53 
     54   // The index of the view being dragged.
     55   size_t index_;
     56 
     57   // The MIME type for the clipboard format for BrowserActionDragData.
     58   static const char* kClipboardFormatString;
     59 
     60   DISALLOW_COPY_AND_ASSIGN(BrowserActionDragData);
     61 };
     62 
     63 #endif  // CHROME_BROWSER_UI_VIEWS_EXTENSIONS_BROWSER_ACTION_DRAG_DATA_H_
     64