Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / ui / cocoa / tab_contents / web_drag_bookmark_handler_mac.mm
blob17fe2953d1c84f98e32ac3cea5bf1bdee5c7e62a
1 // Copyright (c) 2012 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.
5 #include "chrome/browser/ui/cocoa/tab_contents/web_drag_bookmark_handler_mac.h"
7 #include "chrome/browser/ui/browser.h"
8 #include "chrome/browser/ui/browser_finder.h"
9 #include "chrome/browser/ui/browser_window.h"
10 #include "chrome/browser/ui/bookmarks/bookmark_tab_helper.h"
11 #include "content/public/browser/web_contents.h"
13 using content::WebContents;
15 WebDragBookmarkHandlerMac::WebDragBookmarkHandlerMac()
16     : bookmark_tab_helper_(NULL),
17       web_contents_(NULL) {
20 WebDragBookmarkHandlerMac::~WebDragBookmarkHandlerMac() {}
22 void WebDragBookmarkHandlerMac::DragInitialize(WebContents* contents) {
23   web_contents_ = contents;
24   if (!bookmark_tab_helper_)
25     bookmark_tab_helper_ = BookmarkTabHelper::FromWebContents(contents);
27   bookmark_drag_data_.ReadFromClipboard(ui::CLIPBOARD_TYPE_DRAG);
30 void WebDragBookmarkHandlerMac::OnDragOver() {
31   if (bookmark_tab_helper_ && bookmark_tab_helper_->bookmark_drag_delegate()) {
32     bookmark_tab_helper_->bookmark_drag_delegate()->OnDragOver(
33         bookmark_drag_data_);
34   }
37 void WebDragBookmarkHandlerMac::OnDragEnter() {
38   if (bookmark_tab_helper_ && bookmark_tab_helper_->bookmark_drag_delegate()) {
39     bookmark_tab_helper_->bookmark_drag_delegate()->OnDragEnter(
40         bookmark_drag_data_);
41   }
44 void WebDragBookmarkHandlerMac::OnDrop() {
45   // This is non-null if the web_contents_ is showing an ExtensionWebUI with
46   // support for (at the moment experimental) drag and drop extensions.
47   if (bookmark_tab_helper_) {
48     if (bookmark_tab_helper_->bookmark_drag_delegate()) {
49       bookmark_tab_helper_->bookmark_drag_delegate()->OnDrop(
50           bookmark_drag_data_);
51     }
53     // Focus the target browser.
54     Browser* browser = chrome::FindBrowserWithWebContents(web_contents_);
55     if (browser)
56       browser->window()->Show();
57   }
60 void WebDragBookmarkHandlerMac::OnDragLeave() {
61   if (bookmark_tab_helper_ && bookmark_tab_helper_->bookmark_drag_delegate()) {
62     bookmark_tab_helper_->bookmark_drag_delegate()->OnDragLeave(
63         bookmark_drag_data_);
64   }