Chromium Code Reviews| Index: chrome/browser/guestview/webview/webview_guest.cc |
| diff --git a/chrome/browser/guestview/webview/webview_guest.cc b/chrome/browser/guestview/webview/webview_guest.cc |
| index a7df8e965fd658873dfed29f1d65da2b59c8cfed..b5cd4f0180bfa78e59d854805d5e6ec63bb55aa5 100644 |
| --- a/chrome/browser/guestview/webview/webview_guest.cc |
| +++ b/chrome/browser/guestview/webview/webview_guest.cc |
| @@ -11,6 +11,8 @@ |
| #include "chrome/browser/guestview/guestview_constants.h" |
| #include "chrome/browser/guestview/webview/webview_constants.h" |
| #include "content/public/browser/browser_thread.h" |
| +#include "content/public/browser/notification_source.h" |
| +#include "content/public/browser/notification_types.h" |
| #include "content/public/browser/render_process_host.h" |
| #include "content/public/browser/web_contents.h" |
| @@ -35,6 +37,9 @@ WebViewGuest::WebViewGuest(WebContents* guest_web_contents) |
| WebContentsObserver(guest_web_contents), |
| script_executor_(new extensions::ScriptExecutor(guest_web_contents, |
| &script_observers_)) { |
| + notification_registrar_.Add( |
| + this, content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, |
| + content::Source<WebContents>(guest_web_contents)); |
| } |
| // static |
| @@ -68,6 +73,22 @@ AdViewGuest* WebViewGuest::AsAdView() { |
| return NULL; |
| } |
| +void WebViewGuest::Observe(int type, |
| + const content::NotificationSource& source, |
| + const content::NotificationDetails& details) { |
| + switch (type) { |
| + case content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME: { |
| + DCHECK_EQ(content::Source<WebContents>(source).ptr(), |
| + guest_web_contents()); |
| + LoadHandlerCalled(); |
|
lazyboy
2013/06/28 18:55:08
if (source == guest_web_contents()) {
LoadHandle
Fady Samuel
2013/06/28 21:24:35
Done.
|
| + break; |
| + } |
| + default: |
| + NOTREACHED() << "Unexpected notification sent."; |
| + break; |
| + } |
| +} |
| + |
| void WebViewGuest::Go(int relative_index) { |
| guest_web_contents()->GetController().GoToOffset(relative_index); |
| } |
| @@ -109,6 +130,11 @@ void WebViewGuest::WebContentsDestroyed(WebContents* web_contents) { |
| delete this; |
| } |
| +void WebViewGuest::LoadHandlerCalled() { |
| + scoped_ptr<DictionaryValue> args(new DictionaryValue()); |
| + DispatchEvent(new GuestView::Event(webview::kEventContentLoad, args.Pass())); |
| +} |
| + |
| void WebViewGuest::AddWebViewToExtensionRendererState() { |
| ExtensionRendererState::WebViewInfo webview_info; |
| webview_info.embedder_process_id = embedder_render_process_id(); |