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

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

Issue 2004353002: Delete unused code for exclusive access permission prompting. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@fullscreen-mac-remove-window-controller
Patch Set: Remove changes to content settings UI (spun out to CL 2045163002). Created 4 years, 6 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/location.h" 9 #include "base/location.h"
10 #include "base/metrics/histogram_macros.h" 10 #include "base/metrics/histogram_macros.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 namespace { 44 namespace {
45 45
46 const char kBubbleReshowsHistogramName[] = 46 const char kBubbleReshowsHistogramName[] =
47 "ExclusiveAccess.BubbleReshowsPerSession.Fullscreen"; 47 "ExclusiveAccess.BubbleReshowsPerSession.Fullscreen";
48 48
49 } // namespace 49 } // namespace
50 50
51 FullscreenController::FullscreenController(ExclusiveAccessManager* manager) 51 FullscreenController::FullscreenController(ExclusiveAccessManager* manager)
52 : ExclusiveAccessControllerBase(manager), 52 : ExclusiveAccessControllerBase(manager),
53 state_prior_to_tab_fullscreen_(STATE_INVALID), 53 state_prior_to_tab_fullscreen_(STATE_INVALID),
54 tab_fullscreen_accepted_(false), 54 tab_fullscreen_(false),
55 toggled_into_fullscreen_(false), 55 toggled_into_fullscreen_(false),
56 reentrant_window_state_change_call_check_(false), 56 reentrant_window_state_change_call_check_(false),
57 is_privileged_fullscreen_for_testing_(false), 57 is_privileged_fullscreen_for_testing_(false),
58 ptr_factory_(this) { 58 ptr_factory_(this) {
59 } 59 }
60 60
61 FullscreenController::~FullscreenController() { 61 FullscreenController::~FullscreenController() {
62 } 62 }
63 63
64 bool FullscreenController::IsFullscreenForBrowser() const { 64 bool FullscreenController::IsFullscreenForBrowser() const {
(...skipping 23 matching lines...) Expand all
88 } 88 }
89 89
90 bool FullscreenController::IsExtensionFullscreenOrPending() const { 90 bool FullscreenController::IsExtensionFullscreenOrPending() const {
91 return !extension_caused_fullscreen_.is_empty(); 91 return !extension_caused_fullscreen_.is_empty();
92 } 92 }
93 93
94 bool FullscreenController::IsControllerInitiatedFullscreen() const { 94 bool FullscreenController::IsControllerInitiatedFullscreen() const {
95 return toggled_into_fullscreen_; 95 return toggled_into_fullscreen_;
96 } 96 }
97 97
98 bool FullscreenController::IsUserAcceptedFullscreen() const { 98 bool FullscreenController::IsTabFullscreen() const {
99 return tab_fullscreen_accepted_; 99 return tab_fullscreen_;
100 } 100 }
101 101
102 bool FullscreenController::IsFullscreenForTabOrPending( 102 bool FullscreenController::IsFullscreenForTabOrPending(
103 const WebContents* web_contents) const { 103 const WebContents* web_contents) const {
104 if (IsFullscreenForCapturedTab(web_contents)) 104 if (IsFullscreenForCapturedTab(web_contents))
105 return true; 105 return true;
106 if (web_contents == exclusive_access_tab()) { 106 if (web_contents == exclusive_access_tab()) {
107 DCHECK(web_contents == 107 DCHECK(web_contents ==
108 exclusive_access_manager()->context()->GetActiveWebContents()); 108 exclusive_access_manager()->context()->GetActiveWebContents());
109 return true; 109 return true;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 // Browser Fullscreen with Toolbar -> Tab Fullscreen (no toolbar). 148 // Browser Fullscreen with Toolbar -> Tab Fullscreen (no toolbar).
149 exclusive_access_context->UpdateFullscreenWithToolbar(false); 149 exclusive_access_context->UpdateFullscreenWithToolbar(false);
150 state_prior_to_tab_fullscreen_ = STATE_BROWSER_FULLSCREEN_WITH_TOOLBAR; 150 state_prior_to_tab_fullscreen_ = STATE_BROWSER_FULLSCREEN_WITH_TOOLBAR;
151 } else { 151 } else {
152 // Browser Fullscreen without Toolbar -> Tab Fullscreen. 152 // Browser Fullscreen without Toolbar -> Tab Fullscreen.
153 state_prior_to_tab_fullscreen_ = STATE_BROWSER_FULLSCREEN_NO_TOOLBAR; 153 state_prior_to_tab_fullscreen_ = STATE_BROWSER_FULLSCREEN_NO_TOOLBAR;
154 } 154 }
155 155
156 // We need to update the fullscreen exit bubble, e.g., going from browser 156 // We need to update the fullscreen exit bubble, e.g., going from browser
157 // fullscreen to tab fullscreen will need to show different content. 157 // fullscreen to tab fullscreen will need to show different content.
158 if (!tab_fullscreen_accepted_) { 158 tab_fullscreen_ = true;
159 tab_fullscreen_accepted_ = GetFullscreenSetting() == CONTENT_SETTING_ALLOW;
160 }
161 exclusive_access_manager()->UpdateExclusiveAccessExitBubbleContent(); 159 exclusive_access_manager()->UpdateExclusiveAccessExitBubbleContent();
162 160
163 // This is only a change between Browser and Tab fullscreen. We generate 161 // This is only a change between Browser and Tab fullscreen. We generate
164 // a fullscreen notification now because there is no window change. 162 // a fullscreen notification now because there is no window change.
165 PostFullscreenChangeNotification(true); 163 PostFullscreenChangeNotification(true);
166 } 164 }
167 165
168 void FullscreenController::ExitFullscreenModeForTab(WebContents* web_contents) { 166 void FullscreenController::ExitFullscreenModeForTab(WebContents* web_contents) {
169 if (MaybeToggleFullscreenForCapturedTab(web_contents, false)) { 167 if (MaybeToggleFullscreenForCapturedTab(web_contents, false)) {
170 // During tab capture of fullscreen-within-tab views, the browser window 168 // During tab capture of fullscreen-within-tab views, the browser window
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 return true; 283 return true;
286 } 284 }
287 285
288 void FullscreenController::ExitExclusiveAccessToPreviousState() { 286 void FullscreenController::ExitExclusiveAccessToPreviousState() {
289 if (IsWindowFullscreenForTabOrPending()) 287 if (IsWindowFullscreenForTabOrPending())
290 ExitFullscreenModeForTab(exclusive_access_tab()); 288 ExitFullscreenModeForTab(exclusive_access_tab());
291 else if (IsFullscreenForBrowser()) 289 else if (IsFullscreenForBrowser())
292 ExitFullscreenModeInternal(); 290 ExitFullscreenModeInternal();
293 } 291 }
294 292
295 bool FullscreenController::OnAcceptExclusiveAccessPermission() {
296 ExclusiveAccessBubbleType bubble_type =
297 exclusive_access_manager()->GetExclusiveAccessExitBubbleType();
298 bool fullscreen = false;
299 exclusive_access_bubble::PermissionRequestedByType(bubble_type, &fullscreen,
300 nullptr);
301 DCHECK(!(fullscreen && tab_fullscreen_accepted_));
302
303 if (fullscreen && !tab_fullscreen_accepted_) {
304 DCHECK(exclusive_access_tab());
305 // Origins can enter fullscreen even when embedded in other origins.
306 // Permission is tracked based on the combinations of requester and
307 // embedder. Thus, even if a requesting origin has been previously approved
308 // for embedder A, it will not be approved when embedded in a different
309 // origin B.
310 //
311 // However, an exception is made when a requester and an embedder are the
312 // same origin. In other words, if the requester is the top-level frame. If
313 // that combination is ALLOWED, then future requests from that origin will
314 // succeed no matter what the embedder is. For example, if youtube.com
315 // is visited and user selects ALLOW. Later user visits example.com which
316 // embeds youtube.com in an iframe, which is then ALLOWED to go fullscreen.
317 GURL requester = GetRequestingOrigin();
318 GURL embedder = GetEmbeddingOrigin();
319
320 // Do not store preference on file:// URLs, they don't have a clean
321 // origin policy.
322 // TODO(estark): Revisit this when crbug.com/455882 is fixed.
323 if (!requester.SchemeIsFile() && !embedder.SchemeIsFile()) {
324 HostContentSettingsMap* settings_map =
325 HostContentSettingsMapFactory::GetForProfile(
326 exclusive_access_manager()->context()->GetProfile());
327 settings_map->SetContentSettingDefaultScope(
328 requester, embedder, CONTENT_SETTINGS_TYPE_FULLSCREEN, std::string(),
329 CONTENT_SETTING_ALLOW);
330 }
331 tab_fullscreen_accepted_ = true;
332 return true;
333 }
334
335 return false;
336 }
337
338 bool FullscreenController::OnDenyExclusiveAccessPermission() {
339 if (IsWindowFullscreenForTabOrPending()) {
340 ExitExclusiveAccessIfNecessary();
341 return true;
342 }
343
344 return false;
345 }
346
347 GURL FullscreenController::GetURLForExclusiveAccessBubble() const { 293 GURL FullscreenController::GetURLForExclusiveAccessBubble() const {
348 if (exclusive_access_tab()) 294 if (exclusive_access_tab())
349 return GetRequestingOrigin(); 295 return GetRequestingOrigin();
350 return extension_caused_fullscreen_; 296 return extension_caused_fullscreen_;
351 } 297 }
352 298
353 void FullscreenController::ExitExclusiveAccessIfNecessary() { 299 void FullscreenController::ExitExclusiveAccessIfNecessary() {
354 if (IsWindowFullscreenForTabOrPending()) 300 if (IsWindowFullscreenForTabOrPending())
355 ExitFullscreenModeForTab(exclusive_access_tab()); 301 ExitFullscreenModeForTab(exclusive_access_tab());
356 else 302 else
(...skipping 14 matching lines...) Expand all
371 content::Details<bool>(&is_fullscreen)); 317 content::Details<bool>(&is_fullscreen));
372 } 318 }
373 319
374 void FullscreenController::NotifyTabExclusiveAccessLost() { 320 void FullscreenController::NotifyTabExclusiveAccessLost() {
375 if (exclusive_access_tab()) { 321 if (exclusive_access_tab()) {
376 WebContents* web_contents = exclusive_access_tab(); 322 WebContents* web_contents = exclusive_access_tab();
377 SetTabWithExclusiveAccess(nullptr); 323 SetTabWithExclusiveAccess(nullptr);
378 fullscreened_origin_ = GURL(); 324 fullscreened_origin_ = GURL();
379 bool will_cause_resize = IsFullscreenCausedByTab(); 325 bool will_cause_resize = IsFullscreenCausedByTab();
380 state_prior_to_tab_fullscreen_ = STATE_INVALID; 326 state_prior_to_tab_fullscreen_ = STATE_INVALID;
381 tab_fullscreen_accepted_ = false; 327 tab_fullscreen_ = false;
382 web_contents->ExitFullscreen(will_cause_resize); 328 web_contents->ExitFullscreen(will_cause_resize);
383 exclusive_access_manager()->UpdateExclusiveAccessExitBubbleContent(); 329 exclusive_access_manager()->UpdateExclusiveAccessExitBubbleContent();
384 } 330 }
385 } 331 }
386 332
387 void FullscreenController::RecordBubbleReshowsHistogram( 333 void FullscreenController::RecordBubbleReshowsHistogram(
388 int bubble_reshow_count) { 334 int bubble_reshow_count) {
389 UMA_HISTOGRAM_COUNTS_100(kBubbleReshowsHistogramName, bubble_reshow_count); 335 UMA_HISTOGRAM_COUNTS_100(kBubbleReshowsHistogramName, bubble_reshow_count);
390 } 336 }
391 337
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 else 377 else
432 ExitFullscreenModeInternal(); 378 ExitFullscreenModeInternal();
433 } 379 }
434 380
435 void FullscreenController::EnterFullscreenModeInternal( 381 void FullscreenController::EnterFullscreenModeInternal(
436 FullscreenInternalOption option) { 382 FullscreenInternalOption option) {
437 toggled_into_fullscreen_ = true; 383 toggled_into_fullscreen_ = true;
438 GURL url; 384 GURL url;
439 if (option == TAB) { 385 if (option == TAB) {
440 url = GetRequestingOrigin(); 386 url = GetRequestingOrigin();
441 tab_fullscreen_accepted_ = GetFullscreenSetting() == CONTENT_SETTING_ALLOW; 387 tab_fullscreen_ = true;
442 } else { 388 } else {
443 if (!extension_caused_fullscreen_.is_empty()) 389 if (!extension_caused_fullscreen_.is_empty())
444 url = extension_caused_fullscreen_; 390 url = extension_caused_fullscreen_;
445 } 391 }
446 392
447 if (option == BROWSER) 393 if (option == BROWSER)
448 content::RecordAction(UserMetricsAction("ToggleFullscreen")); 394 content::RecordAction(UserMetricsAction("ToggleFullscreen"));
449 // TODO(scheib): Record metrics for WITH_TOOLBAR, without counting transitions 395 // TODO(scheib): Record metrics for WITH_TOOLBAR, without counting transitions
450 // from tab fullscreen out to browser with toolbar. 396 // from tab fullscreen out to browser with toolbar.
451 397
(...skipping 17 matching lines...) Expand all
469 // state_prior_to_tab_fullscreen_ to match them else other logic using 415 // state_prior_to_tab_fullscreen_ to match them else other logic using
470 // state_prior_to_tab_fullscreen_ will be incorrect. 416 // state_prior_to_tab_fullscreen_ will be incorrect.
471 NotifyTabExclusiveAccessLost(); 417 NotifyTabExclusiveAccessLost();
472 #endif 418 #endif
473 exclusive_access_manager()->context()->ExitFullscreen(); 419 exclusive_access_manager()->context()->ExitFullscreen();
474 extension_caused_fullscreen_ = GURL(); 420 extension_caused_fullscreen_ = GURL();
475 421
476 exclusive_access_manager()->UpdateExclusiveAccessExitBubbleContent(); 422 exclusive_access_manager()->UpdateExclusiveAccessExitBubbleContent();
477 } 423 }
478 424
479 ContentSetting FullscreenController::GetFullscreenSetting() const {
480 // The new policy is to always allow (even if the flag is disabled).
481 // TODO(mgiuca): Remove this function and clean up callers
482 // (https://crbug.com/610900).
483 return CONTENT_SETTING_ALLOW;
484 }
485
486 bool FullscreenController::IsPrivilegedFullscreenForTab() const { 425 bool FullscreenController::IsPrivilegedFullscreenForTab() const {
487 const bool embedded_widget_present = 426 const bool embedded_widget_present =
488 exclusive_access_tab() && 427 exclusive_access_tab() &&
489 exclusive_access_tab()->GetFullscreenRenderWidgetHostView(); 428 exclusive_access_tab()->GetFullscreenRenderWidgetHostView();
490 return embedded_widget_present || is_privileged_fullscreen_for_testing_; 429 return embedded_widget_present || is_privileged_fullscreen_for_testing_;
491 } 430 }
492 431
493 void FullscreenController::SetPrivilegedFullscreenForTesting( 432 void FullscreenController::SetPrivilegedFullscreenForTesting(
494 bool is_privileged) { 433 bool is_privileged) {
495 is_privileged_fullscreen_for_testing_ = is_privileged; 434 is_privileged_fullscreen_for_testing_ = is_privileged;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
536 return fullscreened_origin_; 475 return fullscreened_origin_;
537 476
538 return exclusive_access_tab()->GetLastCommittedURL(); 477 return exclusive_access_tab()->GetLastCommittedURL();
539 } 478 }
540 479
541 GURL FullscreenController::GetEmbeddingOrigin() const { 480 GURL FullscreenController::GetEmbeddingOrigin() const {
542 DCHECK(exclusive_access_tab()); 481 DCHECK(exclusive_access_tab());
543 482
544 return exclusive_access_tab()->GetLastCommittedURL(); 483 return exclusive_access_tab()->GetLastCommittedURL();
545 } 484 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698