| 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 #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/prefs/pref_service.h" | 18 #include "chrome/browser/prefs/pref_service.h" |
| 19 #include "chrome/browser/printing/cloud_print/cloud_print_url.h" | 19 #include "chrome/browser/printing/cloud_print/cloud_print_url.h" |
| 20 #include "chrome/browser/profiles/profile.h" | 20 #include "chrome/browser/profiles/profile.h" |
| 21 #include "chrome/browser/profiles/profile_manager.h" | 21 #include "chrome/browser/profiles/profile_manager.h" |
| 22 #include "chrome/browser/ui/browser_dialogs.h" | 22 #include "chrome/browser/ui/browser_dialogs.h" |
| 23 #include "chrome/browser/ui/browser_list.h" | 23 #include "chrome/browser/ui/browser_list.h" |
| 24 #include "chrome/browser/ui/browser_window.h" |
| 24 #include "chrome/browser/ui/dialog_style.h" | 25 #include "chrome/browser/ui/dialog_style.h" |
| 25 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 26 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 26 #include "chrome/common/chrome_switches.h" | 27 #include "chrome/common/chrome_switches.h" |
| 27 #include "chrome/common/pref_names.h" | 28 #include "chrome/common/pref_names.h" |
| 28 #include "chrome/common/print_messages.h" | 29 #include "chrome/common/print_messages.h" |
| 29 #include "chrome/common/url_constants.h" | 30 #include "chrome/common/url_constants.h" |
| 30 #include "content/public/browser/browser_thread.h" | 31 #include "content/public/browser/browser_thread.h" |
| 31 #include "content/public/browser/navigation_controller.h" | 32 #include "content/public/browser/navigation_controller.h" |
| 32 #include "content/public/browser/navigation_entry.h" | 33 #include "content/public/browser/navigation_entry.h" |
| 33 #include "content/public/browser/notification_registrar.h" | 34 #include "content/public/browser/notification_registrar.h" |
| (...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 681 } | 682 } |
| 682 | 683 |
| 683 int width = pref_service->GetInteger(prefs::kCloudPrintDialogWidth); | 684 int width = pref_service->GetInteger(prefs::kCloudPrintDialogWidth); |
| 684 int height = pref_service->GetInteger(prefs::kCloudPrintDialogHeight); | 685 int height = pref_service->GetInteger(prefs::kCloudPrintDialogHeight); |
| 685 | 686 |
| 686 HtmlDialogUIDelegate* dialog_delegate = | 687 HtmlDialogUIDelegate* dialog_delegate = |
| 687 new internal_cloud_print_helpers::CloudPrintHtmlDialogDelegate( | 688 new internal_cloud_print_helpers::CloudPrintHtmlDialogDelegate( |
| 688 path_to_file, width, height, std::string(), job_title, print_ticket, | 689 path_to_file, width, height, std::string(), job_title, print_ticket, |
| 689 file_type, modal, delete_on_close, close_after_signin, | 690 file_type, modal, delete_on_close, close_after_signin, |
| 690 callback); | 691 callback); |
| 691 if (modal) { | 692 browser::ShowHtmlDialog(modal ? browser->window()->GetNativeHandle() : NULL, |
| 692 DCHECK(browser); | 693 profile, |
| 693 | 694 browser, |
| 694 #if defined(USE_AURA) | 695 dialog_delegate, |
| 695 HtmlDialogView* html_view = | 696 STYLE_GENERIC); |
| 696 new HtmlDialogView(profile, browser, dialog_delegate); | |
| 697 views::Widget::CreateWindowWithParent(html_view, | |
| 698 browser->window()->GetNativeHandle()); | |
| 699 html_view->InitDialog(); | |
| 700 views::Widget* widget = html_view->GetWidget(); | |
| 701 DCHECK(widget); | |
| 702 widget->Show(); | |
| 703 #if defined(OS_WIN) | |
| 704 gfx::NativeWindow window = widget->GetNativeWindow(); | |
| 705 #endif | |
| 706 #else | |
| 707 #if defined(OS_WIN) | |
| 708 gfx::NativeWindow window = | |
| 709 #endif | |
| 710 browser->BrowserShowHtmlDialog(dialog_delegate, NULL, STYLE_GENERIC); | |
| 711 #endif | |
| 712 #if defined(OS_WIN) | |
| 713 HWND dialog_handle; | |
| 714 #if defined(USE_AURA) | |
| 715 dialog_handle = window->GetRootWindow()->GetAcceleratedWidget(); | |
| 716 #else | |
| 717 dialog_handle = window; | |
| 718 #endif | |
| 719 if (::GetForegroundWindow() != dialog_handle) { | |
| 720 ui::ForegroundHelper::SetForeground(dialog_handle); | |
| 721 } | |
| 722 #endif | |
| 723 } else { | |
| 724 browser::ShowHtmlDialog(NULL, | |
| 725 profile, | |
| 726 browser, | |
| 727 dialog_delegate, | |
| 728 STYLE_GENERIC); | |
| 729 } | |
| 730 } | 697 } |
| 731 | 698 |
| 732 void CreateDialogSigninImpl(const base::Closure& callback) { | 699 void CreateDialogSigninImpl(const base::Closure& callback) { |
| 733 CreateDialogImpl(FilePath(), string16(), string16(), std::string(), | 700 CreateDialogImpl(FilePath(), string16(), string16(), std::string(), |
| 734 true, false, true, callback); | 701 true, false, true, callback); |
| 735 } | 702 } |
| 736 | 703 |
| 737 void CreateDialogFullImpl(const FilePath& path_to_file, | 704 void CreateDialogFullImpl(const FilePath& path_to_file, |
| 738 const string16& print_job_title, | 705 const string16& print_job_title, |
| 739 const string16& print_ticket, | 706 const string16& print_ticket, |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 836 file_type, | 803 file_type, |
| 837 false, | 804 false, |
| 838 delete_on_close); | 805 delete_on_close); |
| 839 return true; | 806 return true; |
| 840 } | 807 } |
| 841 } | 808 } |
| 842 return false; | 809 return false; |
| 843 } | 810 } |
| 844 | 811 |
| 845 } // end namespace | 812 } // end namespace |
| OLD | NEW |