Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "chrome/browser/guest_view/guest_view_base.h" | 5 #include "chrome/browser/guest_view/guest_view_base.h" |
| 6 | 6 |
| 7 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
| 8 #include "base/strings/utf_string_conversions.h" | |
| 8 #include "chrome/browser/guest_view/ad_view/ad_view_guest.h" | 9 #include "chrome/browser/guest_view/ad_view/ad_view_guest.h" |
| 9 #include "chrome/browser/guest_view/guest_view_constants.h" | 10 #include "chrome/browser/guest_view/guest_view_constants.h" |
| 10 #include "chrome/browser/guest_view/guest_view_manager.h" | 11 #include "chrome/browser/guest_view/guest_view_manager.h" |
| 11 #include "chrome/browser/guest_view/web_view/web_view_guest.h" | 12 #include "chrome/browser/guest_view/web_view/web_view_guest.h" |
| 12 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
| 13 #include "chrome/common/content_settings.h" | 14 #include "chrome/common/content_settings.h" |
| 15 #include "content/public/browser/render_frame_host.h" | |
| 14 #include "content/public/browser/render_process_host.h" | 16 #include "content/public/browser/render_process_host.h" |
| 17 #include "content/public/browser/render_view_host.h" | |
| 15 #include "content/public/browser/web_contents.h" | 18 #include "content/public/browser/web_contents.h" |
| 16 #include "content/public/common/url_constants.h" | 19 #include "content/public/common/url_constants.h" |
| 17 #include "extensions/browser/event_router.h" | 20 #include "extensions/browser/event_router.h" |
| 18 #include "net/base/escape.h" | 21 #include "net/base/escape.h" |
| 19 #include "third_party/WebKit/public/web/WebInputEvent.h" | 22 #include "third_party/WebKit/public/web/WebInputEvent.h" |
| 20 | 23 |
| 21 using content::WebContents; | 24 using content::WebContents; |
| 22 | 25 |
| 23 namespace { | 26 namespace { |
| 24 | 27 |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 216 return; | 219 return; |
| 217 } | 220 } |
| 218 opener_ = base::WeakPtr<GuestViewBase>(); | 221 opener_ = base::WeakPtr<GuestViewBase>(); |
| 219 } | 222 } |
| 220 | 223 |
| 221 void GuestViewBase::RegisterDestructionCallback( | 224 void GuestViewBase::RegisterDestructionCallback( |
| 222 const DestructionCallback& callback) { | 225 const DestructionCallback& callback) { |
| 223 destruction_callback_ = callback; | 226 destruction_callback_ = callback; |
| 224 } | 227 } |
| 225 | 228 |
| 229 void GuestViewBase::DidStopLoading(content::RenderViewHost* render_view_host) { | |
| 230 // Disable drag-and-drop by default. Derived classes that override this method | |
|
lazyboy
2014/05/30 00:30:52
Don't think this is a good way of doing this: "you
Fady Samuel
2014/05/30 01:53:21
You got the logic reversed. This disables DND by d
lazyboy
2014/05/30 03:11:40
Yeah I misread.
But my concern is still the same,
| |
| 231 // can avoid the script injection, thereby enabling drag-and-drop. | |
| 232 const char script[] = "window.addEventListener('dragstart', function() { " | |
| 233 " window.event.preventDefault(); " | |
| 234 "});"; | |
| 235 render_view_host->GetMainFrame()->ExecuteJavaScript( | |
| 236 base::ASCIIToUTF16(script)); | |
| 237 } | |
| 238 | |
| 226 void GuestViewBase::WebContentsDestroyed() { | 239 void GuestViewBase::WebContentsDestroyed() { |
| 227 delete this; | 240 delete this; |
| 228 } | 241 } |
| 229 | 242 |
| 230 bool GuestViewBase::ShouldFocusPageAfterCrash() { | 243 bool GuestViewBase::ShouldFocusPageAfterCrash() { |
| 231 // Focus is managed elsewhere. | 244 // Focus is managed elsewhere. |
| 232 return false; | 245 return false; |
| 233 } | 246 } |
| 234 | 247 |
| 235 bool GuestViewBase::PreHandleGestureEvent(content::WebContents* source, | 248 bool GuestViewBase::PreHandleGestureEvent(content::WebContents* source, |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 282 | 295 |
| 283 void GuestViewBase::SendQueuedEvents() { | 296 void GuestViewBase::SendQueuedEvents() { |
| 284 if (!attached()) | 297 if (!attached()) |
| 285 return; | 298 return; |
| 286 while (!pending_events_.empty()) { | 299 while (!pending_events_.empty()) { |
| 287 linked_ptr<Event> event_ptr = pending_events_.front(); | 300 linked_ptr<Event> event_ptr = pending_events_.front(); |
| 288 pending_events_.pop_front(); | 301 pending_events_.pop_front(); |
| 289 DispatchEvent(event_ptr.release()); | 302 DispatchEvent(event_ptr.release()); |
| 290 } | 303 } |
| 291 } | 304 } |
| OLD | NEW |