<commit_before>// 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.

#if defined(OS_WIN)
#include <atlbase.h>
#include <atlapp.h>
#include <atlmisc.h>
#endif

#include "chrome/browser/tab_contents/web_drag_source.h"

#include "chrome/browser/renderer_host/render_view_host.h"

namespace {

static void GetCursorPositions(gfx::NativeWindow wnd, gfx::Point* client,
                               gfx::Point* screen) {
#if defined(OS_WIN)
  POINT cursor_pos;
  GetCursorPos(&cursor_pos);
  screen->SetPoint(cursor_pos.x, cursor_pos.y);
  ScreenToClient(wnd, &cursor_pos);
  client->SetPoint(cursor_pos.x, cursor_pos.y);
#else
  // TODO(port): Get the cursor positions.
  NOTIMPLEMENTED();
#endif
}

}  // namespace
///////////////////////////////////////////////////////////////////////////////
// WebDragSource, public:

WebDragSource::WebDragSource(gfx::NativeWindow source_wnd,
                             RenderViewHost* render_view_host)
    : BaseDragSource(),
      source_wnd_(source_wnd),
      render_view_host_(render_view_host) {
}

void WebDragSource::OnDragSourceCancel() {
  gfx::Point client;
  gfx::Point screen;
  GetCursorPositions(source_wnd_, &client, &screen);
  render_view_host_->DragSourceEndedAt(client.x(), client.y(),
                                       screen.x(), screen.y());
}

void WebDragSource::OnDragSourceDrop() {
  gfx::Point client;
  gfx::Point screen;
  GetCursorPositions(source_wnd_, &client, &screen);
  render_view_host_->DragSourceEndedAt(client.x(), client.y(),
                                       screen.x(), screen.y());
}

void WebDragSource::OnDragSourceMove() {
  gfx::Point client;
  gfx::Point screen;
  GetCursorPositions(source_wnd_, &client, &screen);
  render_view_host_->DragSourceMovedTo(client.x(), client.y(),<commit_msg>Try to track down the cause of the Drag&Drop crash seen in bug 12524.<commit_after>// 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.

#if defined(OS_WIN)
#include <atlbase.h>
#include <atlapp.h>
#include <atlmisc.h>
#endif

#include "chrome/browser/tab_contents/web_drag_source.h"

#include "chrome/browser/renderer_host/render_view_host.h"

namespace {

static void GetCursorPositions(gfx::NativeWindow wnd, gfx::Point* client,
                               gfx::Point* screen) {
#if defined(OS_WIN)
  POINT cursor_pos;
  GetCursorPos(&cursor_pos);
  screen->SetPoint(cursor_pos.x, cursor_pos.y);
  ScreenToClient(wnd, &cursor_pos);
  client->SetPoint(cursor_pos.x, cursor_pos.y);
#else
  // TODO(port): Get the cursor positions.
  NOTIMPLEMENTED();
#endif
}

}  // namespace
///////////////////////////////////////////////////////////////////////////////
// WebDragSource, public:

WebDragSource::WebDragSource(gfx::NativeWindow source_wnd,
                             RenderViewHost* render_view_host)
    : BaseDragSource(),
      source_wnd_(source_wnd),
      render_view_host_(render_view_host) {
  // In an effort to try to track down http://crbug.com/12524 we now CHECK
  // when a NULL render_view_host is passed to us. I think this is what is
  // happening but it is hard to tell since the minidump is not helpful in this
  // case. At least we can then rule that out.
  CHECK(render_view_host_);
}

void WebDragSource::OnDragSourceCancel() {
  gfx::Point client;
  gfx::Point screen;
  GetCursorPositions(source_wnd_, &client, &screen);
  render_view_host_->DragSourceEndedAt(client.x(), client.y(),
                                       screen.x(), screen.y());
}

void WebDragSource::OnDragSourceDrop() {
  gfx::Point client;
  gfx::Point screen;
  GetCursorPositions(source_wnd_, &client, &screen);
  render_view_host_->DragSourceEndedAt(client.x(), client.y(),
                                       screen.x(), screen.y());
}

void WebDragSource::OnDragSourceMove() {
  gfx::Point client;
  gfx::Point screen;
  GetCursorPositions(source_wnd_, &client, &screen);
  render_view_host_->DragSourceMovedTo(client.x(), client.y(),
{'fraction_non_alphanumeric': 0.1548217276860493, 'fraction_numerical': 0.006221584111031347, 'mean_word_length': 3.086021505376344, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5620280', 'n_tokens_mistral': 1327, 'n_tokens_neox': 1301, 'n_words': 297}