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 <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 WebContents* PrintPreviewDialogController::GetOrCreatePreviewDialog( | 171 WebContents* PrintPreviewDialogController::GetOrCreatePreviewDialog( |
172 WebContents* initiator) { | 172 WebContents* initiator) { |
173 DCHECK(initiator); | 173 DCHECK(initiator); |
174 | 174 |
175 // Get the print preview dialog for |initiator|. | 175 // Get the print preview dialog for |initiator|. |
176 WebContents* preview_dialog = GetPrintPreviewForContents(initiator); | 176 WebContents* preview_dialog = GetPrintPreviewForContents(initiator); |
177 if (!preview_dialog) | 177 if (!preview_dialog) |
178 return CreatePrintPreviewDialog(initiator); | 178 return CreatePrintPreviewDialog(initiator); |
179 | 179 |
180 // Show the initiator holding the existing preview dialog. | 180 // Show the initiator holding the existing preview dialog. |
181 initiator->GetDelegate()->ActivateContents(initiator); | 181 // TODO(johnme): Can we sometimes be certain this was for a user gesture? |
| 182 initiator->GetDelegate()->ActivateContents(initiator, |
| 183 false /* user_gesture */); |
182 return preview_dialog; | 184 return preview_dialog; |
183 } | 185 } |
184 | 186 |
185 WebContents* PrintPreviewDialogController::GetPrintPreviewForContents( | 187 WebContents* PrintPreviewDialogController::GetPrintPreviewForContents( |
186 WebContents* contents) const { | 188 WebContents* contents) const { |
187 // |preview_dialog_map_| is keyed by the preview dialog, so if find() | 189 // |preview_dialog_map_| is keyed by the preview dialog, so if find() |
188 // succeeds, then |contents| is the preview dialog. | 190 // succeeds, then |contents| is the preview dialog. |
189 PrintPreviewDialogMap::const_iterator it = preview_dialog_map_.find(contents); | 191 PrintPreviewDialogMap::const_iterator it = preview_dialog_map_.find(contents); |
190 if (it != preview_dialog_map_.end()) | 192 if (it != preview_dialog_map_.end()) |
191 return contents; | 193 return contents; |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
458 static_cast<PrintPreviewUI*>(web_ui->GetController()); | 460 static_cast<PrintPreviewUI*>(web_ui->GetController()); |
459 if (print_preview_ui) | 461 if (print_preview_ui) |
460 print_preview_ui->OnPrintPreviewDialogDestroyed(); | 462 print_preview_ui->OnPrintPreviewDialogDestroyed(); |
461 } | 463 } |
462 | 464 |
463 preview_dialog_map_.erase(preview_dialog); | 465 preview_dialog_map_.erase(preview_dialog); |
464 RemoveObservers(preview_dialog); | 466 RemoveObservers(preview_dialog); |
465 } | 467 } |
466 | 468 |
467 } // namespace printing | 469 } // namespace printing |
OLD | NEW |