Home | History | Annotate | Download | only in base
      1 // Copyright (c) 2006-2008 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 #include "base/base_drag_source.h"
      6 
      7 ///////////////////////////////////////////////////////////////////////////////
      8 // BaseDragSource, public:
      9 
     10 BaseDragSource::BaseDragSource() : cancel_drag_(false) {
     11 }
     12 
     13 ///////////////////////////////////////////////////////////////////////////////
     14 // BaseDragSource, IDropSource implementation:
     15 
     16 HRESULT BaseDragSource::QueryContinueDrag(BOOL escape_pressed,
     17                                           DWORD key_state) {
     18   if (cancel_drag_)
     19     return DRAGDROP_S_CANCEL;
     20 
     21   if (escape_pressed) {
     22     OnDragSourceCancel();
     23     return DRAGDROP_S_CANCEL;
     24   }
     25 
     26   if (!(key_state & MK_LBUTTON)) {
     27     OnDragSourceDrop();
     28     return DRAGDROP_S_DROP;
     29   }
     30 
     31   OnDragSourceMove();
     32   return S_OK;
     33 }
     34 
     35 HRESULT BaseDragSource::GiveFeedback(DWORD effect) {
     36   return DRAGDROP_S_USEDEFAULTCURSORS;
     37 }
     38 
     39 ///////////////////////////////////////////////////////////////////////////////
     40 // BaseDragSource, IUnknown implementation:
     41 
     42 HRESULT BaseDragSource::QueryInterface(const IID& iid, void** object) {
     43   *object = NULL;
     44   if (IsEqualIID(iid, IID_IUnknown) || IsEqualIID(iid, IID_IDropSource)) {
     45     *object = this;
     46   } else {
     47     return E_NOINTERFACE;
     48   }
     49   AddRef();
     50   return S_OK;
     51 }
     52 
     53 ULONG BaseDragSource::AddRef() {
     54   base::RefCountedThreadSafe<BaseDragSource>::AddRef();
     55   return 0;
     56 }
     57 
     58 ULONG BaseDragSource::Release() {
     59   base::RefCountedThreadSafe<BaseDragSource>::Release();
     60   return 0;
     61 }
     62