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

Side by Side Diff: webkit/plugins/ppapi/ppapi_plugin_instance.cc

Issue 10540033: Add ENABLE_PRINTING and disable it on Android. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Arrange some ifdefs Created 8 years, 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « printing/printing.gyp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" 5 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/debug/trace_event.h" 8 #include "base/debug/trace_event.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/linked_ptr.h" 10 #include "base/memory/linked_ptr.h"
(...skipping 1151 matching lines...) Expand 10 before | Expand all | Expand 10 after
1162 return 0; 1162 return 0;
1163 current_print_settings_ = print_settings; 1163 current_print_settings_ = print_settings;
1164 #if defined(USE_SKIA) 1164 #if defined(USE_SKIA)
1165 canvas_ = NULL; 1165 canvas_ = NULL;
1166 ranges_.clear(); 1166 ranges_.clear();
1167 #endif // USE_SKIA 1167 #endif // USE_SKIA
1168 return num_pages; 1168 return num_pages;
1169 } 1169 }
1170 1170
1171 bool PluginInstance::PrintPage(int page_number, WebKit::WebCanvas* canvas) { 1171 bool PluginInstance::PrintPage(int page_number, WebKit::WebCanvas* canvas) {
1172 #if defined(ENABLE_PRINTING)
1172 DCHECK(plugin_print_interface_); 1173 DCHECK(plugin_print_interface_);
1173 PP_PrintPageNumberRange_Dev page_range; 1174 PP_PrintPageNumberRange_Dev page_range;
1174 page_range.first_page_number = page_range.last_page_number = page_number; 1175 page_range.first_page_number = page_range.last_page_number = page_number;
1175 #if defined(USE_SKIA) 1176 #if defined(USE_SKIA)
1176 // The canvas only has a metafile on it for print preview. 1177 // The canvas only has a metafile on it for print preview.
1177 bool save_for_later = 1178 bool save_for_later =
1178 (printing::MetafileSkiaWrapper::GetMetafileFromCanvas(*canvas) != NULL); 1179 (printing::MetafileSkiaWrapper::GetMetafileFromCanvas(*canvas) != NULL);
1179 #if defined(OS_MACOSX) || defined(OS_WIN) 1180 #if defined(OS_MACOSX) || defined(OS_WIN)
1180 save_for_later = save_for_later && skia::IsPreviewMetafile(*canvas); 1181 save_for_later = save_for_later && skia::IsPreviewMetafile(*canvas);
1181 #endif 1182 #endif
1182 if (save_for_later) { 1183 if (save_for_later) {
1183 ranges_.push_back(page_range); 1184 ranges_.push_back(page_range);
1184 canvas_ = canvas; 1185 canvas_ = canvas;
1185 return true; 1186 return true;
1186 } else 1187 } else
1187 #endif // USE_SKIA 1188 #endif // USE_SKIA
1188 { 1189 {
1189 return PrintPageHelper(&page_range, 1, canvas); 1190 return PrintPageHelper(&page_range, 1, canvas);
1190 } 1191 }
1192 #else // defined(ENABLED_PRINTING)
1193 return false;
1194 #endif
1191 } 1195 }
1192 1196
1193 bool PluginInstance::PrintPageHelper(PP_PrintPageNumberRange_Dev* page_ranges, 1197 bool PluginInstance::PrintPageHelper(PP_PrintPageNumberRange_Dev* page_ranges,
1194 int num_ranges, 1198 int num_ranges,
1195 WebKit::WebCanvas* canvas) { 1199 WebKit::WebCanvas* canvas) {
1196 // Keep a reference on the stack. See NOTE above. 1200 // Keep a reference on the stack. See NOTE above.
1197 scoped_refptr<PluginInstance> ref(this); 1201 scoped_refptr<PluginInstance> ref(this);
1198 DCHECK(plugin_print_interface_); 1202 DCHECK(plugin_print_interface_);
1199 if (!plugin_print_interface_) 1203 if (!plugin_print_interface_)
1200 return false; 1204 return false;
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
1408 1412
1409 PluginDelegate::PlatformContext3D* PluginInstance::CreateContext3D() { 1413 PluginDelegate::PlatformContext3D* PluginInstance::CreateContext3D() {
1410 if (fullscreen_container_) 1414 if (fullscreen_container_)
1411 return fullscreen_container_->CreateContext3D(); 1415 return fullscreen_container_->CreateContext3D();
1412 else 1416 else
1413 return delegate_->CreateContext3D(); 1417 return delegate_->CreateContext3D();
1414 } 1418 }
1415 1419
1416 bool PluginInstance::PrintPDFOutput(PP_Resource print_output, 1420 bool PluginInstance::PrintPDFOutput(PP_Resource print_output,
1417 WebKit::WebCanvas* canvas) { 1421 WebKit::WebCanvas* canvas) {
1422 #if defined(ENABLE_PRINTING)
1418 ::ppapi::thunk::EnterResourceNoLock<PPB_Buffer_API> enter(print_output, true); 1423 ::ppapi::thunk::EnterResourceNoLock<PPB_Buffer_API> enter(print_output, true);
1419 if (enter.failed()) 1424 if (enter.failed())
1420 return false; 1425 return false;
1421 1426
1422 BufferAutoMapper mapper(enter.object()); 1427 BufferAutoMapper mapper(enter.object());
1423 if (!mapper.data() || !mapper.size()) { 1428 if (!mapper.data() || !mapper.size()) {
1424 NOTREACHED(); 1429 NOTREACHED();
1425 return false; 1430 return false;
1426 } 1431 }
1427 #if defined(OS_WIN) 1432 #if defined(OS_WIN)
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
1511 1516
1512 ret = render_proc(static_cast<unsigned char*>(mapper.data()), mapper.size(), 1517 ret = render_proc(static_cast<unsigned char*>(mapper.data()), mapper.size(),
1513 0, dc, current_print_settings_.dpi, 1518 0, dc, current_print_settings_.dpi,
1514 current_print_settings_.dpi, 0, 0, size_in_pixels.width(), 1519 current_print_settings_.dpi, 0, 0, size_in_pixels.width(),
1515 size_in_pixels.height(), true, false, true, true, true); 1520 size_in_pixels.height(), true, false, true, true, true);
1516 skia::EndPlatformPaint(canvas); 1521 skia::EndPlatformPaint(canvas);
1517 } 1522 }
1518 #endif // defined(OS_WIN) 1523 #endif // defined(OS_WIN)
1519 1524
1520 return ret; 1525 return ret;
1526 #else // defined(ENABLE_PRINTING)
1527 return false;
1528 #endif
1521 } 1529 }
1522 1530
1523 PPB_Graphics2D_Impl* PluginInstance::GetBoundGraphics2D() const { 1531 PPB_Graphics2D_Impl* PluginInstance::GetBoundGraphics2D() const {
1524 if (bound_graphics_.get() == NULL) 1532 if (bound_graphics_.get() == NULL)
1525 return NULL; 1533 return NULL;
1526 1534
1527 if (bound_graphics_->AsPPB_Graphics2D_API()) 1535 if (bound_graphics_->AsPPB_Graphics2D_API())
1528 return static_cast<PPB_Graphics2D_Impl*>(bound_graphics_.get()); 1536 return static_cast<PPB_Graphics2D_Impl*>(bound_graphics_.get());
1529 return NULL; 1537 return NULL;
1530 } 1538 }
(...skipping 606 matching lines...) Expand 10 before | Expand all | Expand 10 after
2137 screen_size_for_fullscreen_ = gfx::Size(); 2145 screen_size_for_fullscreen_ = gfx::Size();
2138 WebElement element = container_->element(); 2146 WebElement element = container_->element();
2139 element.setAttribute(WebString::fromUTF8(kWidth), width_before_fullscreen_); 2147 element.setAttribute(WebString::fromUTF8(kWidth), width_before_fullscreen_);
2140 element.setAttribute(WebString::fromUTF8(kHeight), height_before_fullscreen_); 2148 element.setAttribute(WebString::fromUTF8(kHeight), height_before_fullscreen_);
2141 element.setAttribute(WebString::fromUTF8(kBorder), border_before_fullscreen_); 2149 element.setAttribute(WebString::fromUTF8(kBorder), border_before_fullscreen_);
2142 element.setAttribute(WebString::fromUTF8(kStyle), style_before_fullscreen_); 2150 element.setAttribute(WebString::fromUTF8(kStyle), style_before_fullscreen_);
2143 } 2151 }
2144 2152
2145 } // namespace ppapi 2153 } // namespace ppapi
2146 } // namespace webkit 2154 } // namespace webkit
OLDNEW
« no previous file with comments | « printing/printing.gyp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698