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 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 #include "content/browser/download/save_package.h" | 142 #include "content/browser/download/save_package.h" |
143 #include "content/browser/host_zoom_map.h" | 143 #include "content/browser/host_zoom_map.h" |
144 #include "content/browser/plugin_service.h" | 144 #include "content/browser/plugin_service.h" |
145 #include "content/browser/renderer_host/render_view_host.h" | 145 #include "content/browser/renderer_host/render_view_host.h" |
146 #include "content/browser/site_instance.h" | 146 #include "content/browser/site_instance.h" |
147 #include "content/browser/tab_contents/interstitial_page.h" | 147 #include "content/browser/tab_contents/interstitial_page.h" |
148 #include "content/browser/tab_contents/navigation_controller.h" | 148 #include "content/browser/tab_contents/navigation_controller.h" |
149 #include "content/browser/tab_contents/navigation_entry.h" | 149 #include "content/browser/tab_contents/navigation_entry.h" |
150 #include "content/browser/tab_contents/tab_contents_view.h" | 150 #include "content/browser/tab_contents/tab_contents_view.h" |
151 #include "content/browser/user_metrics.h" | 151 #include "content/browser/user_metrics.h" |
152 #include "content/common/content_restriction.h" | |
153 #include "content/public/browser/notification_service.h" | 152 #include "content/public/browser/notification_service.h" |
154 #include "content/public/browser/notification_details.h" | 153 #include "content/public/browser/notification_details.h" |
| 154 #include "content/public/common/content_restriction.h" |
155 #include "content/public/common/content_switches.h" | 155 #include "content/public/common/content_switches.h" |
156 #include "grit/chromium_strings.h" | 156 #include "grit/chromium_strings.h" |
157 #include "grit/generated_resources.h" | 157 #include "grit/generated_resources.h" |
158 #include "grit/locale_settings.h" | 158 #include "grit/locale_settings.h" |
159 #include "grit/theme_resources_standard.h" | 159 #include "grit/theme_resources_standard.h" |
160 #include "net/base/cookie_monster.h" | 160 #include "net/base/cookie_monster.h" |
161 #include "net/base/net_util.h" | 161 #include "net/base/net_util.h" |
162 #include "net/base/registry_controlled_domain.h" | 162 #include "net/base/registry_controlled_domain.h" |
163 #include "net/url_request/url_request_context.h" | 163 #include "net/url_request/url_request_context.h" |
164 #include "ui/base/animation/animation.h" | 164 #include "ui/base/animation/animation.h" |
(...skipping 4555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4720 #endif | 4720 #endif |
4721 | 4721 |
4722 UpdateCommandsForContentRestrictionState(); | 4722 UpdateCommandsForContentRestrictionState(); |
4723 UpdateCommandsForBookmarkEditing(); | 4723 UpdateCommandsForBookmarkEditing(); |
4724 } | 4724 } |
4725 | 4725 |
4726 void Browser::UpdateCommandsForContentRestrictionState() { | 4726 void Browser::UpdateCommandsForContentRestrictionState() { |
4727 int restrictions = GetContentRestrictionsForSelectedTab(); | 4727 int restrictions = GetContentRestrictionsForSelectedTab(); |
4728 | 4728 |
4729 command_updater_.UpdateCommandEnabled( | 4729 command_updater_.UpdateCommandEnabled( |
4730 IDC_COPY, !(restrictions & CONTENT_RESTRICTION_COPY)); | 4730 IDC_COPY, !(restrictions & content::CONTENT_RESTRICTION_COPY)); |
4731 command_updater_.UpdateCommandEnabled( | 4731 command_updater_.UpdateCommandEnabled( |
4732 IDC_CUT, !(restrictions & CONTENT_RESTRICTION_CUT)); | 4732 IDC_CUT, !(restrictions & content::CONTENT_RESTRICTION_CUT)); |
4733 command_updater_.UpdateCommandEnabled( | 4733 command_updater_.UpdateCommandEnabled( |
4734 IDC_PASTE, !(restrictions & CONTENT_RESTRICTION_PASTE)); | 4734 IDC_PASTE, !(restrictions & content::CONTENT_RESTRICTION_PASTE)); |
4735 UpdateSaveAsState(restrictions); | 4735 UpdateSaveAsState(restrictions); |
4736 UpdatePrintingState(restrictions); | 4736 UpdatePrintingState(restrictions); |
4737 } | 4737 } |
4738 | 4738 |
4739 void Browser::UpdatePrintingState(int content_restrictions) { | 4739 void Browser::UpdatePrintingState(int content_restrictions) { |
4740 bool print_enabled = true; | 4740 bool print_enabled = true; |
4741 bool advanced_print_enabled = true; | 4741 bool advanced_print_enabled = true; |
4742 if (g_browser_process->local_state()) { | 4742 if (g_browser_process->local_state()) { |
4743 print_enabled = | 4743 print_enabled = |
4744 g_browser_process->local_state()->GetBoolean(prefs::kPrintingEnabled); | 4744 g_browser_process->local_state()->GetBoolean(prefs::kPrintingEnabled); |
4745 advanced_print_enabled = print_enabled; | 4745 advanced_print_enabled = print_enabled; |
4746 } | 4746 } |
4747 if (print_enabled) { | 4747 if (print_enabled) { |
4748 // Do not print when a constrained window is showing. It's confusing. | 4748 // Do not print when a constrained window is showing. It's confusing. |
4749 TabContentsWrapper* wrapper = GetSelectedTabContentsWrapper(); | 4749 TabContentsWrapper* wrapper = GetSelectedTabContentsWrapper(); |
4750 bool has_constrained_window = (wrapper && | 4750 bool has_constrained_window = (wrapper && |
4751 wrapper->constrained_window_tab_helper()->constrained_window_count()); | 4751 wrapper->constrained_window_tab_helper()->constrained_window_count()); |
4752 if (has_constrained_window || | 4752 if (has_constrained_window || |
4753 content_restrictions & CONTENT_RESTRICTION_PRINT) { | 4753 content_restrictions & content::CONTENT_RESTRICTION_PRINT) { |
4754 print_enabled = false; | 4754 print_enabled = false; |
4755 advanced_print_enabled = false; | 4755 advanced_print_enabled = false; |
4756 } | 4756 } |
4757 | 4757 |
4758 // The exception is print preview, | 4758 // The exception is print preview, |
4759 // where advanced printing is always enabled. | 4759 // where advanced printing is always enabled. |
4760 printing::PrintPreviewTabController* controller = | 4760 printing::PrintPreviewTabController* controller = |
4761 printing::PrintPreviewTabController::GetInstance(); | 4761 printing::PrintPreviewTabController::GetInstance(); |
4762 if (controller && | 4762 if (controller && |
4763 wrapper && | 4763 wrapper && |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4809 !profile_->GetPrefs()->IsManagedPreference(prefs::kShowBookmarkBar) && | 4809 !profile_->GetPrefs()->IsManagedPreference(prefs::kShowBookmarkBar) && |
4810 show_main_ui); | 4810 show_main_ui); |
4811 } | 4811 } |
4812 | 4812 |
4813 void Browser::MarkHomePageAsChanged(PrefService* pref_service) { | 4813 void Browser::MarkHomePageAsChanged(PrefService* pref_service) { |
4814 pref_service->SetBoolean(prefs::kHomePageChanged, true); | 4814 pref_service->SetBoolean(prefs::kHomePageChanged, true); |
4815 pref_service->ScheduleSavePersistentPrefs(); | 4815 pref_service->ScheduleSavePersistentPrefs(); |
4816 } | 4816 } |
4817 | 4817 |
4818 void Browser::UpdateSaveAsState(int content_restrictions) { | 4818 void Browser::UpdateSaveAsState(int content_restrictions) { |
4819 bool enabled = !(content_restrictions & CONTENT_RESTRICTION_SAVE); | 4819 bool enabled = !(content_restrictions & content::CONTENT_RESTRICTION_SAVE); |
4820 PrefService* state = g_browser_process->local_state(); | 4820 PrefService* state = g_browser_process->local_state(); |
4821 if (state) | 4821 if (state) |
4822 enabled = enabled && state->GetBoolean(prefs::kAllowFileSelectionDialogs); | 4822 enabled = enabled && state->GetBoolean(prefs::kAllowFileSelectionDialogs); |
4823 | 4823 |
4824 command_updater_.UpdateCommandEnabled(IDC_SAVE_PAGE, enabled); | 4824 command_updater_.UpdateCommandEnabled(IDC_SAVE_PAGE, enabled); |
4825 } | 4825 } |
4826 | 4826 |
4827 void Browser::UpdateOpenFileState() { | 4827 void Browser::UpdateOpenFileState() { |
4828 bool enabled = true; | 4828 bool enabled = true; |
4829 PrefService* local_state = g_browser_process->local_state(); | 4829 PrefService* local_state = g_browser_process->local_state(); |
(...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5375 } | 5375 } |
5376 | 5376 |
5377 int Browser::GetContentRestrictionsForSelectedTab() { | 5377 int Browser::GetContentRestrictionsForSelectedTab() { |
5378 int content_restrictions = 0; | 5378 int content_restrictions = 0; |
5379 TabContents* current_tab = GetSelectedTabContents(); | 5379 TabContents* current_tab = GetSelectedTabContents(); |
5380 if (current_tab) { | 5380 if (current_tab) { |
5381 content_restrictions = current_tab->content_restrictions(); | 5381 content_restrictions = current_tab->content_restrictions(); |
5382 NavigationEntry* active_entry = current_tab->controller().GetActiveEntry(); | 5382 NavigationEntry* active_entry = current_tab->controller().GetActiveEntry(); |
5383 // See comment in UpdateCommandsForTabState about why we call url(). | 5383 // See comment in UpdateCommandsForTabState about why we call url(). |
5384 if (!SavePackage::IsSavableURL(active_entry ? active_entry->url() : GURL())) | 5384 if (!SavePackage::IsSavableURL(active_entry ? active_entry->url() : GURL())) |
5385 content_restrictions |= CONTENT_RESTRICTION_SAVE; | 5385 content_restrictions |= content::CONTENT_RESTRICTION_SAVE; |
5386 } | 5386 } |
5387 return content_restrictions; | 5387 return content_restrictions; |
5388 } | 5388 } |
5389 | 5389 |
5390 void Browser::UpdateBookmarkBarState(BookmarkBarStateChangeReason reason) { | 5390 void Browser::UpdateBookmarkBarState(BookmarkBarStateChangeReason reason) { |
5391 BookmarkBar::State state; | 5391 BookmarkBar::State state; |
5392 // The bookmark bar is hidden in fullscreen mode, unless on the new tab page. | 5392 // The bookmark bar is hidden in fullscreen mode, unless on the new tab page. |
5393 if (browser_defaults::bookmarks_enabled && | 5393 if (browser_defaults::bookmarks_enabled && |
5394 profile_->GetPrefs()->GetBoolean(prefs::kShowBookmarkBar) && | 5394 profile_->GetPrefs()->GetBoolean(prefs::kShowBookmarkBar) && |
5395 (!window_ || !window_->IsFullscreen())) { | 5395 (!window_ || !window_->IsFullscreen())) { |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5494 } | 5494 } |
5495 | 5495 |
5496 void Browser::UpdateFullscreenExitBubbleContent() { | 5496 void Browser::UpdateFullscreenExitBubbleContent() { |
5497 GURL url; | 5497 GURL url; |
5498 if (fullscreened_tab_) | 5498 if (fullscreened_tab_) |
5499 url = fullscreened_tab_->tab_contents()->GetURL(); | 5499 url = fullscreened_tab_->tab_contents()->GetURL(); |
5500 | 5500 |
5501 window_->UpdateFullscreenExitBubbleContent( | 5501 window_->UpdateFullscreenExitBubbleContent( |
5502 url, GetFullscreenExitBubbleType()); | 5502 url, GetFullscreenExitBubbleType()); |
5503 } | 5503 } |
OLD | NEW |