Chromium Code Reviews| 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/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
| 11 #include "base/thread_task_runner_handle.h" | 11 #include "base/thread_task_runner_handle.h" |
| 12 #include "chrome/browser/app_mode/app_mode_utils.h" | 12 #include "chrome/browser/app_mode/app_mode_utils.h" |
| 13 #include "chrome/browser/chrome_notification_types.h" | 13 #include "chrome/browser/chrome_notification_types.h" |
| 14 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" | 14 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" |
| 15 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
| 16 #include "chrome/browser/ui/exclusive_access/exclusive_access_context.h" | 16 #include "chrome/browser/ui/exclusive_access/exclusive_access_context.h" |
| 17 #include "chrome/browser/ui/exclusive_access/exclusive_access_manager.h" | 17 #include "chrome/browser/ui/exclusive_access/exclusive_access_manager.h" |
| 18 #include "chrome/browser/ui/exclusive_access/fullscreen_within_tab_helper.h" | 18 #include "chrome/browser/ui/exclusive_access/fullscreen_within_tab_helper.h" |
| 19 #include "chrome/browser/ui/status_bubble.h" | 19 #include "chrome/browser/ui/status_bubble.h" |
| 20 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 20 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 21 #include "chrome/browser/ui/web_contents_sizer.h" | 21 #include "chrome/browser/ui/web_contents_sizer.h" |
| 22 #include "chrome/common/chrome_switches.h" | 22 #include "chrome/common/chrome_switches.h" |
| 23 #include "components/content_settings/core/browser/host_content_settings_map.h" | 23 #include "components/content_settings/core/browser/host_content_settings_map.h" |
| 24 #include "content/public/browser/navigation_details.h" | 24 #include "content/public/browser/navigation_details.h" |
| 25 #include "content/public/browser/navigation_entry.h" | 25 #include "content/public/browser/navigation_entry.h" |
| 26 #include "content/public/browser/notification_service.h" | 26 #include "content/public/browser/notification_service.h" |
| 27 #include "content/public/browser/render_view_host.h" | 27 #include "content/public/browser/render_view_host.h" |
| 28 #include "content/public/browser/render_widget_host.h" | |
| 28 #include "content/public/browser/render_widget_host_view.h" | 29 #include "content/public/browser/render_widget_host_view.h" |
| 29 #include "content/public/browser/user_metrics.h" | 30 #include "content/public/browser/user_metrics.h" |
| 30 #include "content/public/browser/web_contents.h" | 31 #include "content/public/browser/web_contents.h" |
| 31 #include "extensions/common/extension.h" | 32 #include "extensions/common/extension.h" |
| 32 | 33 |
| 33 #if !defined(OS_MACOSX) | 34 #if !defined(OS_MACOSX) |
| 34 #include "base/prefs/pref_service.h" | 35 #include "base/prefs/pref_service.h" |
| 35 #include "chrome/common/pref_names.h" | 36 #include "chrome/common/pref_names.h" |
| 36 #endif | 37 #endif |
| 37 | 38 |
| 38 using base::UserMetricsAction; | 39 using base::UserMetricsAction; |
| 39 using content::RenderViewHost; | 40 using content::RenderViewHost; |
| 41 using content::RenderWidgetHost; | |
| 42 using content::RenderWidgetHostView; | |
| 40 using content::WebContents; | 43 using content::WebContents; |
| 41 | 44 |
| 42 FullscreenController::FullscreenController(ExclusiveAccessManager* manager) | 45 FullscreenController::FullscreenController(ExclusiveAccessManager* manager) |
| 43 : ExclusiveAccessControllerBase(manager), | 46 : ExclusiveAccessControllerBase(manager), |
| 44 state_prior_to_tab_fullscreen_(STATE_INVALID), | 47 state_prior_to_tab_fullscreen_(STATE_INVALID), |
| 45 tab_fullscreen_accepted_(false), | 48 tab_fullscreen_accepted_(false), |
| 46 toggled_into_fullscreen_(false), | 49 toggled_into_fullscreen_(false), |
| 47 reentrant_window_state_change_call_check_(false), | 50 reentrant_window_state_change_call_check_(false), |
| 48 is_privileged_fullscreen_for_testing_(false), | 51 is_privileged_fullscreen_for_testing_(false), |
| 49 ptr_factory_(this) { | 52 ptr_factory_(this) { |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 211 // If currently there is a tab in "tab fullscreen" mode and fullscreen | 214 // If currently there is a tab in "tab fullscreen" mode and fullscreen |
| 212 // was not caused by it (i.e., previously it was in "browser fullscreen" | 215 // was not caused by it (i.e., previously it was in "browser fullscreen" |
| 213 // mode), we need to switch back to "browser fullscreen" mode. In this | 216 // mode), we need to switch back to "browser fullscreen" mode. In this |
| 214 // case, all we have to do is notifying the tab that it has exited "tab | 217 // case, all we have to do is notifying the tab that it has exited "tab |
| 215 // fullscreen" mode. | 218 // fullscreen" mode. |
| 216 NotifyTabExclusiveAccessLost(); | 219 NotifyTabExclusiveAccessLost(); |
| 217 | 220 |
| 218 // This is only a change between Browser and Tab fullscreen. We generate | 221 // This is only a change between Browser and Tab fullscreen. We generate |
| 219 // a fullscreen notification now because there is no window change. | 222 // a fullscreen notification now because there is no window change. |
| 220 PostFullscreenChangeNotification(true); | 223 PostFullscreenChangeNotification(true); |
| 224 | |
| 225 // Ensure web contents exit fullscreen state by sending a resize message, | |
|
scheib
2015/12/01 00:30:18
I'm a bit wondering why this isn't part of ::Notif
bokan
2015/12/01 20:46:10
I rarely dwell in these parts so it's entirely lik
| |
| 226 // which includes the fullscreen state. This is required for the situation | |
| 227 // of the browser moving the view into a fullscreen state "browser fullscreen" | |
| 228 // and then the contents entering "tab fullscreen". Exiting the contents | |
| 229 // "tab fullscreen" then won't have the side effect of the view resizing, | |
| 230 // hence the explicit call here is required. | |
| 231 if (RenderWidgetHostView* rwhv = web_contents->GetRenderWidgetHostView()) { | |
| 232 if (RenderWidgetHost* render_widget_host = rwhv->GetRenderWidgetHost()) | |
| 233 render_widget_host->WasResized(); | |
| 234 } | |
| 221 } | 235 } |
| 222 | 236 |
| 223 #if defined(OS_WIN) | 237 #if defined(OS_WIN) |
| 224 bool FullscreenController::IsInMetroSnapMode() { | 238 bool FullscreenController::IsInMetroSnapMode() { |
| 225 return exclusive_access_manager()->context()->IsInMetroSnapMode(); | 239 return exclusive_access_manager()->context()->IsInMetroSnapMode(); |
| 226 } | 240 } |
| 227 | 241 |
| 228 void FullscreenController::SetMetroSnapMode(bool enable) { | 242 void FullscreenController::SetMetroSnapMode(bool enable) { |
| 229 reentrant_window_state_change_call_check_ = false; | 243 reentrant_window_state_change_call_check_ = false; |
| 230 | 244 |
| (...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 596 return fullscreened_origin_; | 610 return fullscreened_origin_; |
| 597 | 611 |
| 598 return exclusive_access_tab()->GetLastCommittedURL(); | 612 return exclusive_access_tab()->GetLastCommittedURL(); |
| 599 } | 613 } |
| 600 | 614 |
| 601 GURL FullscreenController::GetEmbeddingOrigin() const { | 615 GURL FullscreenController::GetEmbeddingOrigin() const { |
| 602 DCHECK(exclusive_access_tab()); | 616 DCHECK(exclusive_access_tab()); |
| 603 | 617 |
| 604 return exclusive_access_tab()->GetLastCommittedURL(); | 618 return exclusive_access_tab()->GetLastCommittedURL(); |
| 605 } | 619 } |
| OLD | NEW |