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/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
9 #include "chrome/browser/sessions/session_tab_helper.h" | 9 #include "chrome/browser/sessions/session_tab_helper.h" |
10 #include "chrome/common/url_constants.h" | 10 #include "chrome/common/url_constants.h" |
11 #include "chrome/grit/chromium_strings.h" | 11 #include "chrome/grit/chromium_strings.h" |
| 12 #include "components/signin/core/common/profile_management_switches.h" |
12 #include "content/public/browser/render_frame_host.h" | 13 #include "content/public/browser/render_frame_host.h" |
13 #include "content/public/browser/web_ui.h" | 14 #include "content/public/browser/web_ui.h" |
14 #include "content/public/browser/web_ui_data_source.h" | 15 #include "content/public/browser/web_ui_data_source.h" |
15 #include "grit/browser_resources.h" | 16 #include "grit/browser_resources.h" |
16 #if defined(OS_CHROMEOS) | 17 #if defined(OS_CHROMEOS) |
17 #include "chrome/browser/ui/webui/chromeos/login/inline_login_handler_chromeos.h
" | 18 #include "chrome/browser/ui/webui/chromeos/login/inline_login_handler_chromeos.h
" |
18 #else | 19 #else |
19 #include "chrome/browser/ui/webui/signin/inline_login_handler_impl.h" | 20 #include "chrome/browser/ui/webui/signin/inline_login_handler_impl.h" |
20 #endif | 21 #endif |
21 | 22 |
22 namespace { | 23 namespace { |
23 | 24 |
24 content::WebUIDataSource* CreateWebUIDataSource() { | 25 content::WebUIDataSource* CreateWebUIDataSource() { |
25 content::WebUIDataSource* source = | 26 content::WebUIDataSource* source = |
26 content::WebUIDataSource::Create(chrome::kChromeUIChromeSigninHost); | 27 content::WebUIDataSource::Create(chrome::kChromeUIChromeSigninHost); |
27 source->OverrideContentSecurityPolicyFrameSrc("frame-src chrome-extension:;"); | 28 source->OverrideContentSecurityPolicyFrameSrc("frame-src chrome-extension:;"); |
28 source->OverrideContentSecurityPolicyObjectSrc("object-src *;"); | 29 source->OverrideContentSecurityPolicyObjectSrc("object-src *;"); |
29 source->SetJsonPath("strings.js"); | 30 source->SetJsonPath("strings.js"); |
30 | 31 |
31 source->SetDefaultResource(IDR_INLINE_LOGIN_HTML); | 32 bool is_webview_signin_enabled = switches::IsEnableWebviewBasedSignin(); |
| 33 source->SetDefaultResource(is_webview_signin_enabled ? |
| 34 IDR_NEW_INLINE_LOGIN_HTML : IDR_INLINE_LOGIN_HTML); |
32 source->AddResourcePath("inline_login.css", IDR_INLINE_LOGIN_CSS); | 35 source->AddResourcePath("inline_login.css", IDR_INLINE_LOGIN_CSS); |
33 source->AddResourcePath("inline_login.js", IDR_INLINE_LOGIN_JS); | 36 source->AddResourcePath("inline_login.js", IDR_INLINE_LOGIN_JS); |
| 37 source->AddResourcePath("gaia_auth_host.js", is_webview_signin_enabled ? |
| 38 IDR_GAIA_AUTH_AUTHENTICATOR_JS : IDR_GAIA_AUTH_HOST_JS); |
34 | 39 |
35 source->AddLocalizedString("title", IDS_CHROME_SIGNIN_TITLE); | 40 source->AddLocalizedString("title", IDS_CHROME_SIGNIN_TITLE); |
36 return source; | 41 return source; |
37 } | 42 } |
38 | 43 |
39 void AddToSetIfIsAuthIframe(std::set<content::RenderFrameHost*>* frame_set, | 44 void AddToSetIfIsAuthIframe(std::set<content::RenderFrameHost*>* frame_set, |
40 const GURL& parent_origin, | 45 const GURL& parent_origin, |
41 const std::string& parent_frame_name, | 46 const std::string& parent_frame_name, |
42 content::RenderFrameHost* frame) { | 47 content::RenderFrameHost* frame) { |
43 content::RenderFrameHost* parent = frame->GetParent(); | 48 content::RenderFrameHost* parent = frame->GetParent(); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 std::set<content::RenderFrameHost*> frame_set; | 88 std::set<content::RenderFrameHost*> frame_set; |
84 web_contents->ForEachFrame( | 89 web_contents->ForEachFrame( |
85 base::Bind(&AddToSetIfIsAuthIframe, &frame_set, | 90 base::Bind(&AddToSetIfIsAuthIframe, &frame_set, |
86 parent_origin, parent_frame_name)); | 91 parent_origin, parent_frame_name)); |
87 DCHECK_GE(1U, frame_set.size()); | 92 DCHECK_GE(1U, frame_set.size()); |
88 if (!frame_set.empty()) | 93 if (!frame_set.empty()) |
89 return *frame_set.begin(); | 94 return *frame_set.begin(); |
90 | 95 |
91 return NULL; | 96 return NULL; |
92 } | 97 } |
OLD | NEW |