summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/about_flags.cc8
-rw-r--r--chrome/browser/tab_contents/render_view_context_menu.cc3
-rw-r--r--chrome/browser/ui/browser.cc4
-rw-r--r--chrome/browser/ui/webui/chrome_web_ui_factory.cc8
-rw-r--r--chrome/browser/ui/webui/print_preview_ui_uitest.cc3
-rw-r--r--chrome/common/chrome_switches.cc19
-rw-r--r--chrome/common/chrome_switches.h9
-rw-r--r--chrome/renderer/print_web_view_helper.cc3
-rw-r--r--chrome/renderer/print_web_view_helper_browsertest.cc30
-rw-r--r--content/browser/renderer_host/browser_render_process_host.cc8
10 files changed, 70 insertions, 25 deletions
diff --git a/chrome/browser/about_flags.cc b/chrome/browser/about_flags.cc
index 71105ba..7cd7eee 100644
--- a/chrome/browser/about_flags.cc
+++ b/chrome/browser/about_flags.cc
@@ -150,13 +150,17 @@ const Experiment kExperiments[] = {
kOsWin | kOsLinux | kOsCrOS,
SINGLE_VALUE_TYPE(switches::kEnableAccelerated2dCanvas)
},
+#if !defined(GOOGLE_CHROME_BUILD)
+ // Only expose this for Chromium builds where users may not have the PDF
+ // plugin. Do not give Google Chrome users the option to disable it here.
{
"print-preview", // FLAGS:RECORD_UMA
IDS_FLAGS_PRINT_PREVIEW_NAME,
IDS_FLAGS_PRINT_PREVIEW_DESCRIPTION,
- kOsMac | kOsWin | kOsLinux, // This switch is not available in CrOS.
+ kOsMac | kOsWin | kOsLinux, // This switch is not available in CrOS.
SINGLE_VALUE_TYPE(switches::kEnablePrintPreview)
},
+#endif
{
"enable-nacl", // FLAGS:RECORD_UMA
IDS_FLAGS_ENABLE_NACL_NAME,
@@ -718,7 +722,7 @@ void FlagsState::reset() {
flags_switches_.clear();
}
-} // namespace
+} // namespace
namespace testing {
diff --git a/chrome/browser/tab_contents/render_view_context_menu.cc b/chrome/browser/tab_contents/render_view_context_menu.cc
index 8c65c34..c6600dc 100644
--- a/chrome/browser/tab_contents/render_view_context_menu.cc
+++ b/chrome/browser/tab_contents/render_view_context_menu.cc
@@ -1351,8 +1351,7 @@ void RenderViewContextMenu::ExecuteCommand(int id) {
case IDC_PRINT:
if (params_.media_type == WebContextMenuData::MediaTypeNone) {
- if (CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kEnablePrintPreview)) {
+ if (switches::IsPrintPreviewEnabled()) {
printing::PrintPreviewTabController::PrintPreview(
source_tab_contents_);
} else {
diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc
index 41716b5..78216c3 100644
--- a/chrome/browser/ui/browser.cc
+++ b/chrome/browser/ui/browser.cc
@@ -1669,9 +1669,7 @@ void Browser::EmailPageLocation() {
}
void Browser::Print() {
- UserMetrics::RecordAction(UserMetricsAction("PrintPreview"));
- if (CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kEnablePrintPreview)) {
+ if (switches::IsPrintPreviewEnabled()) {
printing::PrintPreviewTabController::PrintPreview(
GetSelectedTabContents());
} else {
diff --git a/chrome/browser/ui/webui/chrome_web_ui_factory.cc b/chrome/browser/ui/webui/chrome_web_ui_factory.cc
index d86207d..1d48f8c 100644
--- a/chrome/browser/ui/webui/chrome_web_ui_factory.cc
+++ b/chrome/browser/ui/webui/chrome_web_ui_factory.cc
@@ -210,11 +210,9 @@ static WebUIFactoryFunction GetWebUIFactoryFunction(Profile* profile,
#else
if (url.host() == chrome::kChromeUISettingsHost)
return &NewWebUI<OptionsUI>;
- if (url.host() == chrome::kChromeUIPrintHost) {
- if (CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kEnablePrintPreview)) {
- return &NewWebUI<PrintPreviewUI>;
- }
+ if (url.host() == chrome::kChromeUIPrintHost &&
+ switches::IsPrintPreviewEnabled()) {
+ return &NewWebUI<PrintPreviewUI>;
}
#endif // defined(OS_CHROMEOS)
diff --git a/chrome/browser/ui/webui/print_preview_ui_uitest.cc b/chrome/browser/ui/webui/print_preview_ui_uitest.cc
index d53cf33..b24497e 100644
--- a/chrome/browser/ui/webui/print_preview_ui_uitest.cc
+++ b/chrome/browser/ui/webui/print_preview_ui_uitest.cc
@@ -19,8 +19,9 @@ class PrintPreviewUITest : public UITest {
public:
PrintPreviewUITest() {
dom_automation_enabled_ = true;
- // TODO(thestig): Remove when print preview is enabled by default.
+#if !defined(GOOGLE_CHROME_BUILD) || defined(OS_CHROMEOS)
launch_arguments_.AppendSwitch(switches::kEnablePrintPreview);
+#endif
}
void AssertIsPrintPage(TabProxy* tab) {
diff --git a/chrome/common/chrome_switches.cc b/chrome/common/chrome_switches.cc
index 1fe8c98..4c67a94 100644
--- a/chrome/common/chrome_switches.cc
+++ b/chrome/common/chrome_switches.cc
@@ -5,6 +5,7 @@
#include "chrome/common/chrome_switches.h"
#include "base/base_switches.h"
+#include "base/command_line.h"
namespace switches {
@@ -472,9 +473,6 @@ const char kEnablePanels[] = "enable-panels";
// Enable speculative TCP/IP preconnection.
const char kEnablePreconnect[] = "enable-preconnect";
-// Enable print preview (work in progress).
-const char kEnablePrintPreview[] = "enable-print-preview";
-
// Enable the IsSearchProviderInstalled and InstallSearchProvider with an extra
// parameter to indicate if the provider should be the default.
const char kEnableSearchProviderApiV2[] = "enable-search-provider-api-v2";
@@ -1158,6 +1156,21 @@ const char kExposePrivateExtensionApi[] = "expose-private-extension-api";
const char kTouchDevices[] = "touch-devices";
#endif
+#if defined(GOOGLE_CHROME_BUILD) && !defined(OS_CHROMEOS)
+// Disable print preview (Not exposed via about:flags. Only used for testing.)
+const char kDisablePrintPreview[] = "disable-print-preview";
+
+bool IsPrintPreviewEnabled() {
+ return !CommandLine::ForCurrentProcess()->HasSwitch(kDisablePrintPreview);
+}
+#else
+// Enable print preview (no PDF viewer, thus not supported with Chromium).
+const char kEnablePrintPreview[] = "enable-print-preview";
+
+bool IsPrintPreviewEnabled() {
+ return CommandLine::ForCurrentProcess()->HasSwitch(kEnablePrintPreview);
+}
+#endif
// -----------------------------------------------------------------------------
// DO NOT ADD YOUR CRAP TO THE BOTTOM OF THIS FILE.
diff --git a/chrome/common/chrome_switches.h b/chrome/common/chrome_switches.h
index 88caefa..9b2bbc1 100644
--- a/chrome/common/chrome_switches.h
+++ b/chrome/common/chrome_switches.h
@@ -139,7 +139,6 @@ extern const char kEnableNaCl[];
extern const char kEnableNaClDebug[];
extern const char kEnablePanels[];
extern const char kEnablePreconnect[];
-extern const char kEnablePrintPreview[];
extern const char kEnableRemoting[];
extern const char kEnableResourceContentSettings[];
extern const char kEnableSearchProviderApiV2[];
@@ -348,6 +347,14 @@ extern const char kExposePrivateExtensionApi[];
extern const char kTouchDevices[];
#endif
+#if defined(GOOGLE_CHROME_BUILD) && !defined(OS_CHROMEOS)
+extern const char kDisablePrintPreview[];
+#else
+extern const char kEnablePrintPreview[];
+#endif
+
+bool IsPrintPreviewEnabled();
+
// DON'T ADD RANDOM STUFF HERE. Put it in the main section above in
// alphabetical order, or in one of the ifdefs (also in order in each section).
diff --git a/chrome/renderer/print_web_view_helper.cc b/chrome/renderer/print_web_view_helper.cc
index 15ae839..8c5387d 100644
--- a/chrome/renderer/print_web_view_helper.cc
+++ b/chrome/renderer/print_web_view_helper.cc
@@ -121,8 +121,7 @@ PrintWebViewHelper::PrintWebViewHelper(RenderView* render_view)
context_menu_preview_node_(NULL),
user_cancelled_scripted_print_count_(0),
notify_browser_of_print_failure_(true) {
- is_preview_ = CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kEnablePrintPreview);
+ is_preview_ = switches::IsPrintPreviewEnabled();
}
PrintWebViewHelper::~PrintWebViewHelper() {}
diff --git a/chrome/renderer/print_web_view_helper_browsertest.cc b/chrome/renderer/print_web_view_helper_browsertest.cc
index 2c0eafb..c060601 100644
--- a/chrome/renderer/print_web_view_helper_browsertest.cc
+++ b/chrome/renderer/print_web_view_helper_browsertest.cc
@@ -45,10 +45,10 @@ void CreatePrintSettingsDictionary(DictionaryValue* dict) {
} // namespace
-class PrintWebViewHelperTest : public RenderViewTest {
+class PrintWebViewHelperTestBase : public RenderViewTest {
public:
- PrintWebViewHelperTest() {}
- ~PrintWebViewHelperTest() {}
+ PrintWebViewHelperTestBase() {}
+ ~PrintWebViewHelperTestBase() {}
protected:
// The renderer should be done calculating the number of rendered pages
@@ -91,6 +91,25 @@ class PrintWebViewHelperTest : public RenderViewTest {
#endif // defined(OS_CHROMEOS)
}
+ DISALLOW_COPY_AND_ASSIGN(PrintWebViewHelperTestBase);
+};
+
+class PrintWebViewHelperTest : public PrintWebViewHelperTestBase {
+ public:
+ PrintWebViewHelperTest() {}
+ virtual ~PrintWebViewHelperTest() {}
+
+ virtual void SetUp() {
+ // Append the print preview switch before creating the PrintWebViewHelper.
+#if defined(GOOGLE_CHROME_BUILD) && !defined(OS_CHROMEOS)
+ CommandLine::ForCurrentProcess()->AppendSwitch(
+ switches::kDisablePrintPreview);
+#endif
+
+ RenderViewTest::SetUp();
+ }
+
+ protected:
DISALLOW_COPY_AND_ASSIGN(PrintWebViewHelperTest);
};
@@ -275,16 +294,17 @@ TEST_F(PrintWebViewHelperTest, PrintLayoutTest) {
// These print preview tests do not work on Chrome OS yet.
#if !defined(OS_CHROMEOS)
-class PrintWebViewHelperPreviewTest : public PrintWebViewHelperTest {
+class PrintWebViewHelperPreviewTest : public PrintWebViewHelperTestBase {
public:
PrintWebViewHelperPreviewTest() {}
virtual ~PrintWebViewHelperPreviewTest() {}
virtual void SetUp() {
// Append the print preview switch before creating the PrintWebViewHelper.
- // TODO(thestig): Remove when print preview is enabled by default.
+#if !defined(GOOGLE_CHROME_BUILD)
CommandLine::ForCurrentProcess()->AppendSwitch(
switches::kEnablePrintPreview);
+#endif
RenderViewTest::SetUp();
}
diff --git a/content/browser/renderer_host/browser_render_process_host.cc b/content/browser/renderer_host/browser_render_process_host.cc
index 24ee38e..7222b09 100644
--- a/content/browser/renderer_host/browser_render_process_host.cc
+++ b/content/browser/renderer_host/browser_render_process_host.cc
@@ -537,6 +537,13 @@ void BrowserRenderProcessHost::PropagateBrowserCommandLineToRenderer(
switches::kDisableJavaScriptI18NAPI,
switches::kDisableLocalStorage,
switches::kDisableLogging,
+#if defined(GOOGLE_CHROME_BUILD) && !defined(OS_CHROMEOS)
+ // Enabled by default in Google Chrome builds, except on CrOS.
+ switches::kDisablePrintPreview,
+#else
+ // Disabled by default in Chromium builds and on CrOS.
+ switches::kEnablePrintPreview,
+#endif
switches::kDisableSeccompSandbox,
switches::kDisableSessionStorage,
switches::kDisableSharedWorkers,
@@ -560,7 +567,6 @@ void BrowserRenderProcessHost::PropagateBrowserCommandLineToRenderer(
switches::kEnableP2PApi,
#endif
switches::kEnablePepperTesting,
- switches::kEnablePrintPreview,
switches::kEnableQuota,
switches::kEnableRemoting,
switches::kEnableResourceContentSettings,