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