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

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

Issue 2528903002: Allow the PDF extension for chrome://print pages. (Closed)
Patch Set: Created 4 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
« no previous file with comments | « no previous file | content/browser/webui/web_ui_data_source_impl.h » ('j') | 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 <vector> 8 #include <vector>
9 9
10 #include "base/feature_list.h" 10 #include "base/feature_list.h"
11 #include "base/id_map.h" 11 #include "base/id_map.h"
12 #include "base/lazy_instance.h" 12 #include "base/lazy_instance.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/memory/ref_counted_memory.h" 14 #include "base/memory/ref_counted_memory.h"
15 #include "base/metrics/histogram_macros.h" 15 #include "base/metrics/histogram_macros.h"
16 #include "base/strings/string_number_conversions.h" 16 #include "base/strings/string_number_conversions.h"
17 #include "base/strings/string_split.h" 17 #include "base/strings/string_split.h"
18 #include "base/strings/string_util.h" 18 #include "base/strings/string_util.h"
19 #include "base/strings/stringprintf.h"
19 #include "base/strings/utf_string_conversions.h" 20 #include "base/strings/utf_string_conversions.h"
20 #include "base/synchronization/lock.h" 21 #include "base/synchronization/lock.h"
21 #include "base/values.h" 22 #include "base/values.h"
22 #include "build/build_config.h" 23 #include "build/build_config.h"
23 #include "chrome/browser/browser_process.h" 24 #include "chrome/browser/browser_process.h"
24 #include "chrome/browser/printing/background_printing_manager.h" 25 #include "chrome/browser/printing/background_printing_manager.h"
25 #include "chrome/browser/printing/print_preview_data_service.h" 26 #include "chrome/browser/printing/print_preview_data_service.h"
26 #include "chrome/browser/profiles/profile.h" 27 #include "chrome/browser/profiles/profile.h"
27 #include "chrome/browser/ui/webui/metrics_handler.h" 28 #include "chrome/browser/ui/webui/metrics_handler.h"
28 #include "chrome/browser/ui/webui/print_preview/print_preview_handler.h" 29 #include "chrome/browser/ui/webui/print_preview/print_preview_handler.h"
29 #include "chrome/browser/ui/webui/theme_source.h" 30 #include "chrome/browser/ui/webui/theme_source.h"
30 #include "chrome/common/chrome_features.h" 31 #include "chrome/common/chrome_features.h"
31 #include "chrome/common/url_constants.h" 32 #include "chrome/common/url_constants.h"
32 #include "chrome/grit/browser_resources.h" 33 #include "chrome/grit/browser_resources.h"
33 #include "chrome/grit/chromium_strings.h" 34 #include "chrome/grit/chromium_strings.h"
34 #include "chrome/grit/generated_resources.h" 35 #include "chrome/grit/generated_resources.h"
35 #include "components/printing/common/print_messages.h" 36 #include "components/printing/common/print_messages.h"
36 #include "components/strings/grit/components_strings.h" 37 #include "components/strings/grit/components_strings.h"
37 #include "content/public/browser/url_data_source.h" 38 #include "content/public/browser/url_data_source.h"
38 #include "content/public/browser/web_contents.h" 39 #include "content/public/browser/web_contents.h"
39 #include "content/public/browser/web_ui_data_source.h" 40 #include "content/public/browser/web_ui_data_source.h"
41 #include "extensions/common/constants.h"
40 #include "printing/features/features.h" 42 #include "printing/features/features.h"
41 #include "printing/page_size_margins.h" 43 #include "printing/page_size_margins.h"
42 #include "printing/print_job_constants.h" 44 #include "printing/print_job_constants.h"
43 #include "ui/base/l10n/l10n_util.h" 45 #include "ui/base/l10n/l10n_util.h"
44 #include "ui/gfx/geometry/rect.h" 46 #include "ui/gfx/geometry/rect.h"
45 #include "ui/web_dialogs/web_dialog_delegate.h" 47 #include "ui/web_dialogs/web_dialog_delegate.h"
46 #include "ui/web_dialogs/web_dialog_ui.h" 48 #include "ui/web_dialogs/web_dialog_ui.h"
47 49
48 #if defined(OS_CHROMEOS) 50 #if defined(OS_CHROMEOS)
49 #include "base/command_line.h" 51 #include "base/command_line.h"
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 source->AddResourcePath("images/third_party_fedex.png", 392 source->AddResourcePath("images/third_party_fedex.png",
391 IDR_PRINT_PREVIEW_IMAGES_THIRD_PARTY_FEDEX); 393 IDR_PRINT_PREVIEW_IMAGES_THIRD_PARTY_FEDEX);
392 source->AddResourcePath("images/google_doc.png", 394 source->AddResourcePath("images/google_doc.png",
393 IDR_PRINT_PREVIEW_IMAGES_GOOGLE_DOC); 395 IDR_PRINT_PREVIEW_IMAGES_GOOGLE_DOC);
394 source->AddResourcePath("images/pdf.png", IDR_PRINT_PREVIEW_IMAGES_PDF); 396 source->AddResourcePath("images/pdf.png", IDR_PRINT_PREVIEW_IMAGES_PDF);
395 source->AddResourcePath("images/mobile.png", IDR_PRINT_PREVIEW_IMAGES_MOBILE); 397 source->AddResourcePath("images/mobile.png", IDR_PRINT_PREVIEW_IMAGES_MOBILE);
396 source->AddResourcePath("images/mobile_shared.png", 398 source->AddResourcePath("images/mobile_shared.png",
397 IDR_PRINT_PREVIEW_IMAGES_MOBILE_SHARED); 399 IDR_PRINT_PREVIEW_IMAGES_MOBILE_SHARED);
398 source->SetDefaultResource(IDR_PRINT_PREVIEW_HTML); 400 source->SetDefaultResource(IDR_PRINT_PREVIEW_HTML);
399 source->SetRequestFilter(base::Bind(&HandleRequestCallback)); 401 source->SetRequestFilter(base::Bind(&HandleRequestCallback));
402 source->OverrideContentSecurityPolicyScriptSrc(
403 base::StringPrintf("script-src chrome://resources 'self' 'unsafe-eval' "
404 "chrome-extension://%s;",
405 extension_misc::kPdfExtensionId));
400 source->OverrideContentSecurityPolicyChildSrc("child-src 'self';"); 406 source->OverrideContentSecurityPolicyChildSrc("child-src 'self';");
401 source->DisableDenyXFrameOptions(); 407 source->DisableDenyXFrameOptions();
402 source->OverrideContentSecurityPolicyObjectSrc("object-src 'self';"); 408 source->OverrideContentSecurityPolicyObjectSrc("object-src 'self';");
403 source->AddLocalizedString("moreOptionsLabel", IDS_MORE_OPTIONS_LABEL); 409 source->AddLocalizedString("moreOptionsLabel", IDS_MORE_OPTIONS_LABEL);
404 source->AddLocalizedString("lessOptionsLabel", IDS_LESS_OPTIONS_LABEL); 410 source->AddLocalizedString("lessOptionsLabel", IDS_LESS_OPTIONS_LABEL);
405 411
406 bool scaling_enabled = base::FeatureList::IsEnabled(features::kPrintScaling); 412 bool scaling_enabled = base::FeatureList::IsEnabled(features::kPrintScaling);
407 source->AddBoolean("scalingEnabled", scaling_enabled); 413 source->AddBoolean("scalingEnabled", scaling_enabled);
408 414
409 #if defined(OS_CHROMEOS) 415 #if defined(OS_CHROMEOS)
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
683 } 689 }
684 690
685 void PrintPreviewUI::SetSelectedFileForTesting(const base::FilePath& path) { 691 void PrintPreviewUI::SetSelectedFileForTesting(const base::FilePath& path) {
686 handler_->FileSelected(path, 0, NULL); 692 handler_->FileSelected(path, 0, NULL);
687 } 693 }
688 694
689 void PrintPreviewUI::SetPdfSavedClosureForTesting( 695 void PrintPreviewUI::SetPdfSavedClosureForTesting(
690 const base::Closure& closure) { 696 const base::Closure& closure) {
691 handler_->SetPdfSavedClosureForTesting(closure); 697 handler_->SetPdfSavedClosureForTesting(closure);
692 } 698 }
OLDNEW
« no previous file with comments | « no previous file | content/browser/webui/web_ui_data_source_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698