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

Unified Diff: chrome/browser/ui/webui/print_preview/print_preview_ui.cc

Issue 24158002: Cleaned up the print preview API used by app printing browser tests (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Implemented review suggestions Created 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/webui/print_preview/print_preview_ui.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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();
}
« no previous file with comments | « chrome/browser/ui/webui/print_preview/print_preview_ui.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698