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

Unified Diff: chrome/browser/ui/browser_commands.cc

Issue 287123002: [WebModals] New API for browser-scoped popup management. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 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 side-by-side diff with in-line comments
Download patch
« 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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/browser_commands.cc
diff --git a/chrome/browser/ui/browser_commands.cc b/chrome/browser/ui/browser_commands.cc
index 8a593d55da12f375366a2edd253feb7f6b24ab29..ab8e5bb759138bbc78e58a47bfb45345908313d8 100644
--- a/chrome/browser/ui/browser_commands.cc
+++ b/chrome/browser/ui/browser_commands.cc
@@ -64,7 +64,7 @@
#include "components/bookmarks/browser/bookmark_utils.h"
#include "components/google/core/browser/google_util.h"
#include "components/translate/core/browser/language_state.h"
-#include "components/web_modal/web_contents_modal_dialog_manager.h"
+#include "components/web_modal/popup_manager.h"
#include "content/public/browser/devtools_agent_host.h"
#include "content/public/browser/navigation_controller.h"
#include "content/public/browser/navigation_entry.h"
@@ -109,7 +109,6 @@ using content::OpenURLParams;
using content::Referrer;
using content::SSLStatus;
using content::WebContents;
-using web_modal::WebContentsModalDialogManager;
namespace chrome {
namespace {
@@ -245,15 +244,21 @@ void ReloadInternal(Browser* browser,
new_tab->GetController().Reload(true);
}
-bool IsShowingWebContentsModalDialog(const Browser* browser) {
+bool IsShowingWebContentsModalDialog(Browser* browser) {
WebContents* web_contents =
browser->tab_strip_model()->GetActiveWebContents();
if (!web_contents)
return false;
- WebContentsModalDialogManager* web_contents_modal_dialog_manager =
- WebContentsModalDialogManager::FromWebContents(web_contents);
- return web_contents_modal_dialog_manager->IsDialogActive();
+ // In test code we may not have a popup manager.
+ if (!browser->popup_manager())
+ return false;
+
+ // TODO(gbillock): This is currently called in production by the CanPrint
+ // method, and may be too restrictive if we allow print preview to overlap.
+ // Re-assess how to queue print preview after we know more about popup
+ // management policy.
+ return browser->popup_manager()->IsWebModalDialogActive(web_contents);
}
bool PrintPreviewShowing(const Browser* browser) {
@@ -853,9 +858,13 @@ void Print(Browser* browser) {
#endif // defined(ENABLE_PRINTING)
}
-bool CanPrint(const Browser* browser) {
+bool CanPrint(Browser* browser) {
// Do not print when printing is disabled via pref or policy.
// Do not print when a constrained window is showing. It's confusing.
+ // TODO(gbillock): Need to re-assess the call to
+ // IsShowingWebContentsModalDialog after a popup management policy is
+ // refined -- we will probably want to just queue the print request, not
+ // block it.
return browser->profile()->GetPrefs()->GetBoolean(prefs::kPrintingEnabled) &&
!(IsShowingWebContentsModalDialog(browser) ||
GetContentRestrictions(browser) & CONTENT_RESTRICTION_PRINT);
@@ -870,7 +879,7 @@ void AdvancedPrint(Browser* browser) {
#endif
}
-bool CanAdvancedPrint(const Browser* browser) {
+bool CanAdvancedPrint(Browser* browser) {
// If printing is not disabled via pref or policy, it is always possible to
// advanced print when the print preview is visible. The exception to this
// is under Win8 ash, since showing the advanced print dialog will open it
« 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