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

Side by Side Diff: chrome/browser/ui/webui/print_preview_handler.cc

Issue 8892011: Clean up TCW, make it solely a hub for 1:1 observer/helper objects. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years 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 | Annotate | Revision Log
OLDNEW
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/ui/webui/print_preview_handler.h" 5 #include "chrome/browser/ui/webui/print_preview_handler.h"
6 6
7 #include <ctype.h> 7 #include <ctype.h>
8 8
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 // headers and footers are to be displayed. 301 // headers and footers are to be displayed.
302 bool display_header_footer = false; 302 bool display_header_footer = false;
303 if (!settings->GetBoolean(printing::kSettingHeaderFooterEnabled, 303 if (!settings->GetBoolean(printing::kSettingHeaderFooterEnabled,
304 &display_header_footer)) { 304 &display_header_footer)) {
305 NOTREACHED(); 305 NOTREACHED();
306 } 306 }
307 if (display_header_footer) { 307 if (display_header_footer) {
308 settings->SetString(printing::kSettingHeaderFooterTitle, 308 settings->SetString(printing::kSettingHeaderFooterTitle,
309 initiator_tab->tab_contents()->GetTitle()); 309 initiator_tab->tab_contents()->GetTitle());
310 std::string url; 310 std::string url;
311 NavigationEntry* entry = initiator_tab->controller().GetActiveEntry(); 311 NavigationEntry* entry =
312 initiator_tab->tab_contents()->controller().GetActiveEntry();
312 if (entry) 313 if (entry)
313 url = entry->virtual_url().spec(); 314 url = entry->virtual_url().spec();
314 settings->SetString(printing::kSettingHeaderFooterURL, url); 315 settings->SetString(printing::kSettingHeaderFooterURL, url);
315 } 316 }
316 317
317 bool generate_draft_data = false; 318 bool generate_draft_data = false;
318 bool success = settings->GetBoolean(printing::kSettingGenerateDraftData, 319 bool success = settings->GetBoolean(printing::kSettingGenerateDraftData,
319 &generate_draft_data); 320 &generate_draft_data);
320 DCHECK(success); 321 DCHECK(success);
321 322
322 if (!generate_draft_data) { 323 if (!generate_draft_data) {
323 double draft_page_count_double = -1; 324 double draft_page_count_double = -1;
324 success = args->GetDouble(1, &draft_page_count_double); 325 success = args->GetDouble(1, &draft_page_count_double);
325 DCHECK(success); 326 DCHECK(success);
326 int draft_page_count = static_cast<int>(draft_page_count_double); 327 int draft_page_count = static_cast<int>(draft_page_count_double);
327 328
328 bool preview_modifiable = false; 329 bool preview_modifiable = false;
329 success = args->GetBoolean(2, &preview_modifiable); 330 success = args->GetBoolean(2, &preview_modifiable);
330 DCHECK(success); 331 DCHECK(success);
331 332
332 if (draft_page_count != -1 && preview_modifiable && 333 if (draft_page_count != -1 && preview_modifiable &&
333 print_preview_ui->GetAvailableDraftPageCount() != draft_page_count) { 334 print_preview_ui->GetAvailableDraftPageCount() != draft_page_count) {
334 settings->SetBoolean(printing::kSettingGenerateDraftData, true); 335 settings->SetBoolean(printing::kSettingGenerateDraftData, true);
335 } 336 }
336 } 337 }
337 338
338 VLOG(1) << "Print preview request start"; 339 VLOG(1) << "Print preview request start";
339 RenderViewHost* rvh = initiator_tab->render_view_host(); 340 RenderViewHost* rvh = initiator_tab->tab_contents()->render_view_host();
340 rvh->Send(new PrintMsg_PrintPreview(rvh->routing_id(), *settings)); 341 rvh->Send(new PrintMsg_PrintPreview(rvh->routing_id(), *settings));
341 } 342 }
342 343
343 void PrintPreviewHandler::HandlePrint(const ListValue* args) { 344 void PrintPreviewHandler::HandlePrint(const ListValue* args) {
344 ReportStats(); 345 ReportStats();
345 346
346 // Record the number of times the user requests to regenerate preview data 347 // Record the number of times the user requests to regenerate preview data
347 // before printing. 348 // before printing.
348 UMA_HISTOGRAM_COUNTS("PrintPreview.RegeneratePreviewRequest.BeforePrint", 349 UMA_HISTOGRAM_COUNTS("PrintPreview.RegeneratePreviewRequest.BeforePrint",
349 regenerate_preview_request_count_); 350 regenerate_preview_request_count_);
350 351
351 TabContentsWrapper* initiator_tab = GetInitiatorTab(); 352 TabContentsWrapper* initiator_tab = GetInitiatorTab();
352 CHECK(initiator_tab); 353 CHECK(initiator_tab);
353 354
354 RenderViewHost* init_rvh = initiator_tab->render_view_host(); 355 RenderViewHost* init_rvh = initiator_tab->tab_contents()->render_view_host();
355 init_rvh->Send(new PrintMsg_ResetScriptedPrintCount(init_rvh->routing_id())); 356 init_rvh->Send(new PrintMsg_ResetScriptedPrintCount(init_rvh->routing_id()));
356 357
357 scoped_ptr<DictionaryValue> settings(GetSettingsDictionary(args)); 358 scoped_ptr<DictionaryValue> settings(GetSettingsDictionary(args));
358 if (!settings.get()) 359 if (!settings.get())
359 return; 360 return;
360 361
361 // Storing last used color model. 362 // Storing last used color model.
362 int color_model; 363 int color_model;
363 if (!settings->GetInteger(printing::kSettingColor, &color_model)) 364 if (!settings->GetInteger(printing::kSettingColor, &color_model))
364 color_model = printing::GRAY; 365 color_model = printing::GRAY;
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after
837 return; 838 return;
838 839
839 // We no longer require the initiator tab details. Remove those details 840 // We no longer require the initiator tab details. Remove those details
840 // associated with the preview tab to allow the initiator tab to create 841 // associated with the preview tab to allow the initiator tab to create
841 // another preview tab. 842 // another preview tab.
842 printing::PrintPreviewTabController* tab_controller = 843 printing::PrintPreviewTabController* tab_controller =
843 printing::PrintPreviewTabController::GetInstance(); 844 printing::PrintPreviewTabController::GetInstance();
844 if (tab_controller) 845 if (tab_controller)
845 tab_controller->EraseInitiatorTabInfo(preview_tab_wrapper()); 846 tab_controller->EraseInitiatorTabInfo(preview_tab_wrapper());
846 } 847 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/media/media_internals_ui.cc ('k') | chrome/browser/ui/webui/print_preview_handler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698