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/lifetime/application_lifetime.h" |
18 #include "chrome/browser/prefs/pref_service.h" | 19 #include "chrome/browser/prefs/pref_service.h" |
19 #include "chrome/browser/printing/cloud_print/cloud_print_url.h" | 20 #include "chrome/browser/printing/cloud_print/cloud_print_url.h" |
20 #include "chrome/browser/profiles/profile.h" | 21 #include "chrome/browser/profiles/profile.h" |
21 #include "chrome/browser/profiles/profile_manager.h" | 22 #include "chrome/browser/profiles/profile_manager.h" |
22 #include "chrome/browser/ui/browser_dialogs.h" | 23 #include "chrome/browser/ui/browser_dialogs.h" |
23 #include "chrome/browser/ui/browser.h" | 24 #include "chrome/browser/ui/browser.h" |
24 #include "chrome/browser/ui/browser_finder.h" | 25 #include "chrome/browser/ui/browser_finder.h" |
25 #include "chrome/browser/ui/browser_list.h" | 26 #include "chrome/browser/ui/browser_list.h" |
26 #include "chrome/browser/ui/browser_window.h" | 27 #include "chrome/browser/ui/browser_window.h" |
27 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 28 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
(...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
533 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 534 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
534 params_.url = GURL(chrome::kChromeUICloudPrintResourcesURL); | 535 params_.url = GURL(chrome::kChromeUICloudPrintResourcesURL); |
535 params_.height = height; | 536 params_.height = height; |
536 params_.width = width; | 537 params_.width = width; |
537 params_.json_input = json_arguments; | 538 params_.json_input = json_arguments; |
538 | 539 |
539 flow_handler_->SetDialogDelegate(this); | 540 flow_handler_->SetDialogDelegate(this); |
540 // If we're not modal we can show the dialog with no browser. | 541 // If we're not modal we can show the dialog with no browser. |
541 // We need this to keep Chrome alive while our dialog is up. | 542 // We need this to keep Chrome alive while our dialog is up. |
542 if (!modal_) | 543 if (!modal_) |
543 BrowserList::StartKeepAlive(); | 544 browser::StartKeepAlive(); |
544 } | 545 } |
545 | 546 |
546 CloudPrintWebDialogDelegate::~CloudPrintWebDialogDelegate() { | 547 CloudPrintWebDialogDelegate::~CloudPrintWebDialogDelegate() { |
547 // If the flow_handler_ is about to outlive us because we don't own | 548 // If the flow_handler_ is about to outlive us because we don't own |
548 // it anymore, we need to have it remove its reference to us. | 549 // it anymore, we need to have it remove its reference to us. |
549 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 550 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
550 flow_handler_->SetDialogDelegate(NULL); | 551 flow_handler_->SetDialogDelegate(NULL); |
551 if (owns_flow_handler_) { | 552 if (owns_flow_handler_) { |
552 delete flow_handler_; | 553 delete flow_handler_; |
553 } | 554 } |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
590 | 591 |
591 if (delete_on_close_) { | 592 if (delete_on_close_) { |
592 BrowserThread::PostTask( | 593 BrowserThread::PostTask( |
593 BrowserThread::FILE, FROM_HERE, | 594 BrowserThread::FILE, FROM_HERE, |
594 base::Bind(&internal_cloud_print_helpers::Delete, path_to_file_)); | 595 base::Bind(&internal_cloud_print_helpers::Delete, path_to_file_)); |
595 } | 596 } |
596 | 597 |
597 // If we're modal we can show the dialog with no browser. | 598 // If we're modal we can show the dialog with no browser. |
598 // End the keep-alive so that Chrome can exit. | 599 // End the keep-alive so that Chrome can exit. |
599 if (!modal_) | 600 if (!modal_) |
600 BrowserList::EndKeepAlive(); | 601 browser::EndKeepAlive(); |
601 delete this; | 602 delete this; |
602 } | 603 } |
603 | 604 |
604 void CloudPrintWebDialogDelegate::OnCloseContents(WebContents* source, | 605 void CloudPrintWebDialogDelegate::OnCloseContents(WebContents* source, |
605 bool* out_close_dialog) { | 606 bool* out_close_dialog) { |
606 if (out_close_dialog) | 607 if (out_close_dialog) |
607 *out_close_dialog = true; | 608 *out_close_dialog = true; |
608 } | 609 } |
609 | 610 |
610 bool CloudPrintWebDialogDelegate::ShouldShowDialogTitle() const { | 611 bool CloudPrintWebDialogDelegate::ShouldShowDialogTitle() const { |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
802 file_type, | 803 file_type, |
803 false, | 804 false, |
804 delete_on_close); | 805 delete_on_close); |
805 return true; | 806 return true; |
806 } | 807 } |
807 } | 808 } |
808 return false; | 809 return false; |
809 } | 810 } |
810 | 811 |
811 } // end namespace | 812 } // end namespace |
OLD | NEW |