Index: chrome/browser/ui/webui/print_preview/print_preview_ui.cc |
diff --git a/chrome/browser/ui/webui/print_preview/print_preview_ui.cc b/chrome/browser/ui/webui/print_preview/print_preview_ui.cc |
index d0b8f3af11a6b93d51b0b8fc7418255b5adc017a..9289a44a356934f6a5a67001c3d3c05b2a06a67f 100644 |
--- a/chrome/browser/ui/webui/print_preview/print_preview_ui.cc |
+++ b/chrome/browser/ui/webui/print_preview/print_preview_ui.cc |
@@ -338,6 +338,29 @@ content::WebUIDataSource* CreatePrintPreviewUISource() { |
return source; |
} |
+int g_auto_cancel_count_for_testing_ = -1; // Disabled if count < 0. |
+ |
+void EnableAutoCancelAndResetCountForTesting() { |
+ g_auto_cancel_count_for_testing_ = 0; |
+} |
+ |
+void DisableAutoCancelForTesting() { |
+ g_auto_cancel_count_for_testing_ = -1; |
+} |
+ |
+bool IsAutoCancelEnabledForTesting() { |
+ return (g_auto_cancel_count_for_testing_ >= 0); |
+} |
+ |
+void IncrementAutoCancelCountForTesting() { |
+ if (g_auto_cancel_count_for_testing_ >= 0) |
+ ++g_auto_cancel_count_for_testing_; |
+} |
+ |
+int GetAutoCancelCountForTesting() { |
+ return std::max(g_auto_cancel_count_for_testing_, -1); |
+} |
+ |
} // namespace |
PrintPreviewUI::PrintPreviewUI(content::WebUI* web_ui) |
@@ -520,8 +543,8 @@ void PrintPreviewUI::OnPreviewDataIsAvailable(int expected_pages_count, |
} |
base::FundamentalValue ui_identifier(id_); |
base::FundamentalValue ui_preview_request_id(preview_request_id); |
- if (ScopedAutoCancelForTesting::IsEnabledForTesting()) { |
- ScopedAutoCancelForTesting::IncrementCountForTesting(); |
+ if (IsAutoCancelEnabledForTesting()) { |
+ IncrementAutoCancelCountForTesting(); |
OnClosePrintPreviewDialog(); |
} else { |
web_ui()->CallJavascriptFunction("updatePrintPreview", ui_identifier, |
@@ -588,25 +611,14 @@ void PrintPreviewUI::OnPrintPreviewScalingDisabled() { |
web_ui()->CallJavascriptFunction("printScalingDisabledForSourcePDF"); |
} |
-static int g_auto_cancel_count_for_testing_ = -1; // Disabled if count < 0. |
- |
PrintPreviewUI::ScopedAutoCancelForTesting::ScopedAutoCancelForTesting() { |
- g_auto_cancel_count_for_testing_ = 0; |
+ EnableAutoCancelAndResetCountForTesting(); |
} |
PrintPreviewUI::ScopedAutoCancelForTesting::~ScopedAutoCancelForTesting() { |
- g_auto_cancel_count_for_testing_ = -1; |
-} |
- |
-bool PrintPreviewUI::ScopedAutoCancelForTesting::IsEnabledForTesting() { |
- return (g_auto_cancel_count_for_testing_ >= 0); |
-} |
- |
-void PrintPreviewUI::ScopedAutoCancelForTesting::IncrementCountForTesting() { |
- if (g_auto_cancel_count_for_testing_ >= 0) |
- ++g_auto_cancel_count_for_testing_; |
+ DisableAutoCancelForTesting(); |
} |
int PrintPreviewUI::ScopedAutoCancelForTesting::GetCountForTesting() { |
- return std::max(g_auto_cancel_count_for_testing_, -1); |
+ return GetAutoCancelCountForTesting(); |
} |