OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/browser/ui/webui/print_preview_handler.h" | 5 #include "chrome/browser/ui/webui/print_preview_handler.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/i18n/file_util_icu.h" | 9 #include "base/i18n/file_util_icu.h" |
10 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 scoped_refptr<PrintSystemTaskProxy> task = | 268 scoped_refptr<PrintSystemTaskProxy> task = |
269 new PrintSystemTaskProxy(AsWeakPtr(), print_backend_.get()); | 269 new PrintSystemTaskProxy(AsWeakPtr(), print_backend_.get()); |
270 BrowserThread::PostTask( | 270 BrowserThread::PostTask( |
271 BrowserThread::FILE, FROM_HERE, | 271 BrowserThread::FILE, FROM_HERE, |
272 NewRunnableMethod(task.get(), | 272 NewRunnableMethod(task.get(), |
273 &PrintSystemTaskProxy::EnumeratePrinters)); | 273 &PrintSystemTaskProxy::EnumeratePrinters)); |
274 } | 274 } |
275 | 275 |
276 void PrintPreviewHandler::HandleGetPreview(const ListValue* args) { | 276 void PrintPreviewHandler::HandleGetPreview(const ListValue* args) { |
277 TabContents* initiator_tab = GetInitiatorTab(); | 277 TabContents* initiator_tab = GetInitiatorTab(); |
278 if (!initiator_tab) | 278 if (!initiator_tab) { |
| 279 web_ui_->CallJavascriptFunction("printPreviewFailed"); |
279 return; | 280 return; |
| 281 } |
280 scoped_ptr<DictionaryValue> settings(GetSettingsDictionary(args)); | 282 scoped_ptr<DictionaryValue> settings(GetSettingsDictionary(args)); |
281 if (!settings.get()) | 283 if (!settings.get()) |
282 return; | 284 return; |
283 | 285 |
284 RenderViewHost* rvh = initiator_tab->render_view_host(); | 286 RenderViewHost* rvh = initiator_tab->render_view_host(); |
285 rvh->Send(new PrintMsg_PrintPreview(rvh->routing_id(), *settings)); | 287 rvh->Send(new PrintMsg_PrintPreview(rvh->routing_id(), *settings)); |
286 } | 288 } |
287 | 289 |
288 void PrintPreviewHandler::HandlePrint(const ListValue* args) { | 290 void PrintPreviewHandler::HandlePrint(const ListValue* args) { |
289 TabContents* initiator_tab = GetInitiatorTab(); | 291 TabContents* initiator_tab = GetInitiatorTab(); |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
445 metafile->InitFromData(data.first->memory(), data.second); | 447 metafile->InitFromData(data.first->memory(), data.second); |
446 | 448 |
447 // Updating last_saved_path_ to the newly selected folder. | 449 // Updating last_saved_path_ to the newly selected folder. |
448 *last_saved_path_ = path.DirName(); | 450 *last_saved_path_ = path.DirName(); |
449 | 451 |
450 PrintToPdfTask* task = new PrintToPdfTask(metafile, path); | 452 PrintToPdfTask* task = new PrintToPdfTask(metafile, path); |
451 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, task); | 453 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, task); |
452 | 454 |
453 ActivateInitiatorTabAndClosePreviewTab(); | 455 ActivateInitiatorTabAndClosePreviewTab(); |
454 } | 456 } |
OLD | NEW |