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

Side by Side Diff: chrome/browser/ui/webui/signin/inline_login_ui.cc

Issue 1412453002: Remove enable-iframe-based-signin flag. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use nullptr Created 5 years 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
OLDNEW
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 "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/files/file_util.h" 8 #include "base/files/file_util.h"
9 #include "base/path_service.h" 9 #include "base/path_service.h"
10 #include "base/strings/string_split.h" 10 #include "base/strings/string_split.h"
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 return true; 55 return true;
56 } 56 }
57 57
58 content::WebUIDataSource* CreateWebUIDataSource() { 58 content::WebUIDataSource* CreateWebUIDataSource() {
59 content::WebUIDataSource* source = 59 content::WebUIDataSource* source =
60 content::WebUIDataSource::Create(chrome::kChromeUIChromeSigninHost); 60 content::WebUIDataSource::Create(chrome::kChromeUIChromeSigninHost);
61 source->OverrideContentSecurityPolicyFrameSrc("frame-src chrome-extension:;"); 61 source->OverrideContentSecurityPolicyFrameSrc("frame-src chrome-extension:;");
62 source->OverrideContentSecurityPolicyObjectSrc("object-src *;"); 62 source->OverrideContentSecurityPolicyObjectSrc("object-src *;");
63 source->SetJsonPath("strings.js"); 63 source->SetJsonPath("strings.js");
64 64
65 bool is_webview_signin_enabled = switches::IsEnableWebviewBasedSignin(); 65 source->SetDefaultResource(IDR_NEW_INLINE_LOGIN_HTML);
66 source->SetDefaultResource(is_webview_signin_enabled ?
67 IDR_NEW_INLINE_LOGIN_HTML : IDR_INLINE_LOGIN_HTML);
68 66
69 // Only add a filter when runing as test. 67 // Only add a filter when runing as test.
70 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); 68 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
71 const bool is_running_test = command_line->HasSwitch(::switches::kTestName) || 69 const bool is_running_test = command_line->HasSwitch(::switches::kTestName) ||
72 command_line->HasSwitch(::switches::kTestType); 70 command_line->HasSwitch(::switches::kTestType);
73 if (is_running_test) 71 if (is_running_test)
74 source->SetRequestFilter(base::Bind(&HandleTestFileRequestCallback)); 72 source->SetRequestFilter(base::Bind(&HandleTestFileRequestCallback));
75 73
76 source->AddResourcePath("inline_login.css", IDR_INLINE_LOGIN_CSS); 74 source->AddResourcePath("inline_login.css", IDR_INLINE_LOGIN_CSS);
77 source->AddResourcePath("inline_login.js", IDR_INLINE_LOGIN_JS); 75 source->AddResourcePath("inline_login.js", IDR_INLINE_LOGIN_JS);
78 source->AddResourcePath("gaia_auth_host.js", is_webview_signin_enabled ? 76 source->AddResourcePath("gaia_auth_host.js", IDR_GAIA_AUTH_AUTHENTICATOR_JS);
79 IDR_GAIA_AUTH_AUTHENTICATOR_JS : IDR_GAIA_AUTH_HOST_JS);
80 77
81 source->AddLocalizedString("title", IDS_CHROME_SIGNIN_TITLE); 78 source->AddLocalizedString("title", IDS_CHROME_SIGNIN_TITLE);
82 return source; 79 return source;
83 } 80 }
84 81
85 void AddToSetIfIsAuthIframe(std::set<content::RenderFrameHost*>* frame_set, 82 bool AddToSet(std::set<content::RenderFrameHost*>* frame_set,
86 const GURL& parent_origin, 83 const std::string& web_view_name,
87 const std::string& parent_frame_name, 84 content::WebContents* web_contents) {
88 content::RenderFrameHost* frame) {
89 content::RenderFrameHost* parent = frame->GetParent();
90 if (parent && parent->GetFrameName() == parent_frame_name &&
91 (parent_origin.is_empty() ||
92 parent->GetLastCommittedURL().GetOrigin() == parent_origin)) {
93 frame_set->insert(frame);
94 }
95 }
96
97 bool AddToSetIfSigninWebview(std::set<content::RenderFrameHost*>* frame_set,
98 const std::string& web_view_name,
99 content::WebContents* web_contents) {
100 auto* web_view = extensions::WebViewGuest::FromWebContents(web_contents); 85 auto* web_view = extensions::WebViewGuest::FromWebContents(web_contents);
101 if (web_view && web_view->name() == web_view_name) 86 if (web_view && web_view->name() == web_view_name)
102 frame_set->insert(web_contents->GetMainFrame()); 87 frame_set->insert(web_contents->GetMainFrame());
103 return false; 88 return false;
104 } 89 }
105 90
106 } // empty namespace 91 } // empty namespace
107 92
108 InlineLoginUI::InlineLoginUI(content::WebUI* web_ui) 93 InlineLoginUI::InlineLoginUI(content::WebUI* web_ui)
109 : WebDialogUI(web_ui), 94 : WebDialogUI(web_ui),
(...skipping 20 matching lines...) Expand all
130 } 115 }
131 116
132 InlineLoginUI::~InlineLoginUI() {} 117 InlineLoginUI::~InlineLoginUI() {}
133 118
134 // Gets the Gaia iframe within a WebContents. 119 // Gets the Gaia iframe within a WebContents.
135 content::RenderFrameHost* InlineLoginUI::GetAuthFrame( 120 content::RenderFrameHost* InlineLoginUI::GetAuthFrame(
136 content::WebContents* web_contents, 121 content::WebContents* web_contents,
137 const GURL& parent_origin, 122 const GURL& parent_origin,
138 const std::string& parent_frame_name) { 123 const std::string& parent_frame_name) {
139 std::set<content::RenderFrameHost*> frame_set; 124 std::set<content::RenderFrameHost*> frame_set;
140 bool is_webview = switches::IsEnableWebviewBasedSignin(); 125 auto* manager =
141 #if defined(OS_CHROMEOS) 126 guest_view::GuestViewManager::FromBrowserContext(
142 is_webview = is_webview || chromeos::StartupUtils::IsWebviewSigninEnabled(); 127 web_contents->GetBrowserContext());
143 #endif 128 if (manager) {
144 if (is_webview) { 129 manager->ForEachGuest(web_contents,
145 guest_view::GuestViewManager* manager = 130 base::Bind(&AddToSet, &frame_set, parent_frame_name));
146 guest_view::GuestViewManager::FromBrowserContext(
147 web_contents->GetBrowserContext());
148 if (manager) {
149 manager->ForEachGuest(
150 web_contents,
151 base::Bind(&AddToSetIfSigninWebview, &frame_set, parent_frame_name));
152 }
153 } else {
154 web_contents->ForEachFrame(
155 base::Bind(&AddToSetIfIsAuthIframe, &frame_set,
156 parent_origin, parent_frame_name));
157 } 131 }
158 DCHECK_GE(1U, frame_set.size()); 132 DCHECK_GE(1U, frame_set.size());
159 if (!frame_set.empty()) 133 if (!frame_set.empty())
160 return *frame_set.begin(); 134 return *frame_set.begin();
161 135
162 return NULL; 136 return nullptr;
163 } 137 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698