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

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: fix ups 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 15 matching lines...) Expand all
26 #include "base/utf_string_conversions.h" 26 #include "base/utf_string_conversions.h"
27 #include "chrome/app/chrome_command_ids.h" 27 #include "chrome/app/chrome_command_ids.h"
28 #include "chrome/browser/autofill/autofill_manager.h" 28 #include "chrome/browser/autofill/autofill_manager.h"
29 #include "chrome/browser/autofill/personal_data_manager_factory.h" 29 #include "chrome/browser/autofill/personal_data_manager_factory.h"
30 #include "chrome/browser/background/background_contents_service.h" 30 #include "chrome/browser/background/background_contents_service.h"
31 #include "chrome/browser/bookmarks/bookmark_model.h" 31 #include "chrome/browser/bookmarks/bookmark_model.h"
32 #include "chrome/browser/bookmarks/bookmark_utils.h" 32 #include "chrome/browser/bookmarks/bookmark_utils.h"
33 #include "chrome/browser/browser_process.h" 33 #include "chrome/browser/browser_process.h"
34 #include "chrome/browser/browser_shutdown.h" 34 #include "chrome/browser/browser_shutdown.h"
35 #include "chrome/browser/character_encoding.h" 35 #include "chrome/browser/character_encoding.h"
36 #include "chrome/browser/content_settings/host_content_settings_map.h"
36 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" 37 #include "chrome/browser/custom_handlers/protocol_handler_registry.h"
37 #include "chrome/browser/custom_handlers/register_protocol_handler_infobar_deleg ate.h" 38 #include "chrome/browser/custom_handlers/register_protocol_handler_infobar_deleg ate.h"
38 #include "chrome/browser/debugger/devtools_toggle_action.h" 39 #include "chrome/browser/debugger/devtools_toggle_action.h"
39 #include "chrome/browser/debugger/devtools_window.h" 40 #include "chrome/browser/debugger/devtools_window.h"
40 #include "chrome/browser/download/chrome_download_manager_delegate.h" 41 #include "chrome/browser/download/chrome_download_manager_delegate.h"
41 #include "chrome/browser/download/download_item_model.h" 42 #include "chrome/browser/download/download_item_model.h"
42 #include "chrome/browser/download/download_started_animation.h" 43 #include "chrome/browser/download/download_started_animation.h"
43 #include "chrome/browser/extensions/crx_installer.h" 44 #include "chrome/browser/extensions/crx_installer.h"
44 #include "chrome/browser/extensions/extension_browser_event_router.h" 45 #include "chrome/browser/extensions/extension_browser_event_router.h"
45 #include "chrome/browser/extensions/extension_disabled_infobar_delegate.h" 46 #include "chrome/browser/extensions/extension_disabled_infobar_delegate.h"
(...skipping 686 matching lines...) Expand 10 before | Expand all | Expand 10 after
732 browser::Navigate(&params); 733 browser::Navigate(&params);
733 contents = params.target_contents->tab_contents(); 734 contents = params.target_contents->tab_contents();
734 } 735 }
735 736
736 // TODO(skerner): If we are already in full screen mode, and the user 737 // TODO(skerner): If we are already in full screen mode, and the user
737 // set the app to open as a regular or pinned tab, what should happen? 738 // set the app to open as a regular or pinned tab, what should happen?
738 // Today we open the tab, but stay in full screen mode. Should we leave 739 // Today we open the tab, but stay in full screen mode. Should we leave
739 // full screen mode in this case? 740 // full screen mode in this case?
740 if (launch_type == ExtensionPrefs::LAUNCH_FULLSCREEN && 741 if (launch_type == ExtensionPrefs::LAUNCH_FULLSCREEN &&
741 !browser->window()->IsFullscreen()) 742 !browser->window()->IsFullscreen())
742 browser->ToggleFullscreenMode(); 743 browser->ToggleFullscreenMode(false);
743 744
744 return contents; 745 return contents;
745 } 746 }
746 747
747 // static 748 // static
748 void Browser::OpenBookmarkManagerWindow(Profile* profile) { 749 void Browser::OpenBookmarkManagerWindow(Profile* profile) {
749 Browser* browser = Browser::Create(profile); 750 Browser* browser = Browser::Create(profile);
750 browser->OpenBookmarkManager(); 751 browser->OpenBookmarkManager();
751 browser->window()->Show(); 752 browser->window()->Show();
752 } 753 }
(...skipping 875 matching lines...) Expand 10 before | Expand all | Expand 10 after
1628 void Browser::ConvertPopupToTabbedBrowser() { 1629 void Browser::ConvertPopupToTabbedBrowser() {
1629 UserMetrics::RecordAction(UserMetricsAction("ShowAsTab")); 1630 UserMetrics::RecordAction(UserMetricsAction("ShowAsTab"));
1630 int tab_strip_index = tab_handler_->GetTabStripModel()->active_index(); 1631 int tab_strip_index = tab_handler_->GetTabStripModel()->active_index();
1631 TabContentsWrapper* contents = 1632 TabContentsWrapper* contents =
1632 tab_handler_->GetTabStripModel()->DetachTabContentsAt(tab_strip_index); 1633 tab_handler_->GetTabStripModel()->DetachTabContentsAt(tab_strip_index);
1633 Browser* browser = Browser::Create(profile_); 1634 Browser* browser = Browser::Create(profile_);
1634 browser->tabstrip_model()->AppendTabContents(contents, true); 1635 browser->tabstrip_model()->AppendTabContents(contents, true);
1635 browser->window()->Show(); 1636 browser->window()->Show();
1636 } 1637 }
1637 1638
1638 void Browser::ToggleFullscreenMode() { 1639 // 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.
1640 void Browser::ToggleFullscreenMode(bool for_tab) {
1641 bool entering_fullscreen = !window_->IsFullscreen();
1642
1639 #if !defined(OS_MACOSX) 1643 #if !defined(OS_MACOSX)
1640 // In kiosk mode, we always want to be fullscreen. When the browser first 1644 // In kiosk mode, we always want to be fullscreen. When the browser first
1641 // starts we're not yet fullscreen, so let the initial toggle go through. 1645 // starts we're not yet fullscreen, so let the initial toggle go through.
1642 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kKioskMode) && 1646 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kKioskMode) &&
1643 window_->IsFullscreen()) 1647 window_->IsFullscreen())
1644 return; 1648 return;
1645 #endif 1649 #endif
1646 1650
1647 UserMetrics::RecordAction(UserMetricsAction("ToggleFullscreen")); 1651 UserMetrics::RecordAction(UserMetricsAction("ToggleFullscreen"));
1648 window_->SetFullscreen(!window_->IsFullscreen()); 1652 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.
1653 const GURL& url = GetSelectedTabContents()->GetURL();
1654 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.
1655 GetFullscreenSetting(url) == CONTENT_SETTING_ASK;
1656 window_->SetFullscreen(entering_fullscreen, url, ask_permission);
1657 } else {
1658 // TODO Replace with browser-specific fullscreen function.
1659 window_->SetFullscreen(entering_fullscreen, GURL(), false);
1660 }
1649 1661
1650 // Once the window has become fullscreen it'll call back to 1662 // Once the window has become fullscreen it'll call back to
1651 // WindowFullscreenStateChanged(). We don't do this immediately as 1663 // WindowFullscreenStateChanged(). We don't do this immediately as
1652 // BrowserWindow::SetFullscreen() asks for bookmark_bar_state_, so we let the 1664 // BrowserWindow::SetFullscreen() asks for bookmark_bar_state_, so we let the
1653 // BrowserWindow invoke WindowFullscreenStateChanged when appropriate. 1665 // BrowserWindow invoke WindowFullscreenStateChanged when appropriate.
1654 1666
1655 // TODO: convert mac to invoke WindowFullscreenStateChanged once it updates 1667 // TODO: convert mac to invoke WindowFullscreenStateChanged once it updates
1656 // the necessary state of the frame. 1668 // the necessary state of the frame.
1657 #if defined(OS_MACOSX) 1669 #if defined(OS_MACOSX)
1658 WindowFullscreenStateChanged(); 1670 WindowFullscreenStateChanged();
1659 #endif 1671 #endif
1660 } 1672 }
1661 1673
1662 void Browser::NotifyTabOfFullscreenExitIfNecessary() { 1674 void Browser::NotifyTabOfFullscreenExitIfNecessary() {
1663 if (fullscreened_tab_) 1675 if (fullscreened_tab_)
1664 fullscreened_tab_->ExitFullscreenMode(); 1676 fullscreened_tab_->ExitFullscreenMode();
1665 fullscreened_tab_ = NULL; 1677 fullscreened_tab_ = NULL;
1666 tab_caused_fullscreen_ = false; 1678 tab_caused_fullscreen_ = false;
1667 } 1679 }
1668 1680
1669 #if defined(OS_MACOSX) 1681 #if defined(OS_MACOSX)
1670 void Browser::TogglePresentationMode() { 1682 void Browser::TogglePresentationMode(bool for_tab) {
1671 window_->SetPresentationMode(!window_->InPresentationMode()); 1683 bool entering_fullscreen = !window_->InPresentationMode();
1684 if (for_tab) {
1685 const GURL& url = GetSelectedTabContents()->GetURL();
1686 bool ask_permission = GetFullscreenSetting(url) == CONTENT_SETTING_ASK;
1687 window_->SetPresentationMode(entering_fullscreen, url, ask_permission);
1688 } else {
1689 window_->SetPresentationMode(entering_fullscreen, GURL(), false);
1690 }
1672 WindowFullscreenStateChanged(); 1691 WindowFullscreenStateChanged();
1673 } 1692 }
1674 #endif 1693 #endif
1675 1694
1676 #if defined(OS_CHROMEOS) 1695 #if defined(OS_CHROMEOS)
1677 void Browser::Search() { 1696 void Browser::Search() {
1678 // Exit fullscreen to show omnibox. 1697 // Exit fullscreen to show omnibox.
1679 if (window_->IsFullscreen()) { 1698 if (window_->IsFullscreen()) {
1680 ToggleFullscreenMode(); 1699 ToggleFullscreenMode(false);
1681 // ToggleFullscreenMode is asynchronous, so we don't have omnibox 1700 // ToggleFullscreenMode is asynchronous, so we don't have omnibox
1682 // visible at this point. Wait for next event cycle which toggles 1701 // visible at this point. Wait for next event cycle which toggles
1683 // the visibility of omnibox before creating new tab. 1702 // the visibility of omnibox before creating new tab.
1684 MessageLoop::current()->PostTask( 1703 MessageLoop::current()->PostTask(
1685 FROM_HERE, method_factory_.NewRunnableMethod(&Browser::Search)); 1704 FROM_HERE, method_factory_.NewRunnableMethod(&Browser::Search));
1686 return; 1705 return;
1687 } 1706 }
1688 1707
1689 const GURL& url = GetSelectedTabContents()->GetURL(); 1708 const GURL& url = GetSelectedTabContents()->GetURL();
1690 if (url.SchemeIs(chrome::kChromeUIScheme) && 1709 if (url.SchemeIs(chrome::kChromeUIScheme) &&
(...skipping 906 matching lines...) Expand 10 before | Expand all | Expand 10 after
2597 case IDC_SELECT_TAB_4: 2616 case IDC_SELECT_TAB_4:
2598 case IDC_SELECT_TAB_5: 2617 case IDC_SELECT_TAB_5:
2599 case IDC_SELECT_TAB_6: 2618 case IDC_SELECT_TAB_6:
2600 case IDC_SELECT_TAB_7: SelectNumberedTab(id - IDC_SELECT_TAB_0); 2619 case IDC_SELECT_TAB_7: SelectNumberedTab(id - IDC_SELECT_TAB_0);
2601 break; 2620 break;
2602 case IDC_SELECT_LAST_TAB: SelectLastTab(); break; 2621 case IDC_SELECT_LAST_TAB: SelectLastTab(); break;
2603 case IDC_DUPLICATE_TAB: DuplicateTab(); break; 2622 case IDC_DUPLICATE_TAB: DuplicateTab(); break;
2604 case IDC_RESTORE_TAB: RestoreTab(); break; 2623 case IDC_RESTORE_TAB: RestoreTab(); break;
2605 case IDC_COPY_URL: WriteCurrentURLToClipboard(); break; 2624 case IDC_COPY_URL: WriteCurrentURLToClipboard(); break;
2606 case IDC_SHOW_AS_TAB: ConvertPopupToTabbedBrowser(); break; 2625 case IDC_SHOW_AS_TAB: ConvertPopupToTabbedBrowser(); break;
2607 case IDC_FULLSCREEN: ToggleFullscreenMode(); break; 2626 case IDC_FULLSCREEN: ToggleFullscreenMode(false); break;
2608 #if defined(OS_MACOSX) 2627 #if defined(OS_MACOSX)
2609 case IDC_PRESENTATION_MODE: TogglePresentationMode(); break; 2628 case IDC_PRESENTATION_MODE: TogglePresentationMode(false); break;
2610 #endif 2629 #endif
2611 case IDC_EXIT: Exit(); break; 2630 case IDC_EXIT: Exit(); break;
2612 #if defined(OS_CHROMEOS) 2631 #if defined(OS_CHROMEOS)
2613 case IDC_SEARCH: Search(); break; 2632 case IDC_SEARCH: Search(); break;
2614 case IDC_SHOW_KEYBOARD_OVERLAY: ShowKeyboardOverlay(); break; 2633 case IDC_SHOW_KEYBOARD_OVERLAY: ShowKeyboardOverlay(); break;
2615 #endif 2634 #endif
2616 2635
2617 // Page-related commands 2636 // Page-related commands
2618 case IDC_SAVE_PAGE: SavePage(); break; 2637 case IDC_SAVE_PAGE: SavePage(); break;
2619 case IDC_BOOKMARK_PAGE: BookmarkCurrentPage(); break; 2638 case IDC_BOOKMARK_PAGE: BookmarkCurrentPage(); break;
(...skipping 1153 matching lines...) Expand 10 before | Expand all | Expand 10 after
3773 in_correct_mode_for_tab_fullscreen = window_->InPresentationMode(); 3792 in_correct_mode_for_tab_fullscreen = window_->InPresentationMode();
3774 #else 3793 #else
3775 in_correct_mode_for_tab_fullscreen = window_->IsFullscreen(); 3794 in_correct_mode_for_tab_fullscreen = window_->IsFullscreen();
3776 #endif 3795 #endif
3777 if (!in_correct_mode_for_tab_fullscreen) 3796 if (!in_correct_mode_for_tab_fullscreen)
3778 tab_caused_fullscreen_ = true; 3797 tab_caused_fullscreen_ = true;
3779 } 3798 }
3780 3799
3781 if (tab_caused_fullscreen_) { 3800 if (tab_caused_fullscreen_) {
3782 #if defined(OS_MACOSX) 3801 #if defined(OS_MACOSX)
3783 TogglePresentationMode(); 3802 TogglePresentationMode(true);
3784 #else 3803 #else
3785 ToggleFullscreenMode(); 3804 ToggleFullscreenMode(true);
3786 #endif 3805 #endif
3787 } else if (!enter_fullscreen) { 3806 } else if (!enter_fullscreen) {
3788 // If currently there is a tab in "tab fullscreen" mode and fullscreen was 3807 // If currently there is a tab in "tab fullscreen" mode and fullscreen was
3789 // not caused by it (i.e., previously it was in "browser fullscreen" mode), 3808 // not caused by it (i.e., previously it was in "browser fullscreen" mode),
3790 // we need to switch back to "browser fullscreen" mode. In this case, all we 3809 // we need to switch back to "browser fullscreen" mode. In this case, all we
3791 // have to do is notifying the tab that it has exited "tab fullscreen" mode. 3810 // have to do is notifying the tab that it has exited "tab fullscreen" mode.
3792 NotifyTabOfFullscreenExitIfNecessary(); 3811 NotifyTabOfFullscreenExitIfNecessary();
3793 } 3812 }
3794 } 3813 }
3795 3814
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
3851 FindReplyHelper(tab, request_id, number_of_matches, selection_rect, 3870 FindReplyHelper(tab, request_id, number_of_matches, selection_rect,
3852 active_match_ordinal, final_update); 3871 active_match_ordinal, final_update);
3853 } 3872 }
3854 3873
3855 void Browser::CrashedPlugin(TabContents* tab, const FilePath& plugin_path) { 3874 void Browser::CrashedPlugin(TabContents* tab, const FilePath& plugin_path) {
3856 CrashedPluginHelper(tab, plugin_path); 3875 CrashedPluginHelper(tab, plugin_path);
3857 } 3876 }
3858 3877
3859 void Browser::ExitTabbedFullscreenModeIfNecessary() { 3878 void Browser::ExitTabbedFullscreenModeIfNecessary() {
3860 if (tab_caused_fullscreen_) 3879 if (tab_caused_fullscreen_)
3861 ToggleFullscreenMode(); 3880 ToggleFullscreenMode(false);
3862 else 3881 else
3863 NotifyTabOfFullscreenExitIfNecessary(); 3882 NotifyTabOfFullscreenExitIfNecessary();
3864 } 3883 }
3865 3884
3866 void Browser::UpdatePreferredSize(TabContents* source, 3885 void Browser::UpdatePreferredSize(TabContents* source,
3867 const gfx::Size& pref_size) { 3886 const gfx::Size& pref_size) {
3868 window_->UpdatePreferredSize(source, pref_size); 3887 window_->UpdatePreferredSize(source, pref_size);
3869 } 3888 }
3870 3889
3890 void Browser::OnAcceptFullscreenPermission(const GURL& url) {
3891 HostContentSettingsMap* settings_map = profile()->GetHostContentSettingsMap();
3892
3893 settings_map->SetContentSetting(
3894 ContentSettingsPattern::FromString(url.host()),
3895 ContentSettingsPattern::Wildcard(), CONTENT_SETTINGS_TYPE_FULLSCREEN,
3896 "", 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.
3897 }
3898
3899 void Browser::OnDenyFullscreenPermission() {
3900 ExitTabbedFullscreenModeIfNecessary();
3901 }
3902
3903 ContentSetting Browser::GetFullscreenSetting(const GURL& url) {
3904 HostContentSettingsMap* settings_map = profile()->GetHostContentSettingsMap();
3905 return settings_map->GetContentSetting(url, url,
3906 CONTENT_SETTINGS_TYPE_FULLSCREEN, "");
3907 }
3908
3871 /////////////////////////////////////////////////////////////////////////////// 3909 ///////////////////////////////////////////////////////////////////////////////
3872 // Browser, TabContentsWrapperDelegate implementation: 3910 // Browser, TabContentsWrapperDelegate implementation:
3873 3911
3874 void Browser::OnDidGetApplicationInfo(TabContentsWrapper* source, 3912 void Browser::OnDidGetApplicationInfo(TabContentsWrapper* source,
3875 int32 page_id) { 3913 int32 page_id) {
3876 if (GetSelectedTabContentsWrapper() != source) 3914 if (GetSelectedTabContentsWrapper() != source)
3877 return; 3915 return;
3878 3916
3879 NavigationEntry* entry = source->controller().GetLastCommittedEntry(); 3917 NavigationEntry* entry = source->controller().GetLastCommittedEntry();
3880 if (!entry || (entry->page_id() != page_id)) 3918 if (!entry || (entry->page_id() != page_id))
(...skipping 1393 matching lines...) Expand 10 before | Expand all | Expand 10 after
5274 window_->GetLocationBar()->ShowFirstRunBubble(bubble_type); 5312 window_->GetLocationBar()->ShowFirstRunBubble(bubble_type);
5275 } else if (is_type_tabbed()) { 5313 } else if (is_type_tabbed()) {
5276 GlobalErrorService* service = 5314 GlobalErrorService* service =
5277 GlobalErrorServiceFactory::GetForProfile(profile()); 5315 GlobalErrorServiceFactory::GetForProfile(profile());
5278 GlobalError* error = service->GetFirstGlobalErrorWithBubbleView(); 5316 GlobalError* error = service->GetFirstGlobalErrorWithBubbleView();
5279 if (error) { 5317 if (error) {
5280 error->ShowBubbleView(this); 5318 error->ShowBubbleView(this);
5281 } 5319 }
5282 } 5320 }
5283 } 5321 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698