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/ui/webui/signin/inline_login_ui.h" | 5 #include "chrome/browser/ui/webui/signin/inline_login_ui.h" |
6 | 6 |
7 #include "chrome/browser/extensions/chrome_extension_web_contents_observer.h" | 7 #include "chrome/browser/extensions/chrome_extension_web_contents_observer.h" |
8 #include "chrome/browser/extensions/tab_helper.h" | 8 #include "chrome/browser/extensions/tab_helper.h" |
9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
10 #include "chrome/browser/sessions/session_tab_helper.h" | 10 #include "chrome/browser/sessions/session_tab_helper.h" |
11 #include "chrome/common/url_constants.h" | 11 #include "chrome/common/url_constants.h" |
12 #include "chrome/grit/chromium_strings.h" | 12 #include "chrome/grit/chromium_strings.h" |
13 #include "components/signin/core/common/profile_management_switches.h" | 13 #include "components/signin/core/common/profile_management_switches.h" |
14 #include "content/public/browser/render_frame_host.h" | 14 #include "content/public/browser/render_frame_host.h" |
15 #include "content/public/browser/web_ui.h" | 15 #include "content/public/browser/web_ui.h" |
16 #include "content/public/browser/web_ui_data_source.h" | 16 #include "content/public/browser/web_ui_data_source.h" |
| 17 #include "extensions/browser/guest_view/guest_view_manager.h" |
17 #include "grit/browser_resources.h" | 18 #include "grit/browser_resources.h" |
18 #if defined(OS_CHROMEOS) | 19 #if defined(OS_CHROMEOS) |
19 #include "chrome/browser/ui/webui/chromeos/login/inline_login_handler_chromeos.h
" | 20 #include "chrome/browser/ui/webui/chromeos/login/inline_login_handler_chromeos.h
" |
20 #else | 21 #else |
21 #include "chrome/browser/ui/webui/signin/inline_login_handler_impl.h" | 22 #include "chrome/browser/ui/webui/signin/inline_login_handler_impl.h" |
22 #endif | 23 #endif |
23 | 24 |
24 namespace { | 25 namespace { |
25 | 26 |
26 content::WebUIDataSource* CreateWebUIDataSource() { | 27 content::WebUIDataSource* CreateWebUIDataSource() { |
(...skipping 20 matching lines...) Expand all Loading... |
47 const std::string& parent_frame_name, | 48 const std::string& parent_frame_name, |
48 content::RenderFrameHost* frame) { | 49 content::RenderFrameHost* frame) { |
49 content::RenderFrameHost* parent = frame->GetParent(); | 50 content::RenderFrameHost* parent = frame->GetParent(); |
50 if (parent && parent->GetFrameName() == parent_frame_name && | 51 if (parent && parent->GetFrameName() == parent_frame_name && |
51 (parent_origin.is_empty() || | 52 (parent_origin.is_empty() || |
52 parent->GetLastCommittedURL().GetOrigin() == parent_origin)) { | 53 parent->GetLastCommittedURL().GetOrigin() == parent_origin)) { |
53 frame_set->insert(frame); | 54 frame_set->insert(frame); |
54 } | 55 } |
55 } | 56 } |
56 | 57 |
| 58 bool AddToSetIfSigninWebview(std::set<content::RenderFrameHost*>* frame_set, |
| 59 content::WebContents* web_contents) { |
| 60 frame_set->insert(web_contents->GetMainFrame()); |
| 61 return false; |
| 62 } |
| 63 |
57 } // empty namespace | 64 } // empty namespace |
58 | 65 |
59 InlineLoginUI::InlineLoginUI(content::WebUI* web_ui) | 66 InlineLoginUI::InlineLoginUI(content::WebUI* web_ui) |
60 : WebDialogUI(web_ui), | 67 : WebDialogUI(web_ui), |
61 auth_extension_(Profile::FromWebUI(web_ui)) { | 68 auth_extension_(Profile::FromWebUI(web_ui)) { |
62 Profile* profile = Profile::FromWebUI(web_ui); | 69 Profile* profile = Profile::FromWebUI(web_ui); |
63 content::WebUIDataSource::Add(profile, CreateWebUIDataSource()); | 70 content::WebUIDataSource::Add(profile, CreateWebUIDataSource()); |
64 | 71 |
65 #if defined(OS_CHROMEOS) | 72 #if defined(OS_CHROMEOS) |
66 web_ui->AddMessageHandler(new chromeos::InlineLoginHandlerChromeOS()); | 73 web_ui->AddMessageHandler(new chromeos::InlineLoginHandlerChromeOS()); |
(...skipping 14 matching lines...) Expand all Loading... |
81 } | 88 } |
82 | 89 |
83 InlineLoginUI::~InlineLoginUI() {} | 90 InlineLoginUI::~InlineLoginUI() {} |
84 | 91 |
85 // Gets the Gaia iframe within a WebContents. | 92 // Gets the Gaia iframe within a WebContents. |
86 content::RenderFrameHost* InlineLoginUI::GetAuthIframe( | 93 content::RenderFrameHost* InlineLoginUI::GetAuthIframe( |
87 content::WebContents* web_contents, | 94 content::WebContents* web_contents, |
88 const GURL& parent_origin, | 95 const GURL& parent_origin, |
89 const std::string& parent_frame_name) { | 96 const std::string& parent_frame_name) { |
90 std::set<content::RenderFrameHost*> frame_set; | 97 std::set<content::RenderFrameHost*> frame_set; |
91 web_contents->ForEachFrame( | 98 if (switches::IsEnableWebviewBasedSignin()) { |
92 base::Bind(&AddToSetIfIsAuthIframe, &frame_set, | 99 extensions::GuestViewManager* manager = |
93 parent_origin, parent_frame_name)); | 100 extensions::GuestViewManager::FromBrowserContext( |
| 101 web_contents->GetBrowserContext()); |
| 102 manager->ForEachGuest(web_contents, |
| 103 base::Bind(&AddToSetIfSigninWebview, &frame_set)); |
| 104 } else { |
| 105 web_contents->ForEachFrame( |
| 106 base::Bind(&AddToSetIfIsAuthIframe, &frame_set, |
| 107 parent_origin, parent_frame_name)); |
| 108 } |
94 DCHECK_GE(1U, frame_set.size()); | 109 DCHECK_GE(1U, frame_set.size()); |
95 if (!frame_set.empty()) | 110 if (!frame_set.empty()) |
96 return *frame_set.begin(); | 111 return *frame_set.begin(); |
97 | 112 |
98 return NULL; | 113 return NULL; |
99 } | 114 } |
OLD | NEW |