Chromium Code Reviews| Index: chrome/browser/ui/browser.cc |
| diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc |
| index f83aaa923e3fcd9afc2165d6976a2800c2ede6aa..50c652d0ad70d8cca984a815a1fe6ffd8385bcf5 100644 |
| --- a/chrome/browser/ui/browser.cc |
| +++ b/chrome/browser/ui/browser.cc |
| @@ -33,6 +33,7 @@ |
| #include "chrome/browser/browser_process.h" |
| #include "chrome/browser/browser_shutdown.h" |
| #include "chrome/browser/character_encoding.h" |
| +#include "chrome/browser/content_settings/host_content_settings_map.h" |
| #include "chrome/browser/custom_handlers/protocol_handler_registry.h" |
| #include "chrome/browser/custom_handlers/register_protocol_handler_infobar_delegate.h" |
| #include "chrome/browser/debugger/devtools_toggle_action.h" |
| @@ -739,7 +740,7 @@ TabContents* Browser::OpenApplicationTab(Profile* profile, |
| // full screen mode in this case? |
| if (launch_type == ExtensionPrefs::LAUNCH_FULLSCREEN && |
| !browser->window()->IsFullscreen()) |
| - browser->ToggleFullscreenMode(); |
| + browser->ToggleFullscreenMode(false); |
| return contents; |
| } |
| @@ -1635,7 +1636,10 @@ void Browser::ConvertPopupToTabbedBrowser() { |
| browser->window()->Show(); |
| } |
| -void Browser::ToggleFullscreenMode() { |
| +// TODO Change this to an enum. |
|
Peter Kasting
2011/10/11 23:08:32
Nit: Change what to an enum?
Also please give an
koz (OOO until 15th September)
2011/10/12 05:38:23
Done.
|
| +void Browser::ToggleFullscreenMode(bool for_tab) { |
| + bool entering_fullscreen = !window_->IsFullscreen(); |
| + |
| #if !defined(OS_MACOSX) |
| // In kiosk mode, we always want to be fullscreen. When the browser first |
| // starts we're not yet fullscreen, so let the initial toggle go through. |
| @@ -1645,7 +1649,15 @@ void Browser::ToggleFullscreenMode() { |
| #endif |
| UserMetrics::RecordAction(UserMetricsAction("ToggleFullscreen")); |
| - window_->SetFullscreen(!window_->IsFullscreen()); |
| + if (for_tab) { |
|
Peter Kasting
2011/10/11 23:08:32
Nit: Less duplication:
GURL requesting_url;
b
koz (OOO until 15th September)
2011/10/12 05:38:23
Done.
|
| + const GURL& url = GetSelectedTabContents()->GetURL(); |
| + bool ask_permission = (!url.SchemeIsFile()) && |
|
Peter Kasting
2011/10/11 23:08:32
Nit: No parens around unary. Put them around the
koz (OOO until 15th September)
2011/10/12 05:38:23
Done.
|
| + GetFullscreenSetting(url) == CONTENT_SETTING_ASK; |
| + window_->SetFullscreen(entering_fullscreen, url, ask_permission); |
| + } else { |
| + // TODO Replace with browser-specific fullscreen function. |
| + window_->SetFullscreen(entering_fullscreen, GURL(), false); |
| + } |
| // Once the window has become fullscreen it'll call back to |
| // WindowFullscreenStateChanged(). We don't do this immediately as |
| @@ -1667,8 +1679,15 @@ void Browser::NotifyTabOfFullscreenExitIfNecessary() { |
| } |
| #if defined(OS_MACOSX) |
| -void Browser::TogglePresentationMode() { |
| - window_->SetPresentationMode(!window_->InPresentationMode()); |
| +void Browser::TogglePresentationMode(bool for_tab) { |
| + bool entering_fullscreen = !window_->InPresentationMode(); |
| + if (for_tab) { |
| + const GURL& url = GetSelectedTabContents()->GetURL(); |
| + bool ask_permission = GetFullscreenSetting(url) == CONTENT_SETTING_ASK; |
| + window_->SetPresentationMode(entering_fullscreen, url, ask_permission); |
| + } else { |
| + window_->SetPresentationMode(entering_fullscreen, GURL(), false); |
| + } |
| WindowFullscreenStateChanged(); |
| } |
| #endif |
| @@ -1677,7 +1696,7 @@ void Browser::TogglePresentationMode() { |
| void Browser::Search() { |
| // Exit fullscreen to show omnibox. |
| if (window_->IsFullscreen()) { |
| - ToggleFullscreenMode(); |
| + ToggleFullscreenMode(false); |
| // ToggleFullscreenMode is asynchronous, so we don't have omnibox |
| // visible at this point. Wait for next event cycle which toggles |
| // the visibility of omnibox before creating new tab. |
| @@ -2604,9 +2623,9 @@ void Browser::ExecuteCommandWithDisposition( |
| case IDC_RESTORE_TAB: RestoreTab(); break; |
| case IDC_COPY_URL: WriteCurrentURLToClipboard(); break; |
| case IDC_SHOW_AS_TAB: ConvertPopupToTabbedBrowser(); break; |
| - case IDC_FULLSCREEN: ToggleFullscreenMode(); break; |
| + case IDC_FULLSCREEN: ToggleFullscreenMode(false); break; |
| #if defined(OS_MACOSX) |
| - case IDC_PRESENTATION_MODE: TogglePresentationMode(); break; |
| + case IDC_PRESENTATION_MODE: TogglePresentationMode(false); break; |
| #endif |
| case IDC_EXIT: Exit(); break; |
| #if defined(OS_CHROMEOS) |
| @@ -3780,9 +3799,9 @@ void Browser::ToggleFullscreenModeForTab(TabContents* tab, |
| if (tab_caused_fullscreen_) { |
| #if defined(OS_MACOSX) |
| - TogglePresentationMode(); |
| + TogglePresentationMode(true); |
| #else |
| - ToggleFullscreenMode(); |
| + ToggleFullscreenMode(true); |
| #endif |
| } else if (!enter_fullscreen) { |
| // If currently there is a tab in "tab fullscreen" mode and fullscreen was |
| @@ -3858,7 +3877,7 @@ void Browser::CrashedPlugin(TabContents* tab, const FilePath& plugin_path) { |
| void Browser::ExitTabbedFullscreenModeIfNecessary() { |
| if (tab_caused_fullscreen_) |
| - ToggleFullscreenMode(); |
| + ToggleFullscreenMode(false); |
| else |
| NotifyTabOfFullscreenExitIfNecessary(); |
| } |
| @@ -3868,6 +3887,25 @@ void Browser::UpdatePreferredSize(TabContents* source, |
| window_->UpdatePreferredSize(source, pref_size); |
| } |
| +void Browser::OnAcceptFullscreenPermission(const GURL& url) { |
| + HostContentSettingsMap* settings_map = profile()->GetHostContentSettingsMap(); |
| + |
| + settings_map->SetContentSetting( |
| + ContentSettingsPattern::FromString(url.host()), |
| + ContentSettingsPattern::Wildcard(), CONTENT_SETTINGS_TYPE_FULLSCREEN, |
| + "", CONTENT_SETTING_ALLOW); |
|
Peter Kasting
2011/10/11 23:08:32
Nit: "" -> std::string() (2 places)
koz (OOO until 15th September)
2011/10/12 05:38:23
Done.
|
| +} |
| + |
| +void Browser::OnDenyFullscreenPermission() { |
| + ExitTabbedFullscreenModeIfNecessary(); |
| +} |
| + |
| +ContentSetting Browser::GetFullscreenSetting(const GURL& url) { |
| + HostContentSettingsMap* settings_map = profile()->GetHostContentSettingsMap(); |
| + return settings_map->GetContentSetting(url, url, |
| + CONTENT_SETTINGS_TYPE_FULLSCREEN, ""); |
| +} |
| + |
| /////////////////////////////////////////////////////////////////////////////// |
| // Browser, TabContentsWrapperDelegate implementation: |