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/browser/printing/print_preview_dialog_controller.h" | 5 #include "chrome/browser/printing/print_preview_dialog_controller.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <string> | 10 #include <string> |
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
344 return; | 344 return; |
345 } | 345 } |
346 } | 346 } |
347 NOTREACHED(); | 347 NOTREACHED(); |
348 return; | 348 return; |
349 } | 349 } |
350 if (details) { | 350 if (details) { |
351 ui::PageTransition type = details->entry->GetTransitionType(); | 351 ui::PageTransition type = details->entry->GetTransitionType(); |
352 content::NavigationType nav_type = details->type; | 352 content::NavigationType nav_type = details->type; |
353 if (nav_type == content::NAVIGATION_TYPE_EXISTING_PAGE && | 353 if (nav_type == content::NAVIGATION_TYPE_EXISTING_PAGE && |
354 (ui::PageTransitionCoreTypeIs(type, ui::PAGE_TRANSITION_TYPED) || | 354 (ui::PageTransitionTypeIncludingQualifiersIs( |
355 ui::PageTransitionCoreTypeIs(type, ui::PAGE_TRANSITION_LINK))) | 355 type, |
| 356 ui::PageTransitionFromInt(ui::PAGE_TRANSITION_TYPED | |
| 357 ui::PAGE_TRANSITION_FROM_ADDRESS_BAR)) || |
| 358 ui::PageTransitionTypeIncludingQualifiersIs(type, |
| 359 ui::PAGE_TRANSITION_LINK))) |
356 return; | 360 return; |
357 } | 361 } |
358 | 362 |
359 RemoveInitiator(contents); | 363 RemoveInitiator(contents); |
360 } | 364 } |
361 | 365 |
362 WebContents* PrintPreviewDialogController::CreatePrintPreviewDialog( | 366 WebContents* PrintPreviewDialogController::CreatePrintPreviewDialog( |
363 WebContents* initiator) { | 367 WebContents* initiator) { |
364 base::AutoReset<bool> auto_reset(&is_creating_print_preview_dialog_, true); | 368 base::AutoReset<bool> auto_reset(&is_creating_print_preview_dialog_, true); |
365 | 369 |
(...skipping 17 matching lines...) Expand all Loading... |
383 | 387 |
384 // Add an entry to the map. | 388 // Add an entry to the map. |
385 preview_dialog_map_[preview_dialog] = initiator; | 389 preview_dialog_map_[preview_dialog] = initiator; |
386 waiting_for_new_preview_page_ = true; | 390 waiting_for_new_preview_page_ = true; |
387 | 391 |
388 // Make the print preview WebContents show up in the task manager. | 392 // Make the print preview WebContents show up in the task manager. |
389 task_manager::WebContentsTags::CreateForPrintingContents(preview_dialog); | 393 task_manager::WebContentsTags::CreateForPrintingContents(preview_dialog); |
390 | 394 |
391 AddObservers(initiator); | 395 AddObservers(initiator); |
392 AddObservers(preview_dialog); | 396 AddObservers(preview_dialog); |
393 | |
394 return preview_dialog; | 397 return preview_dialog; |
395 } | 398 } |
396 | 399 |
397 void PrintPreviewDialogController::SaveInitiatorTitle( | 400 void PrintPreviewDialogController::SaveInitiatorTitle( |
398 WebContents* preview_dialog) { | 401 WebContents* preview_dialog) { |
399 WebContents* initiator = GetInitiator(preview_dialog); | 402 WebContents* initiator = GetInitiator(preview_dialog); |
400 if (initiator && preview_dialog->GetWebUI()) { | 403 if (initiator && preview_dialog->GetWebUI()) { |
401 PrintPreviewUI* print_preview_ui = static_cast<PrintPreviewUI*>( | 404 PrintPreviewUI* print_preview_ui = static_cast<PrintPreviewUI*>( |
402 preview_dialog->GetWebUI()->GetController()); | 405 preview_dialog->GetWebUI()->GetController()); |
403 print_preview_ui->SetInitiatorTitle( | 406 print_preview_ui->SetInitiatorTitle( |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
441 | 444 |
442 void PrintPreviewDialogController::RemoveInitiator( | 445 void PrintPreviewDialogController::RemoveInitiator( |
443 WebContents* initiator) { | 446 WebContents* initiator) { |
444 WebContents* preview_dialog = GetPrintPreviewForContents(initiator); | 447 WebContents* preview_dialog = GetPrintPreviewForContents(initiator); |
445 DCHECK(preview_dialog); | 448 DCHECK(preview_dialog); |
446 // Update the map entry first, so when the print preview dialog gets destroyed | 449 // Update the map entry first, so when the print preview dialog gets destroyed |
447 // and reaches RemovePreviewDialog(), it does not attempt to also remove the | 450 // and reaches RemovePreviewDialog(), it does not attempt to also remove the |
448 // initiator's observers. | 451 // initiator's observers. |
449 preview_dialog_map_[preview_dialog] = nullptr; | 452 preview_dialog_map_[preview_dialog] = nullptr; |
450 RemoveObservers(initiator); | 453 RemoveObservers(initiator); |
451 | |
452 PrintViewManager::FromWebContents(initiator)->PrintPreviewDone(); | 454 PrintViewManager::FromWebContents(initiator)->PrintPreviewDone(); |
453 | |
454 // initiator is closed. Close the print preview dialog too. | 455 // initiator is closed. Close the print preview dialog too. |
455 if (content::WebUI* web_ui = preview_dialog->GetWebUI()) { | 456 if (content::WebUI* web_ui = preview_dialog->GetWebUI()) { |
456 PrintPreviewUI* print_preview_ui = | 457 PrintPreviewUI* print_preview_ui = |
457 static_cast<PrintPreviewUI*>(web_ui->GetController()); | 458 static_cast<PrintPreviewUI*>(web_ui->GetController()); |
458 if (print_preview_ui) | 459 if (print_preview_ui) |
459 print_preview_ui->OnInitiatorClosed(); | 460 print_preview_ui->OnInitiatorClosed(); |
460 } | 461 } |
461 } | 462 } |
462 | 463 |
463 void PrintPreviewDialogController::RemovePreviewDialog( | 464 void PrintPreviewDialogController::RemovePreviewDialog( |
464 WebContents* preview_dialog) { | 465 WebContents* preview_dialog) { |
465 // Remove the initiator's observers before erasing the mapping. | 466 // Remove the initiator's observers before erasing the mapping. |
466 WebContents* initiator = GetInitiator(preview_dialog); | 467 WebContents* initiator = GetInitiator(preview_dialog); |
467 if (initiator) { | 468 if (initiator) { |
468 RemoveObservers(initiator); | 469 RemoveObservers(initiator); |
469 PrintViewManager::FromWebContents(initiator)->PrintPreviewDone(); | 470 PrintViewManager::FromWebContents(initiator)->PrintPreviewDone(); |
470 } | 471 } |
471 | 472 |
472 preview_dialog_map_.erase(preview_dialog); | 473 preview_dialog_map_.erase(preview_dialog); |
473 RemoveObservers(preview_dialog); | 474 RemoveObservers(preview_dialog); |
474 } | 475 } |
475 | 476 |
476 } // namespace printing | 477 } // namespace printing |
OLD | NEW |