| 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 "base/strings/utf_string_conversions.h" |
| 9 #include "chrome/browser/guest_view/ad_view/ad_view_guest.h" | 9 #include "chrome/browser/guest_view/ad_view/ad_view_guest.h" |
| 10 #include "chrome/browser/guest_view/guest_view_constants.h" | 10 #include "chrome/browser/guest_view/guest_view_constants.h" |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 if (!in_extension()) | 204 if (!in_extension()) |
| 205 return; | 205 return; |
| 206 | 206 |
| 207 base::MessageLoop::current()->PostTask( | 207 base::MessageLoop::current()->PostTask( |
| 208 FROM_HERE, | 208 FROM_HERE, |
| 209 base::Bind(&GuestViewBase::SendQueuedEvents, | 209 base::Bind(&GuestViewBase::SendQueuedEvents, |
| 210 weak_ptr_factory_.GetWeakPtr())); | 210 weak_ptr_factory_.GetWeakPtr())); |
| 211 } | 211 } |
| 212 | 212 |
| 213 void GuestViewBase::Destroy() { | 213 void GuestViewBase::Destroy() { |
| 214 WillBeDestroyed(); |
| 214 if (!destruction_callback_.is_null()) | 215 if (!destruction_callback_.is_null()) |
| 215 destruction_callback_.Run(); | 216 destruction_callback_.Run(); |
| 216 delete guest_web_contents(); | 217 delete guest_web_contents(); |
| 217 } | 218 } |
| 218 | 219 |
| 219 | 220 |
| 220 void GuestViewBase::SetOpener(GuestViewBase* guest) { | 221 void GuestViewBase::SetOpener(GuestViewBase* guest) { |
| 221 if (guest && guest->IsViewType(GetViewType())) { | 222 if (guest && guest->IsViewType(GetViewType())) { |
| 222 opener_ = guest->AsWeakPtr(); | 223 opener_ = guest->AsWeakPtr(); |
| 223 return; | 224 return; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 235 const char script[] = "window.addEventListener('dragstart', function() { " | 236 const char script[] = "window.addEventListener('dragstart', function() { " |
| 236 " window.event.preventDefault(); " | 237 " window.event.preventDefault(); " |
| 237 "});"; | 238 "});"; |
| 238 render_view_host->GetMainFrame()->ExecuteJavaScript( | 239 render_view_host->GetMainFrame()->ExecuteJavaScript( |
| 239 base::ASCIIToUTF16(script)); | 240 base::ASCIIToUTF16(script)); |
| 240 } | 241 } |
| 241 DidStopLoading(); | 242 DidStopLoading(); |
| 242 } | 243 } |
| 243 | 244 |
| 244 void GuestViewBase::WebContentsDestroyed() { | 245 void GuestViewBase::WebContentsDestroyed() { |
| 246 GuestDestroyed(); |
| 245 delete this; | 247 delete this; |
| 246 } | 248 } |
| 247 | 249 |
| 248 bool GuestViewBase::ShouldFocusPageAfterCrash() { | 250 bool GuestViewBase::ShouldFocusPageAfterCrash() { |
| 249 // Focus is managed elsewhere. | 251 // Focus is managed elsewhere. |
| 250 return false; | 252 return false; |
| 251 } | 253 } |
| 252 | 254 |
| 253 bool GuestViewBase::PreHandleGestureEvent(content::WebContents* source, | 255 bool GuestViewBase::PreHandleGestureEvent(content::WebContents* source, |
| 254 const blink::WebGestureEvent& event) { | 256 const blink::WebGestureEvent& event) { |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 | 301 |
| 300 void GuestViewBase::SendQueuedEvents() { | 302 void GuestViewBase::SendQueuedEvents() { |
| 301 if (!attached()) | 303 if (!attached()) |
| 302 return; | 304 return; |
| 303 while (!pending_events_.empty()) { | 305 while (!pending_events_.empty()) { |
| 304 linked_ptr<Event> event_ptr = pending_events_.front(); | 306 linked_ptr<Event> event_ptr = pending_events_.front(); |
| 305 pending_events_.pop_front(); | 307 pending_events_.pop_front(); |
| 306 DispatchEvent(event_ptr.release()); | 308 DispatchEvent(event_ptr.release()); |
| 307 } | 309 } |
| 308 } | 310 } |
| OLD | NEW |