Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(31)

Side by Side Diff: chrome/browser/ui/webui/print_preview/print_preview_ui.cc

Issue 2806603003: WebUI: prevent WebContent to hold an invalid pointer. (Closed)
Patch Set: Better ownership semantics Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/ui/webui/constrained_web_dialog_ui_browsertest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/ui/webui/print_preview/print_preview_ui.h" 5 #include "chrome/browser/ui/webui/print_preview/print_preview_ui.h"
6 6
7 #include <map> 7 #include <map>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 636 matching lines...) Expand 10 before | Expand all | Expand 10 after
647 void PrintPreviewUI::OnHidePreviewDialog() { 647 void PrintPreviewUI::OnHidePreviewDialog() {
648 WebContents* preview_dialog = web_ui()->GetWebContents(); 648 WebContents* preview_dialog = web_ui()->GetWebContents();
649 printing::BackgroundPrintingManager* background_printing_manager = 649 printing::BackgroundPrintingManager* background_printing_manager =
650 g_browser_process->background_printing_manager(); 650 g_browser_process->background_printing_manager();
651 if (background_printing_manager->HasPrintPreviewDialog(preview_dialog)) 651 if (background_printing_manager->HasPrintPreviewDialog(preview_dialog))
652 return; 652 return;
653 653
654 ConstrainedWebDialogDelegate* delegate = GetConstrainedDelegate(); 654 ConstrainedWebDialogDelegate* delegate = GetConstrainedDelegate();
655 if (!delegate) 655 if (!delegate)
656 return; 656 return;
657 delegate->ReleaseWebContentsOnDialogClose(); 657 std::unique_ptr<content::WebContents> preview_contents =
658 background_printing_manager->OwnPrintPreviewDialog(preview_dialog); 658 delegate->ReleaseWebContents();
659 DCHECK_EQ(preview_dialog, preview_contents.get());
660 background_printing_manager->OwnPrintPreviewDialog(
661 preview_contents.release());
659 OnClosePrintPreviewDialog(); 662 OnClosePrintPreviewDialog();
660 } 663 }
661 664
662 void PrintPreviewUI::OnClosePrintPreviewDialog() { 665 void PrintPreviewUI::OnClosePrintPreviewDialog() {
663 if (dialog_closed_) 666 if (dialog_closed_)
664 return; 667 return;
665 dialog_closed_ = true; 668 dialog_closed_ = true;
666 ConstrainedWebDialogDelegate* delegate = GetConstrainedDelegate(); 669 ConstrainedWebDialogDelegate* delegate = GetConstrainedDelegate();
667 if (!delegate) 670 if (!delegate)
668 return; 671 return;
(...skipping 22 matching lines...) Expand all
691 } 694 }
692 695
693 void PrintPreviewUI::SetSelectedFileForTesting(const base::FilePath& path) { 696 void PrintPreviewUI::SetSelectedFileForTesting(const base::FilePath& path) {
694 handler_->FileSelected(path, 0, NULL); 697 handler_->FileSelected(path, 0, NULL);
695 } 698 }
696 699
697 void PrintPreviewUI::SetPdfSavedClosureForTesting( 700 void PrintPreviewUI::SetPdfSavedClosureForTesting(
698 const base::Closure& closure) { 701 const base::Closure& closure) {
699 handler_->SetPdfSavedClosureForTesting(closure); 702 handler_->SetPdfSavedClosureForTesting(closure);
700 } 703 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/constrained_web_dialog_ui_browsertest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698