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

Side by Side Diff: chrome/browser/printing/print_dialog_cloud.cc

Issue 10388214: Make cloud print dialog creation function not use browser list, instead obtain profile and parent w… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 7 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) 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 "chrome/browser/printing/print_dialog_cloud.h" 5 #include "chrome/browser/printing/print_dialog_cloud.h"
6 #include "chrome/browser/printing/print_dialog_cloud_internal.h" 6 #include "chrome/browser/printing/print_dialog_cloud_internal.h"
7 7
8 #include "base/base64.h" 8 #include "base/base64.h"
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/file_util.h" 12 #include "base/file_util.h"
13 #include "base/json/json_reader.h" 13 #include "base/json/json_reader.h"
14 #include "base/utf_string_conversions.h" 14 #include "base/utf_string_conversions.h"
15 #include "base/values.h" 15 #include "base/values.h"
16 #include "chrome/browser/browser_process_impl.h" 16 #include "chrome/browser/browser_process_impl.h"
17 #include "chrome/browser/debugger/devtools_window.h" 17 #include "chrome/browser/debugger/devtools_window.h"
18 #include "chrome/browser/lifetime/application_lifetime.h" 18 #include "chrome/browser/lifetime/application_lifetime.h"
19 #include "chrome/browser/prefs/pref_service.h" 19 #include "chrome/browser/prefs/pref_service.h"
20 #include "chrome/browser/printing/cloud_print/cloud_print_url.h" 20 #include "chrome/browser/printing/cloud_print/cloud_print_url.h"
21 #include "chrome/browser/profiles/profile.h" 21 #include "chrome/browser/profiles/profile.h"
22 #include "chrome/browser/profiles/profile_manager.h" 22 #include "chrome/browser/profiles/profile_manager.h"
23 #include "chrome/browser/ui/browser_dialogs.h" 23 #include "chrome/browser/ui/browser_dialogs.h"
24 #include "chrome/browser/ui/browser.h"
25 #include "chrome/browser/ui/browser_finder.h"
26 #include "chrome/browser/ui/browser_list.h"
27 #include "chrome/browser/ui/browser_window.h"
28 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
29 #include "chrome/common/chrome_switches.h" 24 #include "chrome/common/chrome_switches.h"
30 #include "chrome/common/pref_names.h" 25 #include "chrome/common/pref_names.h"
31 #include "chrome/common/print_messages.h" 26 #include "chrome/common/print_messages.h"
32 #include "chrome/common/url_constants.h" 27 #include "chrome/common/url_constants.h"
33 #include "content/public/browser/browser_thread.h" 28 #include "content/public/browser/browser_thread.h"
34 #include "content/public/browser/navigation_controller.h" 29 #include "content/public/browser/navigation_controller.h"
35 #include "content/public/browser/navigation_entry.h" 30 #include "content/public/browser/navigation_entry.h"
36 #include "content/public/browser/notification_registrar.h" 31 #include "content/public/browser/notification_registrar.h"
37 #include "content/public/browser/notification_source.h" 32 #include "content/public/browser/notification_source.h"
38 #include "content/public/browser/notification_types.h" 33 #include "content/public/browser/notification_types.h"
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 gfx::Size size = web_ui()->GetWebContents()->GetView()->GetContainerSize(); 479 gfx::Size size = web_ui()->GetWebContents()->GetView()->GetContainerSize();
485 Profile* profile = Profile::FromWebUI(web_ui()); 480 Profile* profile = Profile::FromWebUI(web_ui());
486 profile->GetPrefs()->SetInteger(prefs::kCloudPrintDialogWidth, 481 profile->GetPrefs()->SetInteger(prefs::kCloudPrintDialogWidth,
487 size.width()); 482 size.width());
488 profile->GetPrefs()->SetInteger(prefs::kCloudPrintDialogHeight, 483 profile->GetPrefs()->SetInteger(prefs::kCloudPrintDialogHeight,
489 size.height()); 484 size.height());
490 } 485 }
491 } 486 }
492 487
493 CloudPrintWebDialogDelegate::CloudPrintWebDialogDelegate( 488 CloudPrintWebDialogDelegate::CloudPrintWebDialogDelegate(
489 content::BrowserContext* browser_context,
490 gfx::NativeWindow modal_parent,
494 const FilePath& path_to_file, 491 const FilePath& path_to_file,
495 int width, int height,
496 const std::string& json_arguments, 492 const std::string& json_arguments,
497 const string16& print_job_title, 493 const string16& print_job_title,
498 const string16& print_ticket, 494 const string16& print_ticket,
499 const std::string& file_type, 495 const std::string& file_type,
500 bool modal,
501 bool delete_on_close, 496 bool delete_on_close,
502 bool close_after_signin, 497 bool close_after_signin,
503 const base::Closure& callback) 498 const base::Closure& callback)
504 : delete_on_close_(delete_on_close), 499 : delete_on_close_(delete_on_close),
505 flow_handler_(new CloudPrintFlowHandler(path_to_file, 500 flow_handler_(new CloudPrintFlowHandler(path_to_file,
506 print_job_title, 501 print_job_title,
507 print_ticket, 502 print_ticket,
508 file_type, 503 file_type,
509 close_after_signin, 504 close_after_signin,
510 callback)), 505 callback)),
511 modal_(modal), 506 modal_parent_(modal_parent),
512 owns_flow_handler_(true), 507 owns_flow_handler_(true),
513 path_to_file_(path_to_file) { 508 path_to_file_(path_to_file) {
514 Init(width, height, json_arguments); 509 Init(browser_context, json_arguments);
515 } 510 }
516 511
517 // For unit testing. 512 // For unit testing.
518 CloudPrintWebDialogDelegate::CloudPrintWebDialogDelegate( 513 CloudPrintWebDialogDelegate::CloudPrintWebDialogDelegate(
514 const FilePath& path_to_file,
519 CloudPrintFlowHandler* flow_handler, 515 CloudPrintFlowHandler* flow_handler,
520 int width, int height,
521 const std::string& json_arguments, 516 const std::string& json_arguments,
522 bool modal,
523 bool delete_on_close) 517 bool delete_on_close)
524 : delete_on_close_(delete_on_close), 518 : delete_on_close_(delete_on_close),
525 flow_handler_(flow_handler), 519 flow_handler_(flow_handler),
526 modal_(modal), 520 modal_parent_(NULL),
527 owns_flow_handler_(true) { 521 owns_flow_handler_(true) {
528 Init(width, height, json_arguments); 522 Init(NULL, json_arguments);
529 } 523 }
530 524
531 void CloudPrintWebDialogDelegate::Init(int width, int height, 525 // Returns the persisted width/height for the print dialog.
526 void GetDialogWidthAndHeightFromPrefs(content::BrowserContext* browser_context,
527 int* width,
528 int* height) {
529 const int kDefaultWidth = 912;
530 const int kDefaultHeight = 633;
531 if (!browser_context) {
532 *width = kDefaultWidth;
533 *height = kDefaultHeight;
534 return;
535 }
536
537 Profile* profile = Profile::FromBrowserContext(browser_context);
538 if (!profile->GetPrefs()->FindPreference(prefs::kCloudPrintDialogWidth)) {
539 profile->GetPrefs()->RegisterIntegerPref(prefs::kCloudPrintDialogWidth,
540 kDefaultWidth,
541 PrefService::UNSYNCABLE_PREF);
542 }
543 if (!profile->GetPrefs()->FindPreference(prefs::kCloudPrintDialogHeight)) {
544 profile->GetPrefs()->RegisterIntegerPref(prefs::kCloudPrintDialogHeight,
545 kDefaultHeight,
546 PrefService::UNSYNCABLE_PREF);
547 }
548
549 *width = profile->GetPrefs()->GetInteger(prefs::kCloudPrintDialogWidth);
550 *height = profile->GetPrefs()->GetInteger(prefs::kCloudPrintDialogHeight);
551 }
552
553 void CloudPrintWebDialogDelegate::Init(content::BrowserContext* browser_context,
532 const std::string& json_arguments) { 554 const std::string& json_arguments) {
533 // This information is needed to show the dialog HTML content. 555 // This information is needed to show the dialog HTML content.
534 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 556 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
557
535 params_.url = GURL(chrome::kChromeUICloudPrintResourcesURL); 558 params_.url = GURL(chrome::kChromeUICloudPrintResourcesURL);
536 params_.height = height; 559 GetDialogWidthAndHeightFromPrefs(browser_context,
537 params_.width = width; 560 &params_.width,
561 &params_.height);
538 params_.json_input = json_arguments; 562 params_.json_input = json_arguments;
539 563
540 flow_handler_->SetDialogDelegate(this); 564 flow_handler_->SetDialogDelegate(this);
541 // If we're not modal we can show the dialog with no browser. 565 // If we're not modal we can show the dialog with no browser.
542 // We need this to keep Chrome alive while our dialog is up. 566 // We need this to keep Chrome alive while our dialog is up.
543 if (!modal_) 567 if (!modal_parent_)
544 browser::StartKeepAlive(); 568 browser::StartKeepAlive();
545 } 569 }
546 570
547 CloudPrintWebDialogDelegate::~CloudPrintWebDialogDelegate() { 571 CloudPrintWebDialogDelegate::~CloudPrintWebDialogDelegate() {
548 // If the flow_handler_ is about to outlive us because we don't own 572 // If the flow_handler_ is about to outlive us because we don't own
549 // it anymore, we need to have it remove its reference to us. 573 // it anymore, we need to have it remove its reference to us.
550 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 574 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
551 flow_handler_->SetDialogDelegate(NULL); 575 flow_handler_->SetDialogDelegate(NULL);
552 if (owns_flow_handler_) { 576 if (owns_flow_handler_) {
553 delete flow_handler_; 577 delete flow_handler_;
554 } 578 }
555 } 579 }
556 580
557 ui::ModalType CloudPrintWebDialogDelegate::GetDialogModalType() const { 581 ui::ModalType CloudPrintWebDialogDelegate::GetDialogModalType() const {
558 return modal_ ? ui::MODAL_TYPE_WINDOW : ui::MODAL_TYPE_NONE; 582 return modal_parent_ ? ui::MODAL_TYPE_WINDOW : ui::MODAL_TYPE_NONE;
559 } 583 }
560 584
561 string16 CloudPrintWebDialogDelegate::GetDialogTitle() const { 585 string16 CloudPrintWebDialogDelegate::GetDialogTitle() const {
562 return string16(); 586 return string16();
563 } 587 }
564 588
565 GURL CloudPrintWebDialogDelegate::GetDialogContentURL() const { 589 GURL CloudPrintWebDialogDelegate::GetDialogContentURL() const {
566 return params_.url; 590 return params_.url;
567 } 591 }
568 592
(...skipping 21 matching lines...) Expand all
590 flow_handler_->StoreDialogClientSize(); 614 flow_handler_->StoreDialogClientSize();
591 615
592 if (delete_on_close_) { 616 if (delete_on_close_) {
593 BrowserThread::PostTask( 617 BrowserThread::PostTask(
594 BrowserThread::FILE, FROM_HERE, 618 BrowserThread::FILE, FROM_HERE,
595 base::Bind(&internal_cloud_print_helpers::Delete, path_to_file_)); 619 base::Bind(&internal_cloud_print_helpers::Delete, path_to_file_));
596 } 620 }
597 621
598 // If we're modal we can show the dialog with no browser. 622 // If we're modal we can show the dialog with no browser.
599 // End the keep-alive so that Chrome can exit. 623 // End the keep-alive so that Chrome can exit.
600 if (!modal_) 624 if (!modal_parent_)
601 browser::EndKeepAlive(); 625 browser::EndKeepAlive();
602 delete this; 626 delete this;
603 } 627 }
604 628
605 void CloudPrintWebDialogDelegate::OnCloseContents(WebContents* source, 629 void CloudPrintWebDialogDelegate::OnCloseContents(WebContents* source,
606 bool* out_close_dialog) { 630 bool* out_close_dialog) {
607 if (out_close_dialog) 631 if (out_close_dialog)
608 *out_close_dialog = true; 632 *out_close_dialog = true;
609 } 633 }
610 634
611 bool CloudPrintWebDialogDelegate::ShouldShowDialogTitle() const { 635 bool CloudPrintWebDialogDelegate::ShouldShowDialogTitle() const {
612 return false; 636 return false;
613 } 637 }
614 638
615 bool CloudPrintWebDialogDelegate::HandleContextMenu( 639 bool CloudPrintWebDialogDelegate::HandleContextMenu(
616 const content::ContextMenuParams& params) { 640 const content::ContextMenuParams& params) {
617 return true; 641 return true;
618 } 642 }
619 643
620 void CreatePrintDialogForBytesImpl(scoped_refptr<base::RefCountedBytes> data, 644 void CreatePrintDialogForBytesImpl(content::BrowserContext* browser_context,
645 gfx::NativeWindow modal_parent,
646 scoped_refptr<base::RefCountedBytes> data,
621 const string16& print_job_title, 647 const string16& print_job_title,
622 const string16& print_ticket, 648 const string16& print_ticket,
623 const std::string& file_type, 649 const std::string& file_type) {
624 bool modal) {
625 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 650 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
626 // TODO(abodenha@chromium.org) Writing the PDF to a file before printing 651 // TODO(abodenha@chromium.org) Writing the PDF to a file before printing
627 // is wasteful. Modify the dialog flow to pull PDF data from memory. 652 // is wasteful. Modify the dialog flow to pull PDF data from memory.
628 // See http://code.google.com/p/chromium/issues/detail?id=44093 653 // See http://code.google.com/p/chromium/issues/detail?id=44093
629 FilePath path; 654 FilePath path;
630 if (file_util::CreateTemporaryFile(&path)) { 655 if (file_util::CreateTemporaryFile(&path)) {
631 file_util::WriteFile(path, 656 file_util::WriteFile(path,
632 reinterpret_cast<const char*>(data->front()), 657 reinterpret_cast<const char*>(data->front()),
633 data->size()); 658 data->size());
634 } 659 }
635 print_dialog_cloud::CreatePrintDialogForFile(path, 660 print_dialog_cloud::CreatePrintDialogForFile(browser_context,
661 modal_parent,
662 path,
636 print_job_title, 663 print_job_title,
637 print_ticket, 664 print_ticket,
638 file_type, 665 file_type,
639 modal,
640 true); 666 true);
641 } 667 }
642 668
643 // Called from the UI thread, starts up the dialog. 669 // Called from the UI thread, starts up the dialog.
644 void CreateDialogImpl(const FilePath& path_to_file, 670 void CreateDialogImpl(content::BrowserContext* browser_context,
671 gfx::NativeWindow modal_parent,
672 const FilePath& path_to_file,
645 const string16& print_job_title, 673 const string16& print_job_title,
646 const string16& print_ticket, 674 const string16& print_ticket,
647 const std::string& file_type, 675 const std::string& file_type,
648 bool modal,
649 bool delete_on_close, 676 bool delete_on_close,
650 bool close_after_signin, 677 bool close_after_signin,
651 const base::Closure& callback) { 678 const base::Closure& callback) {
652 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 679 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
653 Browser* browser = BrowserList::GetLastActive();
654
655 const int kDefaultWidth = 912;
656 const int kDefaultHeight = 633;
657 string16 job_title = print_job_title;
658 Profile* profile = NULL;
659 if (modal) {
660 if (job_title.empty()) {
661 WebContents* web_contents = browser->GetSelectedWebContents();
662 if (web_contents)
663 job_title = web_contents->GetTitle();
664 }
665 profile = browser->profile();
666 } else {
667 std::vector<Profile*> loaded_profiles =
668 g_browser_process->profile_manager()->GetLoadedProfiles();
669 DCHECK_GT(loaded_profiles.size(), 0U);
670 profile = loaded_profiles[0];
671 browser = browser::FindLastActiveWithProfile(profile);
672 }
673 DCHECK(profile);
674 PrefService* pref_service = profile->GetPrefs();
675 DCHECK(pref_service);
676 if (!pref_service->FindPreference(prefs::kCloudPrintDialogWidth)) {
677 pref_service->RegisterIntegerPref(prefs::kCloudPrintDialogWidth,
678 kDefaultWidth,
679 PrefService::UNSYNCABLE_PREF);
680 }
681 if (!pref_service->FindPreference(prefs::kCloudPrintDialogHeight)) {
682 pref_service->RegisterIntegerPref(prefs::kCloudPrintDialogHeight,
683 kDefaultHeight,
684 PrefService::UNSYNCABLE_PREF);
685 }
686
687 int width = pref_service->GetInteger(prefs::kCloudPrintDialogWidth);
688 int height = pref_service->GetInteger(prefs::kCloudPrintDialogHeight);
689
690 WebDialogDelegate* dialog_delegate = 680 WebDialogDelegate* dialog_delegate =
691 new internal_cloud_print_helpers::CloudPrintWebDialogDelegate( 681 new internal_cloud_print_helpers::CloudPrintWebDialogDelegate(
692 path_to_file, width, height, std::string(), job_title, print_ticket, 682 browser_context,
693 file_type, modal, delete_on_close, close_after_signin, 683 modal_parent,
684 path_to_file,
685 std::string(),
686 print_job_title,
687 print_ticket,
688 file_type,
689 delete_on_close,
690 close_after_signin,
694 callback); 691 callback);
695 browser::ShowWebDialog(modal ? browser->window()->GetNativeHandle() : NULL, 692 browser::ShowWebDialog(modal_parent,
696 profile, browser, dialog_delegate); 693 Profile::FromBrowserContext(browser_context),
694 NULL,
695 dialog_delegate);
697 } 696 }
698 697
699 void CreateDialogSigninImpl(const base::Closure& callback) { 698 void CreateDialogSigninImpl(content::BrowserContext* browser_context,
700 CreateDialogImpl(FilePath(), string16(), string16(), std::string(), 699 gfx::NativeWindow modal_parent,
701 true, false, true, callback); 700 const base::Closure& callback) {
701 CreateDialogImpl(browser_context, modal_parent, FilePath(), string16(),
702 string16(), std::string(), false, true, callback);
702 } 703 }
703 704
704 void CreateDialogFullImpl(const FilePath& path_to_file, 705 void CreateDialogFullImpl(content::BrowserContext* browser_context,
705 const string16& print_job_title, 706 gfx::NativeWindow modal_parent,
706 const string16& print_ticket, 707 const FilePath& path_to_file,
707 const std::string& file_type, 708 const string16& print_job_title,
708 bool modal, 709 const string16& print_ticket,
709 bool delete_on_close) { 710 const std::string& file_type,
710 CreateDialogImpl(path_to_file, print_job_title, print_ticket, file_type, 711 bool delete_on_close) {
711 modal, delete_on_close, false, base::Closure()); 712 CreateDialogImpl(browser_context, modal_parent, path_to_file, print_job_title,
713 print_ticket, file_type, delete_on_close, false,
714 base::Closure());
712 } 715 }
713 716
714 717
715 718
716 // Provides a runnable function to delete a file. 719 // Provides a runnable function to delete a file.
717 void Delete(const FilePath& file_path) { 720 void Delete(const FilePath& file_path) {
718 file_util::Delete(file_path, false); 721 file_util::Delete(file_path, false);
719 } 722 }
720 723
721 } // namespace internal_cloud_print_helpers 724 } // namespace internal_cloud_print_helpers
722 725
723 namespace print_dialog_cloud { 726 namespace print_dialog_cloud {
724 727
725 // Called on the FILE or UI thread. This is the main entry point into creating 728 // Called on the FILE or UI thread. This is the main entry point into creating
726 // the dialog. 729 // the dialog.
727 730
728 // TODO(scottbyer): The signature here will need to change as the 731 // TODO(scottbyer): The signature here will need to change as the
729 // workflow through the printing code changes to allow for dynamically 732 // workflow through the printing code changes to allow for dynamically
730 // changing page setup parameters while the dialog is active. 733 // changing page setup parameters while the dialog is active.
731 void CreatePrintDialogForFile(const FilePath& path_to_file, 734 void CreatePrintDialogForFile(content::BrowserContext* browser_context,
735 gfx::NativeWindow modal_parent,
736 const FilePath& path_to_file,
732 const string16& print_job_title, 737 const string16& print_job_title,
733 const string16& print_ticket, 738 const string16& print_ticket,
734 const std::string& file_type, 739 const std::string& file_type,
735 bool modal,
736 bool delete_on_close) { 740 bool delete_on_close) {
737 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE) || 741 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE) ||
738 BrowserThread::CurrentlyOn(BrowserThread::UI)); 742 BrowserThread::CurrentlyOn(BrowserThread::UI));
739
740 BrowserThread::PostTask( 743 BrowserThread::PostTask(
741 BrowserThread::UI, FROM_HERE, 744 BrowserThread::UI, FROM_HERE,
742 base::Bind(&internal_cloud_print_helpers::CreateDialogFullImpl, 745 base::Bind(&internal_cloud_print_helpers::CreateDialogFullImpl,
743 path_to_file, print_job_title, print_ticket, file_type, modal, 746 browser_context, modal_parent, path_to_file, print_job_title,
744 delete_on_close)); 747 print_ticket, file_type, delete_on_close));
745 } 748 }
746 749
747 void CreateCloudPrintSigninDialog(const base::Closure& callback) { 750 void CreateCloudPrintSigninDialog(content::BrowserContext* browser_context,
751 gfx::NativeWindow modal_parent,
752 const base::Closure& callback) {
748 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 753 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
749 754
750 BrowserThread::PostTask( 755 BrowserThread::PostTask(
751 BrowserThread::UI, FROM_HERE, 756 BrowserThread::UI, FROM_HERE,
752 base::Bind(&internal_cloud_print_helpers::CreateDialogSigninImpl, 757 base::Bind(&internal_cloud_print_helpers::CreateDialogSigninImpl,
758 browser_context,
759 modal_parent,
753 callback)); 760 callback));
754 } 761 }
755 762
756 void CreatePrintDialogForBytes(scoped_refptr<base::RefCountedBytes> data, 763 void CreatePrintDialogForBytes(content::BrowserContext* browser_context,
764 gfx::NativeWindow modal_parent,
765 scoped_refptr<base::RefCountedBytes> data,
757 const string16& print_job_title, 766 const string16& print_job_title,
758 const string16& print_ticket, 767 const string16& print_ticket,
759 const std::string& file_type, 768 const std::string& file_type) {
760 bool modal) {
761 // TODO(abodenha@chromium.org) Avoid cloning the PDF data. Make use of a 769 // TODO(abodenha@chromium.org) Avoid cloning the PDF data. Make use of a
762 // shared memory object instead. 770 // shared memory object instead.
763 // http://code.google.com/p/chromium/issues/detail?id=44093 771 // http://code.google.com/p/chromium/issues/detail?id=44093
764 scoped_refptr<base::RefCountedBytes> cloned_data = 772 scoped_refptr<base::RefCountedBytes> cloned_data =
765 new base::RefCountedBytes(data->data()); 773 new base::RefCountedBytes(data->data());
766 BrowserThread::PostTask( 774 BrowserThread::PostTask(
767 BrowserThread::FILE, FROM_HERE, 775 BrowserThread::FILE, FROM_HERE,
768 base::Bind(&internal_cloud_print_helpers::CreatePrintDialogForBytesImpl, 776 base::Bind(&internal_cloud_print_helpers::CreatePrintDialogForBytesImpl,
769 cloned_data, print_job_title, print_ticket, file_type, modal)); 777 browser_context, modal_parent, cloned_data, print_job_title,
778 print_ticket, file_type));
770 } 779 }
771 780
772 bool CreatePrintDialogFromCommandLine(const CommandLine& command_line) { 781 bool CreatePrintDialogFromCommandLine(const CommandLine& command_line) {
773 DCHECK(command_line.HasSwitch(switches::kCloudPrintFile)); 782 DCHECK(command_line.HasSwitch(switches::kCloudPrintFile));
774 if (!command_line.GetSwitchValuePath(switches::kCloudPrintFile).empty()) { 783 if (!command_line.GetSwitchValuePath(switches::kCloudPrintFile).empty()) {
775 FilePath cloud_print_file; 784 FilePath cloud_print_file;
776 cloud_print_file = 785 cloud_print_file =
777 command_line.GetSwitchValuePath(switches::kCloudPrintFile); 786 command_line.GetSwitchValuePath(switches::kCloudPrintFile);
778 if (!cloud_print_file.empty()) { 787 if (!cloud_print_file.empty()) {
779 string16 print_job_title; 788 string16 print_job_title;
(...skipping 10 matching lines...) Expand all
790 } 799 }
791 std::string file_type = "application/pdf"; 800 std::string file_type = "application/pdf";
792 if (command_line.HasSwitch(switches::kCloudPrintFileType)) { 801 if (command_line.HasSwitch(switches::kCloudPrintFileType)) {
793 file_type = command_line.GetSwitchValueASCII( 802 file_type = command_line.GetSwitchValueASCII(
794 switches::kCloudPrintFileType); 803 switches::kCloudPrintFileType);
795 } 804 }
796 805
797 bool delete_on_close = CommandLine::ForCurrentProcess()->HasSwitch( 806 bool delete_on_close = CommandLine::ForCurrentProcess()->HasSwitch(
798 switches::kCloudPrintDeleteFile); 807 switches::kCloudPrintDeleteFile);
799 808
800 print_dialog_cloud::CreatePrintDialogForFile(cloud_print_file, 809 print_dialog_cloud::CreatePrintDialogForFile(
801 print_job_title, 810 ProfileManager::GetDefaultProfile(),
802 print_job_print_ticket, 811 NULL,
803 file_type, 812 cloud_print_file,
804 false, 813 print_job_title,
805 delete_on_close); 814 print_job_print_ticket,
815 file_type,
816 delete_on_close);
806 return true; 817 return true;
807 } 818 }
808 } 819 }
809 return false; 820 return false;
810 } 821 }
811 822
812 } // end namespace 823 } // end namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698