Chromium Code Reviews| 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 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 298 // We listen to all notification sources because the bookmark bar | 298 // We listen to all notification sources because the bookmark bar |
| 299 // state needs to stay in sync between the incognito and normal profiles. | 299 // state needs to stay in sync between the incognito and normal profiles. |
| 300 registrar_.Add(this, | 300 registrar_.Add(this, |
| 301 chrome::NOTIFICATION_BOOKMARK_BAR_VISIBILITY_PREF_CHANGED, | 301 chrome::NOTIFICATION_BOOKMARK_BAR_VISIBILITY_PREF_CHANGED, |
| 302 NotificationService::AllBrowserContextsAndSources()); | 302 NotificationService::AllBrowserContextsAndSources()); |
| 303 | 303 |
| 304 // Need to know when to alert the user of theme install delay. | 304 // Need to know when to alert the user of theme install delay. |
| 305 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_READY_FOR_INSTALL, | 305 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_READY_FOR_INSTALL, |
| 306 NotificationService::AllSources()); | 306 NotificationService::AllSources()); |
| 307 | 307 |
| 308 registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED, | |
|
Peter Kasting
2011/09/23 19:20:06
Why is this here when you have the more-specific o
koz (OOO until 15th September)
2011/09/26 08:15:21
Oops, this was left over from previous iterations.
| |
| 309 NotificationService::AllSources()); | |
| 310 | |
| 308 PrefService* local_state = g_browser_process->local_state(); | 311 PrefService* local_state = g_browser_process->local_state(); |
| 309 if (local_state) { | 312 if (local_state) { |
| 310 local_pref_registrar_.Init(local_state); | 313 local_pref_registrar_.Init(local_state); |
| 311 local_pref_registrar_.Add(prefs::kPrintingEnabled, this); | 314 local_pref_registrar_.Add(prefs::kPrintingEnabled, this); |
| 312 local_pref_registrar_.Add(prefs::kAllowFileSelectionDialogs, this); | 315 local_pref_registrar_.Add(prefs::kAllowFileSelectionDialogs, this); |
| 313 local_pref_registrar_.Add(prefs::kMetricsReportingEnabled, this); | 316 local_pref_registrar_.Add(prefs::kMetricsReportingEnabled, this); |
| 314 } | 317 } |
| 315 | 318 |
| 316 profile_pref_registrar_.Init(profile_->GetPrefs()); | 319 profile_pref_registrar_.Init(profile_->GetPrefs()); |
| 317 profile_pref_registrar_.Add(prefs::kDevToolsDisabled, this); | 320 profile_pref_registrar_.Add(prefs::kDevToolsDisabled, this); |
| (...skipping 1377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1695 // BrowserWindow invoke WindowFullscreenStateChanged when appropriate. | 1698 // BrowserWindow invoke WindowFullscreenStateChanged when appropriate. |
| 1696 | 1699 |
| 1697 // TODO: convert mac to invoke WindowFullscreenStateChanged once it updates | 1700 // TODO: convert mac to invoke WindowFullscreenStateChanged once it updates |
| 1698 // the necessary state of the frame. | 1701 // the necessary state of the frame. |
| 1699 #if defined(OS_MACOSX) | 1702 #if defined(OS_MACOSX) |
| 1700 WindowFullscreenStateChanged(); | 1703 WindowFullscreenStateChanged(); |
| 1701 #endif | 1704 #endif |
| 1702 } | 1705 } |
| 1703 | 1706 |
| 1704 void Browser::NotifyTabOfFullscreenExitIfNecessary() { | 1707 void Browser::NotifyTabOfFullscreenExitIfNecessary() { |
| 1705 if (fullscreened_tab_) | 1708 if (fullscreened_tab_) { |
| 1706 fullscreened_tab_->ExitFullscreenMode(); | 1709 fullscreened_tab_->ExitFullscreenMode(); |
| 1710 registrar_.Remove(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED, | |
| 1711 Source<NavigationController>(&fullscreened_tab_->controller())); | |
| 1712 } | |
| 1707 fullscreened_tab_ = NULL; | 1713 fullscreened_tab_ = NULL; |
| 1708 tab_caused_fullscreen_ = false; | 1714 tab_caused_fullscreen_ = false; |
| 1709 } | 1715 } |
| 1710 | 1716 |
| 1711 #if defined(OS_MACOSX) | 1717 #if defined(OS_MACOSX) |
| 1712 void Browser::TogglePresentationMode() { | 1718 void Browser::TogglePresentationMode() { |
| 1713 window_->SetPresentationMode(!window_->InPresentationMode()); | 1719 window_->SetPresentationMode(!window_->InPresentationMode()); |
| 1714 WindowFullscreenStateChanged(); | 1720 WindowFullscreenStateChanged(); |
| 1715 } | 1721 } |
| 1716 #endif | 1722 #endif |
| (...skipping 2084 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3801 | 3807 |
| 3802 void Browser::EnumerateDirectory(TabContents* tab, int request_id, | 3808 void Browser::EnumerateDirectory(TabContents* tab, int request_id, |
| 3803 const FilePath& path) { | 3809 const FilePath& path) { |
| 3804 EnumerateDirectoryHelper(tab, request_id, path); | 3810 EnumerateDirectoryHelper(tab, request_id, path); |
| 3805 } | 3811 } |
| 3806 | 3812 |
| 3807 void Browser::ToggleFullscreenModeForTab(TabContents* tab, | 3813 void Browser::ToggleFullscreenModeForTab(TabContents* tab, |
| 3808 bool enter_fullscreen) { | 3814 bool enter_fullscreen) { |
| 3809 if (tab != GetSelectedTabContents()) | 3815 if (tab != GetSelectedTabContents()) |
| 3810 return; | 3816 return; |
| 3811 fullscreened_tab_ = enter_fullscreen ? | 3817 if (enter_fullscreen) { |
| 3812 TabContentsWrapper::GetCurrentWrapperForContents(tab) : NULL; | 3818 fullscreened_tab_ = |
| 3819 TabContentsWrapper::GetCurrentWrapperForContents(tab); | |
| 3820 registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED, | |
| 3821 Source<NavigationController>(&fullscreened_tab_->controller())); | |
| 3822 } else { | |
| 3823 registrar_.Remove(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED, | |
|
Peter Kasting
2011/09/23 19:20:06
Is this codepath guaranteed to be reached in all c
koz (OOO until 15th September)
2011/09/26 08:15:21
I think it is. It is equivalent to exiting tabbed
| |
| 3824 Source<NavigationController>(&fullscreened_tab_->controller())); | |
| 3825 fullscreened_tab_ = NULL; | |
| 3826 } | |
| 3813 bool in_correct_mode_for_tab_fullscreen; | 3827 bool in_correct_mode_for_tab_fullscreen; |
| 3814 #if defined(OS_MACOSX) | 3828 #if defined(OS_MACOSX) |
| 3815 in_correct_mode_for_tab_fullscreen = window_->InPresentationMode(); | 3829 in_correct_mode_for_tab_fullscreen = window_->InPresentationMode(); |
| 3816 #else | 3830 #else |
| 3817 in_correct_mode_for_tab_fullscreen = window_->IsFullscreen(); | 3831 in_correct_mode_for_tab_fullscreen = window_->IsFullscreen(); |
| 3818 #endif | 3832 #endif |
| 3819 if (enter_fullscreen && !in_correct_mode_for_tab_fullscreen) | 3833 if (enter_fullscreen && !in_correct_mode_for_tab_fullscreen) |
| 3820 tab_caused_fullscreen_ = true; | 3834 tab_caused_fullscreen_ = true; |
| 3821 if (tab_caused_fullscreen_) { | 3835 if (tab_caused_fullscreen_) { |
| 3822 #if defined(OS_MACOSX) | 3836 #if defined(OS_MACOSX) |
| (...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4129 } | 4143 } |
| 4130 | 4144 |
| 4131 case content::NOTIFICATION_INTERSTITIAL_ATTACHED: | 4145 case content::NOTIFICATION_INTERSTITIAL_ATTACHED: |
| 4132 UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_TAB_STATE); | 4146 UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_TAB_STATE); |
| 4133 break; | 4147 break; |
| 4134 | 4148 |
| 4135 case chrome::NOTIFICATION_BOOKMARK_BAR_VISIBILITY_PREF_CHANGED: | 4149 case chrome::NOTIFICATION_BOOKMARK_BAR_VISIBILITY_PREF_CHANGED: |
| 4136 if (profile_->IsSameProfile(Source<Profile>(source).ptr())) | 4150 if (profile_->IsSameProfile(Source<Profile>(source).ptr())) |
| 4137 UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_PREF_CHANGE); | 4151 UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_PREF_CHANGE); |
| 4138 break; | 4152 break; |
| 4153 case content::NOTIFICATION_NAV_ENTRY_COMMITTED: { | |
| 4154 ExitTabbedFullscreenModeIfNecessary(); | |
|
Peter Kasting
2011/09/23 19:20:06
Are you sure this is what you want to do? It seem
koz (OOO until 15th September)
2011/09/26 08:15:21
I've added a check for NavigationTypes that should
| |
| 4155 break; | |
| 4156 } | |
| 4139 | 4157 |
| 4140 default: | 4158 default: |
| 4141 NOTREACHED() << "Got a notification we didn't register for."; | 4159 NOTREACHED() << "Got a notification we didn't register for."; |
| 4142 } | 4160 } |
| 4143 } | 4161 } |
| 4144 | 4162 |
| 4145 /////////////////////////////////////////////////////////////////////////////// | 4163 /////////////////////////////////////////////////////////////////////////////// |
| 4146 // Browser, ProfileSyncServiceObserver implementation: | 4164 // Browser, ProfileSyncServiceObserver implementation: |
| 4147 | 4165 |
| 4148 void Browser::OnStateChanged() { | 4166 void Browser::OnStateChanged() { |
| (...skipping 1101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5250 profile()->GetOriginalProfile()->GetProfileSyncService(); | 5268 profile()->GetOriginalProfile()->GetProfileSyncService(); |
| 5251 if (service->HasSyncSetupCompleted()) | 5269 if (service->HasSyncSetupCompleted()) |
| 5252 ShowOptionsTab(chrome::kSyncSetupSubPage); | 5270 ShowOptionsTab(chrome::kSyncSetupSubPage); |
| 5253 else | 5271 else |
| 5254 service->ShowLoginDialog(); | 5272 service->ShowLoginDialog(); |
| 5255 } | 5273 } |
| 5256 | 5274 |
| 5257 void Browser::ToggleSpeechInput() { | 5275 void Browser::ToggleSpeechInput() { |
| 5258 GetSelectedTabContentsWrapper()->render_view_host()->ToggleSpeechInput(); | 5276 GetSelectedTabContentsWrapper()->render_view_host()->ToggleSpeechInput(); |
| 5259 } | 5277 } |
| OLD | NEW |