summaryrefslogtreecommitdiffstats
path: root/chrome/browser/tab_contents/web_drag_source.h
blob: 597e087bfdf88d7cf3cfa9887318c510ec9fd95a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// Copyright (c) 2006-2008 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 CHROME_BROWSER_TAB_CONTENTS_WEB_DRAG_SOURCE_H_
#define CHROME_BROWSER_TAB_CONTENTS_WEB_DRAG_SOURCE_H_

#include "app/gfx/native_widget_types.h"
#include "base/basictypes.h"
#include "base/gfx/point.h"
#include "chrome/common/notification_observer.h"
#include "chrome/common/notification_registrar.h"

// TODO(port): Port this file.
#if defined(OS_WIN)
#include "base/base_drag_source.h"
#else
#include "chrome/common/temp_scaffolding_stubs.h"
#endif

class RenderViewHost;
class TabContents;

///////////////////////////////////////////////////////////////////////////////
//
// WebDragSource
//
//  An IDropSource implementation for a TabContents. Handles notifications sent
//  by an active drag-drop operation as the user mouses over other drop targets
//  on their system. This object tells Windows whether or not the drag should
//  continue, and supplies the appropriate cursors.
//
class WebDragSource : public BaseDragSource,
                      public NotificationObserver {
 public:
  // Create a new DragSource for a given HWND and TabContents.
  WebDragSource(gfx::NativeWindow source_wnd, TabContents* tab_contents);
  virtual ~WebDragSource() { }

  // NotificationObserver implementation.
  virtual void Observe(NotificationType type,
                       const NotificationSource& source,
                       const NotificationDetails& details);

 protected:
  // BaseDragSource
  virtual void OnDragSourceCancel();
  virtual void OnDragSourceDrop();
  virtual void OnDragSourceMove();

 private:
  // Cannot construct thusly.
  WebDragSource();

  // Keep a reference to the window so we can translate the cursor position.
  gfx::NativeWindow source_wnd_;

  // We use this as a channel to the renderer to tell it about various drag
  // drop events that it needs to know about (such as when a drag operation it
  // initiated terminates).
  RenderViewHost* render_view_host_;

  NotificationRegistrar registrar_;

  DISALLOW_COPY_AND_ASSIGN(WebDragSource);
};

#endif  // CHROME_BROWSER_TAB_CONTENTS_WEB_DRAG_SOURCE_H_