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

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

Issue 586933002: Re-Revert "[WebModals] New API for browser-scoped popup management." (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2125
Patch Set: Created 6 years, 3 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
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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 #include "chrome/browser/web_applications/web_app.h" 58 #include "chrome/browser/web_applications/web_app.h"
59 #include "chrome/common/chrome_switches.h" 59 #include "chrome/common/chrome_switches.h"
60 #include "chrome/common/chrome_version_info.h" 60 #include "chrome/common/chrome_version_info.h"
61 #include "chrome/common/content_restriction.h" 61 #include "chrome/common/content_restriction.h"
62 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h" 62 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h"
63 #include "chrome/common/pref_names.h" 63 #include "chrome/common/pref_names.h"
64 #include "components/bookmarks/browser/bookmark_model.h" 64 #include "components/bookmarks/browser/bookmark_model.h"
65 #include "components/bookmarks/browser/bookmark_utils.h" 65 #include "components/bookmarks/browser/bookmark_utils.h"
66 #include "components/google/core/browser/google_util.h" 66 #include "components/google/core/browser/google_util.h"
67 #include "components/translate/core/browser/language_state.h" 67 #include "components/translate/core/browser/language_state.h"
68 #include "components/web_modal/popup_manager.h" 68 #include "components/web_modal/web_contents_modal_dialog_manager.h"
69 #include "content/public/browser/devtools_agent_host.h" 69 #include "content/public/browser/devtools_agent_host.h"
70 #include "content/public/browser/navigation_controller.h" 70 #include "content/public/browser/navigation_controller.h"
71 #include "content/public/browser/navigation_entry.h" 71 #include "content/public/browser/navigation_entry.h"
72 #include "content/public/browser/notification_service.h" 72 #include "content/public/browser/notification_service.h"
73 #include "content/public/browser/page_navigator.h" 73 #include "content/public/browser/page_navigator.h"
74 #include "content/public/browser/render_view_host.h" 74 #include "content/public/browser/render_view_host.h"
75 #include "content/public/browser/render_widget_host_view.h" 75 #include "content/public/browser/render_widget_host_view.h"
76 #include "content/public/browser/user_metrics.h" 76 #include "content/public/browser/user_metrics.h"
77 #include "content/public/browser/web_contents.h" 77 #include "content/public/browser/web_contents.h"
78 #include "content/public/common/renderer_preferences.h" 78 #include "content/public/common/renderer_preferences.h"
(...skipping 24 matching lines...) Expand all
103 const char kOsOverrideForTabletSite[] = "Linux; Android 4.0.3"; 103 const char kOsOverrideForTabletSite[] = "Linux; Android 4.0.3";
104 } 104 }
105 105
106 using base::UserMetricsAction; 106 using base::UserMetricsAction;
107 using content::NavigationController; 107 using content::NavigationController;
108 using content::NavigationEntry; 108 using content::NavigationEntry;
109 using content::OpenURLParams; 109 using content::OpenURLParams;
110 using content::Referrer; 110 using content::Referrer;
111 using content::SSLStatus; 111 using content::SSLStatus;
112 using content::WebContents; 112 using content::WebContents;
113 using web_modal::WebContentsModalDialogManager;
113 114
114 namespace chrome { 115 namespace chrome {
115 namespace { 116 namespace {
116 117
117 bool CanBookmarkCurrentPageInternal(const Browser* browser, 118 bool CanBookmarkCurrentPageInternal(const Browser* browser,
118 bool check_remove_bookmark_ui) { 119 bool check_remove_bookmark_ui) {
119 BookmarkModel* model = 120 BookmarkModel* model =
120 BookmarkModelFactory::GetForProfile(browser->profile()); 121 BookmarkModelFactory::GetForProfile(browser->profile());
121 return browser_defaults::bookmarks_enabled && 122 return browser_defaults::bookmarks_enabled &&
122 browser->profile()->GetPrefs()->GetBoolean( 123 browser->profile()->GetPrefs()->GetBoolean(
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 WebContents* new_tab = GetTabAndRevertIfNecessary(browser, disposition); 239 WebContents* new_tab = GetTabAndRevertIfNecessary(browser, disposition);
239 new_tab->UserGestureDone(); 240 new_tab->UserGestureDone();
240 if (!new_tab->FocusLocationBarByDefault()) 241 if (!new_tab->FocusLocationBarByDefault())
241 new_tab->Focus(); 242 new_tab->Focus();
242 if (ignore_cache) 243 if (ignore_cache)
243 new_tab->GetController().ReloadIgnoringCache(true); 244 new_tab->GetController().ReloadIgnoringCache(true);
244 else 245 else
245 new_tab->GetController().Reload(true); 246 new_tab->GetController().Reload(true);
246 } 247 }
247 248
248 bool IsShowingWebContentsModalDialog(Browser* browser) { 249 bool IsShowingWebContentsModalDialog(const Browser* browser) {
249 WebContents* web_contents = 250 WebContents* web_contents =
250 browser->tab_strip_model()->GetActiveWebContents(); 251 browser->tab_strip_model()->GetActiveWebContents();
251 if (!web_contents) 252 if (!web_contents)
252 return false; 253 return false;
253 254
254 // In test code we may not have a popup manager. 255 WebContentsModalDialogManager* web_contents_modal_dialog_manager =
255 if (!browser->popup_manager()) 256 WebContentsModalDialogManager::FromWebContents(web_contents);
256 return false; 257 return web_contents_modal_dialog_manager->IsDialogActive();
257
258 // TODO(gbillock): This is currently called in production by the CanPrint
259 // method, and may be too restrictive if we allow print preview to overlap.
260 // Re-assess how to queue print preview after we know more about popup
261 // management policy.
262 return browser->popup_manager()->IsWebModalDialogActive(web_contents);
263 } 258 }
264 259
265 bool PrintPreviewShowing(const Browser* browser) { 260 bool PrintPreviewShowing(const Browser* browser) {
266 #if defined(ENABLE_FULL_PRINTING) 261 #if defined(ENABLE_FULL_PRINTING)
267 WebContents* contents = browser->tab_strip_model()->GetActiveWebContents(); 262 WebContents* contents = browser->tab_strip_model()->GetActiveWebContents();
268 printing::PrintPreviewDialogController* controller = 263 printing::PrintPreviewDialogController* controller =
269 printing::PrintPreviewDialogController::GetInstance(); 264 printing::PrintPreviewDialogController::GetInstance();
270 return controller && (controller->GetPrintPreviewForContents(contents) || 265 return controller && (controller->GetPrintPreviewForContents(contents) ||
271 controller->is_creating_print_preview_dialog()); 266 controller->is_creating_print_preview_dialog());
272 #else 267 #else
(...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after
860 else 855 else
861 print_view_manager->PrintPreviewNow(false); 856 print_view_manager->PrintPreviewNow(false);
862 #else 857 #else
863 printing::PrintViewManagerBasic* print_view_manager = 858 printing::PrintViewManagerBasic* print_view_manager =
864 printing::PrintViewManagerBasic::FromWebContents(contents); 859 printing::PrintViewManagerBasic::FromWebContents(contents);
865 print_view_manager->PrintNow(); 860 print_view_manager->PrintNow();
866 #endif // defined(ENABLE_FULL_PRINTING) 861 #endif // defined(ENABLE_FULL_PRINTING)
867 #endif // defined(ENABLE_PRINTING) 862 #endif // defined(ENABLE_PRINTING)
868 } 863 }
869 864
870 bool CanPrint(Browser* browser) { 865 bool CanPrint(const Browser* browser) {
871 // Do not print when printing is disabled via pref or policy. 866 // Do not print when printing is disabled via pref or policy.
872 // Do not print when a constrained window is showing. It's confusing. 867 // Do not print when a constrained window is showing. It's confusing.
873 // TODO(gbillock): Need to re-assess the call to
874 // IsShowingWebContentsModalDialog after a popup management policy is
875 // refined -- we will probably want to just queue the print request, not
876 // block it.
877 return browser->profile()->GetPrefs()->GetBoolean(prefs::kPrintingEnabled) && 868 return browser->profile()->GetPrefs()->GetBoolean(prefs::kPrintingEnabled) &&
878 !(IsShowingWebContentsModalDialog(browser) || 869 !(IsShowingWebContentsModalDialog(browser) ||
879 GetContentRestrictions(browser) & CONTENT_RESTRICTION_PRINT); 870 GetContentRestrictions(browser) & CONTENT_RESTRICTION_PRINT);
880 } 871 }
881 872
882 void AdvancedPrint(Browser* browser) { 873 void AdvancedPrint(Browser* browser) {
883 #if defined(ENABLE_FULL_PRINTING) 874 #if defined(ENABLE_FULL_PRINTING)
884 printing::PrintViewManager* print_view_manager = 875 printing::PrintViewManager* print_view_manager =
885 printing::PrintViewManager::FromWebContents( 876 printing::PrintViewManager::FromWebContents(
886 browser->tab_strip_model()->GetActiveWebContents()); 877 browser->tab_strip_model()->GetActiveWebContents());
887 print_view_manager->AdvancedPrintNow(); 878 print_view_manager->AdvancedPrintNow();
888 #endif 879 #endif
889 } 880 }
890 881
891 bool CanAdvancedPrint(Browser* browser) { 882 bool CanAdvancedPrint(const Browser* browser) {
892 // If printing is not disabled via pref or policy, it is always possible to 883 // If printing is not disabled via pref or policy, it is always possible to
893 // advanced print when the print preview is visible. The exception to this 884 // advanced print when the print preview is visible. The exception to this
894 // is under Win8 ash, since showing the advanced print dialog will open it 885 // is under Win8 ash, since showing the advanced print dialog will open it
895 // modally on the Desktop and hang the browser. We can remove this check 886 // modally on the Desktop and hang the browser. We can remove this check
896 // once we integrate with the system print charm. 887 // once we integrate with the system print charm.
897 #if defined(OS_WIN) 888 #if defined(OS_WIN)
898 if (chrome::GetActiveDesktop() == chrome::HOST_DESKTOP_TYPE_ASH) 889 if (chrome::GetActiveDesktop() == chrome::HOST_DESKTOP_TYPE_ASH)
899 return false; 890 return false;
900 #endif 891 #endif
901 892
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after
1284 browser->profile(), 1275 browser->profile(),
1285 browser->host_desktop_type())); 1276 browser->host_desktop_type()));
1286 app_browser->tab_strip_model()->AppendWebContents(contents, true); 1277 app_browser->tab_strip_model()->AppendWebContents(contents, true);
1287 1278
1288 contents->GetMutableRendererPrefs()->can_accept_load_drops = false; 1279 contents->GetMutableRendererPrefs()->can_accept_load_drops = false;
1289 contents->GetRenderViewHost()->SyncRendererPrefs(); 1280 contents->GetRenderViewHost()->SyncRendererPrefs();
1290 app_browser->window()->Show(); 1281 app_browser->window()->Show();
1291 } 1282 }
1292 1283
1293 } // namespace chrome 1284 } // namespace chrome
OLDNEW
« no previous file with comments | « chrome/browser/ui/browser_commands.h ('k') | chrome/browser/ui/cocoa/browser_window_controller.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698