Chromium Code Reviews| 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 DCHECK(browser); | |
| 693 | 692 |
| 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(); | |
| 703 #if defined(OS_WIN) | 693 #if defined(OS_WIN) |
|
sky
2012/04/20 22:59:37
Oy, what an ifdef soup.
Albert Bodenhamer
2012/04/21 00:19:48
Yep. The joys of needing to hack window focus on
| |
| 704 gfx::NativeWindow window = widget->GetNativeWindow(); | 694 gfx::NativeWindow window = |
| 705 #endif | 695 #endif |
| 706 #else | 696 browser::ShowHtmlDialog( |
| 707 #if defined(OS_WIN) | 697 modal ? browser->window()->GetNativeHandle() : NULL, |
| 708 gfx::NativeWindow window = | 698 profile, |
| 709 #endif | 699 browser, |
| 710 browser->BrowserShowHtmlDialog(dialog_delegate, NULL, STYLE_GENERIC); | 700 dialog_delegate, |
| 711 #endif | 701 STYLE_GENERIC); |
| 702 | |
| 712 #if defined(OS_WIN) | 703 #if defined(OS_WIN) |
| 713 HWND dialog_handle; | 704 HWND dialog_handle; |
| 714 #if defined(USE_AURA) | 705 #if defined(USE_AURA) |
| 715 dialog_handle = window->GetRootWindow()->GetAcceleratedWidget(); | 706 dialog_handle = window->GetRootWindow()->GetAcceleratedWidget(); |
| 716 #else | 707 #else |
| 717 dialog_handle = window; | 708 dialog_handle = window; |
| 718 #endif | 709 #endif |
| 719 if (::GetForegroundWindow() != dialog_handle) { | 710 if (::GetForegroundWindow() != dialog_handle) |
| 720 ui::ForegroundHelper::SetForeground(dialog_handle); | 711 ui::ForegroundHelper::SetForeground(dialog_handle); |
| 721 } | |
| 722 #endif | 712 #endif |
| 723 } else { | |
| 724 browser::ShowHtmlDialog(NULL, | |
| 725 profile, | |
| 726 browser, | |
| 727 dialog_delegate, | |
| 728 STYLE_GENERIC); | |
| 729 } | |
| 730 } | 713 } |
| 731 | 714 |
| 732 void CreateDialogSigninImpl(const base::Closure& callback) { | 715 void CreateDialogSigninImpl(const base::Closure& callback) { |
| 733 CreateDialogImpl(FilePath(), string16(), string16(), std::string(), | 716 CreateDialogImpl(FilePath(), string16(), string16(), std::string(), |
| 734 true, false, true, callback); | 717 true, false, true, callback); |
| 735 } | 718 } |
| 736 | 719 |
| 737 void CreateDialogFullImpl(const FilePath& path_to_file, | 720 void CreateDialogFullImpl(const FilePath& path_to_file, |
| 738 const string16& print_job_title, | 721 const string16& print_job_title, |
| 739 const string16& print_ticket, | 722 const string16& print_ticket, |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 836 file_type, | 819 file_type, |
| 837 false, | 820 false, |
| 838 delete_on_close); | 821 delete_on_close); |
| 839 return true; | 822 return true; |
| 840 } | 823 } |
| 841 } | 824 } |
| 842 return false; | 825 return false; |
| 843 } | 826 } |
| 844 | 827 |
| 845 } // end namespace | 828 } // end namespace |
| OLD | NEW |