OLD | NEW |
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 Loading... |
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 // |
| 353 // Do not store preference on file:// URLs, they don't have a clean |
| 354 // origin policy. |
| 355 // TODO(estark): Revisit this when crbug.com/455882 is fixed. |
| 356 if (!requester.SchemeIsFile() && !embedder.SchemeIsFile() && |
| 357 primary_pattern.IsValid() && secondary_pattern.IsValid()) { |
351 HostContentSettingsMap* settings_map = | 358 HostContentSettingsMap* settings_map = |
352 profile()->GetHostContentSettingsMap(); | 359 profile()->GetHostContentSettingsMap(); |
353 settings_map->SetContentSetting( | 360 settings_map->SetContentSetting( |
354 primary_pattern, secondary_pattern, CONTENT_SETTINGS_TYPE_FULLSCREEN, | 361 primary_pattern, secondary_pattern, CONTENT_SETTINGS_TYPE_FULLSCREEN, |
355 std::string(), CONTENT_SETTING_ALLOW); | 362 std::string(), CONTENT_SETTING_ALLOW); |
356 } | 363 } |
357 tab_fullscreen_accepted_ = true; | 364 tab_fullscreen_accepted_ = true; |
358 return true; | 365 return true; |
359 } | 366 } |
360 | 367 |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
495 extension_caused_fullscreen_ = GURL(); | 502 extension_caused_fullscreen_ = GURL(); |
496 | 503 |
497 exclusive_access_manager()->UpdateExclusiveAccessExitBubbleContent(); | 504 exclusive_access_manager()->UpdateExclusiveAccessExitBubbleContent(); |
498 } | 505 } |
499 | 506 |
500 ContentSetting FullscreenController::GetFullscreenSetting() const { | 507 ContentSetting FullscreenController::GetFullscreenSetting() const { |
501 DCHECK(exclusive_access_tab()); | 508 DCHECK(exclusive_access_tab()); |
502 | 509 |
503 GURL url = GetRequestingOrigin(); | 510 GURL url = GetRequestingOrigin(); |
504 | 511 |
505 if (IsPrivilegedFullscreenForTab() || url.SchemeIsFile()) | 512 // Always ask on file:// URLs, since we can't meaningfully make the |
| 513 // decision stick for a particular origin. |
| 514 // TODO(estark): Revisit this when crbug.com/455882 is fixed. |
| 515 if (url.SchemeIsFile()) |
| 516 return CONTENT_SETTING_ASK; |
| 517 |
| 518 if (IsPrivilegedFullscreenForTab()) |
506 return CONTENT_SETTING_ALLOW; | 519 return CONTENT_SETTING_ALLOW; |
507 | 520 |
508 // If the permission was granted to the website with no embedder, it should | 521 // If the permission was granted to the website with no embedder, it should |
509 // always be allowed, even if embedded. | 522 // always be allowed, even if embedded. |
510 if (profile()->GetHostContentSettingsMap()->GetContentSetting( | 523 if (profile()->GetHostContentSettingsMap()->GetContentSetting( |
511 url, url, CONTENT_SETTINGS_TYPE_FULLSCREEN, std::string()) == | 524 url, url, CONTENT_SETTINGS_TYPE_FULLSCREEN, std::string()) == |
512 CONTENT_SETTING_ALLOW) { | 525 CONTENT_SETTING_ALLOW) { |
513 return CONTENT_SETTING_ALLOW; | 526 return CONTENT_SETTING_ALLOW; |
514 } | 527 } |
515 | 528 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
573 return fullscreened_origin_; | 586 return fullscreened_origin_; |
574 | 587 |
575 return exclusive_access_tab()->GetLastCommittedURL(); | 588 return exclusive_access_tab()->GetLastCommittedURL(); |
576 } | 589 } |
577 | 590 |
578 GURL FullscreenController::GetEmbeddingOrigin() const { | 591 GURL FullscreenController::GetEmbeddingOrigin() const { |
579 DCHECK(exclusive_access_tab()); | 592 DCHECK(exclusive_access_tab()); |
580 | 593 |
581 return exclusive_access_tab()->GetLastCommittedURL(); | 594 return exclusive_access_tab()->GetLastCommittedURL(); |
582 } | 595 } |
OLD | NEW |