Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(104)

Side by Side Diff: chrome/browser/ui/views/chrome_constrained_window_views_client.cc

Issue 1012373002: Return the outermost embedder when returning the embedder web contents. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/ui/views/chrome_constrained_window_views_client.h" 5 #include "chrome/browser/ui/views/chrome_constrained_window_views_client.h"
6 6
7 #include "chrome/browser/platform_util.h" 7 #include "chrome/browser/platform_util.h"
8 #include "chrome/browser/ui/browser_finder.h" 8 #include "chrome/browser/ui/browser_finder.h"
9 #include "components/web_modal/web_contents_modal_dialog_host.h" 9 #include "components/web_modal/web_contents_modal_dialog_host.h"
10 #include "extensions/browser/guest_view/guest_view_base.h" 10 #include "extensions/browser/guest_view/guest_view_base.h"
11 11
12 namespace { 12 namespace {
13 13
14 class ChromeConstrainedWindowViewsClient 14 class ChromeConstrainedWindowViewsClient
15 : public constrained_window::ConstrainedWindowViewsClient { 15 : public constrained_window::ConstrainedWindowViewsClient {
16 public: 16 public:
17 ChromeConstrainedWindowViewsClient() {} 17 ChromeConstrainedWindowViewsClient() {}
18 ~ChromeConstrainedWindowViewsClient() override {} 18 ~ChromeConstrainedWindowViewsClient() override {}
19 19
20 private: 20 private:
21 // ConstrainedWindowViewsClient: 21 // ConstrainedWindowViewsClient:
22 content::WebContents* GetEmbedderWebContents( 22 content::WebContents* GetEmbedderWebContents(
23 content::WebContents* initiator_web_contents) override { 23 content::WebContents* initiator_web_contents) override {
24 extensions::GuestViewBase* guest_view = 24 // |initiator_web_contents| may be embedded within a chain of nested
25 extensions::GuestViewBase::FromWebContents(initiator_web_contents); 25 // GuestViews. If it is, follow the chain of embedders to the outermost
26 return guest_view && guest_view->embedder_web_contents() ? 26 // WebContents and return it.
27 guest_view->embedder_web_contents() : initiator_web_contents; 27 while (extensions::GuestViewBase* guest_view =
28 extensions::GuestViewBase::FromWebContents(
29 initiator_web_contents)) {
30 if (!guest_view->embedder_web_contents())
31 break;
32 initiator_web_contents = guest_view->embedder_web_contents();
33 }
34 return initiator_web_contents;
28 } 35 }
29 web_modal::ModalDialogHost* GetModalDialogHost( 36 web_modal::ModalDialogHost* GetModalDialogHost(
30 gfx::NativeWindow parent) override { 37 gfx::NativeWindow parent) override {
31 // Get the browser dialog management and hosting components from |parent|. 38 // Get the browser dialog management and hosting components from |parent|.
32 Browser* browser = chrome::FindBrowserWithWindow(parent); 39 Browser* browser = chrome::FindBrowserWithWindow(parent);
33 if (browser) { 40 if (browser) {
34 ChromeWebModalDialogManagerDelegate* manager = browser; 41 ChromeWebModalDialogManagerDelegate* manager = browser;
35 return manager->GetWebContentsModalDialogHost(); 42 return manager->GetWebContentsModalDialogHost();
36 } 43 }
37 return nullptr; 44 return nullptr;
38 } 45 }
39 gfx::NativeView GetDialogHostView(gfx::NativeWindow parent) override { 46 gfx::NativeView GetDialogHostView(gfx::NativeWindow parent) override {
40 return platform_util::GetViewForWindow(parent); 47 return platform_util::GetViewForWindow(parent);
41 } 48 }
42 49
43 DISALLOW_COPY_AND_ASSIGN(ChromeConstrainedWindowViewsClient); 50 DISALLOW_COPY_AND_ASSIGN(ChromeConstrainedWindowViewsClient);
44 }; 51 };
45 52
46 } // namespace 53 } // namespace
47 54
48 scoped_ptr<constrained_window::ConstrainedWindowViewsClient> 55 scoped_ptr<constrained_window::ConstrainedWindowViewsClient>
49 CreateChromeConstrainedWindowViewsClient() { 56 CreateChromeConstrainedWindowViewsClient() {
50 return make_scoped_ptr(new ChromeConstrainedWindowViewsClient); 57 return make_scoped_ptr(new ChromeConstrainedWindowViewsClient);
51 } 58 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698