| 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 | 6 |
| 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/files/file_util.h" | 12 #include "base/files/file_util.h" |
| 13 #include "base/json/json_reader.h" | 13 #include "base/json/json_reader.h" |
| 14 #include "base/location.h" |
| 14 #include "base/prefs/pref_service.h" | 15 #include "base/prefs/pref_service.h" |
| 16 #include "base/single_thread_task_runner.h" |
| 15 #include "base/strings/utf_string_conversions.h" | 17 #include "base/strings/utf_string_conversions.h" |
| 18 #include "base/thread_task_runner_handle.h" |
| 16 #include "base/values.h" | 19 #include "base/values.h" |
| 17 #include "chrome/browser/browser_process.h" | 20 #include "chrome/browser/browser_process.h" |
| 18 #include "chrome/browser/devtools/devtools_window.h" | 21 #include "chrome/browser/devtools/devtools_window.h" |
| 19 #include "chrome/browser/lifetime/application_lifetime.h" | 22 #include "chrome/browser/lifetime/application_lifetime.h" |
| 20 #include "chrome/browser/printing/print_dialog_cloud_internal.h" | 23 #include "chrome/browser/printing/print_dialog_cloud_internal.h" |
| 21 #include "chrome/browser/profiles/profile.h" | 24 #include "chrome/browser/profiles/profile.h" |
| 22 #include "chrome/browser/ui/browser.h" | 25 #include "chrome/browser/ui/browser.h" |
| 23 #include "chrome/browser/ui/browser_dialogs.h" | 26 #include "chrome/browser/ui/browser_dialogs.h" |
| 24 #include "chrome/browser/ui/browser_window.h" | 27 #include "chrome/browser/ui/browser_window.h" |
| 25 #include "chrome/common/chrome_switches.h" | 28 #include "chrome/common/chrome_switches.h" |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 callback_(callback), | 143 callback_(callback), |
| 141 weak_ptr_factory_(this) { | 144 weak_ptr_factory_(this) { |
| 142 } | 145 } |
| 143 | 146 |
| 144 private: | 147 private: |
| 145 // Overridden from content::WebContentsObserver: | 148 // Overridden from content::WebContentsObserver: |
| 146 void DidNavigateMainFrame( | 149 void DidNavigateMainFrame( |
| 147 const content::LoadCommittedDetails& details, | 150 const content::LoadCommittedDetails& details, |
| 148 const content::FrameNavigateParams& params) override { | 151 const content::FrameNavigateParams& params) override { |
| 149 if (IsSimilarUrl(params.url, cloud_print_url_)) { | 152 if (IsSimilarUrl(params.url, cloud_print_url_)) { |
| 150 base::MessageLoop::current()->PostTask( | 153 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 151 FROM_HERE, | 154 FROM_HERE, base::Bind(&SignInObserver::OnSignIn, |
| 152 base::Bind(&SignInObserver::OnSignIn, | 155 weak_ptr_factory_.GetWeakPtr())); |
| 153 weak_ptr_factory_.GetWeakPtr())); | |
| 154 } | 156 } |
| 155 } | 157 } |
| 156 | 158 |
| 157 void WebContentsDestroyed() override { delete this; } | 159 void WebContentsDestroyed() override { delete this; } |
| 158 | 160 |
| 159 void OnSignIn() { | 161 void OnSignIn() { |
| 160 callback_.Run(); | 162 callback_.Run(); |
| 161 if (web_contents()) | 163 if (web_contents()) |
| 162 web_contents()->Close(); | 164 web_contents()->Close(); |
| 163 } | 165 } |
| (...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 587 | 589 |
| 588 void CloudPrintWebDialogDelegate::OnDialogClosed( | 590 void CloudPrintWebDialogDelegate::OnDialogClosed( |
| 589 const std::string& json_retval) { | 591 const std::string& json_retval) { |
| 590 // Get the final dialog size and store it. | 592 // Get the final dialog size and store it. |
| 591 flow_handler_->StoreDialogClientSize(); | 593 flow_handler_->StoreDialogClientSize(); |
| 592 | 594 |
| 593 // If we're modal we can show the dialog with no browser. | 595 // If we're modal we can show the dialog with no browser. |
| 594 // End the keep-alive so that Chrome can exit. | 596 // End the keep-alive so that Chrome can exit. |
| 595 if (!modal_parent_ && keep_alive_when_non_modal_) { | 597 if (!modal_parent_ && keep_alive_when_non_modal_) { |
| 596 // Post to prevent recursive call tho this function. | 598 // Post to prevent recursive call tho this function. |
| 597 base::MessageLoop::current()->PostTask( | 599 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 598 FROM_HERE, base::Bind(&chrome::DecrementKeepAliveCount)); | 600 FROM_HERE, base::Bind(&chrome::DecrementKeepAliveCount)); |
| 599 } | 601 } |
| 600 delete this; | 602 delete this; |
| 601 } | 603 } |
| 602 | 604 |
| 603 void CloudPrintWebDialogDelegate::OnCloseContents(WebContents* source, | 605 void CloudPrintWebDialogDelegate::OnCloseContents(WebContents* source, |
| 604 bool* out_close_dialog) { | 606 bool* out_close_dialog) { |
| 605 *out_close_dialog = true; | 607 *out_close_dialog = true; |
| 606 } | 608 } |
| 607 | 609 |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 768 | 770 |
| 769 print_dialog_cloud::CreatePrintDialogForFile(profile, NULL, | 771 print_dialog_cloud::CreatePrintDialogForFile(profile, NULL, |
| 770 cloud_print_file, print_job_title, print_job_print_ticket, file_type); | 772 cloud_print_file, print_job_title, print_job_print_ticket, file_type); |
| 771 return true; | 773 return true; |
| 772 } | 774 } |
| 773 } | 775 } |
| 774 return false; | 776 return false; |
| 775 } | 777 } |
| 776 | 778 |
| 777 } // namespace print_dialog_cloud | 779 } // namespace print_dialog_cloud |
| OLD | NEW |