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/command_line.h" |
10 #include "base/feature_list.h" | 11 #include "base/feature_list.h" |
11 #include "base/id_map.h" | 12 #include "base/id_map.h" |
12 #include "base/lazy_instance.h" | 13 #include "base/lazy_instance.h" |
13 #include "base/macros.h" | 14 #include "base/macros.h" |
14 #include "base/memory/ref_counted_memory.h" | 15 #include "base/memory/ref_counted_memory.h" |
15 #include "base/metrics/histogram_macros.h" | 16 #include "base/metrics/histogram_macros.h" |
16 #include "base/strings/string_number_conversions.h" | 17 #include "base/strings/string_number_conversions.h" |
17 #include "base/strings/string_split.h" | 18 #include "base/strings/string_split.h" |
18 #include "base/strings/string_util.h" | 19 #include "base/strings/string_util.h" |
19 #include "base/strings/stringprintf.h" | 20 #include "base/strings/stringprintf.h" |
20 #include "base/strings/utf_string_conversions.h" | 21 #include "base/strings/utf_string_conversions.h" |
21 #include "base/synchronization/lock.h" | 22 #include "base/synchronization/lock.h" |
22 #include "base/values.h" | 23 #include "base/values.h" |
23 #include "build/build_config.h" | 24 #include "build/build_config.h" |
24 #include "chrome/browser/browser_process.h" | 25 #include "chrome/browser/browser_process.h" |
25 #include "chrome/browser/printing/background_printing_manager.h" | 26 #include "chrome/browser/printing/background_printing_manager.h" |
26 #include "chrome/browser/printing/print_preview_data_service.h" | 27 #include "chrome/browser/printing/print_preview_data_service.h" |
27 #include "chrome/browser/profiles/profile.h" | 28 #include "chrome/browser/profiles/profile.h" |
28 #include "chrome/browser/ui/webui/metrics_handler.h" | 29 #include "chrome/browser/ui/webui/metrics_handler.h" |
29 #include "chrome/browser/ui/webui/print_preview/print_preview_handler.h" | 30 #include "chrome/browser/ui/webui/print_preview/print_preview_handler.h" |
30 #include "chrome/browser/ui/webui/theme_source.h" | 31 #include "chrome/browser/ui/webui/theme_source.h" |
31 #include "chrome/common/chrome_features.h" | 32 #include "chrome/common/chrome_features.h" |
| 33 #include "chrome/common/chrome_switches.h" |
32 #include "chrome/common/url_constants.h" | 34 #include "chrome/common/url_constants.h" |
33 #include "chrome/grit/browser_resources.h" | 35 #include "chrome/grit/browser_resources.h" |
34 #include "chrome/grit/chromium_strings.h" | 36 #include "chrome/grit/chromium_strings.h" |
35 #include "chrome/grit/generated_resources.h" | 37 #include "chrome/grit/generated_resources.h" |
36 #include "components/printing/common/print_messages.h" | 38 #include "components/printing/common/print_messages.h" |
37 #include "components/strings/grit/components_strings.h" | 39 #include "components/strings/grit/components_strings.h" |
38 #include "content/public/browser/url_data_source.h" | 40 #include "content/public/browser/url_data_source.h" |
39 #include "content/public/browser/web_contents.h" | 41 #include "content/public/browser/web_contents.h" |
40 #include "content/public/browser/web_ui_data_source.h" | 42 #include "content/public/browser/web_ui_data_source.h" |
41 #include "extensions/common/constants.h" | 43 #include "extensions/common/constants.h" |
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
411 source->AddBoolean("scalingEnabled", scaling_enabled); | 413 source->AddBoolean("scalingEnabled", scaling_enabled); |
412 | 414 |
413 #if defined(OS_CHROMEOS) | 415 #if defined(OS_CHROMEOS) |
414 bool cups_and_md_settings_enabled = | 416 bool cups_and_md_settings_enabled = |
415 base::CommandLine::ForCurrentProcess()->HasSwitch( | 417 base::CommandLine::ForCurrentProcess()->HasSwitch( |
416 ::switches::kEnableNativeCups); | 418 ::switches::kEnableNativeCups); |
417 source->AddBoolean("showLocalManageButton", cups_and_md_settings_enabled); | 419 source->AddBoolean("showLocalManageButton", cups_and_md_settings_enabled); |
418 #else | 420 #else |
419 source->AddBoolean("showLocalManageButton", true); | 421 source->AddBoolean("showLocalManageButton", true); |
420 #endif | 422 #endif |
| 423 |
| 424 // printBrowserEnabled is used to determine whether or not to show the navbar |
| 425 #if BUILDFLAG(ENABLE_PRINT_BROWSER) |
| 426 bool print_browser_enabled = |
| 427 base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 428 ::switches::kEnablePrintBrowser); |
| 429 source->AddBoolean("printBrowserEnabled", print_browser_enabled); |
| 430 #else |
| 431 source->AddBoolean("printBrowserEnabled", false); |
| 432 #endif |
421 return source; | 433 return source; |
422 } | 434 } |
423 | 435 |
424 PrintPreviewUI::TestingDelegate* g_testing_delegate = NULL; | 436 PrintPreviewUI::TestingDelegate* g_testing_delegate = NULL; |
425 | 437 |
426 } // namespace | 438 } // namespace |
427 | 439 |
428 PrintPreviewUI::PrintPreviewUI(content::WebUI* web_ui) | 440 PrintPreviewUI::PrintPreviewUI(content::WebUI* web_ui) |
429 : ConstrainedWebDialogUI(web_ui), | 441 : ConstrainedWebDialogUI(web_ui), |
430 initial_preview_start_time_(base::TimeTicks::Now()), | 442 initial_preview_start_time_(base::TimeTicks::Now()), |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
687 } | 699 } |
688 | 700 |
689 void PrintPreviewUI::SetSelectedFileForTesting(const base::FilePath& path) { | 701 void PrintPreviewUI::SetSelectedFileForTesting(const base::FilePath& path) { |
690 handler_->FileSelected(path, 0, NULL); | 702 handler_->FileSelected(path, 0, NULL); |
691 } | 703 } |
692 | 704 |
693 void PrintPreviewUI::SetPdfSavedClosureForTesting( | 705 void PrintPreviewUI::SetPdfSavedClosureForTesting( |
694 const base::Closure& closure) { | 706 const base::Closure& closure) { |
695 handler_->SetPdfSavedClosureForTesting(closure); | 707 handler_->SetPdfSavedClosureForTesting(closure); |
696 } | 708 } |
OLD | NEW |