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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
63 #include "chrome/browser/intents/register_intent_handler_infobar_delegate.h" | 63 #include "chrome/browser/intents/register_intent_handler_infobar_delegate.h" |
64 #include "chrome/browser/intents/web_intents_registry_factory.h" | 64 #include "chrome/browser/intents/web_intents_registry_factory.h" |
65 #include "chrome/browser/net/browser_url_util.h" | 65 #include "chrome/browser/net/browser_url_util.h" |
66 #include "chrome/browser/net/url_fixer_upper.h" | 66 #include "chrome/browser/net/url_fixer_upper.h" |
67 #include "chrome/browser/notifications/notification_ui_manager.h" | 67 #include "chrome/browser/notifications/notification_ui_manager.h" |
68 #include "chrome/browser/platform_util.h" | 68 #include "chrome/browser/platform_util.h" |
69 #include "chrome/browser/prefs/incognito_mode_prefs.h" | 69 #include "chrome/browser/prefs/incognito_mode_prefs.h" |
70 #include "chrome/browser/prefs/pref_service.h" | 70 #include "chrome/browser/prefs/pref_service.h" |
71 #include "chrome/browser/prerender/prerender_tab_helper.h" | 71 #include "chrome/browser/prerender/prerender_tab_helper.h" |
72 #include "chrome/browser/printing/background_printing_manager.h" | 72 #include "chrome/browser/printing/background_printing_manager.h" |
73 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service.h" | |
74 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service_factory. h" | |
73 #include "chrome/browser/printing/cloud_print/cloud_print_setup_flow.h" | 75 #include "chrome/browser/printing/cloud_print/cloud_print_setup_flow.h" |
74 #include "chrome/browser/printing/print_preview_tab_controller.h" | 76 #include "chrome/browser/printing/print_preview_tab_controller.h" |
75 #include "chrome/browser/printing/print_view_manager.h" | 77 #include "chrome/browser/printing/print_view_manager.h" |
76 #include "chrome/browser/profiles/profile.h" | 78 #include "chrome/browser/profiles/profile.h" |
77 #include "chrome/browser/profiles/profile_manager.h" | 79 #include "chrome/browser/profiles/profile_manager.h" |
78 #include "chrome/browser/sessions/restore_tab_helper.h" | 80 #include "chrome/browser/sessions/restore_tab_helper.h" |
79 #include "chrome/browser/sessions/session_service.h" | 81 #include "chrome/browser/sessions/session_service.h" |
80 #include "chrome/browser/sessions/session_service_factory.h" | 82 #include "chrome/browser/sessions/session_service_factory.h" |
81 #include "chrome/browser/sessions/session_types.h" | 83 #include "chrome/browser/sessions/session_types.h" |
82 #include "chrome/browser/sessions/tab_restore_service.h" | 84 #include "chrome/browser/sessions/tab_restore_service.h" |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
321 } | 323 } |
322 | 324 |
323 profile_pref_registrar_.Init(profile_->GetPrefs()); | 325 profile_pref_registrar_.Init(profile_->GetPrefs()); |
324 profile_pref_registrar_.Add(prefs::kDevToolsDisabled, this); | 326 profile_pref_registrar_.Add(prefs::kDevToolsDisabled, this); |
325 profile_pref_registrar_.Add(prefs::kEditBookmarksEnabled, this); | 327 profile_pref_registrar_.Add(prefs::kEditBookmarksEnabled, this); |
326 profile_pref_registrar_.Add(prefs::kShowBookmarkBar, this); | 328 profile_pref_registrar_.Add(prefs::kShowBookmarkBar, this); |
327 profile_pref_registrar_.Add(prefs::kHomePage, this); | 329 profile_pref_registrar_.Add(prefs::kHomePage, this); |
328 profile_pref_registrar_.Add(prefs::kInstantEnabled, this); | 330 profile_pref_registrar_.Add(prefs::kInstantEnabled, this); |
329 profile_pref_registrar_.Add(prefs::kIncognitoModeAvailability, this); | 331 profile_pref_registrar_.Add(prefs::kIncognitoModeAvailability, this); |
330 profile_pref_registrar_.Add(prefs::kSearchSuggestEnabled, this); | 332 profile_pref_registrar_.Add(prefs::kSearchSuggestEnabled, this); |
333 profile_pref_registrar_.Add(prefs::kCloudPrintProxyEnabled, this); | |
331 | 334 |
332 InitCommandState(); | 335 InitCommandState(); |
333 BrowserList::AddBrowser(this); | 336 BrowserList::AddBrowser(this); |
334 | 337 |
335 // NOTE: These prefs all need to be explicitly destroyed in the destructor | 338 // NOTE: These prefs all need to be explicitly destroyed in the destructor |
336 // or you'll get a nasty surprise when you run the incognito tests. | 339 // or you'll get a nasty surprise when you run the incognito tests. |
337 encoding_auto_detect_.Init(prefs::kWebKitUsesUniversalDetector, | 340 encoding_auto_detect_.Init(prefs::kWebKitUsesUniversalDetector, |
338 profile_->GetPrefs(), NULL); | 341 profile_->GetPrefs(), NULL); |
339 | 342 |
340 tab_restore_service_ = TabRestoreServiceFactory::GetForProfile(profile); | 343 tab_restore_service_ = TabRestoreServiceFactory::GetForProfile(profile); |
(...skipping 3986 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4327 UpdateCommandsForBookmarkEditing(); | 4330 UpdateCommandsForBookmarkEditing(); |
4328 } else if (pref_name == prefs::kShowBookmarkBar) { | 4331 } else if (pref_name == prefs::kShowBookmarkBar) { |
4329 UpdateCommandsForBookmarkBar(); | 4332 UpdateCommandsForBookmarkBar(); |
4330 UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_PREF_CHANGE); | 4333 UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_PREF_CHANGE); |
4331 } else if (pref_name == prefs::kHomePage) { | 4334 } else if (pref_name == prefs::kHomePage) { |
4332 PrefService* pref_service = content::Source<PrefService>(source).ptr(); | 4335 PrefService* pref_service = content::Source<PrefService>(source).ptr(); |
4333 MarkHomePageAsChanged(pref_service); | 4336 MarkHomePageAsChanged(pref_service); |
4334 } else if (pref_name == prefs::kAllowFileSelectionDialogs) { | 4337 } else if (pref_name == prefs::kAllowFileSelectionDialogs) { |
4335 UpdateSaveAsState(GetContentRestrictionsForSelectedTab()); | 4338 UpdateSaveAsState(GetContentRestrictionsForSelectedTab()); |
4336 UpdateOpenFileState(); | 4339 UpdateOpenFileState(); |
4340 } else if (pref_name == prefs::kCloudPrintProxyEnabled) { | |
4341 UpdateCloudPrintConnectorState(); | |
4337 } else { | 4342 } else { |
4338 NOTREACHED(); | 4343 NOTREACHED(); |
4339 } | 4344 } |
4340 break; | 4345 break; |
4341 } | 4346 } |
4342 | 4347 |
4343 case chrome::NOTIFICATION_TAB_CONTENT_SETTINGS_CHANGED: { | 4348 case chrome::NOTIFICATION_TAB_CONTENT_SETTINGS_CHANGED: { |
4344 TabContents* tab_contents = content::Source<TabContents>(source).ptr(); | 4349 TabContents* tab_contents = content::Source<TabContents>(source).ptr(); |
4345 if (tab_contents == GetSelectedTabContents()) { | 4350 if (tab_contents == GetSelectedTabContents()) { |
4346 LocationBar* location_bar = window()->GetLocationBar(); | 4351 LocationBar* location_bar = window()->GetLocationBar(); |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4618 | 4623 |
4619 // Toggle speech input | 4624 // Toggle speech input |
4620 command_updater_.UpdateCommandEnabled(IDC_TOGGLE_SPEECH_INPUT, true); | 4625 command_updater_.UpdateCommandEnabled(IDC_TOGGLE_SPEECH_INPUT, true); |
4621 | 4626 |
4622 // Initialize other commands whose state changes based on fullscreen mode. | 4627 // Initialize other commands whose state changes based on fullscreen mode. |
4623 UpdateCommandsForFullscreenMode(false); | 4628 UpdateCommandsForFullscreenMode(false); |
4624 | 4629 |
4625 UpdateCommandsForContentRestrictionState(); | 4630 UpdateCommandsForContentRestrictionState(); |
4626 | 4631 |
4627 UpdateCommandsForBookmarkEditing(); | 4632 UpdateCommandsForBookmarkEditing(); |
4633 | |
4634 UpdateCloudPrintConnectorState(); | |
Peter Kasting
2011/11/01 22:54:10
This seems like the wrong place for this. This fu
Mattias Nissler (ping if slow)
2011/11/02 10:55:56
Agree with Peter. This should probably be hooked o
Scott Byer
2011/11/02 21:33:25
Makes sense - it was a bit trickier, but not too b
| |
4628 } | 4635 } |
4629 | 4636 |
4630 void Browser::UpdateCommandsForFullscreenMode(bool is_fullscreen) { | 4637 void Browser::UpdateCommandsForFullscreenMode(bool is_fullscreen) { |
4631 #if !defined(OS_MACOSX) | 4638 #if !defined(OS_MACOSX) |
4632 const bool show_main_ui = is_type_tabbed() && !is_fullscreen; | 4639 const bool show_main_ui = is_type_tabbed() && !is_fullscreen; |
4633 #else | 4640 #else |
4634 const bool show_main_ui = is_type_tabbed(); | 4641 const bool show_main_ui = is_type_tabbed(); |
4635 #endif | 4642 #endif |
4636 | 4643 |
4637 bool main_not_fullscreen = show_main_ui && !is_fullscreen; | 4644 bool main_not_fullscreen = show_main_ui && !is_fullscreen; |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4770 wrapper && | 4777 wrapper && |
4771 wrapper == controller->GetPrintPreviewForTab(wrapper)) { | 4778 wrapper == controller->GetPrintPreviewForTab(wrapper)) { |
4772 advanced_print_enabled = true; | 4779 advanced_print_enabled = true; |
4773 } | 4780 } |
4774 } | 4781 } |
4775 command_updater_.UpdateCommandEnabled(IDC_PRINT, print_enabled); | 4782 command_updater_.UpdateCommandEnabled(IDC_PRINT, print_enabled); |
4776 command_updater_.UpdateCommandEnabled(IDC_ADVANCED_PRINT, | 4783 command_updater_.UpdateCommandEnabled(IDC_ADVANCED_PRINT, |
4777 advanced_print_enabled); | 4784 advanced_print_enabled); |
4778 } | 4785 } |
4779 | 4786 |
4787 void Browser::UpdateCloudPrintConnectorState() { | |
4788 if (!profile_->GetPrefs()->GetBoolean(prefs::kCloudPrintProxyEnabled)) { | |
4789 std::string email; | |
4790 if (profile_->GetPrefs()->HasPrefPath(prefs::kCloudPrintEmail)) { | |
4791 email = profile_->GetPrefs()->GetString(prefs::kCloudPrintEmail); | |
4792 | |
4793 if (!email.empty()) | |
Mattias Nissler (ping if slow)
2011/11/02 10:55:56
need curlies.
Scott Byer
2011/11/02 21:33:25
Done.
| |
4794 CloudPrintProxyServiceFactory::GetForProfile(profile_)-> | |
4795 DisableForUser(); | |
4796 } | |
4797 } | |
4798 } | |
4799 | |
4780 void Browser::UpdateReloadStopState(bool is_loading, bool force) { | 4800 void Browser::UpdateReloadStopState(bool is_loading, bool force) { |
4781 window_->UpdateReloadStopState(is_loading, force); | 4801 window_->UpdateReloadStopState(is_loading, force); |
4782 command_updater_.UpdateCommandEnabled(IDC_STOP, is_loading); | 4802 command_updater_.UpdateCommandEnabled(IDC_STOP, is_loading); |
4783 } | 4803 } |
4784 | 4804 |
4785 void Browser::UpdateCommandsForDevTools() { | 4805 void Browser::UpdateCommandsForDevTools() { |
4786 bool dev_tools_enabled = | 4806 bool dev_tools_enabled = |
4787 !profile_->GetPrefs()->GetBoolean(prefs::kDevToolsDisabled); | 4807 !profile_->GetPrefs()->GetBoolean(prefs::kDevToolsDisabled); |
4788 command_updater_.UpdateCommandEnabled(IDC_DEV_TOOLS, | 4808 command_updater_.UpdateCommandEnabled(IDC_DEV_TOOLS, |
4789 dev_tools_enabled); | 4809 dev_tools_enabled); |
(...skipping 712 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5502 } | 5522 } |
5503 | 5523 |
5504 void Browser::UpdateFullscreenExitBubbleContent() { | 5524 void Browser::UpdateFullscreenExitBubbleContent() { |
5505 GURL url; | 5525 GURL url; |
5506 if (fullscreened_tab_) | 5526 if (fullscreened_tab_) |
5507 url = fullscreened_tab_->tab_contents()->GetURL(); | 5527 url = fullscreened_tab_->tab_contents()->GetURL(); |
5508 | 5528 |
5509 window_->UpdateFullscreenExitBubbleContent( | 5529 window_->UpdateFullscreenExitBubbleContent( |
5510 url, GetFullscreenExitBubbleType()); | 5530 url, GetFullscreenExitBubbleType()); |
5511 } | 5531 } |
OLD | NEW |