| 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" |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 | 281 |
| 282 CloudPrintFlowHandler::~CloudPrintFlowHandler() { | 282 CloudPrintFlowHandler::~CloudPrintFlowHandler() { |
| 283 // This will also cancel any task in flight. | 283 // This will also cancel any task in flight. |
| 284 CancelAnyRunningTask(); | 284 CancelAnyRunningTask(); |
| 285 } | 285 } |
| 286 | 286 |
| 287 | 287 |
| 288 void CloudPrintFlowHandler::SetDialogDelegate( | 288 void CloudPrintFlowHandler::SetDialogDelegate( |
| 289 CloudPrintHtmlDialogDelegate* delegate) { | 289 CloudPrintHtmlDialogDelegate* delegate) { |
| 290 // Even if setting a new WebUI, it means any previous task needs | 290 // Even if setting a new WebUI, it means any previous task needs |
| 291 // to be cancelled, it's now invalid. | 291 // to be canceled, its now invalid. |
| 292 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 292 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 293 CancelAnyRunningTask(); | 293 CancelAnyRunningTask(); |
| 294 dialog_delegate_ = delegate; | 294 dialog_delegate_ = delegate; |
| 295 } | 295 } |
| 296 | 296 |
| 297 // Cancels any print data sender we have in flight and removes our | 297 // Cancels any print data sender we have in flight and removes our |
| 298 // reference to it, so when the task that is calling it finishes and | 298 // reference to it, so when the task that is calling it finishes and |
| 299 // removes it's reference, it goes away. | 299 // removes its reference, it goes away. |
| 300 void CloudPrintFlowHandler::CancelAnyRunningTask() { | 300 void CloudPrintFlowHandler::CancelAnyRunningTask() { |
| 301 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 301 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 302 if (print_data_sender_.get()) { | 302 if (print_data_sender_.get()) { |
| 303 print_data_sender_->CancelPrintDataFile(); | 303 print_data_sender_->CancelPrintDataFile(); |
| 304 print_data_sender_ = NULL; | 304 print_data_sender_ = NULL; |
| 305 } | 305 } |
| 306 } | 306 } |
| 307 | 307 |
| 308 void CloudPrintFlowHandler::RegisterMessages() { | 308 void CloudPrintFlowHandler::RegisterMessages() { |
| 309 // TODO(scottbyer) - This is where we will register messages for the | 309 // TODO(scottbyer) - This is where we will register messages for the |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 535 | 535 |
| 536 flow_handler_->SetDialogDelegate(this); | 536 flow_handler_->SetDialogDelegate(this); |
| 537 // If we're not modal we can show the dialog with no browser. | 537 // If we're not modal we can show the dialog with no browser. |
| 538 // We need this to keep Chrome alive while our dialog is up. | 538 // We need this to keep Chrome alive while our dialog is up. |
| 539 if (!modal_) | 539 if (!modal_) |
| 540 BrowserList::StartKeepAlive(); | 540 BrowserList::StartKeepAlive(); |
| 541 } | 541 } |
| 542 | 542 |
| 543 CloudPrintHtmlDialogDelegate::~CloudPrintHtmlDialogDelegate() { | 543 CloudPrintHtmlDialogDelegate::~CloudPrintHtmlDialogDelegate() { |
| 544 // If the flow_handler_ is about to outlive us because we don't own | 544 // If the flow_handler_ is about to outlive us because we don't own |
| 545 // it anymore, we need to have it remove it's reference to us. | 545 // it anymore, we need to have it remove its reference to us. |
| 546 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 546 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 547 flow_handler_->SetDialogDelegate(NULL); | 547 flow_handler_->SetDialogDelegate(NULL); |
| 548 if (owns_flow_handler_) { | 548 if (owns_flow_handler_) { |
| 549 delete flow_handler_; | 549 delete flow_handler_; |
| 550 } | 550 } |
| 551 } | 551 } |
| 552 | 552 |
| 553 ui::ModalType CloudPrintHtmlDialogDelegate::GetDialogModalType() const { | 553 ui::ModalType CloudPrintHtmlDialogDelegate::GetDialogModalType() const { |
| 554 return modal_ ? ui::MODAL_TYPE_WINDOW : ui::MODAL_TYPE_NONE; | 554 return modal_ ? ui::MODAL_TYPE_WINDOW : ui::MODAL_TYPE_NONE; |
| 555 } | 555 } |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 835 file_type, | 835 file_type, |
| 836 false, | 836 false, |
| 837 delete_on_close); | 837 delete_on_close); |
| 838 return true; | 838 return true; |
| 839 } | 839 } |
| 840 } | 840 } |
| 841 return false; | 841 return false; |
| 842 } | 842 } |
| 843 | 843 |
| 844 } // end namespace | 844 } // end namespace |
| OLD | NEW |