OLD | NEW |
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 | 6 |
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" |
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
479 } | 479 } |
480 } | 480 } |
481 | 481 |
482 bool CloudPrintFlowHandler::IsCloudPrintDialogUrl(const GURL& url) { | 482 bool CloudPrintFlowHandler::IsCloudPrintDialogUrl(const GURL& url) { |
483 GURL cloud_print_url = cloud_devices::GetCloudPrintURL(); | 483 GURL cloud_print_url = cloud_devices::GetCloudPrintURL(); |
484 return IsSimilarUrl(url, cloud_print_url); | 484 return IsSimilarUrl(url, cloud_print_url); |
485 } | 485 } |
486 | 486 |
487 CloudPrintWebDialogDelegate::CloudPrintWebDialogDelegate( | 487 CloudPrintWebDialogDelegate::CloudPrintWebDialogDelegate( |
488 content::BrowserContext* browser_context, | 488 content::BrowserContext* browser_context, |
489 gfx::NativeWindow modal_parent, | 489 gfx::NativeView modal_parent, |
490 const base::RefCountedMemory* data, | 490 const base::RefCountedMemory* data, |
491 const std::string& json_arguments, | 491 const std::string& json_arguments, |
492 const base::string16& print_job_title, | 492 const base::string16& print_job_title, |
493 const base::string16& print_ticket, | 493 const base::string16& print_ticket, |
494 const std::string& file_type) | 494 const std::string& file_type) |
495 : flow_handler_( | 495 : flow_handler_( |
496 new CloudPrintFlowHandler(data, print_job_title, print_ticket, | 496 new CloudPrintFlowHandler(data, print_job_title, print_ticket, |
497 file_type)), | 497 file_type)), |
498 modal_parent_(modal_parent), | 498 modal_parent_(modal_parent), |
499 owns_flow_handler_(true), | 499 owns_flow_handler_(true), |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
610 return false; | 610 return false; |
611 } | 611 } |
612 | 612 |
613 bool CloudPrintWebDialogDelegate::HandleContextMenu( | 613 bool CloudPrintWebDialogDelegate::HandleContextMenu( |
614 const content::ContextMenuParams& params) { | 614 const content::ContextMenuParams& params) { |
615 return true; | 615 return true; |
616 } | 616 } |
617 | 617 |
618 // Called from the UI thread, starts up the dialog. | 618 // Called from the UI thread, starts up the dialog. |
619 void CreateDialogImpl(content::BrowserContext* browser_context, | 619 void CreateDialogImpl(content::BrowserContext* browser_context, |
620 gfx::NativeWindow modal_parent, | 620 gfx::NativeView modal_parent, |
621 const base::RefCountedMemory* data, | 621 const base::RefCountedMemory* data, |
622 const base::string16& print_job_title, | 622 const base::string16& print_job_title, |
623 const base::string16& print_ticket, | 623 const base::string16& print_ticket, |
624 const std::string& file_type) { | 624 const std::string& file_type) { |
625 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 625 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
626 WebDialogDelegate* dialog_delegate = | 626 WebDialogDelegate* dialog_delegate = |
627 new internal_cloud_print_helpers::CloudPrintWebDialogDelegate( | 627 new internal_cloud_print_helpers::CloudPrintWebDialogDelegate( |
628 browser_context, modal_parent, data, std::string(), print_job_title, | 628 browser_context, modal_parent, data, std::string(), print_job_title, |
629 print_ticket, file_type); | 629 print_ticket, file_type); |
630 #if defined(OS_WIN) | 630 #if defined(OS_WIN) |
(...skipping 11 matching lines...) Expand all Loading... |
642 dialog_handle = window; | 642 dialog_handle = window; |
643 #endif | 643 #endif |
644 if (::GetForegroundWindow() != dialog_handle) { | 644 if (::GetForegroundWindow() != dialog_handle) { |
645 ui::ForegroundHelper::SetForeground(dialog_handle); | 645 ui::ForegroundHelper::SetForeground(dialog_handle); |
646 } | 646 } |
647 } | 647 } |
648 #endif | 648 #endif |
649 } | 649 } |
650 | 650 |
651 void CreateDialogForFileImpl(content::BrowserContext* browser_context, | 651 void CreateDialogForFileImpl(content::BrowserContext* browser_context, |
652 gfx::NativeWindow modal_parent, | 652 gfx::NativeView modal_parent, |
653 const base::FilePath& path_to_file, | 653 const base::FilePath& path_to_file, |
654 const base::string16& print_job_title, | 654 const base::string16& print_job_title, |
655 const base::string16& print_ticket, | 655 const base::string16& print_ticket, |
656 const std::string& file_type) { | 656 const std::string& file_type) { |
657 DCHECK_CURRENTLY_ON(BrowserThread::FILE); | 657 DCHECK_CURRENTLY_ON(BrowserThread::FILE); |
658 scoped_refptr<base::RefCountedMemory> data; | 658 scoped_refptr<base::RefCountedMemory> data; |
659 int64 file_size = 0; | 659 int64 file_size = 0; |
660 if (base::GetFileSize(path_to_file, &file_size) && file_size != 0) { | 660 if (base::GetFileSize(path_to_file, &file_size) && file_size != 0) { |
661 std::string file_data; | 661 std::string file_data; |
662 if (file_size < kuint32max) { | 662 if (file_size < kuint32max) { |
(...skipping 26 matching lines...) Expand all Loading... |
689 registry->RegisterIntegerPref( | 689 registry->RegisterIntegerPref( |
690 prefs::kCloudPrintDialogHeight, | 690 prefs::kCloudPrintDialogHeight, |
691 kDefaultHeight, | 691 kDefaultHeight, |
692 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | 692 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
693 } | 693 } |
694 | 694 |
695 // Called on the FILE or UI thread. This is the main entry point into creating | 695 // Called on the FILE or UI thread. This is the main entry point into creating |
696 // the dialog. | 696 // the dialog. |
697 | 697 |
698 void CreatePrintDialogForFile(content::BrowserContext* browser_context, | 698 void CreatePrintDialogForFile(content::BrowserContext* browser_context, |
699 gfx::NativeWindow modal_parent, | 699 gfx::NativeView modal_parent, |
700 const base::FilePath& path_to_file, | 700 const base::FilePath& path_to_file, |
701 const base::string16& print_job_title, | 701 const base::string16& print_job_title, |
702 const base::string16& print_ticket, | 702 const base::string16& print_ticket, |
703 const std::string& file_type) { | 703 const std::string& file_type) { |
704 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE) || | 704 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE) || |
705 BrowserThread::CurrentlyOn(BrowserThread::UI)); | 705 BrowserThread::CurrentlyOn(BrowserThread::UI)); |
706 BrowserThread::PostTask( | 706 BrowserThread::PostTask( |
707 BrowserThread::FILE, FROM_HERE, | 707 BrowserThread::FILE, FROM_HERE, |
708 base::Bind(&internal_cloud_print_helpers::CreateDialogForFileImpl, | 708 base::Bind(&internal_cloud_print_helpers::CreateDialogForFileImpl, |
709 browser_context, modal_parent, path_to_file, print_job_title, | 709 browser_context, modal_parent, path_to_file, print_job_title, |
(...skipping 20 matching lines...) Expand all Loading... |
730 content::Referrer(), | 730 content::Referrer(), |
731 NEW_FOREGROUND_TAB, | 731 NEW_FOREGROUND_TAB, |
732 ui::PAGE_TRANSITION_AUTO_BOOKMARK, | 732 ui::PAGE_TRANSITION_AUTO_BOOKMARK, |
733 false)); | 733 false)); |
734 new SignInObserver(web_contents, cloud_devices::GetCloudPrintURL(), | 734 new SignInObserver(web_contents, cloud_devices::GetCloudPrintURL(), |
735 callback); | 735 callback); |
736 } | 736 } |
737 } | 737 } |
738 | 738 |
739 void CreatePrintDialogForBytes(content::BrowserContext* browser_context, | 739 void CreatePrintDialogForBytes(content::BrowserContext* browser_context, |
740 gfx::NativeWindow modal_parent, | 740 gfx::NativeView modal_parent, |
741 const base::RefCountedMemory* data, | 741 const base::RefCountedMemory* data, |
742 const base::string16& print_job_title, | 742 const base::string16& print_job_title, |
743 const base::string16& print_ticket, | 743 const base::string16& print_ticket, |
744 const std::string& file_type) { | 744 const std::string& file_type) { |
745 internal_cloud_print_helpers::CreateDialogImpl(browser_context, modal_parent, | 745 internal_cloud_print_helpers::CreateDialogImpl(browser_context, modal_parent, |
746 data, print_job_title, | 746 data, print_job_title, |
747 print_ticket, file_type); | 747 print_ticket, file_type); |
748 } | 748 } |
749 | 749 |
750 bool CreatePrintDialogFromCommandLine(Profile* profile, | 750 bool CreatePrintDialogFromCommandLine(Profile* profile, |
(...skipping 24 matching lines...) Expand all Loading... |
775 | 775 |
776 print_dialog_cloud::CreatePrintDialogForFile(profile, NULL, | 776 print_dialog_cloud::CreatePrintDialogForFile(profile, NULL, |
777 cloud_print_file, print_job_title, print_job_print_ticket, file_type); | 777 cloud_print_file, print_job_title, print_job_print_ticket, file_type); |
778 return true; | 778 return true; |
779 } | 779 } |
780 } | 780 } |
781 return false; | 781 return false; |
782 } | 782 } |
783 | 783 |
784 } // namespace print_dialog_cloud | 784 } // namespace print_dialog_cloud |
OLD | NEW |