| Index: chrome/browser/ui/webui/signin/get_auth_frame.cc
|
| diff --git a/chrome/browser/ui/webui/signin/get_auth_frame.cc b/chrome/browser/ui/webui/signin/get_auth_frame.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..f5705a299978da8b6e019b339a5c9d7edd28903a
|
| --- /dev/null
|
| +++ b/chrome/browser/ui/webui/signin/get_auth_frame.cc
|
| @@ -0,0 +1,54 @@
|
| +// Copyright 2016 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "chrome/browser/ui/webui/signin/get_auth_frame.h"
|
| +
|
| +#include <set>
|
| +
|
| +#include "base/bind.h"
|
| +#include "components/guest_view/browser/guest_view_manager.h"
|
| +#include "content/public/browser/web_contents.h"
|
| +#include "extensions/browser/guest_view/web_view/web_view_guest.h"
|
| +
|
| +namespace {
|
| +
|
| +bool AddWebContentsToSet(std::set<content::WebContents*>* frame_set,
|
| + const std::string& web_view_name,
|
| + content::WebContents* web_contents) {
|
| + auto* web_view = extensions::WebViewGuest::FromWebContents(web_contents);
|
| + if (web_view && web_view->name() == web_view_name)
|
| + frame_set->insert(web_contents);
|
| + return false;
|
| +}
|
| +
|
| +} // namespace
|
| +
|
| +namespace signin {
|
| +
|
| +content::RenderFrameHost* GetAuthFrame(content::WebContents* web_contents,
|
| + const std::string& parent_frame_name) {
|
| + content::WebContents* auth_web_contents =
|
| + GetAuthFrameWebContents(web_contents, parent_frame_name);
|
| + return auth_web_contents ? auth_web_contents->GetMainFrame() : nullptr;
|
| +}
|
| +
|
| +content::WebContents* GetAuthFrameWebContents(
|
| + content::WebContents* web_contents,
|
| + const std::string& parent_frame_name) {
|
| + std::set<content::WebContents*> frame_set;
|
| + auto* manager = guest_view::GuestViewManager::FromBrowserContext(
|
| + web_contents->GetBrowserContext());
|
| + if (manager) {
|
| + manager->ForEachGuest(
|
| + web_contents,
|
| + base::Bind(&AddWebContentsToSet, &frame_set, parent_frame_name));
|
| + }
|
| + DCHECK_GE(1U, frame_set.size());
|
| + if (!frame_set.empty())
|
| + return *frame_set.begin();
|
| +
|
| + return nullptr;
|
| +}
|
| +
|
| +} // namespace signin
|
|
|