| Index: chrome/browser/guestview/guestview.cc
|
| diff --git a/chrome/browser/guestview/guestview.cc b/chrome/browser/guestview/guestview.cc
|
| index a431dcb42f9839eb85e2decec58698fb9a11c6c9..3f0093b7133fd4bc345578e4fa539c927ce7a03f 100644
|
| --- a/chrome/browser/guestview/guestview.cc
|
| +++ b/chrome/browser/guestview/guestview.cc
|
| @@ -45,7 +45,8 @@ scoped_ptr<base::DictionaryValue> GuestView::Event::GetArguments() {
|
| }
|
|
|
| GuestView::GuestView(WebContents* guest_web_contents,
|
| - const std::string& embedder_extension_id)
|
| + const std::string& embedder_extension_id,
|
| + const base::WeakPtr<GuestView>& opener)
|
| : guest_web_contents_(guest_web_contents),
|
| embedder_web_contents_(NULL),
|
| embedder_extension_id_(embedder_extension_id),
|
| @@ -53,6 +54,7 @@ GuestView::GuestView(WebContents* guest_web_contents,
|
| browser_context_(guest_web_contents->GetBrowserContext()),
|
| guest_instance_id_(guest_web_contents->GetEmbeddedInstanceID()),
|
| view_instance_id_(guestview::kInstanceIDNone),
|
| + opener_(opener),
|
| weak_ptr_factory_(this) {
|
| webcontents_guestview_map.Get().insert(
|
| std::make_pair(guest_web_contents, this));
|
| @@ -71,10 +73,13 @@ GuestView::Type GuestView::GetViewTypeFromString(const std::string& api_type) {
|
| // static
|
| GuestView* GuestView::Create(WebContents* guest_web_contents,
|
| const std::string& embedder_extension_id,
|
| - GuestView::Type view_type) {
|
| + GuestView::Type view_type,
|
| + const base::WeakPtr<GuestView>& opener) {
|
| switch (view_type) {
|
| case GuestView::WEBVIEW:
|
| - return new WebViewGuest(guest_web_contents, embedder_extension_id);
|
| + return new WebViewGuest(guest_web_contents,
|
| + embedder_extension_id,
|
| + opener);
|
| case GuestView::ADVIEW:
|
| return new AdViewGuest(guest_web_contents, embedder_extension_id);
|
| default:
|
| @@ -164,10 +169,29 @@ void GuestView::Attach(content::WebContents* embedder_web_contents,
|
| weak_ptr_factory_.GetWeakPtr()));
|
| }
|
|
|
| +WebContents* GuestView::GetOpener() const {
|
| + if (!opener_)
|
| + return NULL;
|
| + return opener_->guest_web_contents();
|
| +}
|
| +
|
| +void GuestView::SetOpener(WebContents* web_contents) {
|
| + GuestView* guest = FromWebContents(web_contents);
|
| + if (guest) {
|
| + opener_ = guest->AsWeakPtr();
|
| + return;
|
| + }
|
| + opener_ = base::WeakPtr<GuestView>();
|
| +}
|
| +
|
| GuestView::Type GuestView::GetViewType() const {
|
| return GuestView::UNKNOWN;
|
| }
|
|
|
| +base::WeakPtr<GuestView> GuestView::AsWeakPtr() {
|
| + return weak_ptr_factory_.GetWeakPtr();
|
| +}
|
| +
|
| WebViewGuest* GuestView::AsWebView() {
|
| return NULL;
|
| }
|
|
|