| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_preview_tab_controller.h" | 5 #include "chrome/browser/printing/print_preview_tab_controller.h" |
| 6 | 6 |
| 7 #include "chrome/browser/browser_process.h" | 7 #include "chrome/browser/browser_process.h" |
| 8 #include "chrome/browser/tabs/tab_strip_model.h" | 8 #include "chrome/browser/tabs/tab_strip_model.h" |
| 9 #include "chrome/browser/ui/browser.h" | 9 #include "chrome/browser/ui/browser.h" |
| 10 #include "chrome/browser/ui/browser_list.h" | 10 #include "chrome/browser/ui/browser_list.h" |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 RemoveObservers(source_tab); | 151 RemoveObservers(source_tab); |
| 152 } | 152 } |
| 153 | 153 |
| 154 // static | 154 // static |
| 155 bool PrintPreviewTabController::IsPrintPreviewTab(TabContents* tab) { | 155 bool PrintPreviewTabController::IsPrintPreviewTab(TabContents* tab) { |
| 156 const GURL& url = tab->GetURL(); | 156 const GURL& url = tab->GetURL(); |
| 157 return (url.SchemeIs(chrome::kChromeUIScheme) && | 157 return (url.SchemeIs(chrome::kChromeUIScheme) && |
| 158 url.host() == chrome::kChromeUIPrintHost); | 158 url.host() == chrome::kChromeUIPrintHost); |
| 159 } | 159 } |
| 160 | 160 |
| 161 void PrintPreviewTabController::EraseInitiatorTabInfo( |
| 162 TabContents* preview_tab) { |
| 163 PrintPreviewTabMap::iterator it = preview_tab_map_.find(preview_tab); |
| 164 if (it == preview_tab_map_.end()) |
| 165 return; |
| 166 |
| 167 RemoveObservers(it->second); |
| 168 preview_tab_map_[preview_tab] = NULL; |
| 169 } |
| 170 |
| 161 TabContents* PrintPreviewTabController::GetInitiatorTab( | 171 TabContents* PrintPreviewTabController::GetInitiatorTab( |
| 162 TabContents* preview_tab) { | 172 TabContents* preview_tab) { |
| 163 PrintPreviewTabMap::iterator it = preview_tab_map_.find(preview_tab); | 173 PrintPreviewTabMap::iterator it = preview_tab_map_.find(preview_tab); |
| 164 if (it != preview_tab_map_.end()) | 174 if (it != preview_tab_map_.end()) |
| 165 return preview_tab_map_[preview_tab]; | 175 return preview_tab_map_[preview_tab]; |
| 166 return NULL; | 176 return NULL; |
| 167 } | 177 } |
| 168 | 178 |
| 169 TabContents* PrintPreviewTabController::CreatePrintPreviewTab( | 179 TabContents* PrintPreviewTabController::CreatePrintPreviewTab( |
| 170 TabContents* initiator_tab) { | 180 TabContents* initiator_tab) { |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 } | 224 } |
| 215 | 225 |
| 216 void PrintPreviewTabController::RemoveObservers(TabContents* tab) { | 226 void PrintPreviewTabController::RemoveObservers(TabContents* tab) { |
| 217 registrar_.Remove(this, NotificationType::TAB_CONTENTS_DESTROYED, | 227 registrar_.Remove(this, NotificationType::TAB_CONTENTS_DESTROYED, |
| 218 Source<TabContents>(tab)); | 228 Source<TabContents>(tab)); |
| 219 registrar_.Remove(this, NotificationType::NAV_ENTRY_COMMITTED, | 229 registrar_.Remove(this, NotificationType::NAV_ENTRY_COMMITTED, |
| 220 Source<NavigationController>(&tab->controller())); | 230 Source<NavigationController>(&tab->controller())); |
| 221 } | 231 } |
| 222 | 232 |
| 223 } // namespace printing | 233 } // namespace printing |
| OLD | NEW |