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

Side by Side Diff: chrome/browser/ui/browser_commands.cc

Issue 19800005: Hide knowledge of webkit::ppapi::PluginDelegate from chrome. This is part of moving ppapi implement… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 5 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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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_commands.h" 5 #include "chrome/browser/ui/browser_commands.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/metrics/histogram.h" 8 #include "base/metrics/histogram.h"
9 #include "base/prefs/pref_service.h" 9 #include "base/prefs/pref_service.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 #include "chrome/browser/ui/browser_instant_controller.h" 43 #include "chrome/browser/ui/browser_instant_controller.h"
44 #include "chrome/browser/ui/browser_tab_restore_service_delegate.h" 44 #include "chrome/browser/ui/browser_tab_restore_service_delegate.h"
45 #include "chrome/browser/ui/browser_tabstrip.h" 45 #include "chrome/browser/ui/browser_tabstrip.h"
46 #include "chrome/browser/ui/browser_window.h" 46 #include "chrome/browser/ui/browser_window.h"
47 #include "chrome/browser/ui/chrome_pages.h" 47 #include "chrome/browser/ui/chrome_pages.h"
48 #include "chrome/browser/ui/find_bar/find_bar_controller.h" 48 #include "chrome/browser/ui/find_bar/find_bar_controller.h"
49 #include "chrome/browser/ui/find_bar/find_tab_helper.h" 49 #include "chrome/browser/ui/find_bar/find_tab_helper.h"
50 #include "chrome/browser/ui/fullscreen/fullscreen_controller.h" 50 #include "chrome/browser/ui/fullscreen/fullscreen_controller.h"
51 #include "chrome/browser/ui/omnibox/location_bar.h" 51 #include "chrome/browser/ui/omnibox/location_bar.h"
52 #include "chrome/browser/ui/status_bubble.h" 52 #include "chrome/browser/ui/status_bubble.h"
53 #include "chrome/browser/ui/tab_contents/core_tab_helper.h"
53 #include "chrome/browser/ui/tabs/tab_strip_model.h" 54 #include "chrome/browser/ui/tabs/tab_strip_model.h"
54 #include "chrome/browser/ui/webui/ntp/app_launcher_handler.h" 55 #include "chrome/browser/ui/webui/ntp/app_launcher_handler.h"
55 #include "chrome/browser/upgrade_detector.h" 56 #include "chrome/browser/upgrade_detector.h"
56 #include "chrome/browser/web_applications/web_app.h" 57 #include "chrome/browser/web_applications/web_app.h"
57 #include "chrome/common/chrome_switches.h" 58 #include "chrome/common/chrome_switches.h"
58 #include "chrome/common/chrome_version_info.h" 59 #include "chrome/common/chrome_version_info.h"
60 #include "chrome/common/content_restriction.h"
59 #include "chrome/common/pref_names.h" 61 #include "chrome/common/pref_names.h"
60 #include "components/web_modal/web_contents_modal_dialog_manager.h" 62 #include "components/web_modal/web_contents_modal_dialog_manager.h"
61 #include "content/public/browser/devtools_agent_host.h" 63 #include "content/public/browser/devtools_agent_host.h"
62 #include "content/public/browser/navigation_controller.h" 64 #include "content/public/browser/navigation_controller.h"
63 #include "content/public/browser/navigation_entry.h" 65 #include "content/public/browser/navigation_entry.h"
64 #include "content/public/browser/notification_service.h" 66 #include "content/public/browser/notification_service.h"
65 #include "content/public/browser/page_navigator.h" 67 #include "content/public/browser/page_navigator.h"
66 #include "content/public/browser/render_view_host.h" 68 #include "content/public/browser/render_view_host.h"
67 #include "content/public/browser/user_metrics.h" 69 #include "content/public/browser/user_metrics.h"
68 #include "content/public/browser/web_contents.h" 70 #include "content/public/browser/web_contents.h"
69 #include "content/public/browser/web_contents_view.h" 71 #include "content/public/browser/web_contents_view.h"
70 #include "content/public/common/content_restriction.h"
71 #include "content/public/common/renderer_preferences.h" 72 #include "content/public/common/renderer_preferences.h"
72 #include "content/public/common/url_constants.h" 73 #include "content/public/common/url_constants.h"
73 #include "content/public/common/url_utils.h" 74 #include "content/public/common/url_utils.h"
74 #include "net/base/escape.h" 75 #include "net/base/escape.h"
75 #include "webkit/common/user_agent/user_agent_util.h" 76 #include "webkit/common/user_agent/user_agent_util.h"
76 77
77 #if defined(OS_MACOSX) 78 #if defined(OS_MACOSX)
78 #include "ui/base/cocoa/find_pasteboard.h" 79 #include "ui/base/cocoa/find_pasteboard.h"
79 #endif 80 #endif
80 81
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 int command, 236 int command,
236 CommandObserver* observer) { 237 CommandObserver* observer) {
237 browser->command_controller()->command_updater()->RemoveCommandObserver( 238 browser->command_controller()->command_updater()->RemoveCommandObserver(
238 command, observer); 239 command, observer);
239 } 240 }
240 241
241 int GetContentRestrictions(const Browser* browser) { 242 int GetContentRestrictions(const Browser* browser) {
242 int content_restrictions = 0; 243 int content_restrictions = 0;
243 WebContents* current_tab = browser->tab_strip_model()->GetActiveWebContents(); 244 WebContents* current_tab = browser->tab_strip_model()->GetActiveWebContents();
244 if (current_tab) { 245 if (current_tab) {
245 content_restrictions = current_tab->GetContentRestrictions(); 246 CoreTabHelper* core_tab_helper =
247 CoreTabHelper::FromWebContents(current_tab);
248 content_restrictions = core_tab_helper->content_restrictions();
246 NavigationEntry* active_entry = 249 NavigationEntry* active_entry =
247 current_tab->GetController().GetActiveEntry(); 250 current_tab->GetController().GetActiveEntry();
248 // See comment in UpdateCommandsForTabState about why we call url(). 251 // See comment in UpdateCommandsForTabState about why we call url().
249 if (!content::IsSavableURL( 252 if (!content::IsSavableURL(
250 active_entry ? active_entry->GetURL() : GURL()) || 253 active_entry ? active_entry->GetURL() : GURL()) ||
251 current_tab->ShowingInterstitialPage()) 254 current_tab->ShowingInterstitialPage())
252 content_restrictions |= content::CONTENT_RESTRICTION_SAVE; 255 content_restrictions |= CONTENT_RESTRICTION_SAVE;
253 if (current_tab->ShowingInterstitialPage()) 256 if (current_tab->ShowingInterstitialPage())
254 content_restrictions |= content::CONTENT_RESTRICTION_PRINT; 257 content_restrictions |= CONTENT_RESTRICTION_PRINT;
255 } 258 }
256 return content_restrictions; 259 return content_restrictions;
257 } 260 }
258 261
259 void NewEmptyWindow(Profile* profile, HostDesktopType desktop_type) { 262 void NewEmptyWindow(Profile* profile, HostDesktopType desktop_type) {
260 bool incognito = profile->IsOffTheRecord(); 263 bool incognito = profile->IsOffTheRecord();
261 PrefService* prefs = profile->GetPrefs(); 264 PrefService* prefs = profile->GetPrefs();
262 if (incognito) { 265 if (incognito) {
263 if (IncognitoModePrefs::GetAvailability(prefs) == 266 if (IncognitoModePrefs::GetAvailability(prefs) ==
264 IncognitoModePrefs::DISABLED) { 267 IncognitoModePrefs::DISABLED) {
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after
687 } 690 }
688 691
689 bool CanSavePage(const Browser* browser) { 692 bool CanSavePage(const Browser* browser) {
690 // LocalState can be NULL in tests. 693 // LocalState can be NULL in tests.
691 if (g_browser_process->local_state() && 694 if (g_browser_process->local_state() &&
692 !g_browser_process->local_state()->GetBoolean( 695 !g_browser_process->local_state()->GetBoolean(
693 prefs::kAllowFileSelectionDialogs)) { 696 prefs::kAllowFileSelectionDialogs)) {
694 return false; 697 return false;
695 } 698 }
696 return !browser->is_devtools() && 699 return !browser->is_devtools() &&
697 !(GetContentRestrictions(browser) & content::CONTENT_RESTRICTION_SAVE); 700 !(GetContentRestrictions(browser) & CONTENT_RESTRICTION_SAVE);
698 } 701 }
699 702
700 void ShowFindBar(Browser* browser) { 703 void ShowFindBar(Browser* browser) {
701 browser->GetFindBarController()->Show(); 704 browser->GetFindBarController()->Show();
702 } 705 }
703 706
704 void ShowWebsiteSettings(Browser* browser, 707 void ShowWebsiteSettings(Browser* browser,
705 content::WebContents* web_contents, 708 content::WebContents* web_contents,
706 const GURL& url, 709 const GURL& url,
707 const SSLStatus& ssl) { 710 const SSLStatus& ssl) {
(...skipping 11 matching lines...) Expand all
719 print_view_manager->PrintNow(); 722 print_view_manager->PrintNow();
720 else 723 else
721 print_view_manager->PrintPreviewNow(false); 724 print_view_manager->PrintPreviewNow(false);
722 } 725 }
723 726
724 bool CanPrint(const Browser* browser) { 727 bool CanPrint(const Browser* browser) {
725 // Do not print when printing is disabled via pref or policy. 728 // Do not print when printing is disabled via pref or policy.
726 // Do not print when a constrained window is showing. It's confusing. 729 // Do not print when a constrained window is showing. It's confusing.
727 return browser->profile()->GetPrefs()->GetBoolean(prefs::kPrintingEnabled) && 730 return browser->profile()->GetPrefs()->GetBoolean(prefs::kPrintingEnabled) &&
728 !(IsShowingWebContentsModalDialog(browser) || 731 !(IsShowingWebContentsModalDialog(browser) ||
729 GetContentRestrictions(browser) & content::CONTENT_RESTRICTION_PRINT); 732 GetContentRestrictions(browser) & CONTENT_RESTRICTION_PRINT);
730 } 733 }
731 734
732 void AdvancedPrint(Browser* browser) { 735 void AdvancedPrint(Browser* browser) {
733 printing::PrintViewManager* print_view_manager = 736 printing::PrintViewManager* print_view_manager =
734 printing::PrintViewManager::FromWebContents( 737 printing::PrintViewManager::FromWebContents(
735 browser->tab_strip_model()->GetActiveWebContents()); 738 browser->tab_strip_model()->GetActiveWebContents());
736 print_view_manager->AdvancedPrintNow(); 739 print_view_manager->AdvancedPrintNow();
737 } 740 }
738 741
739 bool CanAdvancedPrint(const Browser* browser) { 742 bool CanAdvancedPrint(const Browser* browser) {
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
1096 Browser::TYPE_POPUP, app_name, gfx::Rect(), browser->profile(), 1099 Browser::TYPE_POPUP, app_name, gfx::Rect(), browser->profile(),
1097 browser->host_desktop_type())); 1100 browser->host_desktop_type()));
1098 app_browser->tab_strip_model()->AppendWebContents(contents, true); 1101 app_browser->tab_strip_model()->AppendWebContents(contents, true);
1099 1102
1100 contents->GetMutableRendererPrefs()->can_accept_load_drops = false; 1103 contents->GetMutableRendererPrefs()->can_accept_load_drops = false;
1101 contents->GetRenderViewHost()->SyncRendererPrefs(); 1104 contents->GetRenderViewHost()->SyncRendererPrefs();
1102 app_browser->window()->Show(); 1105 app_browser->window()->Show();
1103 } 1106 }
1104 1107
1105 } // namespace chrome 1108 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698