| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/guestview/guestview.h" | 5 #include "chrome/browser/guestview/guestview.h" |
| 6 | 6 |
| 7 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
| 8 #include "chrome/browser/guestview/adview/adview_guest.h" | 8 #include "chrome/browser/guestview/adview/adview_guest.h" |
| 9 #include "chrome/browser/guestview/guestview_constants.h" | 9 #include "chrome/browser/guestview/guestview_constants.h" |
| 10 #include "chrome/browser/guestview/webview/webview_guest.h" | 10 #include "chrome/browser/guestview/webview/webview_guest.h" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 | 39 |
| 40 GuestView::Event::~Event() { | 40 GuestView::Event::~Event() { |
| 41 } | 41 } |
| 42 | 42 |
| 43 scoped_ptr<base::DictionaryValue> GuestView::Event::GetArguments() { | 43 scoped_ptr<base::DictionaryValue> GuestView::Event::GetArguments() { |
| 44 return args_.Pass(); | 44 return args_.Pass(); |
| 45 } | 45 } |
| 46 | 46 |
| 47 GuestView::GuestView(WebContents* guest_web_contents, | 47 GuestView::GuestView(WebContents* guest_web_contents, |
| 48 const std::string& extension_id) | 48 const std::string& extension_id) |
| 49 : guest_web_contents_(guest_web_contents), | 49 : weak_ptr_factory_(this), |
| 50 guest_web_contents_(guest_web_contents), |
| 50 embedder_web_contents_(NULL), | 51 embedder_web_contents_(NULL), |
| 51 extension_id_(extension_id), | 52 extension_id_(extension_id), |
| 52 embedder_render_process_id_(0), | 53 embedder_render_process_id_(0), |
| 53 browser_context_(guest_web_contents->GetBrowserContext()), | 54 browser_context_(guest_web_contents->GetBrowserContext()), |
| 54 guest_instance_id_(guest_web_contents->GetEmbeddedInstanceID()), | 55 guest_instance_id_(guest_web_contents->GetEmbeddedInstanceID()), |
| 55 view_instance_id_(guestview::kInstanceIDNone) { | 56 view_instance_id_(guestview::kInstanceIDNone) { |
| 56 webcontents_guestview_map.Get().insert( | 57 webcontents_guestview_map.Get().insert( |
| 57 std::make_pair(guest_web_contents, this)); | 58 std::make_pair(guest_web_contents, this)); |
| 58 } | 59 } |
| 59 | 60 |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 // GuestView::Attach is called prior to initialization (and initial | 151 // GuestView::Attach is called prior to initialization (and initial |
| 151 // navigation) of the guest in the content layer in order to permit mapping | 152 // navigation) of the guest in the content layer in order to permit mapping |
| 152 // the necessary associations between the <*view> element and its guest. This | 153 // the necessary associations between the <*view> element and its guest. This |
| 153 // is needed by the <webview> WebRequest API to allow intercepting resource | 154 // is needed by the <webview> WebRequest API to allow intercepting resource |
| 154 // requests during navigation. However, queued events should be fired after | 155 // requests during navigation. However, queued events should be fired after |
| 155 // content layer initialization in order to ensure that load events (such as | 156 // content layer initialization in order to ensure that load events (such as |
| 156 // 'loadstop') fire in embedder after the contentWindow is available. | 157 // 'loadstop') fire in embedder after the contentWindow is available. |
| 157 base::MessageLoop::current()->PostTask( | 158 base::MessageLoop::current()->PostTask( |
| 158 FROM_HERE, | 159 FROM_HERE, |
| 159 base::Bind(&GuestView::SendQueuedEvents, | 160 base::Bind(&GuestView::SendQueuedEvents, |
| 160 base::Unretained(this))); | 161 weak_ptr_factory_.GetWeakPtr())); |
| 161 } | 162 } |
| 162 | 163 |
| 163 GuestView::Type GuestView::GetViewType() const { | 164 GuestView::Type GuestView::GetViewType() const { |
| 164 return GuestView::UNKNOWN; | 165 return GuestView::UNKNOWN; |
| 165 } | 166 } |
| 166 | 167 |
| 167 WebViewGuest* GuestView::AsWebView() { | 168 WebViewGuest* GuestView::AsWebView() { |
| 168 return NULL; | 169 return NULL; |
| 169 } | 170 } |
| 170 | 171 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 void GuestView::SendQueuedEvents() { | 210 void GuestView::SendQueuedEvents() { |
| 210 if (!attached()) | 211 if (!attached()) |
| 211 return; | 212 return; |
| 212 | 213 |
| 213 while (!pending_events_.empty()) { | 214 while (!pending_events_.empty()) { |
| 214 Event* event = pending_events_.front(); | 215 Event* event = pending_events_.front(); |
| 215 pending_events_.pop(); | 216 pending_events_.pop(); |
| 216 DispatchEvent(event); | 217 DispatchEvent(event); |
| 217 } | 218 } |
| 218 } | 219 } |
| OLD | NEW |