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

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

Issue 1234403005: Don't refer browser-initiated navigations to web-safe URLs to delegate. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 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
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 "components/browsing_data/storage_partition_http_cache_data_remover.h" 10 #include "components/browsing_data/storage_partition_http_cache_data_remover.h"
(...skipping 1205 matching lines...) Expand 10 before | Expand all | Expand 10 after
1216 // There are two use cases to consider from a security perspective: 1216 // There are two use cases to consider from a security perspective:
1217 // 1.) Renderer-initiated navigation to chrome:// must always be blocked even 1217 // 1.) Renderer-initiated navigation to chrome:// must always be blocked even
1218 // if the <webview> is in WebUI. This is handled by 1218 // if the <webview> is in WebUI. This is handled by
1219 // WebViewGuest::LoadURLWithParams. WebViewGuest::NavigateGuest will also 1219 // WebViewGuest::LoadURLWithParams. WebViewGuest::NavigateGuest will also
1220 // call LoadURLWithParams. CreateNewGuestWebViewWindow creates a new 1220 // call LoadURLWithParams. CreateNewGuestWebViewWindow creates a new
1221 // WebViewGuest which will call NavigateGuest in DidInitialize. 1221 // WebViewGuest which will call NavigateGuest in DidInitialize.
1222 // 2.) The Language Settings context menu item should always work, both in 1222 // 2.) The Language Settings context menu item should always work, both in
1223 // Chrome Apps and WebUI. This is a browser initiated request and so 1223 // Chrome Apps and WebUI. This is a browser initiated request and so
1224 // we pass it along to the embedder's WebContentsDelegate to get the 1224 // we pass it along to the embedder's WebContentsDelegate to get the
1225 // browser to perform the action for the <webview>. 1225 // browser to perform the action for the <webview>.
1226 if (!params.is_renderer_initiated) { 1226 // However, browser-initiated navigations (e.g. from extensions) to web-safe
1227 // urls should not be referred to the delegate, which may block them.
Charlie Reis 2015/07/17 00:05:15 I feel like this code is getting very difficult to
wjmaclean 2015/07/17 01:29:46 Yes, that was my conclusion, though I didn't think
1228 if (!params.is_renderer_initiated &&
1229 !content::ChildProcessSecurityPolicy::GetInstance()->IsWebSafeScheme(
1230 params.url.scheme())) {
1227 if (!owner_web_contents()->GetDelegate()) 1231 if (!owner_web_contents()->GetDelegate())
1228 return nullptr; 1232 return nullptr;
1229 return owner_web_contents()->GetDelegate()->OpenURLFromTab( 1233 return owner_web_contents()->GetDelegate()->OpenURLFromTab(
1230 owner_web_contents(), params); 1234 owner_web_contents(), params);
1231 } 1235 }
1232 1236
1233 // If the guest wishes to navigate away prior to attachment then we save the 1237 // If the guest wishes to navigate away prior to attachment then we save the
1234 // navigation to perform upon attachment. Navigation initializes a lot of 1238 // navigation to perform upon attachment. Navigation initializes a lot of
1235 // state that assumes an embedder exists, such as RenderWidgetHostViewGuest. 1239 // state that assumes an embedder exists, such as RenderWidgetHostViewGuest.
1236 // Navigation also resumes resource loading which we don't want to allow 1240 // Navigation also resumes resource loading which we don't want to allow
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
1450 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); 1454 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue());
1451 DispatchEventToView( 1455 DispatchEventToView(
1452 new GuestViewEvent(webview::kEventExitFullscreen, args.Pass())); 1456 new GuestViewEvent(webview::kEventExitFullscreen, args.Pass()));
1453 } 1457 }
1454 // Since we changed fullscreen state, sending a Resize message ensures that 1458 // Since we changed fullscreen state, sending a Resize message ensures that
1455 // renderer/ sees the change. 1459 // renderer/ sees the change.
1456 web_contents()->GetRenderViewHost()->WasResized(); 1460 web_contents()->GetRenderViewHost()->WasResized();
1457 } 1461 }
1458 1462
1459 } // namespace extensions 1463 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698