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

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

Issue 1350073002: PDFs viewed inside a <webview> should navigate the same as PDFs in tabs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Pass boolean instead of tabId. Created 5 years, 2 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 1217 matching lines...) Expand 10 before | Expand all | Expand 10 after
1228 *was_blocked = false; 1228 *was_blocked = false;
1229 RequestNewWindowPermission(disposition, 1229 RequestNewWindowPermission(disposition,
1230 initial_rect, 1230 initial_rect,
1231 user_gesture, 1231 user_gesture,
1232 new_contents); 1232 new_contents);
1233 } 1233 }
1234 1234
1235 WebContents* WebViewGuest::OpenURLFromTab( 1235 WebContents* WebViewGuest::OpenURLFromTab(
1236 WebContents* source, 1236 WebContents* source,
1237 const content::OpenURLParams& params) { 1237 const content::OpenURLParams& params) {
1238 // There are two use cases to consider from a security perspective: 1238 // Most navigations should be handled by WebViewGuest::LoadURLWithParams,
1239 // 1.) Renderer-initiated navigation to chrome:// must always be blocked even 1239 // which takes care of blocking chrome:// URLs and other web-unsafe schemes.
1240 // if the <webview> is in WebUI. This is handled by 1240 // (NavigateGuest and CreateNewGuestWebViewWindow also go through
1241 // WebViewGuest::LoadURLWithParams. WebViewGuest::NavigateGuest will also 1241 // LoadURLWithParams.)
1242 // call LoadURLWithParams. CreateNewGuestWebViewWindow creates a new 1242 //
1243 // WebViewGuest which will call NavigateGuest in DidInitialize. 1243 // We make an exception here for context menu items, since the Language
1244 // 2.) The Language Settings context menu item should always work, both in 1244 // Settings item uses a browser-initiated navigation to a chrome:// URL.
1245 // Chrome Apps and WebUI. This is a browser initiated request and so 1245 // These can be passed to the embedder's WebContentsDelegate so that the
1246 // we pass it along to the embedder's WebContentsDelegate to get the 1246 // browser performs the action for the <webview>. Navigations to a new
1247 // browser to perform the action for the <webview>. 1247 // tab, etc., are also handled by the WebContentsDelegate.
1248 if (!params.is_renderer_initiated) { 1248 if (!params.is_renderer_initiated &&
1249 (!content::ChildProcessSecurityPolicy::GetInstance()->IsWebSafeScheme(
1250 params.url.scheme()) ||
1251 params.disposition != CURRENT_TAB)) {
1249 if (!owner_web_contents()->GetDelegate()) 1252 if (!owner_web_contents()->GetDelegate())
1250 return nullptr; 1253 return nullptr;
1251 return owner_web_contents()->GetDelegate()->OpenURLFromTab( 1254 return owner_web_contents()->GetDelegate()->OpenURLFromTab(
1252 owner_web_contents(), params); 1255 owner_web_contents(), params);
1253 } 1256 }
1254 1257
1255 if (!attached()) { 1258 if (!attached()) {
1256 WebViewGuest* opener = GetOpener(); 1259 WebViewGuest* opener = GetOpener();
1257 // If the guest wishes to navigate away prior to attachment then we save the 1260 // If the guest wishes to navigate away prior to attachment then we save the
1258 // navigation to perform upon attachment. Navigation initializes a lot of 1261 // navigation to perform upon attachment. Navigation initializes a lot of
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
1481 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); 1484 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue());
1482 DispatchEventToView( 1485 DispatchEventToView(
1483 new GuestViewEvent(webview::kEventExitFullscreen, args.Pass())); 1486 new GuestViewEvent(webview::kEventExitFullscreen, args.Pass()));
1484 } 1487 }
1485 // Since we changed fullscreen state, sending a Resize message ensures that 1488 // Since we changed fullscreen state, sending a Resize message ensures that
1486 // renderer/ sees the change. 1489 // renderer/ sees the change.
1487 web_contents()->GetRenderViewHost()->WasResized(); 1490 web_contents()->GetRenderViewHost()->WasResized();
1488 } 1491 }
1489 1492
1490 } // namespace extensions 1493 } // namespace extensions
OLDNEW
« chrome/browser/resources/pdf/pdf.js ('K') | « chrome/browser/resources/pdf/pdf.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698