| 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/test/base/test_tab_strip_model_observer.h" | 5 #include "chrome/test/base/test_tab_strip_model_observer.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "chrome/browser/printing/print_preview_dialog_controller.h" | 9 #include "chrome/browser/printing/print_preview_dialog_controller.h" |
| 10 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 10 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 | 21 |
| 22 TestTabStripModelObserver::~TestTabStripModelObserver() { | 22 TestTabStripModelObserver::~TestTabStripModelObserver() { |
| 23 tab_strip_model_->RemoveObserver(this); | 23 tab_strip_model_->RemoveObserver(this); |
| 24 } | 24 } |
| 25 | 25 |
| 26 void TestTabStripModelObserver::TabBlockedStateChanged( | 26 void TestTabStripModelObserver::TabBlockedStateChanged( |
| 27 content::WebContents* contents, int index) { | 27 content::WebContents* contents, int index) { |
| 28 // Need to do this later - the print preview dialog has not been created yet. | 28 // Need to do this later - the print preview dialog has not been created yet. |
| 29 MessageLoop::current()->PostTask( | 29 MessageLoop::current()->PostTask( |
| 30 FROM_HERE, | 30 FROM_HERE, |
| 31 base::Bind(&TestTabStripModelObserver::ObservePrintPreviewTabContents, | 31 base::Bind(&TestTabStripModelObserver::ObservePrintPreviewDialog, |
| 32 base::Unretained(this), | 32 base::Unretained(this), |
| 33 contents)); | 33 contents)); |
| 34 } | 34 } |
| 35 | 35 |
| 36 void TestTabStripModelObserver::ObservePrintPreviewTabContents( | 36 void TestTabStripModelObserver::ObservePrintPreviewDialog( |
| 37 content::WebContents* contents) { | 37 content::WebContents* contents) { |
| 38 printing::PrintPreviewDialogController* tab_controller = | 38 printing::PrintPreviewDialogController* dialog_controller = |
| 39 printing::PrintPreviewDialogController::GetInstance(); | 39 printing::PrintPreviewDialogController::GetInstance(); |
| 40 if (tab_controller) { | 40 if (!dialog_controller) |
| 41 content::WebContents* preview_tab = | 41 return; |
| 42 tab_controller->GetPrintPreviewForTab(contents); | 42 content::WebContents* preview_dialog = |
| 43 if (preview_tab) { | 43 dialog_controller->GetPrintPreviewForContents(contents); |
| 44 RegisterAsObserver(content::Source<content::NavigationController>( | 44 if (!preview_dialog) |
| 45 &preview_tab->GetController())); | 45 return; |
| 46 } | 46 RegisterAsObserver(content::Source<content::NavigationController>( |
| 47 } | 47 &preview_dialog->GetController())); |
| 48 } | 48 } |
| OLD | NEW |