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 |