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 #if defined(USE_AURA) | |
|
James Hawkins
2012/01/11 17:25:54
OS-specific includes go after the cross-platform i
Albert Bodenhamer
2012/01/11 18:11:44
Done.
| |
| 25 #include "chrome/browser/ui/browser_window.h" | |
| 26 #endif | |
| 24 #include "chrome/browser/ui/dialog_style.h" | 27 #include "chrome/browser/ui/dialog_style.h" |
| 25 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 28 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 29 #if defined(USE_AURA) | |
| 30 #include "chrome/browser/ui/views/html_dialog_view.h" | |
| 31 #endif | |
| 26 #include "chrome/common/chrome_switches.h" | 32 #include "chrome/common/chrome_switches.h" |
| 27 #include "chrome/common/pref_names.h" | 33 #include "chrome/common/pref_names.h" |
| 28 #include "chrome/common/print_messages.h" | 34 #include "chrome/common/print_messages.h" |
| 29 #include "chrome/common/url_constants.h" | 35 #include "chrome/common/url_constants.h" |
| 30 #include "content/browser/renderer_host/render_view_host.h" | 36 #include "content/browser/renderer_host/render_view_host.h" |
| 31 #include "content/browser/tab_contents/tab_contents_view.h" | 37 #include "content/browser/tab_contents/tab_contents_view.h" |
| 32 #include "content/browser/webui/web_ui.h" | 38 #include "content/browser/webui/web_ui.h" |
| 33 #include "content/public/browser/browser_thread.h" | 39 #include "content/public/browser/browser_thread.h" |
| 34 #include "content/public/browser/navigation_controller.h" | 40 #include "content/public/browser/navigation_controller.h" |
| 35 #include "content/public/browser/navigation_entry.h" | 41 #include "content/public/browser/navigation_entry.h" |
| 36 #include "content/public/browser/notification_registrar.h" | 42 #include "content/public/browser/notification_registrar.h" |
| 37 #include "content/public/browser/notification_source.h" | 43 #include "content/public/browser/notification_source.h" |
| 38 #include "content/public/browser/notification_types.h" | 44 #include "content/public/browser/notification_types.h" |
| 39 #include "content/public/browser/web_contents.h" | 45 #include "content/public/browser/web_contents.h" |
| 40 #include "ui/base/l10n/l10n_util.h" | 46 #include "ui/base/l10n/l10n_util.h" |
| 47 #if defined(USE_AURA) | |
| 48 #include "ui/views/widget/widget.h" | |
| 49 #endif | |
| 41 #include "webkit/glue/webpreferences.h" | 50 #include "webkit/glue/webpreferences.h" |
| 42 | 51 |
| 43 #include "grit/generated_resources.h" | 52 #include "grit/generated_resources.h" |
| 44 | 53 |
| 45 // This module implements the UI support in Chrome for cloud printing. | 54 // This module implements the UI support in Chrome for cloud printing. |
| 46 // This means hosting a dialog containing HTML/JavaScript and using | 55 // This means hosting a dialog containing HTML/JavaScript and using |
| 47 // the published cloud print user interface integration APIs to get | 56 // the published cloud print user interface integration APIs to get |
| 48 // page setup settings from the dialog contents and provide the | 57 // page setup settings from the dialog contents and provide the |
| 49 // generated print data to the dialog contents for uploading to the | 58 // generated print data to the dialog contents for uploading to the |
| 50 // cloud print service. | 59 // cloud print service. |
| (...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 593 // Called from the UI thread, starts up the dialog. | 602 // Called from the UI thread, starts up the dialog. |
| 594 void CreateDialogImpl(const FilePath& path_to_file, | 603 void CreateDialogImpl(const FilePath& path_to_file, |
| 595 const string16& print_job_title, | 604 const string16& print_job_title, |
| 596 const string16& print_ticket, | 605 const string16& print_ticket, |
| 597 const std::string& file_type, | 606 const std::string& file_type, |
| 598 bool modal, | 607 bool modal, |
| 599 bool delete_on_close) { | 608 bool delete_on_close) { |
| 600 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 609 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 601 Browser* browser = BrowserList::GetLastActive(); | 610 Browser* browser = BrowserList::GetLastActive(); |
| 602 | 611 |
| 603 const int kDefaultWidth = 497; | 612 const int kDefaultWidth = 912; |
|
James Hawkins
2012/01/11 17:25:54
What is this change about?
Albert Bodenhamer
2012/01/11 18:11:44
The sign-in dialog has gotten much larger since th
| |
| 604 const int kDefaultHeight = 332; | 613 const int kDefaultHeight = 633; |
| 605 string16 job_title = print_job_title; | 614 string16 job_title = print_job_title; |
| 606 Profile* profile = NULL; | 615 Profile* profile = NULL; |
| 607 if (modal) { | 616 if (modal) { |
| 608 if (job_title.empty()) { | 617 if (job_title.empty()) { |
| 609 WebContents* web_contents = browser->GetSelectedWebContents(); | 618 WebContents* web_contents = browser->GetSelectedWebContents(); |
| 610 if (web_contents) | 619 if (web_contents) |
| 611 job_title = web_contents->GetTitle(); | 620 job_title = web_contents->GetTitle(); |
| 612 } | 621 } |
| 613 profile = browser->GetProfile(); | 622 profile = browser->GetProfile(); |
| 614 } else { | 623 } else { |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 633 | 642 |
| 634 int width = pref_service->GetInteger(prefs::kCloudPrintDialogWidth); | 643 int width = pref_service->GetInteger(prefs::kCloudPrintDialogWidth); |
| 635 int height = pref_service->GetInteger(prefs::kCloudPrintDialogHeight); | 644 int height = pref_service->GetInteger(prefs::kCloudPrintDialogHeight); |
| 636 | 645 |
| 637 HtmlDialogUIDelegate* dialog_delegate = | 646 HtmlDialogUIDelegate* dialog_delegate = |
| 638 new internal_cloud_print_helpers::CloudPrintHtmlDialogDelegate( | 647 new internal_cloud_print_helpers::CloudPrintHtmlDialogDelegate( |
| 639 path_to_file, width, height, std::string(), job_title, print_ticket, | 648 path_to_file, width, height, std::string(), job_title, print_ticket, |
| 640 file_type, modal, delete_on_close); | 649 file_type, modal, delete_on_close); |
| 641 if (modal) { | 650 if (modal) { |
| 642 DCHECK(browser); | 651 DCHECK(browser); |
| 652 #if defined(USE_AURA) | |
| 653 HtmlDialogView* html_view = | |
| 654 new HtmlDialogView(profile, dialog_delegate); | |
| 655 views::Widget::CreateWindowWithParent(html_view, | |
| 656 browser->window()->GetNativeHandle()); | |
| 657 html_view->InitDialog(); | |
| 658 html_view->GetWidget()->Show(); | |
| 659 #else | |
| 643 browser->BrowserShowHtmlDialog(dialog_delegate, NULL, STYLE_GENERIC); | 660 browser->BrowserShowHtmlDialog(dialog_delegate, NULL, STYLE_GENERIC); |
| 661 #endif | |
| 644 } else { | 662 } else { |
| 645 browser::ShowHtmlDialog(NULL, profile, dialog_delegate, STYLE_GENERIC); | 663 browser::ShowHtmlDialog(NULL, profile, dialog_delegate, STYLE_GENERIC); |
| 646 } | 664 } |
| 647 } | 665 } |
| 648 | 666 |
| 649 // Provides a runnable function to delete a file. | 667 // Provides a runnable function to delete a file. |
| 650 void Delete(const FilePath& file_path) { | 668 void Delete(const FilePath& file_path) { |
| 651 file_util::Delete(file_path, false); | 669 file_util::Delete(file_path, false); |
| 652 } | 670 } |
| 653 | 671 |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 726 file_type, | 744 file_type, |
| 727 false, | 745 false, |
| 728 delete_on_close); | 746 delete_on_close); |
| 729 return true; | 747 return true; |
| 730 } | 748 } |
| 731 } | 749 } |
| 732 return false; | 750 return false; |
| 733 } | 751 } |
| 734 | 752 |
| 735 } // end namespace | 753 } // end namespace |
| OLD | NEW |