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

Side by Side Diff: chrome/browser/printing/print_preview_dialog_controller.cc

Issue 1125343004: Add a "Simplify Page" option to the print preview dialog (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix for the failing tests Created 5 years, 4 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
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/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 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 if (!preview_dialog) 176 if (!preview_dialog)
177 return CreatePrintPreviewDialog(initiator); 177 return CreatePrintPreviewDialog(initiator);
178 178
179 // Show the initiator holding the existing preview dialog. 179 // Show the initiator holding the existing preview dialog.
180 initiator->GetDelegate()->ActivateContents(initiator); 180 initiator->GetDelegate()->ActivateContents(initiator);
181 return preview_dialog; 181 return preview_dialog;
182 } 182 }
183 183
184 WebContents* PrintPreviewDialogController::GetPrintPreviewForContents( 184 WebContents* PrintPreviewDialogController::GetPrintPreviewForContents(
185 WebContents* contents) const { 185 WebContents* contents) const {
186 // If this WebContents relies on another for its preview dialog, we
187 // need to act as if we are looking for the proxied content's dialog.
188 PrintPreviewDialogMap::const_iterator proxied =
189 proxied_dialog_map_.find(contents);
190 if (proxied != proxied_dialog_map_.end()) {
191 contents = proxied->second;
192 }
193
186 // |preview_dialog_map_| is keyed by the preview dialog, so if find() 194 // |preview_dialog_map_| is keyed by the preview dialog, so if find()
187 // succeeds, then |contents| is the preview dialog. 195 // succeeds, then |contents| is the preview dialog.
188 PrintPreviewDialogMap::const_iterator it = preview_dialog_map_.find(contents); 196 PrintPreviewDialogMap::const_iterator it = preview_dialog_map_.find(contents);
189 if (it != preview_dialog_map_.end()) 197 if (it != preview_dialog_map_.end())
190 return contents; 198 return contents;
191 199
192 for (it = preview_dialog_map_.begin(); 200 for (it = preview_dialog_map_.begin();
193 it != preview_dialog_map_.end(); 201 it != preview_dialog_map_.end();
194 ++it) { 202 ++it) {
195 // If |contents| is an initiator. 203 // If |contents| is an initiator.
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 379
372 // Make the print preview WebContents show up in the task manager. 380 // Make the print preview WebContents show up in the task manager.
373 task_management::WebContentsTags::CreateForPrintingContents(preview_dialog); 381 task_management::WebContentsTags::CreateForPrintingContents(preview_dialog);
374 382
375 AddObservers(initiator); 383 AddObservers(initiator);
376 AddObservers(preview_dialog); 384 AddObservers(preview_dialog);
377 385
378 return preview_dialog; 386 return preview_dialog;
379 } 387 }
380 388
389 void PrintPreviewDialogController::AddProxyDialogForWebContents(
390 WebContents* source,
391 WebContents* target) {
392 proxied_dialog_map_[source] = target;
393 }
394
395 void PrintPreviewDialogController::RemoveProxyDialogForWebContents(
396 WebContents* source) {
397 proxied_dialog_map_.erase(source);
398 }
399
381 void PrintPreviewDialogController::SaveInitiatorTitle( 400 void PrintPreviewDialogController::SaveInitiatorTitle(
382 WebContents* preview_dialog) { 401 WebContents* preview_dialog) {
383 WebContents* initiator = GetInitiator(preview_dialog); 402 WebContents* initiator = GetInitiator(preview_dialog);
384 if (initiator && preview_dialog->GetWebUI()) { 403 if (initiator && preview_dialog->GetWebUI()) {
385 PrintPreviewUI* print_preview_ui = static_cast<PrintPreviewUI*>( 404 PrintPreviewUI* print_preview_ui = static_cast<PrintPreviewUI*>(
386 preview_dialog->GetWebUI()->GetController()); 405 preview_dialog->GetWebUI()->GetController());
387 print_preview_ui->SetInitiatorTitle( 406 print_preview_ui->SetInitiatorTitle(
388 PrintViewManager::FromWebContents(initiator)->RenderSourceName()); 407 PrintViewManager::FromWebContents(initiator)->RenderSourceName());
389 } 408 }
390 } 409 }
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
460 static_cast<PrintPreviewUI*>(web_ui->GetController()); 479 static_cast<PrintPreviewUI*>(web_ui->GetController());
461 if (print_preview_ui) 480 if (print_preview_ui)
462 print_preview_ui->OnPrintPreviewDialogDestroyed(); 481 print_preview_ui->OnPrintPreviewDialogDestroyed();
463 } 482 }
464 483
465 preview_dialog_map_.erase(preview_dialog); 484 preview_dialog_map_.erase(preview_dialog);
466 RemoveObservers(preview_dialog); 485 RemoveObservers(preview_dialog);
467 } 486 }
468 487
469 } // namespace printing 488 } // namespace printing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698