diff options
author | dpapad@chromium.org <dpapad@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-02 19:25:17 +0000 |
---|---|---|
committer | dpapad@chromium.org <dpapad@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-02 19:25:17 +0000 |
commit | 5ad7617cd93b48a67395f532b8483b8ace445ca2 (patch) | |
tree | ef6ec65870ccdea737de7e0fdcf1d89e2d887511 /chrome/plugin | |
parent | f83773f72845ed180a23dcbbfa9afbc3c295f758 (diff) | |
download | chromium_src-5ad7617cd93b48a67395f532b8483b8ace445ca2.zip chromium_src-5ad7617cd93b48a67395f532b8483b8ace445ca2.tar.gz chromium_src-5ad7617cd93b48a67395f532b8483b8ace445ca2.tar.bz2 |
Applying factory pattern (through NativeMetafileFactory class). It is used to retrieve different printing contexts (based on the platform and user preferences).
BUG=NONE
TEST=NONE
Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=76553
Reverted: http://src.chromium.org/viewvc/chrome?view=rev&revision=76555
Review URL: http://codereview.chromium.org/6544028
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@76581 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/plugin')
-rw-r--r-- | chrome/plugin/webplugin_delegate_stub.cc | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/chrome/plugin/webplugin_delegate_stub.cc b/chrome/plugin/webplugin_delegate_stub.cc index 6b0f39a..75a3dc8 100644 --- a/chrome/plugin/webplugin_delegate_stub.cc +++ b/chrome/plugin/webplugin_delegate_stub.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -14,7 +14,6 @@ #include "chrome/plugin/plugin_channel.h" #include "chrome/plugin/plugin_thread.h" #include "chrome/plugin/webplugin_proxy.h" -#include "printing/native_metafile.h" #include "third_party/npapi/bindings/npapi.h" #include "third_party/npapi/bindings/npruntime.h" #include "skia/ext/platform_device.h" @@ -23,6 +22,12 @@ #include "webkit/plugins/npapi/webplugin_delegate_impl.h" #include "webkit/glue/webcursor.h" +#if defined(OS_WIN) +#include "base/scoped_ptr.h" +#include "printing/native_metafile_factory.h" +#include "printing/native_metafile.h" +#endif // defined(OS_WIN) + #if defined(ENABLE_GPU) #include "app/gfx/gl/gl_context.h" #endif @@ -281,26 +286,27 @@ void WebPluginDelegateStub::OnDidPaint() { void WebPluginDelegateStub::OnPrint(base::SharedMemoryHandle* shared_memory, uint32* size) { #if defined(OS_WIN) - printing::NativeMetafile metafile; - if (!metafile.CreateDc(NULL, NULL)) { + scoped_ptr<printing::NativeMetafile> metafile( + printing::NativeMetafileFactory::CreateMetafile()); + if (!metafile->CreateDc(NULL, NULL)) { NOTREACHED(); return; } - HDC hdc = metafile.hdc(); + HDC hdc = metafile->hdc(); skia::PlatformDevice::InitializeDC(hdc); delegate_->Print(hdc); - if (!metafile.CloseDc()) { + if (!metafile->CloseDc()) { NOTREACHED(); return; } - *size = metafile.GetDataSize(); + *size = metafile->GetDataSize(); DCHECK(*size); base::SharedMemory shared_buf; CreateSharedBuffer(*size, &shared_buf, shared_memory); // Retrieve a copy of the data. - bool success = metafile.GetData(shared_buf.memory(), *size); + bool success = metafile->GetData(shared_buf.memory(), *size); DCHECK(success); #else // TODO(port): plugin printing. |