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

Side by Side Diff: chrome/browser/ui/exclusive_access/fullscreen_controller.cc

Issue 903683005: Always prompt for permission on fullscreen and mouse lock on file:// URLs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add unit test for permissions menu for fullscreen/mouse lock on file:// 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/exclusive_access/fullscreen_controller.h" 5 #include "chrome/browser/ui/exclusive_access/fullscreen_controller.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "chrome/browser/app_mode/app_mode_utils.h" 10 #include "chrome/browser/app_mode/app_mode_utils.h"
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 // embedder. Thus, even if a requesting origin has been previously approved 333 // embedder. Thus, even if a requesting origin has been previously approved
334 // for embedder A, it will not be approved when embedded in a different 334 // for embedder A, it will not be approved when embedded in a different
335 // origin B. 335 // origin B.
336 // 336 //
337 // However, an exception is made when a requester and an embedder are the 337 // However, an exception is made when a requester and an embedder are the
338 // same origin. In other words, if the requester is the top-level frame. If 338 // same origin. In other words, if the requester is the top-level frame. If
339 // that combination is ALLOWED, then future requests from that origin will 339 // that combination is ALLOWED, then future requests from that origin will
340 // succeed no matter what the embedder is. For example, if youtube.com 340 // succeed no matter what the embedder is. For example, if youtube.com
341 // is visited and user selects ALLOW. Later user visits example.com which 341 // is visited and user selects ALLOW. Later user visits example.com which
342 // embeds youtube.com in an iframe, which is then ALLOWED to go fullscreen. 342 // embeds youtube.com in an iframe, which is then ALLOWED to go fullscreen.
343 GURL requester = GetRequestingOrigin();
344 GURL embedder = GetEmbeddingOrigin();
343 ContentSettingsPattern primary_pattern = 345 ContentSettingsPattern primary_pattern =
344 ContentSettingsPattern::FromURLNoWildcard(GetRequestingOrigin()); 346 ContentSettingsPattern::FromURLNoWildcard(requester);
345 ContentSettingsPattern secondary_pattern = 347 ContentSettingsPattern secondary_pattern =
346 ContentSettingsPattern::FromURLNoWildcard(GetEmbeddingOrigin()); 348 ContentSettingsPattern::FromURLNoWildcard(embedder);
347 349
348 // ContentSettings requires valid patterns and the patterns might be invalid 350 // ContentSettings requires valid patterns and the patterns might be invalid
349 // in some edge cases like if the current frame is about:blank. 351 // in some edge cases like if the current frame is about:blank.
350 if (primary_pattern.IsValid() && secondary_pattern.IsValid()) { 352 if (!requester.SchemeIsFile() && !embedder.SchemeIsFile() &&
scheib 2015/02/11 16:48:34 Add comment along lines of: "Do not store preferen
estark 2015/02/11 21:21:58 Done.
353 primary_pattern.IsValid() && secondary_pattern.IsValid()) {
351 HostContentSettingsMap* settings_map = 354 HostContentSettingsMap* settings_map =
352 profile()->GetHostContentSettingsMap(); 355 profile()->GetHostContentSettingsMap();
353 settings_map->SetContentSetting( 356 settings_map->SetContentSetting(
354 primary_pattern, secondary_pattern, CONTENT_SETTINGS_TYPE_FULLSCREEN, 357 primary_pattern, secondary_pattern, CONTENT_SETTINGS_TYPE_FULLSCREEN,
355 std::string(), CONTENT_SETTING_ALLOW); 358 std::string(), CONTENT_SETTING_ALLOW);
356 } 359 }
357 tab_fullscreen_accepted_ = true; 360 tab_fullscreen_accepted_ = true;
358 return true; 361 return true;
359 } 362 }
360 363
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 extension_caused_fullscreen_ = GURL(); 498 extension_caused_fullscreen_ = GURL();
496 499
497 exclusive_access_manager()->UpdateExclusiveAccessExitBubbleContent(); 500 exclusive_access_manager()->UpdateExclusiveAccessExitBubbleContent();
498 } 501 }
499 502
500 ContentSetting FullscreenController::GetFullscreenSetting() const { 503 ContentSetting FullscreenController::GetFullscreenSetting() const {
501 DCHECK(exclusive_access_tab()); 504 DCHECK(exclusive_access_tab());
502 505
503 GURL url = GetRequestingOrigin(); 506 GURL url = GetRequestingOrigin();
504 507
505 if (IsPrivilegedFullscreenForTab() || url.SchemeIsFile()) 508 // Always ask on file:// URLs, since we can't meaningfully make the
509 // decision stick for a particular origin.
510 // TODO(estark): Revisit this when crbug.com/455882 is fixed.
511 if (url.SchemeIsFile())
512 return CONTENT_SETTING_ASK;
513
514 if (IsPrivilegedFullscreenForTab())
506 return CONTENT_SETTING_ALLOW; 515 return CONTENT_SETTING_ALLOW;
507 516
508 // If the permission was granted to the website with no embedder, it should 517 // If the permission was granted to the website with no embedder, it should
509 // always be allowed, even if embedded. 518 // always be allowed, even if embedded.
510 if (profile()->GetHostContentSettingsMap()->GetContentSetting( 519 if (profile()->GetHostContentSettingsMap()->GetContentSetting(
511 url, url, CONTENT_SETTINGS_TYPE_FULLSCREEN, std::string()) == 520 url, url, CONTENT_SETTINGS_TYPE_FULLSCREEN, std::string()) ==
512 CONTENT_SETTING_ALLOW) { 521 CONTENT_SETTING_ALLOW) {
513 return CONTENT_SETTING_ALLOW; 522 return CONTENT_SETTING_ALLOW;
514 } 523 }
515 524
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
573 return fullscreened_origin_; 582 return fullscreened_origin_;
574 583
575 return exclusive_access_tab()->GetLastCommittedURL(); 584 return exclusive_access_tab()->GetLastCommittedURL();
576 } 585 }
577 586
578 GURL FullscreenController::GetEmbeddingOrigin() const { 587 GURL FullscreenController::GetEmbeddingOrigin() const {
579 DCHECK(exclusive_access_tab()); 588 DCHECK(exclusive_access_tab());
580 589
581 return exclusive_access_tab()->GetLastCommittedURL(); 590 return exclusive_access_tab()->GetLastCommittedURL();
582 } 591 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698