| 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_tab_controller.h" | 9 #include "chrome/browser/printing/print_preview_tab_controller.h" |
| 10 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 10 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
| 11 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 11 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 12 #include "content/public/browser/notification_source.h" | 12 #include "content/public/browser/notification_source.h" |
| 13 #include "content/public/browser/web_contents.h" | 13 #include "content/public/browser/web_contents.h" |
| 14 | 14 |
| 15 using content::NavigationController; | 15 using content::NavigationController; |
| 16 | 16 |
| 17 TestTabStripModelObserver::TestTabStripModelObserver( | 17 TestTabStripModelObserver::TestTabStripModelObserver( |
| 18 TabStripModel* tab_strip_model, | 18 TabStripModel* tab_strip_model, |
| 19 content::JsInjectionReadyObserver* js_injection_ready_observer) | 19 content::JsInjectionReadyObserver* js_injection_ready_observer) |
| 20 : TestNavigationObserver(js_injection_ready_observer, 1), | 20 : TestNavigationObserver(js_injection_ready_observer, 1), |
| 21 tab_strip_model_(tab_strip_model) { | 21 tab_strip_model_(tab_strip_model) { |
| 22 tab_strip_model_->AddObserver(this); | 22 tab_strip_model_->AddObserver(this); |
| 23 } | 23 } |
| 24 | 24 |
| 25 TestTabStripModelObserver::~TestTabStripModelObserver() { | 25 TestTabStripModelObserver::~TestTabStripModelObserver() { |
| 26 tab_strip_model_->RemoveObserver(this); | 26 tab_strip_model_->RemoveObserver(this); |
| 27 } | 27 } |
| 28 | 28 |
| 29 void TestTabStripModelObserver::TabBlockedStateChanged( | 29 void TestTabStripModelObserver::TabBlockedStateChanged( |
| 30 TabContentsWrapper* contents, int index) { | 30 TabContents* contents, int index) { |
| 31 // Need to do this later - the print preview tab has not been created yet. | 31 // Need to do this later - the print preview tab has not been created yet. |
| 32 MessageLoop::current()->PostTask( | 32 MessageLoop::current()->PostTask( |
| 33 FROM_HERE, | 33 FROM_HERE, |
| 34 base::Bind(&TestTabStripModelObserver::ObservePrintPreviewTabContents, | 34 base::Bind(&TestTabStripModelObserver::ObservePrintPreviewTabContents, |
| 35 base::Unretained(this), | 35 base::Unretained(this), |
| 36 contents)); | 36 contents)); |
| 37 } | 37 } |
| 38 | 38 |
| 39 void TestTabStripModelObserver::ObservePrintPreviewTabContents( | 39 void TestTabStripModelObserver::ObservePrintPreviewTabContents( |
| 40 TabContentsWrapper* contents) { | 40 TabContents* contents) { |
| 41 printing::PrintPreviewTabController* tab_controller = | 41 printing::PrintPreviewTabController* tab_controller = |
| 42 printing::PrintPreviewTabController::GetInstance(); | 42 printing::PrintPreviewTabController::GetInstance(); |
| 43 if (tab_controller) { | 43 if (tab_controller) { |
| 44 TabContentsWrapper* preview_tab = | 44 TabContents* preview_tab = |
| 45 tab_controller->GetPrintPreviewForTab(contents); | 45 tab_controller->GetPrintPreviewForTab(contents); |
| 46 if (preview_tab) { | 46 if (preview_tab) { |
| 47 RegisterAsObserver(content::Source<NavigationController>( | 47 RegisterAsObserver(content::Source<NavigationController>( |
| 48 &preview_tab->web_contents()->GetController())); | 48 &preview_tab->web_contents()->GetController())); |
| 49 } | 49 } |
| 50 } | 50 } |
| 51 } | 51 } |
| OLD | NEW |