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/location.h" | 9 #include "base/location.h" |
| 10 #include "base/metrics/histogram_macros.h" |
10 #include "base/single_thread_task_runner.h" | 11 #include "base/single_thread_task_runner.h" |
11 #include "base/thread_task_runner_handle.h" | 12 #include "base/thread_task_runner_handle.h" |
12 #include "build/build_config.h" | 13 #include "build/build_config.h" |
13 #include "chrome/browser/app_mode/app_mode_utils.h" | 14 #include "chrome/browser/app_mode/app_mode_utils.h" |
14 #include "chrome/browser/chrome_notification_types.h" | 15 #include "chrome/browser/chrome_notification_types.h" |
15 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" | 16 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" |
16 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
17 #include "chrome/browser/ui/exclusive_access/exclusive_access_context.h" | 18 #include "chrome/browser/ui/exclusive_access/exclusive_access_context.h" |
18 #include "chrome/browser/ui/exclusive_access/exclusive_access_manager.h" | 19 #include "chrome/browser/ui/exclusive_access/exclusive_access_manager.h" |
19 #include "chrome/browser/ui/exclusive_access/fullscreen_within_tab_helper.h" | 20 #include "chrome/browser/ui/exclusive_access/fullscreen_within_tab_helper.h" |
(...skipping 13 matching lines...) Expand all Loading... |
33 | 34 |
34 #if !defined(OS_MACOSX) | 35 #if !defined(OS_MACOSX) |
35 #include "chrome/common/pref_names.h" | 36 #include "chrome/common/pref_names.h" |
36 #include "components/prefs/pref_service.h" | 37 #include "components/prefs/pref_service.h" |
37 #endif | 38 #endif |
38 | 39 |
39 using base::UserMetricsAction; | 40 using base::UserMetricsAction; |
40 using content::RenderViewHost; | 41 using content::RenderViewHost; |
41 using content::WebContents; | 42 using content::WebContents; |
42 | 43 |
| 44 namespace { |
| 45 |
| 46 const char kBubbleReshowsHistogramName[] = |
| 47 "ExclusiveAccess.BubbleReshowsPerSession.Fullscreen"; |
| 48 |
| 49 } // namespace |
| 50 |
43 FullscreenController::FullscreenController(ExclusiveAccessManager* manager) | 51 FullscreenController::FullscreenController(ExclusiveAccessManager* manager) |
44 : ExclusiveAccessControllerBase(manager), | 52 : ExclusiveAccessControllerBase(manager), |
45 state_prior_to_tab_fullscreen_(STATE_INVALID), | 53 state_prior_to_tab_fullscreen_(STATE_INVALID), |
46 tab_fullscreen_accepted_(false), | 54 tab_fullscreen_accepted_(false), |
47 toggled_into_fullscreen_(false), | 55 toggled_into_fullscreen_(false), |
48 reentrant_window_state_change_call_check_(false), | 56 reentrant_window_state_change_call_check_(false), |
49 is_privileged_fullscreen_for_testing_(false), | 57 is_privileged_fullscreen_for_testing_(false), |
50 ptr_factory_(this) { | 58 ptr_factory_(this) { |
51 } | 59 } |
52 | 60 |
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
413 SetTabWithExclusiveAccess(nullptr); | 421 SetTabWithExclusiveAccess(nullptr); |
414 fullscreened_origin_ = GURL(); | 422 fullscreened_origin_ = GURL(); |
415 bool will_cause_resize = IsFullscreenCausedByTab(); | 423 bool will_cause_resize = IsFullscreenCausedByTab(); |
416 state_prior_to_tab_fullscreen_ = STATE_INVALID; | 424 state_prior_to_tab_fullscreen_ = STATE_INVALID; |
417 tab_fullscreen_accepted_ = false; | 425 tab_fullscreen_accepted_ = false; |
418 web_contents->ExitFullscreen(will_cause_resize); | 426 web_contents->ExitFullscreen(will_cause_resize); |
419 exclusive_access_manager()->UpdateExclusiveAccessExitBubbleContent(); | 427 exclusive_access_manager()->UpdateExclusiveAccessExitBubbleContent(); |
420 } | 428 } |
421 } | 429 } |
422 | 430 |
| 431 void FullscreenController::RecordBubbleReshowsHistogram( |
| 432 int bubble_reshow_count) { |
| 433 UMA_HISTOGRAM_COUNTS_100(kBubbleReshowsHistogramName, bubble_reshow_count); |
| 434 } |
| 435 |
423 void FullscreenController::ToggleFullscreenModeInternal( | 436 void FullscreenController::ToggleFullscreenModeInternal( |
424 FullscreenInternalOption option) { | 437 FullscreenInternalOption option) { |
425 #if defined(OS_WIN) | 438 #if defined(OS_WIN) |
426 // When in Metro snap mode, toggling in and out of fullscreen is prevented. | 439 // When in Metro snap mode, toggling in and out of fullscreen is prevented. |
427 if (IsInMetroSnapMode()) | 440 if (IsInMetroSnapMode()) |
428 return; | 441 return; |
429 #endif | 442 #endif |
430 | 443 |
431 ExclusiveAccessContext* const exclusive_access_context = | 444 ExclusiveAccessContext* const exclusive_access_context = |
432 exclusive_access_manager()->context(); | 445 exclusive_access_manager()->context(); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
492 | 505 |
493 exclusive_access_manager()->UpdateExclusiveAccessExitBubbleContent(); | 506 exclusive_access_manager()->UpdateExclusiveAccessExitBubbleContent(); |
494 | 507 |
495 // Once the window has become fullscreen it'll call back to | 508 // Once the window has become fullscreen it'll call back to |
496 // WindowFullscreenStateChanged(). We don't do this immediately as | 509 // WindowFullscreenStateChanged(). We don't do this immediately as |
497 // BrowserWindow::EnterFullscreen() asks for bookmark_bar_state_, so we let | 510 // BrowserWindow::EnterFullscreen() asks for bookmark_bar_state_, so we let |
498 // the BrowserWindow invoke WindowFullscreenStateChanged when appropriate. | 511 // the BrowserWindow invoke WindowFullscreenStateChanged when appropriate. |
499 } | 512 } |
500 | 513 |
501 void FullscreenController::ExitFullscreenModeInternal() { | 514 void FullscreenController::ExitFullscreenModeInternal() { |
| 515 RecordExitingUMA(); |
502 toggled_into_fullscreen_ = false; | 516 toggled_into_fullscreen_ = false; |
503 #if defined(OS_MACOSX) | 517 #if defined(OS_MACOSX) |
504 // Mac windows report a state change instantly, and so we must also clear | 518 // Mac windows report a state change instantly, and so we must also clear |
505 // state_prior_to_tab_fullscreen_ to match them else other logic using | 519 // state_prior_to_tab_fullscreen_ to match them else other logic using |
506 // state_prior_to_tab_fullscreen_ will be incorrect. | 520 // state_prior_to_tab_fullscreen_ will be incorrect. |
507 NotifyTabExclusiveAccessLost(); | 521 NotifyTabExclusiveAccessLost(); |
508 #endif | 522 #endif |
509 exclusive_access_manager()->context()->ExitFullscreen(); | 523 exclusive_access_manager()->context()->ExitFullscreen(); |
510 extension_caused_fullscreen_ = GURL(); | 524 extension_caused_fullscreen_ = GURL(); |
511 | 525 |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
602 return fullscreened_origin_; | 616 return fullscreened_origin_; |
603 | 617 |
604 return exclusive_access_tab()->GetLastCommittedURL(); | 618 return exclusive_access_tab()->GetLastCommittedURL(); |
605 } | 619 } |
606 | 620 |
607 GURL FullscreenController::GetEmbeddingOrigin() const { | 621 GURL FullscreenController::GetEmbeddingOrigin() const { |
608 DCHECK(exclusive_access_tab()); | 622 DCHECK(exclusive_access_tab()); |
609 | 623 |
610 return exclusive_access_tab()->GetLastCommittedURL(); | 624 return exclusive_access_tab()->GetLastCommittedURL(); |
611 } | 625 } |
OLD | NEW |