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

Side by Side Diff: extensions/browser/guest_view/web_view/web_view_guest.cc

Issue 890183002: Allow Signin page to open other chrome:// URLs if login content in <webview> (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added a test Created 5 years, 10 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 | « chrome/browser/apps/guest_view/web_view_browsertest.cc ('k') | 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 "extensions/browser/guest_view/web_view/web_view_guest.h" 5 #include "extensions/browser/guest_view/web_view/web_view_guest.h"
6 6
7 #include "base/message_loop/message_loop.h" 7 #include "base/message_loop/message_loop.h"
8 #include "base/strings/stringprintf.h" 8 #include "base/strings/stringprintf.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "content/public/browser/browser_context.h" 10 #include "content/public/browser/browser_context.h"
(...skipping 1100 matching lines...) Expand 10 before | Expand all | Expand 10 after
1111 *was_blocked = false; 1111 *was_blocked = false;
1112 RequestNewWindowPermission(disposition, 1112 RequestNewWindowPermission(disposition,
1113 initial_rect, 1113 initial_rect,
1114 user_gesture, 1114 user_gesture,
1115 new_contents); 1115 new_contents);
1116 } 1116 }
1117 1117
1118 content::WebContents* WebViewGuest::OpenURLFromTab( 1118 content::WebContents* WebViewGuest::OpenURLFromTab(
1119 content::WebContents* source, 1119 content::WebContents* source,
1120 const content::OpenURLParams& params) { 1120 const content::OpenURLParams& params) {
1121 // There are two use cases to consider from a security perspective:
1122 // 1.) Renderer-initiated nav to chrome:// must always be blocked even if
1123 // the <webview> is in WebUI. This is handled by
1124 // WebViewGuest::NavigateGuest.
Charlie Reis 2015/02/18 22:32:06 nit: It's not obvious how we get to NavigateGuest.
1125 // 2.) The Language Settings context menu item should always work, both in
1126 // Chrome Apps and WebUI. This is a browser initiated request and so
1127 // we pass it along to the embedder's WebContentsDelegate to get the
1128 // browser to perform the action for the <webview>.
1129 if (!params.is_renderer_initiated) {
1130 if (!owner_web_contents()->GetDelegate())
1131 return nullptr;
1132 return owner_web_contents()->GetDelegate()->OpenURLFromTab(
1133 owner_web_contents(), params);
1134 }
1135
1121 // If the guest wishes to navigate away prior to attachment then we save the 1136 // If the guest wishes to navigate away prior to attachment then we save the
1122 // navigation to perform upon attachment. Navigation initializes a lot of 1137 // navigation to perform upon attachment. Navigation initializes a lot of
1123 // state that assumes an embedder exists, such as RenderWidgetHostViewGuest. 1138 // state that assumes an embedder exists, such as RenderWidgetHostViewGuest.
1124 // Navigation also resumes resource loading which we don't want to allow 1139 // Navigation also resumes resource loading which we don't want to allow
1125 // until attachment. 1140 // until attachment.
1126 if (!attached()) { 1141 if (!attached()) {
1127 WebViewGuest* opener = GetOpener(); 1142 WebViewGuest* opener = GetOpener();
1128 auto it = opener->pending_new_windows_.find(this); 1143 auto it = opener->pending_new_windows_.find(this);
1129 if (it == opener->pending_new_windows_.end()) 1144 if (it == opener->pending_new_windows_.end())
1130 return nullptr; 1145 return nullptr;
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
1232 WebViewGuest::From(owner_web_contents()->GetRenderProcessHost()->GetID(), 1247 WebViewGuest::From(owner_web_contents()->GetRenderProcessHost()->GetID(),
1233 new_window_instance_id); 1248 new_window_instance_id);
1234 if (!guest) 1249 if (!guest)
1235 return; 1250 return;
1236 1251
1237 if (!allow) 1252 if (!allow)
1238 guest->Destroy(); 1253 guest->Destroy();
1239 } 1254 }
1240 1255
1241 } // namespace extensions 1256 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/apps/guest_view/web_view_browsertest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698