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/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/id_map.h" | 10 #include "base/id_map.h" |
(...skipping 24 matching lines...) Expand all Loading... |
35 #include "content/public/browser/url_data_source.h" | 35 #include "content/public/browser/url_data_source.h" |
36 #include "content/public/browser/web_contents.h" | 36 #include "content/public/browser/web_contents.h" |
37 #include "content/public/browser/web_ui_data_source.h" | 37 #include "content/public/browser/web_ui_data_source.h" |
38 #include "printing/page_size_margins.h" | 38 #include "printing/page_size_margins.h" |
39 #include "printing/print_job_constants.h" | 39 #include "printing/print_job_constants.h" |
40 #include "ui/base/l10n/l10n_util.h" | 40 #include "ui/base/l10n/l10n_util.h" |
41 #include "ui/gfx/geometry/rect.h" | 41 #include "ui/gfx/geometry/rect.h" |
42 #include "ui/web_dialogs/web_dialog_delegate.h" | 42 #include "ui/web_dialogs/web_dialog_delegate.h" |
43 #include "ui/web_dialogs/web_dialog_ui.h" | 43 #include "ui/web_dialogs/web_dialog_ui.h" |
44 | 44 |
| 45 #if defined(OS_CHROMEOS) |
| 46 #include "base/command_line.h" |
| 47 #include "base/feature_list.h" |
| 48 #include "chrome/common/chrome_features.h" |
| 49 #include "chrome/common/chrome_switches.h" |
| 50 #endif |
| 51 |
45 using content::WebContents; | 52 using content::WebContents; |
46 using printing::PageSizeMargins; | 53 using printing::PageSizeMargins; |
47 | 54 |
48 namespace { | 55 namespace { |
49 | 56 |
50 #if defined(OS_MACOSX) | 57 #if defined(OS_MACOSX) |
51 // U+0028 U+21E7 U+2318 U+0050 U+0029 in UTF8 | 58 // U+0028 U+21E7 U+2318 U+0050 U+0029 in UTF8 |
52 const char kBasicPrintShortcut[] = "\x28\xE2\x8c\xA5\xE2\x8C\x98\x50\x29"; | 59 const char kBasicPrintShortcut[] = "\x28\xE2\x8c\xA5\xE2\x8C\x98\x50\x29"; |
53 #elif defined(OS_WIN) || defined(OS_CHROMEOS) | 60 #elif defined(OS_WIN) || defined(OS_CHROMEOS) |
54 const char kBasicPrintShortcut[] = "(Ctrl+Shift+P)"; | 61 const char kBasicPrintShortcut[] = "(Ctrl+Shift+P)"; |
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
386 source->AddResourcePath("images/mobile.png", IDR_PRINT_PREVIEW_IMAGES_MOBILE); | 393 source->AddResourcePath("images/mobile.png", IDR_PRINT_PREVIEW_IMAGES_MOBILE); |
387 source->AddResourcePath("images/mobile_shared.png", | 394 source->AddResourcePath("images/mobile_shared.png", |
388 IDR_PRINT_PREVIEW_IMAGES_MOBILE_SHARED); | 395 IDR_PRINT_PREVIEW_IMAGES_MOBILE_SHARED); |
389 source->SetDefaultResource(IDR_PRINT_PREVIEW_HTML); | 396 source->SetDefaultResource(IDR_PRINT_PREVIEW_HTML); |
390 source->SetRequestFilter(base::Bind(&HandleRequestCallback)); | 397 source->SetRequestFilter(base::Bind(&HandleRequestCallback)); |
391 source->OverrideContentSecurityPolicyChildSrc("child-src 'self';"); | 398 source->OverrideContentSecurityPolicyChildSrc("child-src 'self';"); |
392 source->DisableDenyXFrameOptions(); | 399 source->DisableDenyXFrameOptions(); |
393 source->OverrideContentSecurityPolicyObjectSrc("object-src 'self';"); | 400 source->OverrideContentSecurityPolicyObjectSrc("object-src 'self';"); |
394 source->AddLocalizedString("moreOptionsLabel", IDS_MORE_OPTIONS_LABEL); | 401 source->AddLocalizedString("moreOptionsLabel", IDS_MORE_OPTIONS_LABEL); |
395 source->AddLocalizedString("lessOptionsLabel", IDS_LESS_OPTIONS_LABEL); | 402 source->AddLocalizedString("lessOptionsLabel", IDS_LESS_OPTIONS_LABEL); |
| 403 #if defined(OS_CHROMEOS) |
| 404 bool cups_and_md_settings_enabled = |
| 405 base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 406 ::switches::kEnableNativeCups) && |
| 407 base::FeatureList::IsEnabled(features::kMaterialDesignSettings); |
| 408 source->AddBoolean("showLocalManageButton", cups_and_md_settings_enabled); |
| 409 #else |
| 410 source->AddBoolean("showLocalManageButton", true); |
| 411 #endif |
396 return source; | 412 return source; |
397 } | 413 } |
398 | 414 |
399 PrintPreviewUI::TestingDelegate* g_testing_delegate = NULL; | 415 PrintPreviewUI::TestingDelegate* g_testing_delegate = NULL; |
400 | 416 |
401 } // namespace | 417 } // namespace |
402 | 418 |
403 PrintPreviewUI::PrintPreviewUI(content::WebUI* web_ui) | 419 PrintPreviewUI::PrintPreviewUI(content::WebUI* web_ui) |
404 : ConstrainedWebDialogUI(web_ui), | 420 : ConstrainedWebDialogUI(web_ui), |
405 initial_preview_start_time_(base::TimeTicks::Now()), | 421 initial_preview_start_time_(base::TimeTicks::Now()), |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
661 } | 677 } |
662 | 678 |
663 void PrintPreviewUI::SetSelectedFileForTesting(const base::FilePath& path) { | 679 void PrintPreviewUI::SetSelectedFileForTesting(const base::FilePath& path) { |
664 handler_->FileSelected(path, 0, NULL); | 680 handler_->FileSelected(path, 0, NULL); |
665 } | 681 } |
666 | 682 |
667 void PrintPreviewUI::SetPdfSavedClosureForTesting( | 683 void PrintPreviewUI::SetPdfSavedClosureForTesting( |
668 const base::Closure& closure) { | 684 const base::Closure& closure) { |
669 handler_->SetPdfSavedClosureForTesting(closure); | 685 handler_->SetPdfSavedClosureForTesting(closure); |
670 } | 686 } |
OLD | NEW |