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 <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 | 189 |
190 ResetPreviewTabOverrideTitle(preview_tab); | 190 ResetPreviewTabOverrideTitle(preview_tab); |
191 RemoveObservers(tab); | 191 RemoveObservers(tab); |
192 } | 192 } |
193 | 193 |
194 void PrintPreviewTabController::OnNavEntryCommitted( | 194 void PrintPreviewTabController::OnNavEntryCommitted( |
195 TabContentsWrapper* tab, content::LoadCommittedDetails* details) { | 195 TabContentsWrapper* tab, content::LoadCommittedDetails* details) { |
196 TabContentsWrapper* preview_tab = GetPrintPreviewForTab(tab); | 196 TabContentsWrapper* preview_tab = GetPrintPreviewForTab(tab); |
197 bool source_tab_is_preview_tab = (tab == preview_tab); | 197 bool source_tab_is_preview_tab = (tab == preview_tab); |
198 if (details) { | 198 if (details) { |
199 PageTransition::Type transition_type = details->entry->transition_type(); | 199 content::PageTransition transition_type = details->entry->transition_type(); |
200 NavigationType::Type nav_type = details->type; | 200 NavigationType::Type nav_type = details->type; |
201 | 201 |
202 // Don't update/erase the map entry if the page has not changed. | 202 // Don't update/erase the map entry if the page has not changed. |
203 if (transition_type == PageTransition::RELOAD || | 203 if (transition_type == content::PAGE_TRANSITION_RELOAD || |
204 nav_type == NavigationType::SAME_PAGE) { | 204 nav_type == NavigationType::SAME_PAGE) { |
205 if (source_tab_is_preview_tab) | 205 if (source_tab_is_preview_tab) |
206 SetInitiatorTabURLAndTitle(preview_tab); | 206 SetInitiatorTabURLAndTitle(preview_tab); |
207 return; | 207 return; |
208 } | 208 } |
209 | 209 |
210 // New |preview_tab| is created. Don't update/erase map entry. | 210 // New |preview_tab| is created. Don't update/erase map entry. |
211 if (waiting_for_new_preview_page_ && | 211 if (waiting_for_new_preview_page_ && |
212 transition_type == PageTransition::LINK && | 212 transition_type == content::PAGE_TRANSITION_LINK && |
213 nav_type == NavigationType::NEW_PAGE && | 213 nav_type == NavigationType::NEW_PAGE && |
214 source_tab_is_preview_tab) { | 214 source_tab_is_preview_tab) { |
215 waiting_for_new_preview_page_ = false; | 215 waiting_for_new_preview_page_ = false; |
216 SetInitiatorTabURLAndTitle(preview_tab); | 216 SetInitiatorTabURLAndTitle(preview_tab); |
217 return; | 217 return; |
218 } | 218 } |
219 | 219 |
220 // User navigated to a preview tab using forward/back button. | 220 // User navigated to a preview tab using forward/back button. |
221 if (source_tab_is_preview_tab && | 221 if (source_tab_is_preview_tab && |
222 transition_type == PageTransition::FORWARD_BACK && | 222 transition_type == content::PAGE_TRANSITION_FORWARD_BACK && |
223 nav_type == NavigationType::EXISTING_PAGE) { | 223 nav_type == NavigationType::EXISTING_PAGE) { |
224 return; | 224 return; |
225 } | 225 } |
226 } | 226 } |
227 | 227 |
228 RemoveObservers(tab); | 228 RemoveObservers(tab); |
229 ResetPreviewTabOverrideTitle(preview_tab); | 229 ResetPreviewTabOverrideTitle(preview_tab); |
230 if (source_tab_is_preview_tab) { | 230 if (source_tab_is_preview_tab) { |
231 // Remove the initiator tab's observers before erasing the mapping. | 231 // Remove the initiator tab's observers before erasing the mapping. |
232 TabContentsWrapper* initiator_tab = GetInitiatorTab(tab); | 232 TabContentsWrapper* initiator_tab = GetInitiatorTab(tab); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 return NULL; | 289 return NULL; |
290 } | 290 } |
291 } else { | 291 } else { |
292 return NULL; | 292 return NULL; |
293 } | 293 } |
294 } | 294 } |
295 | 295 |
296 // Add a new tab next to initiator tab. | 296 // Add a new tab next to initiator tab. |
297 browser::NavigateParams params(current_browser, | 297 browser::NavigateParams params(current_browser, |
298 GURL(chrome::kChromeUIPrintURL), | 298 GURL(chrome::kChromeUIPrintURL), |
299 PageTransition::LINK); | 299 content::PAGE_TRANSITION_LINK); |
300 params.disposition = NEW_FOREGROUND_TAB; | 300 params.disposition = NEW_FOREGROUND_TAB; |
301 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kChromeFrame)) | 301 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kChromeFrame)) |
302 params.disposition = NEW_POPUP; | 302 params.disposition = NEW_POPUP; |
303 | 303 |
304 // For normal tabs, set the position as immediately to the right, | 304 // For normal tabs, set the position as immediately to the right, |
305 // otherwise let the tab strip decide. | 305 // otherwise let the tab strip decide. |
306 if (current_browser->is_type_tabbed()) { | 306 if (current_browser->is_type_tabbed()) { |
307 params.tabstrip_index = current_browser->tabstrip_model()-> | 307 params.tabstrip_index = current_browser->tabstrip_model()-> |
308 GetIndexOfTabContents(initiator_tab) + 1; | 308 GetIndexOfTabContents(initiator_tab) + 1; |
309 } | 309 } |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
365 RenderProcessHost* rph = tab->render_view_host()->process(); | 365 RenderProcessHost* rph = tab->render_view_host()->process(); |
366 if (registrar_.IsRegistered(this, | 366 if (registrar_.IsRegistered(this, |
367 content::NOTIFICATION_RENDERER_PROCESS_CLOSED, | 367 content::NOTIFICATION_RENDERER_PROCESS_CLOSED, |
368 Source<RenderProcessHost>(rph))) { | 368 Source<RenderProcessHost>(rph))) { |
369 registrar_.Remove(this, content::NOTIFICATION_RENDERER_PROCESS_CLOSED, | 369 registrar_.Remove(this, content::NOTIFICATION_RENDERER_PROCESS_CLOSED, |
370 Source<RenderProcessHost>(rph)); | 370 Source<RenderProcessHost>(rph)); |
371 } | 371 } |
372 } | 372 } |
373 | 373 |
374 } // namespace printing | 374 } // namespace printing |
OLD | NEW |