| 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 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 PrintPreviewTabMap::iterator it = preview_tab_map_.find(preview_tab); | 163 PrintPreviewTabMap::iterator it = preview_tab_map_.find(preview_tab); |
| 164 if (it != preview_tab_map_.end()) | 164 if (it != preview_tab_map_.end()) |
| 165 return preview_tab_map_[preview_tab]; | 165 return preview_tab_map_[preview_tab]; |
| 166 return NULL; | 166 return NULL; |
| 167 } | 167 } |
| 168 | 168 |
| 169 TabContents* PrintPreviewTabController::CreatePrintPreviewTab( | 169 TabContents* PrintPreviewTabController::CreatePrintPreviewTab( |
| 170 TabContents* initiator_tab) { | 170 TabContents* initiator_tab) { |
| 171 Browser* current_browser = BrowserList::FindBrowserWithID( | 171 Browser* current_browser = BrowserList::FindBrowserWithID( |
| 172 initiator_tab->controller().window_id().id()); | 172 initiator_tab->controller().window_id().id()); |
| 173 if (!current_browser) | 173 if (!current_browser) { |
| 174 return NULL; | 174 if (initiator_tab->delegate()->IsExternalTabContainer()) { |
| 175 current_browser = Browser::CreateForType(Browser::TYPE_POPUP, |
| 176 initiator_tab->profile()); |
| 177 if (!current_browser) { |
| 178 NOTREACHED() << "Failed to create popup browser window"; |
| 179 return NULL; |
| 180 } |
| 181 } else { |
| 182 return NULL; |
| 183 } |
| 184 } |
| 175 | 185 |
| 176 // Add a new tab next to initiator tab. | 186 // Add a new tab next to initiator tab. |
| 177 browser::NavigateParams params(current_browser, | 187 browser::NavigateParams params(current_browser, |
| 178 GURL(chrome::kChromeUIPrintURL), | 188 GURL(chrome::kChromeUIPrintURL), |
| 179 PageTransition::LINK); | 189 PageTransition::LINK); |
| 180 params.disposition = NEW_FOREGROUND_TAB; | 190 params.disposition = NEW_FOREGROUND_TAB; |
| 191 if (initiator_tab->delegate()->IsExternalTabContainer()) |
| 192 params.disposition = NEW_POPUP; |
| 181 params.tabstrip_index = current_browser->tabstrip_model()-> | 193 params.tabstrip_index = current_browser->tabstrip_model()-> |
| 182 GetWrapperIndex(initiator_tab) + 1; | 194 GetWrapperIndex(initiator_tab) + 1; |
| 183 browser::Navigate(¶ms); | 195 browser::Navigate(¶ms); |
| 184 TabContentsWrapper* preview_tab = params.target_contents; | 196 TabContentsWrapper* preview_tab = params.target_contents; |
| 185 preview_tab->tab_contents()->Activate(); | 197 preview_tab->tab_contents()->Activate(); |
| 186 | 198 |
| 187 // Add an entry to the map. | 199 // Add an entry to the map. |
| 188 preview_tab_map_[preview_tab->tab_contents()] = initiator_tab; | 200 preview_tab_map_[preview_tab->tab_contents()] = initiator_tab; |
| 189 waiting_for_new_preview_page_ = true; | 201 waiting_for_new_preview_page_ = true; |
| 190 | 202 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 202 } | 214 } |
| 203 | 215 |
| 204 void PrintPreviewTabController::RemoveObservers(TabContents* tab) { | 216 void PrintPreviewTabController::RemoveObservers(TabContents* tab) { |
| 205 registrar_.Remove(this, NotificationType::TAB_CONTENTS_DESTROYED, | 217 registrar_.Remove(this, NotificationType::TAB_CONTENTS_DESTROYED, |
| 206 Source<TabContents>(tab)); | 218 Source<TabContents>(tab)); |
| 207 registrar_.Remove(this, NotificationType::NAV_ENTRY_COMMITTED, | 219 registrar_.Remove(this, NotificationType::NAV_ENTRY_COMMITTED, |
| 208 Source<NavigationController>(&tab->controller())); | 220 Source<NavigationController>(&tab->controller())); |
| 209 } | 221 } |
| 210 | 222 |
| 211 } // namespace printing | 223 } // namespace printing |
| OLD | NEW |