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/fullscreen/fullscreen_controller.h" | 5 #include "chrome/browser/ui/fullscreen/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.h" | 9 #include "base/message_loop.h" |
10 #include "chrome/browser/content_settings/host_content_settings_map.h" | 10 #include "chrome/browser/content_settings/host_content_settings_map.h" |
11 #include "chrome/browser/download/download_shelf.h" | 11 #include "chrome/browser/download/download_shelf.h" |
12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
13 #include "chrome/browser/ui/browser.h" | 13 #include "chrome/browser/ui/browser.h" |
14 #include "chrome/browser/ui/browser_tabstrip.h" | 14 #include "chrome/browser/ui/browser_tabstrip.h" |
15 #include "chrome/browser/ui/browser_window.h" | 15 #include "chrome/browser/ui/browser_window.h" |
16 #include "chrome/browser/ui/tab_contents/tab_contents.h" | |
17 #include "chrome/common/chrome_notification_types.h" | 16 #include "chrome/common/chrome_notification_types.h" |
18 #include "chrome/common/chrome_switches.h" | 17 #include "chrome/common/chrome_switches.h" |
19 #include "chrome/common/extensions/extension.h" | 18 #include "chrome/common/extensions/extension.h" |
20 #include "content/public/browser/navigation_details.h" | 19 #include "content/public/browser/navigation_details.h" |
21 #include "content/public/browser/navigation_entry.h" | 20 #include "content/public/browser/navigation_entry.h" |
22 #include "content/public/browser/notification_service.h" | 21 #include "content/public/browser/notification_service.h" |
23 #include "content/public/browser/render_view_host.h" | 22 #include "content/public/browser/render_view_host.h" |
24 #include "content/public/browser/render_widget_host_view.h" | 23 #include "content/public/browser/render_widget_host_view.h" |
25 #include "content/public/browser/user_metrics.h" | 24 #include "content/public/browser/user_metrics.h" |
26 #include "content/public/browser/web_contents.h" | 25 #include "content/public/browser/web_contents.h" |
(...skipping 29 matching lines...) Expand all Loading... |
56 extension_caused_fullscreen_ = GURL(); | 55 extension_caused_fullscreen_ = GURL(); |
57 ToggleFullscreenModeInternal(false); | 56 ToggleFullscreenModeInternal(false); |
58 } | 57 } |
59 | 58 |
60 bool FullscreenController::IsFullscreenForTabOrPending() const { | 59 bool FullscreenController::IsFullscreenForTabOrPending() const { |
61 return fullscreened_tab_ != NULL; | 60 return fullscreened_tab_ != NULL; |
62 } | 61 } |
63 | 62 |
64 bool FullscreenController::IsFullscreenForTabOrPending( | 63 bool FullscreenController::IsFullscreenForTabOrPending( |
65 const WebContents* web_contents) const { | 64 const WebContents* web_contents) const { |
66 const TabContents* tab_contents = | 65 if (web_contents != fullscreened_tab_) |
67 TabContents::FromWebContents(web_contents); | |
68 if (!tab_contents || (tab_contents != fullscreened_tab_)) | |
69 return false; | 66 return false; |
70 DCHECK(web_contents == chrome::GetActiveWebContents(browser_)); | 67 DCHECK(web_contents == chrome::GetActiveWebContents(browser_)); |
71 return true; | 68 return true; |
72 } | 69 } |
73 | 70 |
74 void FullscreenController::ToggleFullscreenModeForTab(WebContents* web_contents, | 71 void FullscreenController::ToggleFullscreenModeForTab(WebContents* web_contents, |
75 bool enter_fullscreen) { | 72 bool enter_fullscreen) { |
76 if (web_contents != chrome::GetActiveWebContents(browser_)) | 73 if (web_contents != chrome::GetActiveWebContents(browser_)) |
77 return; | 74 return; |
78 | 75 |
79 #if defined(OS_WIN) | 76 #if defined(OS_WIN) |
80 // For now, avoid breaking when initiating full screen tab mode while in | 77 // For now, avoid breaking when initiating full screen tab mode while in |
81 // a metro snap. | 78 // a metro snap. |
82 // TODO(robertshield): Find a way to reconcile tab-initiated fullscreen | 79 // TODO(robertshield): Find a way to reconcile tab-initiated fullscreen |
83 // modes with metro snap. | 80 // modes with metro snap. |
84 if (IsInMetroSnapMode()) | 81 if (IsInMetroSnapMode()) |
85 return; | 82 return; |
86 #endif | 83 #endif |
87 | 84 |
88 bool in_browser_or_tab_fullscreen_mode; | 85 bool in_browser_or_tab_fullscreen_mode; |
89 #if defined(OS_MACOSX) | 86 #if defined(OS_MACOSX) |
90 in_browser_or_tab_fullscreen_mode = window_->InPresentationMode(); | 87 in_browser_or_tab_fullscreen_mode = window_->InPresentationMode(); |
91 #else | 88 #else |
92 in_browser_or_tab_fullscreen_mode = window_->IsFullscreen(); | 89 in_browser_or_tab_fullscreen_mode = window_->IsFullscreen(); |
93 #endif | 90 #endif |
94 | 91 |
95 if (enter_fullscreen) { | 92 if (enter_fullscreen) { |
96 SetFullscreenedTab(TabContents::FromWebContents(web_contents)); | 93 SetFullscreenedTab(web_contents); |
97 if (!in_browser_or_tab_fullscreen_mode) { | 94 if (!in_browser_or_tab_fullscreen_mode) { |
98 tab_caused_fullscreen_ = true; | 95 tab_caused_fullscreen_ = true; |
99 #if defined(OS_MACOSX) | 96 #if defined(OS_MACOSX) |
100 TogglePresentationModeInternal(true); | 97 TogglePresentationModeInternal(true); |
101 #else | 98 #else |
102 ToggleFullscreenModeInternal(true); | 99 ToggleFullscreenModeInternal(true); |
103 #endif | 100 #endif |
104 } else { | 101 } else { |
105 // We need to update the fullscreen exit bubble, e.g., going from browser | 102 // We need to update the fullscreen exit bubble, e.g., going from browser |
106 // fullscreen to tab fullscreen will need to show different content. | 103 // fullscreen to tab fullscreen will need to show different content. |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 | 189 |
193 // Must have a user gesture to prevent misbehaving sites from constantly | 190 // Must have a user gesture to prevent misbehaving sites from constantly |
194 // re-locking the mouse. Exceptions are when the page has unlocked | 191 // re-locking the mouse. Exceptions are when the page has unlocked |
195 // (i.e. not the user), or if we're in tab fullscreen (user gesture required | 192 // (i.e. not the user), or if we're in tab fullscreen (user gesture required |
196 // for that) | 193 // for that) |
197 if (!last_unlocked_by_target && !user_gesture && | 194 if (!last_unlocked_by_target && !user_gesture && |
198 !IsFullscreenForTabOrPending(web_contents)) { | 195 !IsFullscreenForTabOrPending(web_contents)) { |
199 web_contents->GotResponseToLockMouseRequest(false); | 196 web_contents->GotResponseToLockMouseRequest(false); |
200 return; | 197 return; |
201 } | 198 } |
202 SetMouseLockTab(TabContents::FromWebContents(web_contents)); | 199 SetMouseLockTab(web_contents); |
203 FullscreenExitBubbleType bubble_type = GetFullscreenExitBubbleType(); | 200 FullscreenExitBubbleType bubble_type = GetFullscreenExitBubbleType(); |
204 | 201 |
205 switch (GetMouseLockSetting(web_contents->GetURL())) { | 202 switch (GetMouseLockSetting(web_contents->GetURL())) { |
206 case CONTENT_SETTING_ALLOW: | 203 case CONTENT_SETTING_ALLOW: |
207 // If bubble already displaying buttons we must not lock the mouse yet, | 204 // If bubble already displaying buttons we must not lock the mouse yet, |
208 // or it would prevent pressing those buttons. Instead, merge the request. | 205 // or it would prevent pressing those buttons. Instead, merge the request. |
209 if (fullscreen_bubble::ShowButtonsForType(bubble_type)) { | 206 if (fullscreen_bubble::ShowButtonsForType(bubble_type)) { |
210 mouse_lock_state_ = MOUSELOCK_REQUESTED; | 207 mouse_lock_state_ = MOUSELOCK_REQUESTED; |
211 } else { | 208 } else { |
212 // Lock mouse. | 209 // Lock mouse. |
(...skipping 17 matching lines...) Expand all Loading... |
230 case CONTENT_SETTING_ASK: | 227 case CONTENT_SETTING_ASK: |
231 mouse_lock_state_ = MOUSELOCK_REQUESTED; | 228 mouse_lock_state_ = MOUSELOCK_REQUESTED; |
232 break; | 229 break; |
233 default: | 230 default: |
234 NOTREACHED(); | 231 NOTREACHED(); |
235 } | 232 } |
236 UpdateFullscreenExitBubbleContent(); | 233 UpdateFullscreenExitBubbleContent(); |
237 } | 234 } |
238 | 235 |
239 void FullscreenController::OnTabDeactivated(WebContents* web_contents) { | 236 void FullscreenController::OnTabDeactivated(WebContents* web_contents) { |
240 const TabContents* contents = TabContents::FromWebContents(web_contents); | 237 if (web_contents == fullscreened_tab_ || web_contents == mouse_lock_tab_) |
241 if (contents && | |
242 (contents == fullscreened_tab_ || contents == mouse_lock_tab_)) { | |
243 ExitTabFullscreenOrMouseLockIfNecessary(); | 238 ExitTabFullscreenOrMouseLockIfNecessary(); |
244 } | |
245 } | 239 } |
246 | 240 |
247 void FullscreenController::OnTabClosing(WebContents* web_contents) { | 241 void FullscreenController::OnTabClosing(WebContents* web_contents) { |
248 const TabContents* contents = TabContents::FromWebContents(web_contents); | 242 if (web_contents == fullscreened_tab_ || web_contents == mouse_lock_tab_) { |
249 if (contents && | |
250 (contents == fullscreened_tab_ || contents == mouse_lock_tab_)) { | |
251 ExitTabFullscreenOrMouseLockIfNecessary(); | 243 ExitTabFullscreenOrMouseLockIfNecessary(); |
252 // The call to exit fullscreen may result in asynchronous notification of | 244 // The call to exit fullscreen may result in asynchronous notification of |
253 // fullscreen state change (e.g., on Linux). We don't want to rely on it | 245 // fullscreen state change (e.g., on Linux). We don't want to rely on it |
254 // to call NotifyTabOfExitIfNecessary(), because at that point | 246 // to call NotifyTabOfExitIfNecessary(), because at that point |
255 // |fullscreened_tab_| may not be valid. Instead, we call it here to clean | 247 // |fullscreened_tab_| may not be valid. Instead, we call it here to clean |
256 // up tab fullscreen related state. | 248 // up tab fullscreen related state. |
257 NotifyTabOfExitIfNecessary(); | 249 NotifyTabOfExitIfNecessary(); |
258 } | 250 } |
259 } | 251 } |
260 | 252 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 DCHECK(IsMouseLockRequested()); | 295 DCHECK(IsMouseLockRequested()); |
304 // TODO(markusheintz): We should allow patterns for all possible URLs here. | 296 // TODO(markusheintz): We should allow patterns for all possible URLs here. |
305 if (pattern.IsValid()) { | 297 if (pattern.IsValid()) { |
306 settings_map->SetContentSetting( | 298 settings_map->SetContentSetting( |
307 pattern, ContentSettingsPattern::Wildcard(), | 299 pattern, ContentSettingsPattern::Wildcard(), |
308 CONTENT_SETTINGS_TYPE_MOUSELOCK, std::string(), | 300 CONTENT_SETTINGS_TYPE_MOUSELOCK, std::string(), |
309 CONTENT_SETTING_ALLOW); | 301 CONTENT_SETTING_ALLOW); |
310 } | 302 } |
311 | 303 |
312 if (mouse_lock_tab_ && | 304 if (mouse_lock_tab_ && |
313 mouse_lock_tab_->web_contents() && | 305 mouse_lock_tab_->GotResponseToLockMouseRequest(true)) { |
314 mouse_lock_tab_->web_contents()->GotResponseToLockMouseRequest(true)) { | |
315 mouse_lock_state_ = MOUSELOCK_ACCEPTED; | 306 mouse_lock_state_ = MOUSELOCK_ACCEPTED; |
316 } else { | 307 } else { |
317 mouse_lock_state_ = MOUSELOCK_NOT_REQUESTED; | 308 mouse_lock_state_ = MOUSELOCK_NOT_REQUESTED; |
318 SetMouseLockTab(NULL); | 309 SetMouseLockTab(NULL); |
319 } | 310 } |
320 NotifyMouseLockChange(); | 311 NotifyMouseLockChange(); |
321 } | 312 } |
322 | 313 |
323 if (fullscreen && !tab_fullscreen_accepted_) { | 314 if (fullscreen && !tab_fullscreen_accepted_) { |
324 DCHECK(fullscreened_tab_); | 315 DCHECK(fullscreened_tab_); |
(...skipping 14 matching lines...) Expand all Loading... |
339 bool fullscreen = false; | 330 bool fullscreen = false; |
340 fullscreen_bubble::PermissionRequestedByType(bubble_type, &fullscreen, | 331 fullscreen_bubble::PermissionRequestedByType(bubble_type, &fullscreen, |
341 &mouse_lock); | 332 &mouse_lock); |
342 DCHECK(fullscreened_tab_ || mouse_lock_tab_); | 333 DCHECK(fullscreened_tab_ || mouse_lock_tab_); |
343 DCHECK(!(fullscreen && tab_fullscreen_accepted_)); | 334 DCHECK(!(fullscreen && tab_fullscreen_accepted_)); |
344 DCHECK(!(mouse_lock && IsMouseLocked())); | 335 DCHECK(!(mouse_lock && IsMouseLocked())); |
345 | 336 |
346 if (mouse_lock) { | 337 if (mouse_lock) { |
347 DCHECK(IsMouseLockRequested()); | 338 DCHECK(IsMouseLockRequested()); |
348 mouse_lock_state_ = MOUSELOCK_NOT_REQUESTED; | 339 mouse_lock_state_ = MOUSELOCK_NOT_REQUESTED; |
349 if (mouse_lock_tab_ && mouse_lock_tab_->web_contents()) | 340 if (mouse_lock_tab_) |
350 mouse_lock_tab_->web_contents()->GotResponseToLockMouseRequest(false); | 341 mouse_lock_tab_->GotResponseToLockMouseRequest(false); |
351 SetMouseLockTab(NULL); | 342 SetMouseLockTab(NULL); |
352 NotifyMouseLockChange(); | 343 NotifyMouseLockChange(); |
353 | 344 |
354 // UpdateFullscreenExitBubbleContent() must be called, but to avoid | 345 // UpdateFullscreenExitBubbleContent() must be called, but to avoid |
355 // duplicate calls we do so only if not adjusting the fullscreen state | 346 // duplicate calls we do so only if not adjusting the fullscreen state |
356 // below, which also calls UpdateFullscreenExitBubbleContent(). | 347 // below, which also calls UpdateFullscreenExitBubbleContent(). |
357 if (!fullscreen) | 348 if (!fullscreen) |
358 UpdateFullscreenExitBubbleContent(); | 349 UpdateFullscreenExitBubbleContent(); |
359 } | 350 } |
360 | 351 |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
430 } | 421 } |
431 } | 422 } |
432 NOTREACHED(); | 423 NOTREACHED(); |
433 return FEB_TYPE_NONE; | 424 return FEB_TYPE_NONE; |
434 } | 425 } |
435 | 426 |
436 void FullscreenController::UpdateNotificationRegistrations() { | 427 void FullscreenController::UpdateNotificationRegistrations() { |
437 if (fullscreened_tab_ && mouse_lock_tab_) | 428 if (fullscreened_tab_ && mouse_lock_tab_) |
438 DCHECK(fullscreened_tab_ == mouse_lock_tab_); | 429 DCHECK(fullscreened_tab_ == mouse_lock_tab_); |
439 | 430 |
440 TabContents* tab = fullscreened_tab_ ? fullscreened_tab_ : mouse_lock_tab_; | 431 WebContents* tab = fullscreened_tab_ ? fullscreened_tab_ : mouse_lock_tab_; |
441 | 432 |
442 if (tab && registrar_.IsEmpty()) { | 433 if (tab && registrar_.IsEmpty()) { |
443 registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED, | 434 registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED, |
444 content::Source<content::NavigationController>( | 435 content::Source<content::NavigationController>(&tab->GetController())); |
445 &tab->web_contents()->GetController())); | |
446 } else if (!tab && !registrar_.IsEmpty()) { | 436 } else if (!tab && !registrar_.IsEmpty()) { |
447 registrar_.RemoveAll(); | 437 registrar_.RemoveAll(); |
448 } | 438 } |
449 } | 439 } |
450 | 440 |
451 void FullscreenController::PostFullscreenChangeNotification( | 441 void FullscreenController::PostFullscreenChangeNotification( |
452 bool is_fullscreen) { | 442 bool is_fullscreen) { |
453 MessageLoop::current()->PostTask(FROM_HERE, | 443 MessageLoop::current()->PostTask(FROM_HERE, |
454 base::Bind(&FullscreenController::NotifyFullscreenChange, | 444 base::Bind(&FullscreenController::NotifyFullscreenChange, |
455 ptr_factory_.GetWeakPtr(), is_fullscreen)); | 445 ptr_factory_.GetWeakPtr(), is_fullscreen)); |
456 } | 446 } |
457 | 447 |
458 void FullscreenController::NotifyFullscreenChange(bool is_fullscreen) { | 448 void FullscreenController::NotifyFullscreenChange(bool is_fullscreen) { |
459 content::NotificationService::current()->Notify( | 449 content::NotificationService::current()->Notify( |
460 chrome::NOTIFICATION_FULLSCREEN_CHANGED, | 450 chrome::NOTIFICATION_FULLSCREEN_CHANGED, |
461 content::Source<FullscreenController>(this), | 451 content::Source<FullscreenController>(this), |
462 content::Details<bool>(&is_fullscreen)); | 452 content::Details<bool>(&is_fullscreen)); |
463 } | 453 } |
464 | 454 |
465 void FullscreenController::NotifyTabOfExitIfNecessary() { | 455 void FullscreenController::NotifyTabOfExitIfNecessary() { |
466 if (fullscreened_tab_) { | 456 if (fullscreened_tab_) { |
467 RenderViewHost* rvh = | 457 RenderViewHost* rvh = fullscreened_tab_->GetRenderViewHost(); |
468 fullscreened_tab_->web_contents()->GetRenderViewHost(); | |
469 SetFullscreenedTab(NULL); | 458 SetFullscreenedTab(NULL); |
470 tab_caused_fullscreen_ = false; | 459 tab_caused_fullscreen_ = false; |
471 tab_fullscreen_accepted_ = false; | 460 tab_fullscreen_accepted_ = false; |
472 if (rvh) | 461 if (rvh) |
473 rvh->ExitFullscreen(); | 462 rvh->ExitFullscreen(); |
474 } | 463 } |
475 | 464 |
476 if (mouse_lock_tab_) { | 465 if (mouse_lock_tab_) { |
477 WebContents* web_contents = mouse_lock_tab_->web_contents(); | |
478 if (IsMouseLockRequested()) { | 466 if (IsMouseLockRequested()) { |
479 web_contents->GotResponseToLockMouseRequest(false); | 467 mouse_lock_tab_->GotResponseToLockMouseRequest(false); |
480 NotifyMouseLockChange(); | 468 NotifyMouseLockChange(); |
481 } else if (web_contents->GetRenderViewHost() && | 469 } else if (mouse_lock_tab_->GetRenderViewHost() && |
482 web_contents->GetRenderViewHost()->GetView()) { | 470 mouse_lock_tab_->GetRenderViewHost()->GetView()) { |
483 web_contents->GetRenderViewHost()->GetView()->UnlockMouse(); | 471 mouse_lock_tab_->GetRenderViewHost()->GetView()->UnlockMouse(); |
484 } | 472 } |
485 SetMouseLockTab(NULL); | 473 SetMouseLockTab(NULL); |
486 mouse_lock_state_ = MOUSELOCK_NOT_REQUESTED; | 474 mouse_lock_state_ = MOUSELOCK_NOT_REQUESTED; |
487 } | 475 } |
488 | 476 |
489 UpdateFullscreenExitBubbleContent(); | 477 UpdateFullscreenExitBubbleContent(); |
490 } | 478 } |
491 | 479 |
492 void FullscreenController::NotifyMouseLockChange() { | 480 void FullscreenController::NotifyMouseLockChange() { |
493 content::NotificationService::current()->Notify( | 481 content::NotificationService::current()->Notify( |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
554 window_->EnterPresentationMode(url, GetFullscreenExitBubbleType()); | 542 window_->EnterPresentationMode(url, GetFullscreenExitBubbleType()); |
555 else | 543 else |
556 window_->ExitFullscreen(); | 544 window_->ExitFullscreen(); |
557 UpdateFullscreenExitBubbleContent(); | 545 UpdateFullscreenExitBubbleContent(); |
558 | 546 |
559 // WindowFullscreenStateChanged will be called by BrowserWindowController | 547 // WindowFullscreenStateChanged will be called by BrowserWindowController |
560 // when the transition completes. | 548 // when the transition completes. |
561 } | 549 } |
562 #endif | 550 #endif |
563 | 551 |
564 void FullscreenController::SetFullscreenedTab(TabContents* tab) { | 552 void FullscreenController::SetFullscreenedTab(WebContents* tab) { |
565 fullscreened_tab_ = tab; | 553 fullscreened_tab_ = tab; |
566 UpdateNotificationRegistrations(); | 554 UpdateNotificationRegistrations(); |
567 } | 555 } |
568 | 556 |
569 void FullscreenController::SetMouseLockTab(TabContents* tab) { | 557 void FullscreenController::SetMouseLockTab(WebContents* tab) { |
570 mouse_lock_tab_ = tab; | 558 mouse_lock_tab_ = tab; |
571 UpdateNotificationRegistrations(); | 559 UpdateNotificationRegistrations(); |
572 } | 560 } |
573 | 561 |
574 void FullscreenController::ExitTabFullscreenOrMouseLockIfNecessary() { | 562 void FullscreenController::ExitTabFullscreenOrMouseLockIfNecessary() { |
575 if (tab_caused_fullscreen_) | 563 if (tab_caused_fullscreen_) |
576 ToggleFullscreenMode(); | 564 ToggleFullscreenMode(); |
577 else | 565 else |
578 NotifyTabOfExitIfNecessary(); | 566 NotifyTabOfExitIfNecessary(); |
579 } | 567 } |
580 | 568 |
581 void FullscreenController::UpdateFullscreenExitBubbleContent() { | 569 void FullscreenController::UpdateFullscreenExitBubbleContent() { |
582 GURL url; | 570 GURL url; |
583 if (fullscreened_tab_) | 571 if (fullscreened_tab_) |
584 url = fullscreened_tab_->web_contents()->GetURL(); | 572 url = fullscreened_tab_->GetURL(); |
585 else if (mouse_lock_tab_) | 573 else if (mouse_lock_tab_) |
586 url = mouse_lock_tab_->web_contents()->GetURL(); | 574 url = mouse_lock_tab_->GetURL(); |
587 else if (!extension_caused_fullscreen_.is_empty()) | 575 else if (!extension_caused_fullscreen_.is_empty()) |
588 url = extension_caused_fullscreen_; | 576 url = extension_caused_fullscreen_; |
589 | 577 |
590 FullscreenExitBubbleType bubble_type = GetFullscreenExitBubbleType(); | 578 FullscreenExitBubbleType bubble_type = GetFullscreenExitBubbleType(); |
591 | 579 |
592 // If bubble displays buttons, unlock mouse to allow pressing them. | 580 // If bubble displays buttons, unlock mouse to allow pressing them. |
593 if (fullscreen_bubble::ShowButtonsForType(bubble_type) && | 581 if (fullscreen_bubble::ShowButtonsForType(bubble_type) && |
594 IsMouseLocked() && | 582 IsMouseLocked() && |
595 mouse_lock_tab_->web_contents()) { | 583 mouse_lock_tab_ && |
596 WebContents* web_contents = mouse_lock_tab_->web_contents(); | 584 mouse_lock_tab_->GetRenderViewHost() && |
597 if (web_contents && web_contents->GetRenderViewHost() && | 585 mouse_lock_tab_->GetRenderViewHost()->GetView()) { |
598 web_contents->GetRenderViewHost()->GetView()) | 586 mouse_lock_tab_->GetRenderViewHost()->GetView()->UnlockMouse(); |
599 web_contents->GetRenderViewHost()->GetView()->UnlockMouse(); | |
600 } | 587 } |
601 | 588 |
602 window_->UpdateFullscreenExitBubbleContent(url, bubble_type); | 589 window_->UpdateFullscreenExitBubbleContent(url, bubble_type); |
603 } | 590 } |
604 | 591 |
605 ContentSetting | 592 ContentSetting |
606 FullscreenController::GetFullscreenSetting(const GURL& url) const { | 593 FullscreenController::GetFullscreenSetting(const GURL& url) const { |
607 if (url.SchemeIsFile()) | 594 if (url.SchemeIsFile()) |
608 return CONTENT_SETTING_ALLOW; | 595 return CONTENT_SETTING_ALLOW; |
609 | 596 |
610 return profile_->GetHostContentSettingsMap()->GetContentSetting(url, url, | 597 return profile_->GetHostContentSettingsMap()->GetContentSetting(url, url, |
611 CONTENT_SETTINGS_TYPE_FULLSCREEN, std::string()); | 598 CONTENT_SETTINGS_TYPE_FULLSCREEN, std::string()); |
612 } | 599 } |
613 | 600 |
614 ContentSetting | 601 ContentSetting |
615 FullscreenController::GetMouseLockSetting(const GURL& url) const { | 602 FullscreenController::GetMouseLockSetting(const GURL& url) const { |
616 if (url.SchemeIsFile()) | 603 if (url.SchemeIsFile()) |
617 return CONTENT_SETTING_ALLOW; | 604 return CONTENT_SETTING_ALLOW; |
618 | 605 |
619 HostContentSettingsMap* settings_map = profile_->GetHostContentSettingsMap(); | 606 HostContentSettingsMap* settings_map = profile_->GetHostContentSettingsMap(); |
620 return settings_map->GetContentSetting(url, url, | 607 return settings_map->GetContentSetting(url, url, |
621 CONTENT_SETTINGS_TYPE_MOUSELOCK, std::string()); | 608 CONTENT_SETTINGS_TYPE_MOUSELOCK, std::string()); |
622 } | 609 } |
OLD | NEW |