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

Side by Side Diff: chrome/common/temp_scaffolding_stubs.cc

Issue 172115: Pass printing result to the browser.... (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 11 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 "chrome/common/temp_scaffolding_stubs.h" 5 #include "chrome/common/temp_scaffolding_stubs.h"
6 6
7 #include "build/build_config.h"
8
9 #include <vector> 7 #include <vector>
10 8
11 #include "base/gfx/rect.h" 9 #include "base/gfx/rect.h"
12 #include "base/logging.h" 10 #include "base/logging.h"
13 #include "chrome/browser/browser_list.h" 11 #include "chrome/browser/browser_list.h"
14 #include "chrome/browser/first_run.h" 12 #include "chrome/browser/first_run.h"
15 #include "chrome/browser/rlz/rlz.h" 13 #include "chrome/browser/rlz/rlz.h"
16 14
17 #if defined(OS_LINUX) 15 #if defined(OS_LINUX)
16 #include "base/path_service.h"
18 #include "chrome/browser/dock_info.h" 17 #include "chrome/browser/dock_info.h"
18 #include "chrome/browser/tab_contents/tab_contents.h"
19 #include "chrome/common/chrome_paths.h"
20 #include "chrome/common/render_messages.h"
21 #include "printing/native_metafile.h"
19 #endif 22 #endif
20 23
21 #if defined(OS_MACOSX) 24 #if defined(OS_MACOSX)
22 #include "chrome/browser/automation/automation_provider.h" 25 #include "chrome/browser/automation/automation_provider.h"
23 #include "chrome/browser/fonts_languages_window.h" 26 #include "chrome/browser/fonts_languages_window.h"
24 #include "chrome/browser/memory_details.h" 27 #include "chrome/browser/memory_details.h"
25 #include "chrome/browser/options_window.h" 28 #include "chrome/browser/options_window.h"
26 #endif 29 #endif
27 30
28 #if defined(TOOLKIT_VIEWS) 31 #if defined(TOOLKIT_VIEWS)
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 Handler* handler) { 318 Handler* handler) {
316 NOTIMPLEMENTED(); 319 NOTIMPLEMENTED();
317 } 320 }
318 321
319 void BookmarkManager::SelectInTree(Profile* profile, const BookmarkNode* node) { 322 void BookmarkManager::SelectInTree(Profile* profile, const BookmarkNode* node) {
320 } 323 }
321 void BookmarkManager::Show(Profile* profile) { 324 void BookmarkManager::Show(Profile* profile) {
322 } 325 }
323 326
324 #endif 327 #endif
328
329 //------------------------------------------------------------------------------
330
331 #if defined(OS_LINUX)
332 // TODO(myhuang): This is a quick hack for testing purpose. We should implement
333 // PrintViewManager and other related classes later on Linux.
334 namespace printing {
335
336 void PrintViewManager::DidPrintPage(
337 const ViewHostMsg_DidPrintPage_Params& params) {
338 base::SharedMemory shared_buf(params.metafile_data_handle, true);
339 if (!shared_buf.Map(params.data_size)) {
340 NOTREACHED() << "couldn't map";
341 owner_.Stop();
342 return;
343 }
344
345 // The only format we can use now is PDF since Cairo needs to create a
346 // temporary file for a PostScript surface. We do not allow disk I/O in the
347 // renderer.
348 scoped_ptr<NativeMetafile> metafile(
349 new NativeMetafile(printing::NativeMetafile::PDF));
350
351 if (!metafile->Init(shared_buf.memory(), params.data_size)) {
352 NOTREACHED() << "Invalid metafile header";
353 shared_buf.Unmap();
354 owner_.Stop();
355 return;
356 }
357
358 // Save the PDF file to default download location.
359 // NOTE: Existing file will be overwritten.
360 FilePath default_save_path;
361 if (!PathService::Get(chrome::DIR_DEFAULT_DOWNLOADS, &default_save_path)) {
362 NOTREACHED();
363 }
364 FilePath save_filename =
365 default_save_path.Append(FilePath("chromium_printing_test.pdf"));
366 metafile->SaveTo(save_filename);
367 shared_buf.Unmap();
368 }
369
370 } // namespace printing
371
372 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698