Home | History | Annotate | Download | only in bookmarks
      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_BOOKMARKS_BOOKMARK_PASTEBOARD_HELPER_MAC_H_
      6 #define CHROME_BROWSER_BOOKMARKS_BOOKMARK_PASTEBOARD_HELPER_MAC_H_
      7 #pragma once
      8 
      9 #include "base/file_path.h"
     10 #include "chrome/browser/bookmarks/bookmark_node_data.h"
     11 #include "ui/gfx/native_widget_types.h"
     12 
     13 // This set of functions lets C++ code interact with the cocoa pasteboard
     14 // and dragging methods.
     15 namespace bookmark_pasteboard_helper_mac {
     16 
     17 // Writes a set of bookmark elements from a profile to the general pasteboard.
     18 // This should be used for copy/paste functions.
     19 void WriteToClipboard(const std::vector<BookmarkNodeData::Element>& elements,
     20                       FilePath::StringType profile_path);
     21 
     22 // Writes a set of bookmark elements from a profile to the dragging pasteboard
     23 // for drag and drop functions.
     24 void WriteToDragClipboard(
     25     const std::vector<BookmarkNodeData::Element>& elements,
     26     FilePath::StringType profile_path);
     27 
     28 // Reads a set of bookmark elements from the general copy/paste clipboard.
     29 bool ReadFromClipboard(std::vector<BookmarkNodeData::Element>& elements,
     30                        FilePath::StringType* profile_path);
     31 
     32 // Reads a set of bookmark elements from the drag and drop clipboard.
     33 bool ReadFromDragClipboard(std::vector<BookmarkNodeData::Element>& elements,
     34                            FilePath::StringType* profile_path);
     35 
     36 // Returns true if the general copy/paste pasteboard contains any sort of
     37 // bookmark elements.  It currently does not consider a plaintext url a
     38 // valid bookmark.
     39 bool ClipboardContainsBookmarks();
     40 
     41 // Returns true if the dragging pasteboard contains any sort of bookmark
     42 // elements.
     43 bool DragClipboardContainsBookmarks();
     44 
     45 // Copies the bookmark nodes to the dragging pasteboard and initiates a
     46 // drag from the specified view.  |view| must be a |TabContentsViewCocoa*|.
     47 void StartDrag(Profile* profile, const std::vector<const BookmarkNode*>& nodes,
     48                gfx::NativeView view);
     49 
     50 }
     51 
     52 #ifdef __OBJC__
     53 @class NSString;
     54 // Pasteboard type for dictionary containing bookmark structure consisting
     55 // of individual bookmark nodes and/or bookmark folders.
     56 extern "C" NSString* const kBookmarkDictionaryListPboardType;
     57 #endif  // __OBJC__
     58 
     59 #endif  // CHROME_BROWSER_BOOKMARKS_BOOKMARK_PASTEBOARD_HELPER_MAC_H_
     60