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

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

Issue 7740044: Implement fullscreen info bubble on Win and Mac (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: windows compile fix Created 9 years, 2 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/browser.h" 5 #include "chrome/browser/ui/browser.h"
6 6
7 #if defined(OS_WIN) 7 #if defined(OS_WIN)
8 #include <windows.h> 8 #include <windows.h>
9 #include <shellapi.h> 9 #include <shellapi.h>
10 #endif // OS_WIN 10 #endif // OS_WIN
(...skipping 16 matching lines...) Expand all
27 #include "base/utf_string_conversions.h" 27 #include "base/utf_string_conversions.h"
28 #include "chrome/app/chrome_command_ids.h" 28 #include "chrome/app/chrome_command_ids.h"
29 #include "chrome/browser/autofill/autofill_manager.h" 29 #include "chrome/browser/autofill/autofill_manager.h"
30 #include "chrome/browser/autofill/personal_data_manager_factory.h" 30 #include "chrome/browser/autofill/personal_data_manager_factory.h"
31 #include "chrome/browser/background/background_contents_service.h" 31 #include "chrome/browser/background/background_contents_service.h"
32 #include "chrome/browser/bookmarks/bookmark_model.h" 32 #include "chrome/browser/bookmarks/bookmark_model.h"
33 #include "chrome/browser/bookmarks/bookmark_utils.h" 33 #include "chrome/browser/bookmarks/bookmark_utils.h"
34 #include "chrome/browser/browser_process.h" 34 #include "chrome/browser/browser_process.h"
35 #include "chrome/browser/browser_shutdown.h" 35 #include "chrome/browser/browser_shutdown.h"
36 #include "chrome/browser/character_encoding.h" 36 #include "chrome/browser/character_encoding.h"
37 #include "chrome/browser/content_settings/host_content_settings_map.h"
37 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" 38 #include "chrome/browser/custom_handlers/protocol_handler_registry.h"
38 #include "chrome/browser/custom_handlers/register_protocol_handler_infobar_deleg ate.h" 39 #include "chrome/browser/custom_handlers/register_protocol_handler_infobar_deleg ate.h"
39 #include "chrome/browser/debugger/devtools_toggle_action.h" 40 #include "chrome/browser/debugger/devtools_toggle_action.h"
40 #include "chrome/browser/debugger/devtools_window.h" 41 #include "chrome/browser/debugger/devtools_window.h"
41 #include "chrome/browser/download/chrome_download_manager_delegate.h" 42 #include "chrome/browser/download/chrome_download_manager_delegate.h"
42 #include "chrome/browser/download/download_item_model.h" 43 #include "chrome/browser/download/download_item_model.h"
43 #include "chrome/browser/download/download_service.h" 44 #include "chrome/browser/download/download_service.h"
44 #include "chrome/browser/download/download_service_factory.h" 45 #include "chrome/browser/download/download_service_factory.h"
45 #include "chrome/browser/download/download_started_animation.h" 46 #include "chrome/browser/download/download_started_animation.h"
46 #include "chrome/browser/extensions/crx_installer.h" 47 #include "chrome/browser/extensions/crx_installer.h"
(...skipping 692 matching lines...) Expand 10 before | Expand all | Expand 10 after
739 browser::Navigate(&params); 740 browser::Navigate(&params);
740 contents = params.target_contents->tab_contents(); 741 contents = params.target_contents->tab_contents();
741 } 742 }
742 743
743 // TODO(skerner): If we are already in full screen mode, and the user 744 // TODO(skerner): If we are already in full screen mode, and the user
744 // set the app to open as a regular or pinned tab, what should happen? 745 // set the app to open as a regular or pinned tab, what should happen?
745 // Today we open the tab, but stay in full screen mode. Should we leave 746 // Today we open the tab, but stay in full screen mode. Should we leave
746 // full screen mode in this case? 747 // full screen mode in this case?
747 if (launch_type == ExtensionPrefs::LAUNCH_FULLSCREEN && 748 if (launch_type == ExtensionPrefs::LAUNCH_FULLSCREEN &&
748 !browser->window()->IsFullscreen()) 749 !browser->window()->IsFullscreen())
749 browser->ToggleFullscreenMode(); 750 browser->ToggleFullscreenMode(false);
750 751
751 return contents; 752 return contents;
752 } 753 }
753 754
754 // static 755 // static
755 void Browser::OpenBookmarkManagerWindow(Profile* profile) { 756 void Browser::OpenBookmarkManagerWindow(Profile* profile) {
756 Browser* browser = Browser::Create(profile); 757 Browser* browser = Browser::Create(profile);
757 browser->OpenBookmarkManager(); 758 browser->OpenBookmarkManager();
758 browser->window()->Show(); 759 browser->window()->Show();
759 } 760 }
(...skipping 880 matching lines...) Expand 10 before | Expand all | Expand 10 after
1640 void Browser::ConvertPopupToTabbedBrowser() { 1641 void Browser::ConvertPopupToTabbedBrowser() {
1641 UserMetrics::RecordAction(UserMetricsAction("ShowAsTab")); 1642 UserMetrics::RecordAction(UserMetricsAction("ShowAsTab"));
1642 int tab_strip_index = tab_handler_->GetTabStripModel()->active_index(); 1643 int tab_strip_index = tab_handler_->GetTabStripModel()->active_index();
1643 TabContentsWrapper* contents = 1644 TabContentsWrapper* contents =
1644 tab_handler_->GetTabStripModel()->DetachTabContentsAt(tab_strip_index); 1645 tab_handler_->GetTabStripModel()->DetachTabContentsAt(tab_strip_index);
1645 Browser* browser = Browser::Create(profile_); 1646 Browser* browser = Browser::Create(profile_);
1646 browser->tabstrip_model()->AppendTabContents(contents, true); 1647 browser->tabstrip_model()->AppendTabContents(contents, true);
1647 browser->window()->Show(); 1648 browser->window()->Show();
1648 } 1649 }
1649 1650
1650 void Browser::ToggleFullscreenMode() { 1651 // TODO(koz): Change |for_tab| to an enum.
1652 void Browser::ToggleFullscreenMode(bool for_tab) {
1653 bool entering_fullscreen = !window_->IsFullscreen();
1654
1651 #if !defined(OS_MACOSX) 1655 #if !defined(OS_MACOSX)
1652 // In kiosk mode, we always want to be fullscreen. When the browser first 1656 // In kiosk mode, we always want to be fullscreen. When the browser first
1653 // starts we're not yet fullscreen, so let the initial toggle go through. 1657 // starts we're not yet fullscreen, so let the initial toggle go through.
1654 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kKioskMode) && 1658 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kKioskMode) &&
1655 window_->IsFullscreen()) 1659 window_->IsFullscreen())
1656 return; 1660 return;
1657 #endif 1661 #endif
1658 1662
1659 UserMetrics::RecordAction(UserMetricsAction("ToggleFullscreen")); 1663 UserMetrics::RecordAction(UserMetricsAction("ToggleFullscreen"));
1660 window_->SetFullscreen(!window_->IsFullscreen()); 1664 GURL url;
1665 bool ask_permission = false;
1666 if (for_tab) {
1667 url = GetSelectedTabContents()->GetURL();
1668 ask_permission = !url.SchemeIsFile() &&
1669 (GetFullscreenSetting(url) == CONTENT_SETTING_ASK);
1670 }
1671 if (entering_fullscreen) {
1672 window_->EnterFullscreen(url, ask_permission);
1673 } else {
1674 window_->ExitFullscreen();
1675 }
1661 1676
1662 // Once the window has become fullscreen it'll call back to 1677 // Once the window has become fullscreen it'll call back to
1663 // WindowFullscreenStateChanged(). We don't do this immediately as 1678 // WindowFullscreenStateChanged(). We don't do this immediately as
1664 // BrowserWindow::SetFullscreen() asks for bookmark_bar_state_, so we let the 1679 // BrowserWindow::EnterFullscreen() asks for bookmark_bar_state_, so we let
1665 // BrowserWindow invoke WindowFullscreenStateChanged when appropriate. 1680 // the BrowserWindow invoke WindowFullscreenStateChanged when appropriate.
1666 1681
1667 // TODO: convert mac to invoke WindowFullscreenStateChanged once it updates 1682 // TODO: convert mac to invoke WindowFullscreenStateChanged once it updates
1668 // the necessary state of the frame. 1683 // the necessary state of the frame.
1669 #if defined(OS_MACOSX) 1684 #if defined(OS_MACOSX)
1670 WindowFullscreenStateChanged(); 1685 WindowFullscreenStateChanged();
1671 #endif 1686 #endif
1672 } 1687 }
1673 1688
1674 void Browser::NotifyTabOfFullscreenExitIfNecessary() { 1689 void Browser::NotifyTabOfFullscreenExitIfNecessary() {
1675 if (fullscreened_tab_) 1690 if (fullscreened_tab_)
1676 fullscreened_tab_->ExitFullscreenMode(); 1691 fullscreened_tab_->ExitFullscreenMode();
1677 fullscreened_tab_ = NULL; 1692 fullscreened_tab_ = NULL;
1678 tab_caused_fullscreen_ = false; 1693 tab_caused_fullscreen_ = false;
1679 } 1694 }
1680 1695
1681 #if defined(OS_MACOSX) 1696 #if defined(OS_MACOSX)
1682 void Browser::TogglePresentationMode() { 1697 void Browser::TogglePresentationMode(bool for_tab) {
1683 window_->SetPresentationMode(!window_->InPresentationMode()); 1698 bool entering_fullscreen = !window_->InPresentationMode();
1699 GURL url;
1700 bool ask_permission = false;
1701 if (for_tab) {
1702 url = GetSelectedTabContents()->GetURL();
1703 ask_permission = !url.SchemeIsFile() &&
1704 (GetFullscreenSetting(url) == CONTENT_SETTING_ASK);
1705 }
1706 window_->SetPresentationMode(entering_fullscreen, url, ask_permission);
1684 WindowFullscreenStateChanged(); 1707 WindowFullscreenStateChanged();
1685 } 1708 }
1686 #endif 1709 #endif
1687 1710
1688 #if defined(OS_CHROMEOS) 1711 #if defined(OS_CHROMEOS)
1689 void Browser::Search() { 1712 void Browser::Search() {
1690 // Exit fullscreen to show omnibox. 1713 // Exit fullscreen to show omnibox.
1691 if (window_->IsFullscreen()) { 1714 if (window_->IsFullscreen()) {
1692 ToggleFullscreenMode(); 1715 ToggleFullscreenMode(false);
1693 // ToggleFullscreenMode is asynchronous, so we don't have omnibox 1716 // ToggleFullscreenMode is asynchronous, so we don't have omnibox
1694 // visible at this point. Wait for next event cycle which toggles 1717 // visible at this point. Wait for next event cycle which toggles
1695 // the visibility of omnibox before creating new tab. 1718 // the visibility of omnibox before creating new tab.
1696 MessageLoop::current()->PostTask( 1719 MessageLoop::current()->PostTask(
1697 FROM_HERE, method_factory_.NewRunnableMethod(&Browser::Search)); 1720 FROM_HERE, method_factory_.NewRunnableMethod(&Browser::Search));
1698 return; 1721 return;
1699 } 1722 }
1700 1723
1701 const GURL& url = GetSelectedTabContents()->GetURL(); 1724 const GURL& url = GetSelectedTabContents()->GetURL();
1702 if (url.SchemeIs(chrome::kChromeUIScheme) && 1725 if (url.SchemeIs(chrome::kChromeUIScheme) &&
(...skipping 906 matching lines...) Expand 10 before | Expand all | Expand 10 after
2609 case IDC_SELECT_TAB_4: 2632 case IDC_SELECT_TAB_4:
2610 case IDC_SELECT_TAB_5: 2633 case IDC_SELECT_TAB_5:
2611 case IDC_SELECT_TAB_6: 2634 case IDC_SELECT_TAB_6:
2612 case IDC_SELECT_TAB_7: SelectNumberedTab(id - IDC_SELECT_TAB_0); 2635 case IDC_SELECT_TAB_7: SelectNumberedTab(id - IDC_SELECT_TAB_0);
2613 break; 2636 break;
2614 case IDC_SELECT_LAST_TAB: SelectLastTab(); break; 2637 case IDC_SELECT_LAST_TAB: SelectLastTab(); break;
2615 case IDC_DUPLICATE_TAB: DuplicateTab(); break; 2638 case IDC_DUPLICATE_TAB: DuplicateTab(); break;
2616 case IDC_RESTORE_TAB: RestoreTab(); break; 2639 case IDC_RESTORE_TAB: RestoreTab(); break;
2617 case IDC_COPY_URL: WriteCurrentURLToClipboard(); break; 2640 case IDC_COPY_URL: WriteCurrentURLToClipboard(); break;
2618 case IDC_SHOW_AS_TAB: ConvertPopupToTabbedBrowser(); break; 2641 case IDC_SHOW_AS_TAB: ConvertPopupToTabbedBrowser(); break;
2619 case IDC_FULLSCREEN: ToggleFullscreenMode(); break; 2642 case IDC_FULLSCREEN: ToggleFullscreenMode(false); break;
2620 #if defined(OS_MACOSX) 2643 #if defined(OS_MACOSX)
2621 case IDC_PRESENTATION_MODE: TogglePresentationMode(); break; 2644 case IDC_PRESENTATION_MODE: TogglePresentationMode(false); break;
2622 #endif 2645 #endif
2623 case IDC_EXIT: Exit(); break; 2646 case IDC_EXIT: Exit(); break;
2624 #if defined(OS_CHROMEOS) 2647 #if defined(OS_CHROMEOS)
2625 case IDC_SEARCH: Search(); break; 2648 case IDC_SEARCH: Search(); break;
2626 case IDC_SHOW_KEYBOARD_OVERLAY: ShowKeyboardOverlay(); break; 2649 case IDC_SHOW_KEYBOARD_OVERLAY: ShowKeyboardOverlay(); break;
2627 #endif 2650 #endif
2628 2651
2629 // Page-related commands 2652 // Page-related commands
2630 case IDC_SAVE_PAGE: SavePage(); break; 2653 case IDC_SAVE_PAGE: SavePage(); break;
2631 case IDC_BOOKMARK_PAGE: BookmarkCurrentPage(); break; 2654 case IDC_BOOKMARK_PAGE: BookmarkCurrentPage(); break;
(...skipping 1155 matching lines...) Expand 10 before | Expand all | Expand 10 after
3787 in_correct_mode_for_tab_fullscreen = window_->InPresentationMode(); 3810 in_correct_mode_for_tab_fullscreen = window_->InPresentationMode();
3788 #else 3811 #else
3789 in_correct_mode_for_tab_fullscreen = window_->IsFullscreen(); 3812 in_correct_mode_for_tab_fullscreen = window_->IsFullscreen();
3790 #endif 3813 #endif
3791 if (!in_correct_mode_for_tab_fullscreen) 3814 if (!in_correct_mode_for_tab_fullscreen)
3792 tab_caused_fullscreen_ = true; 3815 tab_caused_fullscreen_ = true;
3793 } 3816 }
3794 3817
3795 if (tab_caused_fullscreen_) { 3818 if (tab_caused_fullscreen_) {
3796 #if defined(OS_MACOSX) 3819 #if defined(OS_MACOSX)
3797 TogglePresentationMode(); 3820 TogglePresentationMode(true);
3798 #else 3821 #else
3799 ToggleFullscreenMode(); 3822 ToggleFullscreenMode(true);
3800 #endif 3823 #endif
3801 } else if (!enter_fullscreen) { 3824 } else if (!enter_fullscreen) {
3802 // If currently there is a tab in "tab fullscreen" mode and fullscreen was 3825 // If currently there is a tab in "tab fullscreen" mode and fullscreen was
3803 // not caused by it (i.e., previously it was in "browser fullscreen" mode), 3826 // not caused by it (i.e., previously it was in "browser fullscreen" mode),
3804 // we need to switch back to "browser fullscreen" mode. In this case, all we 3827 // we need to switch back to "browser fullscreen" mode. In this case, all we
3805 // have to do is notifying the tab that it has exited "tab fullscreen" mode. 3828 // have to do is notifying the tab that it has exited "tab fullscreen" mode.
3806 NotifyTabOfFullscreenExitIfNecessary(); 3829 NotifyTabOfFullscreenExitIfNecessary();
3807 } 3830 }
3808 } 3831 }
3809 3832
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
3865 FindReplyHelper(tab, request_id, number_of_matches, selection_rect, 3888 FindReplyHelper(tab, request_id, number_of_matches, selection_rect,
3866 active_match_ordinal, final_update); 3889 active_match_ordinal, final_update);
3867 } 3890 }
3868 3891
3869 void Browser::CrashedPlugin(TabContents* tab, const FilePath& plugin_path) { 3892 void Browser::CrashedPlugin(TabContents* tab, const FilePath& plugin_path) {
3870 CrashedPluginHelper(tab, plugin_path); 3893 CrashedPluginHelper(tab, plugin_path);
3871 } 3894 }
3872 3895
3873 void Browser::ExitTabbedFullscreenModeIfNecessary() { 3896 void Browser::ExitTabbedFullscreenModeIfNecessary() {
3874 if (tab_caused_fullscreen_) 3897 if (tab_caused_fullscreen_)
3875 ToggleFullscreenMode(); 3898 ToggleFullscreenMode(false);
3876 else 3899 else
3877 NotifyTabOfFullscreenExitIfNecessary(); 3900 NotifyTabOfFullscreenExitIfNecessary();
3878 } 3901 }
3879 3902
3880 void Browser::UpdatePreferredSize(TabContents* source, 3903 void Browser::UpdatePreferredSize(TabContents* source,
3881 const gfx::Size& pref_size) { 3904 const gfx::Size& pref_size) {
3882 window_->UpdatePreferredSize(source, pref_size); 3905 window_->UpdatePreferredSize(source, pref_size);
3883 } 3906 }
3884 3907
3908 void Browser::OnAcceptFullscreenPermission(const GURL& url) {
3909 HostContentSettingsMap* settings_map = profile()->GetHostContentSettingsMap();
3910
3911 settings_map->SetContentSetting(
3912 ContentSettingsPattern::FromString(url.host()),
3913 ContentSettingsPattern::Wildcard(), CONTENT_SETTINGS_TYPE_FULLSCREEN,
3914 std::string(), CONTENT_SETTING_ALLOW);
3915 }
3916
3917 void Browser::OnDenyFullscreenPermission() {
3918 ExitTabbedFullscreenModeIfNecessary();
3919 }
3920
3921 ContentSetting Browser::GetFullscreenSetting(const GURL& url) {
3922 HostContentSettingsMap* settings_map = profile()->GetHostContentSettingsMap();
3923 return settings_map->GetContentSetting(url, url,
3924 CONTENT_SETTINGS_TYPE_FULLSCREEN, std::string());
3925 }
3926
3885 /////////////////////////////////////////////////////////////////////////////// 3927 ///////////////////////////////////////////////////////////////////////////////
3886 // Browser, TabContentsWrapperDelegate implementation: 3928 // Browser, TabContentsWrapperDelegate implementation:
3887 3929
3888 void Browser::OnDidGetApplicationInfo(TabContentsWrapper* source, 3930 void Browser::OnDidGetApplicationInfo(TabContentsWrapper* source,
3889 int32 page_id) { 3931 int32 page_id) {
3890 if (GetSelectedTabContentsWrapper() != source) 3932 if (GetSelectedTabContentsWrapper() != source)
3891 return; 3933 return;
3892 3934
3893 NavigationEntry* entry = source->controller().GetLastCommittedEntry(); 3935 NavigationEntry* entry = source->controller().GetLastCommittedEntry();
3894 if (!entry || (entry->page_id() != page_id)) 3936 if (!entry || (entry->page_id() != page_id))
(...skipping 1394 matching lines...) Expand 10 before | Expand all | Expand 10 after
5289 window_->GetLocationBar()->ShowFirstRunBubble(bubble_type); 5331 window_->GetLocationBar()->ShowFirstRunBubble(bubble_type);
5290 } else if (is_type_tabbed()) { 5332 } else if (is_type_tabbed()) {
5291 GlobalErrorService* service = 5333 GlobalErrorService* service =
5292 GlobalErrorServiceFactory::GetForProfile(profile()); 5334 GlobalErrorServiceFactory::GetForProfile(profile());
5293 GlobalError* error = service->GetFirstGlobalErrorWithBubbleView(); 5335 GlobalError* error = service->GetFirstGlobalErrorWithBubbleView();
5294 if (error) { 5336 if (error) {
5295 error->ShowBubbleView(this); 5337 error->ShowBubbleView(this);
5296 } 5338 }
5297 } 5339 }
5298 } 5340 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698