Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(84)

Side by Side Diff: content/browser/web_contents/web_contents_view_aura.cc

Issue 14335017: content: Use base::MessageLoop. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/web_contents/web_contents_view_aura.h" 5 #include "content/browser/web_contents/web_contents_view_aura.h"
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/metrics/histogram.h" 8 #include "base/metrics/histogram.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "content/browser/renderer_host/dip_util.h" 10 #include "content/browser/renderer_host/dip_util.h"
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 // slides under the cursor and starts receiving scroll events). However, once 151 // slides under the cursor and starts receiving scroll events). However, once
152 // the gesture is complete, and the window is being displayed as an overlay 152 // the gesture is complete, and the window is being displayed as an overlay
153 // window during navigation, events should not be forwarded anymore. 153 // window during navigation, events should not be forwarded anymore.
154 bool forward_events_; 154 bool forward_events_;
155 155
156 DISALLOW_COPY_AND_ASSIGN(OverscrollWindowDelegate); 156 DISALLOW_COPY_AND_ASSIGN(OverscrollWindowDelegate);
157 }; 157 };
158 158
159 // Listens to all mouse drag events during a drag and drop and sends them to 159 // Listens to all mouse drag events during a drag and drop and sends them to
160 // the renderer. 160 // the renderer.
161 class WebDragSourceAura : public MessageLoopForUI::Observer, 161 class WebDragSourceAura : public base::MessageLoopForUI::Observer,
162 public NotificationObserver { 162 public NotificationObserver {
163 public: 163 public:
164 WebDragSourceAura(aura::Window* window, WebContentsImpl* contents) 164 WebDragSourceAura(aura::Window* window, WebContentsImpl* contents)
165 : window_(window), 165 : window_(window),
166 contents_(contents) { 166 contents_(contents) {
167 MessageLoopForUI::current()->AddObserver(this); 167 base::MessageLoopForUI::current()->AddObserver(this);
168 registrar_.Add(this, NOTIFICATION_WEB_CONTENTS_DISCONNECTED, 168 registrar_.Add(this,
169 NOTIFICATION_WEB_CONTENTS_DISCONNECTED,
169 Source<WebContents>(contents)); 170 Source<WebContents>(contents));
170 } 171 }
171 172
172 virtual ~WebDragSourceAura() { 173 virtual ~WebDragSourceAura() {
173 MessageLoopForUI::current()->RemoveObserver(this); 174 base::MessageLoopForUI::current()->RemoveObserver(this);
174 } 175 }
175 176
176 // MessageLoop::Observer implementation: 177 // MessageLoop::Observer implementation:
177 virtual base::EventStatus WillProcessEvent( 178 virtual base::EventStatus WillProcessEvent(
178 const base::NativeEvent& event) OVERRIDE { 179 const base::NativeEvent& event) OVERRIDE {
179 return base::EVENT_CONTINUE; 180 return base::EVENT_CONTINUE;
180 } 181 }
181 virtual void DidProcessEvent(const base::NativeEvent& event) OVERRIDE { 182 virtual void DidProcessEvent(const base::NativeEvent& event) OVERRIDE {
182 if (!contents_) 183 if (!contents_)
183 return; 184 return;
(...skipping 923 matching lines...) Expand 10 before | Expand all | Expand 10 after
1107 } 1108 }
1108 1109
1109 scoped_ptr<WebDragSourceAura> drag_source( 1110 scoped_ptr<WebDragSourceAura> drag_source(
1110 new WebDragSourceAura(GetNativeView(), web_contents_)); 1111 new WebDragSourceAura(GetNativeView(), web_contents_));
1111 1112
1112 // We need to enable recursive tasks on the message loop so we can get 1113 // We need to enable recursive tasks on the message loop so we can get
1113 // updates while in the system DoDragDrop loop. 1114 // updates while in the system DoDragDrop loop.
1114 int result_op = 0; 1115 int result_op = 0;
1115 { 1116 {
1116 gfx::NativeView content_native_view = GetContentNativeView(); 1117 gfx::NativeView content_native_view = GetContentNativeView();
1117 MessageLoop::ScopedNestableTaskAllower allow(MessageLoop::current()); 1118 base::MessageLoop::ScopedNestableTaskAllower allow(
1118 result_op = aura::client::GetDragDropClient(root_window)->StartDragAndDrop( 1119 base::MessageLoop::current());
1119 data, root_window, content_native_view, 1120 result_op = aura::client::GetDragDropClient(root_window)
1120 event_info.event_location, ConvertFromWeb(operations), 1121 ->StartDragAndDrop(data,
1121 event_info.event_source); 1122 root_window,
1123 content_native_view,
1124 event_info.event_location,
1125 ConvertFromWeb(operations),
1126 event_info.event_source);
1122 } 1127 }
1123 1128
1124 // Bail out immediately if the contents view window is gone. Note that it is 1129 // Bail out immediately if the contents view window is gone. Note that it is
1125 // not safe to access any class members in this case since |this| may already 1130 // not safe to access any class members in this case since |this| may already
1126 // be destroyed. The local variable |drag_source| will still be valid though, 1131 // be destroyed. The local variable |drag_source| will still be valid though,
1127 // so we can use it to determine if the window is gone. 1132 // so we can use it to determine if the window is gone.
1128 if (!drag_source->window()) { 1133 if (!drag_source->window()) {
1129 // Note that in this case, we don't need to call SystemDragEnded() since the 1134 // Note that in this case, we don't need to call SystemDragEnded() since the
1130 // renderer is going away. 1135 // renderer is going away.
1131 return; 1136 return;
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
1414 event.location(), 1419 event.location(),
1415 gfx::Screen::GetScreenFor(GetNativeView())->GetCursorScreenPoint(), 1420 gfx::Screen::GetScreenFor(GetNativeView())->GetCursorScreenPoint(),
1416 ConvertAuraEventFlagsToWebInputEventModifiers(event.flags())); 1421 ConvertAuraEventFlagsToWebInputEventModifiers(event.flags()));
1417 if (drag_dest_delegate_) 1422 if (drag_dest_delegate_)
1418 drag_dest_delegate_->OnDrop(); 1423 drag_dest_delegate_->OnDrop();
1419 current_drop_data_.reset(); 1424 current_drop_data_.reset();
1420 return current_drag_op_; 1425 return current_drag_op_;
1421 } 1426 }
1422 1427
1423 } // namespace content 1428 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/web_contents/web_contents_drag_win.cc ('k') | content/browser/web_contents/web_contents_view_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698