diff options
author | raymes@google.com <raymes@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-21 17:58:24 +0000 |
---|---|---|
committer | raymes@google.com <raymes@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-21 17:58:24 +0000 |
commit | 4d80a3dba1592f7429b784fd751a8ad94399fbfa (patch) | |
tree | bf2d4e820765840b7828132bdf51e0191ba2da2b /ppapi | |
parent | 114313bc5ba93b9a952f07da1224b22ae7011154 (diff) | |
download | chromium_src-4d80a3dba1592f7429b784fd751a8ad94399fbfa.zip chromium_src-4d80a3dba1592f7429b784fd751a8ad94399fbfa.tar.gz chromium_src-4d80a3dba1592f7429b784fd751a8ad94399fbfa.tar.bz2 |
Revert 143294 - Provides a real implementation of GetDefaultPrintSettings.
Reverting due to: http://code.google.com/p/chromium/issues/detail?id=133972
This accesses the Chrome printing code to determine the default print settings for the default printer. Ideally we would query these settings every time they are requested, however this cannot be done (see the description in pepper_print_settings_initializer.h). Instead the settings are grabbed once at startup and cached.
BUG=
TEST=Added ppapi test.
Review URL: https://chromiumcodereview.appspot.com/10539171
TBR=raymes@chromium.org
Review URL: https://chromiumcodereview.appspot.com/10633008
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@143409 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi')
-rw-r--r-- | ppapi/ppapi_sources.gypi | 2 | ||||
-rw-r--r-- | ppapi/proxy/ppapi_messages.h | 3 | ||||
-rw-r--r-- | ppapi/proxy/ppb_instance_proxy.cc | 30 | ||||
-rw-r--r-- | ppapi/proxy/ppb_instance_proxy.h | 3 | ||||
-rw-r--r-- | ppapi/tests/test_printing.cc | 52 | ||||
-rw-r--r-- | ppapi/tests/test_printing.h | 24 |
6 files changed, 32 insertions, 82 deletions
diff --git a/ppapi/ppapi_sources.gypi b/ppapi/ppapi_sources.gypi index a26d13d..155da5a 100644 --- a/ppapi/ppapi_sources.gypi +++ b/ppapi/ppapi_sources.gypi @@ -428,8 +428,6 @@ 'tests/test_net_address_private.h', 'tests/test_network_monitor_private.cc', 'tests/test_network_monitor_private.h', - 'tests/test_printing.cc', - 'tests/test_printing.h', 'tests/test_resource_array.cc', 'tests/test_resource_array.h', 'tests/test_struct_sizes.c', diff --git a/ppapi/proxy/ppapi_messages.h b/ppapi/proxy/ppapi_messages.h index da5d3c1..07c939c 100644 --- a/ppapi/proxy/ppapi_messages.h +++ b/ppapi/proxy/ppapi_messages.h @@ -952,7 +952,8 @@ IPC_MESSAGE_ROUTED1(PpapiHostMsg_PPBInstance_LockMouse, PP_Instance /* instance */) IPC_MESSAGE_ROUTED1(PpapiHostMsg_PPBInstance_UnlockMouse, PP_Instance /* instance */) -IPC_SYNC_MESSAGE_ROUTED0_2(PpapiHostMsg_PPBPInstance_GetDefaultPrintSettings, +IPC_SYNC_MESSAGE_ROUTED1_2(PpapiHostMsg_PPBPInstance_GetDefaultPrintSettings, + PP_Instance /* instance */, PP_PrintSettings_Dev /* settings */, bool /* result */) IPC_SYNC_MESSAGE_ROUTED2_1(PpapiHostMsg_PPBInstance_ResolveRelativeToDocument, diff --git a/ppapi/proxy/ppb_instance_proxy.cc b/ppapi/proxy/ppb_instance_proxy.cc index a11d108..4cbb5ca 100644 --- a/ppapi/proxy/ppb_instance_proxy.cc +++ b/ppapi/proxy/ppb_instance_proxy.cc @@ -124,6 +124,8 @@ bool PPB_Instance_Proxy::OnMessageReceived(const IPC::Message& msg) { OnHostMsgLockMouse) IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_UnlockMouse, OnHostMsgUnlockMouse) + IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBPInstance_GetDefaultPrintSettings, + OnHostMsgGetDefaultPrintSettings) IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_SetCursor, OnHostMsgSetCursor) IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_SetTextInputType, @@ -465,9 +467,8 @@ PP_Bool PPB_Instance_Proxy::GetDefaultPrintSettings( return PP_FALSE; bool result; - PluginGlobals::Get()->plugin_proxy_delegate()->SendToBrowser( - new PpapiHostMsg_PPBPInstance_GetDefaultPrintSettings( - API_ID_PPB_INSTANCE, print_settings, &result)); + dispatcher()->Send(new PpapiHostMsg_PPBPInstance_GetDefaultPrintSettings( + API_ID_PPB_INSTANCE, instance, print_settings, &result)); return PP_FromBool(result); } @@ -664,6 +665,29 @@ void PPB_Instance_Proxy::OnHostMsgUnlockMouse(PP_Instance instance) { enter.functions()->UnlockMouse(instance); } +void PPB_Instance_Proxy::OnHostMsgGetDefaultPrintSettings( + PP_Instance instance, + PP_PrintSettings_Dev* settings, + bool* result) { + // TODO(raymes): This just returns some generic settings. Actually hook this + // up to the browser to return the real defaults. + PP_PrintSettings_Dev default_settings = { + // |printable_area|: all of the sheet of paper. + { { 0, 0 }, { 612, 792 } }, + // |content_area|: 0.5" margins all around. + { { 36, 36 }, { 540, 720 } }, + // |paper_size|: 8.5" x 11" (US letter). + { 612, 792 }, + 300, // |dpi|. + PP_PRINTORIENTATION_NORMAL, // |orientation|. + PP_PRINTSCALINGOPTION_NONE, // |print_scaling_option|. + PP_FALSE, // |grayscale|. + PP_PRINTOUTPUTFORMAT_PDF // |format|. + }; + *settings = default_settings; + *result = true; +} + #if !defined(OS_NACL) void PPB_Instance_Proxy::OnHostMsgResolveRelativeToDocument( PP_Instance instance, diff --git a/ppapi/proxy/ppb_instance_proxy.h b/ppapi/proxy/ppb_instance_proxy.h index 6d65f0c..7a84ec8 100644 --- a/ppapi/proxy/ppb_instance_proxy.h +++ b/ppapi/proxy/ppb_instance_proxy.h @@ -156,6 +156,9 @@ class PPB_Instance_Proxy : public InterfaceProxy, SerializedVarReceiveInput message); void OnHostMsgLockMouse(PP_Instance instance); void OnHostMsgUnlockMouse(PP_Instance instance); + void OnHostMsgGetDefaultPrintSettings(PP_Instance instance, + PP_PrintSettings_Dev* settings, + bool* result); void OnHostMsgSetCursor(PP_Instance instance, int32_t type, const ppapi::HostResource& custom_image, diff --git a/ppapi/tests/test_printing.cc b/ppapi/tests/test_printing.cc deleted file mode 100644 index e459524..0000000 --- a/ppapi/tests/test_printing.cc +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "ppapi/tests/test_printing.h" - -#include "ppapi/cpp/dev/printing_dev.h" -#include "ppapi/cpp/instance.h" -#include "ppapi/tests/testing_instance.h" - -REGISTER_TEST_CASE(Printing); - -class TestPrinting_Dev : public pp::Printing_Dev { -public: - explicit TestPrinting_Dev(pp::Instance* instance) : - pp::Printing_Dev(instance) {} - virtual ~TestPrinting_Dev() {} - virtual uint32_t QuerySupportedPrintOutputFormats() { return 0; } - virtual int32_t PrintBegin( - const PP_PrintSettings_Dev& print_settings) { return 0; } - virtual pp::Resource PrintPages( - const PP_PrintPageNumberRange_Dev* page_ranges, - uint32_t page_range_count) { - return pp::Resource(); - } - virtual void PrintEnd() {} - virtual bool IsPrintScalingDisabled() { return false; } -}; - -TestPrinting::TestPrinting(TestingInstance* instance) - : TestCase(instance) { -} - -void TestPrinting::RunTests(const std::string& filter) { - RUN_TEST(GetDefaultPrintSettings, filter); -} - -std::string TestPrinting::TestGetDefaultPrintSettings() { - PP_PrintSettings_Dev print_settings; - bool success = - TestPrinting_Dev(instance_).GetDefaultPrintSettings(&print_settings); - ASSERT_TRUE(success); - // We can't check any margin values because we don't know what they will be, - // but the following are currently hard-coded. - ASSERT_EQ(print_settings.orientation, PP_PRINTORIENTATION_NORMAL); - ASSERT_EQ( - print_settings.print_scaling_option, PP_PRINTSCALINGOPTION_SOURCE_SIZE); - ASSERT_EQ(print_settings.grayscale, PP_FALSE); - ASSERT_EQ(print_settings.format, PP_PRINTOUTPUTFORMAT_PDF); - - PASS(); -} diff --git a/ppapi/tests/test_printing.h b/ppapi/tests/test_printing.h deleted file mode 100644 index 6b494b6..0000000 --- a/ppapi/tests/test_printing.h +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef PPAPI_TESTS_TEST_PRINTING_H_ -#define PPAPI_TESTS_TEST_PRINTING_H_ - -#include <string> - -#include "ppapi/tests/test_case.h" - -class TestPrinting : public TestCase { - public: - explicit TestPrinting(TestingInstance* instance); - - // TestCase implementation. - virtual void RunTests(const std::string& filter); - - private: - // Tests. - std::string TestGetDefaultPrintSettings(); -}; - -#endif // PPAPI_TESTS_TEST_PRINTING_H_ |