OLD | NEW |
---|---|
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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
124 #include "content/browser/child_process_security_policy.h" | 124 #include "content/browser/child_process_security_policy.h" |
125 #include "content/browser/debugger/devtools_manager.h" | 125 #include "content/browser/debugger/devtools_manager.h" |
126 #include "content/browser/download/download_item.h" | 126 #include "content/browser/download/download_item.h" |
127 #include "content/browser/download/download_manager.h" | 127 #include "content/browser/download/download_manager.h" |
128 #include "content/browser/download/save_package.h" | 128 #include "content/browser/download/save_package.h" |
129 #include "content/browser/host_zoom_map.h" | 129 #include "content/browser/host_zoom_map.h" |
130 #include "content/browser/renderer_host/render_view_host.h" | 130 #include "content/browser/renderer_host/render_view_host.h" |
131 #include "content/browser/site_instance.h" | 131 #include "content/browser/site_instance.h" |
132 #include "content/browser/tab_contents/interstitial_page.h" | 132 #include "content/browser/tab_contents/interstitial_page.h" |
133 #include "content/browser/tab_contents/navigation_controller.h" | 133 #include "content/browser/tab_contents/navigation_controller.h" |
134 #include "content/browser/tab_contents/navigation_details.h" | |
134 #include "content/browser/tab_contents/navigation_entry.h" | 135 #include "content/browser/tab_contents/navigation_entry.h" |
135 #include "content/browser/tab_contents/tab_contents_view.h" | 136 #include "content/browser/tab_contents/tab_contents_view.h" |
136 #include "content/browser/user_metrics.h" | 137 #include "content/browser/user_metrics.h" |
137 #include "content/common/content_restriction.h" | 138 #include "content/common/content_restriction.h" |
138 #include "content/common/content_switches.h" | 139 #include "content/common/content_switches.h" |
139 #include "content/common/notification_service.h" | 140 #include "content/common/notification_service.h" |
140 #include "content/common/page_transition_types.h" | 141 #include "content/common/page_transition_types.h" |
141 #include "content/common/page_zoom.h" | 142 #include "content/common/page_zoom.h" |
142 #include "content/common/view_messages.h" | 143 #include "content/common/view_messages.h" |
143 #include "grit/chromium_strings.h" | 144 #include "grit/chromium_strings.h" |
(...skipping 1551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1695 // BrowserWindow invoke WindowFullscreenStateChanged when appropriate. | 1696 // BrowserWindow invoke WindowFullscreenStateChanged when appropriate. |
1696 | 1697 |
1697 // TODO: convert mac to invoke WindowFullscreenStateChanged once it updates | 1698 // TODO: convert mac to invoke WindowFullscreenStateChanged once it updates |
1698 // the necessary state of the frame. | 1699 // the necessary state of the frame. |
1699 #if defined(OS_MACOSX) | 1700 #if defined(OS_MACOSX) |
1700 WindowFullscreenStateChanged(); | 1701 WindowFullscreenStateChanged(); |
1701 #endif | 1702 #endif |
1702 } | 1703 } |
1703 | 1704 |
1704 void Browser::NotifyTabOfFullscreenExitIfNecessary() { | 1705 void Browser::NotifyTabOfFullscreenExitIfNecessary() { |
1705 if (fullscreened_tab_) | 1706 if (fullscreened_tab_) { |
1706 fullscreened_tab_->ExitFullscreenMode(); | 1707 fullscreened_tab_->ExitFullscreenMode(); |
1708 registrar_.Remove(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED, | |
1709 Source<NavigationController>(&fullscreened_tab_->controller())); | |
1710 } | |
1707 fullscreened_tab_ = NULL; | 1711 fullscreened_tab_ = NULL; |
1708 tab_caused_fullscreen_ = false; | 1712 tab_caused_fullscreen_ = false; |
1709 } | 1713 } |
1710 | 1714 |
1711 #if defined(OS_MACOSX) | 1715 #if defined(OS_MACOSX) |
1712 void Browser::TogglePresentationMode() { | 1716 void Browser::TogglePresentationMode() { |
1713 window_->SetPresentationMode(!window_->InPresentationMode()); | 1717 window_->SetPresentationMode(!window_->InPresentationMode()); |
1714 WindowFullscreenStateChanged(); | 1718 WindowFullscreenStateChanged(); |
1715 } | 1719 } |
1716 #endif | 1720 #endif |
(...skipping 2084 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3801 | 3805 |
3802 void Browser::EnumerateDirectory(TabContents* tab, int request_id, | 3806 void Browser::EnumerateDirectory(TabContents* tab, int request_id, |
3803 const FilePath& path) { | 3807 const FilePath& path) { |
3804 EnumerateDirectoryHelper(tab, request_id, path); | 3808 EnumerateDirectoryHelper(tab, request_id, path); |
3805 } | 3809 } |
3806 | 3810 |
3807 void Browser::ToggleFullscreenModeForTab(TabContents* tab, | 3811 void Browser::ToggleFullscreenModeForTab(TabContents* tab, |
3808 bool enter_fullscreen) { | 3812 bool enter_fullscreen) { |
3809 if (tab != GetSelectedTabContents()) | 3813 if (tab != GetSelectedTabContents()) |
3810 return; | 3814 return; |
3811 fullscreened_tab_ = enter_fullscreen ? | 3815 if (enter_fullscreen) { |
3812 TabContentsWrapper::GetCurrentWrapperForContents(tab) : NULL; | 3816 fullscreened_tab_ = |
3817 TabContentsWrapper::GetCurrentWrapperForContents(tab); | |
3818 registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED, | |
3819 Source<NavigationController>(&fullscreened_tab_->controller())); | |
3820 } else { | |
3821 registrar_.Remove(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED, | |
3822 Source<NavigationController>(&fullscreened_tab_->controller())); | |
3823 fullscreened_tab_ = NULL; | |
3824 } | |
3813 bool in_correct_mode_for_tab_fullscreen; | 3825 bool in_correct_mode_for_tab_fullscreen; |
3814 #if defined(OS_MACOSX) | 3826 #if defined(OS_MACOSX) |
3815 in_correct_mode_for_tab_fullscreen = window_->InPresentationMode(); | 3827 in_correct_mode_for_tab_fullscreen = window_->InPresentationMode(); |
3816 #else | 3828 #else |
3817 in_correct_mode_for_tab_fullscreen = window_->IsFullscreen(); | 3829 in_correct_mode_for_tab_fullscreen = window_->IsFullscreen(); |
3818 #endif | 3830 #endif |
3819 if (enter_fullscreen && !in_correct_mode_for_tab_fullscreen) | 3831 if (enter_fullscreen && !in_correct_mode_for_tab_fullscreen) |
3820 tab_caused_fullscreen_ = true; | 3832 tab_caused_fullscreen_ = true; |
3821 if (tab_caused_fullscreen_) { | 3833 if (tab_caused_fullscreen_) { |
3822 #if defined(OS_MACOSX) | 3834 #if defined(OS_MACOSX) |
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4129 } | 4141 } |
4130 | 4142 |
4131 case content::NOTIFICATION_INTERSTITIAL_ATTACHED: | 4143 case content::NOTIFICATION_INTERSTITIAL_ATTACHED: |
4132 UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_TAB_STATE); | 4144 UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_TAB_STATE); |
4133 break; | 4145 break; |
4134 | 4146 |
4135 case chrome::NOTIFICATION_BOOKMARK_BAR_VISIBILITY_PREF_CHANGED: | 4147 case chrome::NOTIFICATION_BOOKMARK_BAR_VISIBILITY_PREF_CHANGED: |
4136 if (profile_->IsSameProfile(Source<Profile>(source).ptr())) | 4148 if (profile_->IsSameProfile(Source<Profile>(source).ptr())) |
4137 UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_PREF_CHANGE); | 4149 UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_PREF_CHANGE); |
4138 break; | 4150 break; |
4151 case content::NOTIFICATION_NAV_ENTRY_COMMITTED: { | |
4152 const content::LoadCommittedDetails& lcd = | |
4153 *Details<content::LoadCommittedDetails>(details).ptr(); | |
4154 if (lcd.type != NavigationType::AUTO_SUBFRAME && | |
4155 lcd.type != NavigationType::NEW_SUBFRAME && | |
4156 lcd.type != NavigationType::NAV_IGNORE) { | |
Peter Kasting
2011/09/26 20:24:58
This still seems suspicious to me. Why aren't you
koz (OOO until 15th September)
2011/09/26 23:55:58
I figured I'd err on the side of caution with frag
| |
4157 ExitTabbedFullscreenModeIfNecessary(); | |
4158 } | |
4159 break; | |
4160 } | |
4139 | 4161 |
4140 default: | 4162 default: |
4141 NOTREACHED() << "Got a notification we didn't register for."; | 4163 NOTREACHED() << "Got a notification we didn't register for."; |
4142 } | 4164 } |
4143 } | 4165 } |
4144 | 4166 |
4145 /////////////////////////////////////////////////////////////////////////////// | 4167 /////////////////////////////////////////////////////////////////////////////// |
4146 // Browser, ProfileSyncServiceObserver implementation: | 4168 // Browser, ProfileSyncServiceObserver implementation: |
4147 | 4169 |
4148 void Browser::OnStateChanged() { | 4170 void Browser::OnStateChanged() { |
(...skipping 1101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5250 profile()->GetOriginalProfile()->GetProfileSyncService(); | 5272 profile()->GetOriginalProfile()->GetProfileSyncService(); |
5251 if (service->HasSyncSetupCompleted()) | 5273 if (service->HasSyncSetupCompleted()) |
5252 ShowOptionsTab(chrome::kSyncSetupSubPage); | 5274 ShowOptionsTab(chrome::kSyncSetupSubPage); |
5253 else | 5275 else |
5254 service->ShowLoginDialog(); | 5276 service->ShowLoginDialog(); |
5255 } | 5277 } |
5256 | 5278 |
5257 void Browser::ToggleSpeechInput() { | 5279 void Browser::ToggleSpeechInput() { |
5258 GetSelectedTabContentsWrapper()->render_view_host()->ToggleSpeechInput(); | 5280 GetSelectedTabContentsWrapper()->render_view_host()->ToggleSpeechInput(); |
5259 } | 5281 } |
OLD | NEW |