Commit 5209c657 authored by Jimmy Gong's avatar Jimmy Gong Committed by Commit Bot

PrintJobManagement: Add skeleton code for new PrintJobManagement web app

- This CL includes only the skeleton code to open an empty app from
  chrome://print-management.
- The app and browsertests are in Polymer3.
- Includes basic browsertest to test if app is loaded correctly.
- Future CL will set this app as an System Web App.
- This app is hidden behind a feature flag by default.

Bug: 1053704
Test: browsertest

Change-Id: I777c9912568e10621d763be50052f830fa63e765
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2066878Reviewed-by: default avatarJames Cook <jamescook@chromium.org>
Reviewed-by: default avatarSamuel Huang <huangs@chromium.org>
Reviewed-by: default avatarcalamity <calamity@chromium.org>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Reviewed-by: default avatarKyle Horimoto <khorimoto@chromium.org>
Reviewed-by: default avatarBailey Berro <baileyberro@chromium.org>
Reviewed-by: default avatarZentaro Kavanagh <zentaro@chromium.org>
Commit-Queue: jimmy gong <jimmyxgong@chromium.org>
Cr-Commit-Position: refs/heads/master@{#748293}
parent 9a51776d
......@@ -2052,6 +2052,7 @@ jumbo_static_library("ui") {
"//chromeos/components/multidevice",
"//chromeos/components/multidevice/debug_webui",
"//chromeos/components/multidevice/logging",
"//chromeos/components/print_management",
"//chromeos/components/proximity_auth",
"//chromeos/components/tether",
"//chromeos/components/web_applications",
......
......@@ -195,6 +195,8 @@
#include "chromeos/components/media_app_ui/url_constants.h"
#include "chromeos/components/multidevice/debug_webui/proximity_auth_ui.h"
#include "chromeos/components/multidevice/debug_webui/url_constants.h"
#include "chromeos/components/print_management/print_management_ui.h"
#include "chromeos/components/print_management/url_constants.h"
#include "chromeos/components/sample_system_web_app_ui/url_constants.h"
#include "chromeos/constants/chromeos_features.h"
#include "chromeos/constants/chromeos_switches.h"
......@@ -579,6 +581,10 @@ WebUIFactoryFunction GetWebUIFactoryFunction(WebUI* web_ui,
return &NewWebUI<chromeos::settings::OSSettingsUI>;
if (url.host_piece() == chrome::kChromeUIPowerHost)
return &NewWebUI<chromeos::PowerUI>;
if (base::FeatureList::IsEnabled(
chromeos::features::kPrintJobManagementApp) &&
url.host_piece() == chromeos::kChromeUIPrintManagementHost)
return &NewWebUI<chromeos::PrintManagementUI>;
if (base::FeatureList::IsEnabled(chromeos::features::kMediaApp)) {
if (url.host_piece() == chromeos::kChromeUIMediaAppHost)
return &NewWebUI<chromeos::MediaAppUI>;
......
......@@ -42,6 +42,7 @@ source_set("common") {
"//ash/public/cpp",
"//chromeos/components/help_app_ui",
"//chromeos/components/media_app_ui",
"//chromeos/components/print_management",
"//chromeos/constants",
"//chromeos/strings",
]
......
......@@ -162,6 +162,7 @@ template("chrome_extra_paks") {
"$root_gen_dir/chromeos/chromeos_help_app_resources.pak",
"$root_gen_dir/chromeos/chromeos_media_app_bundle_resources.pak",
"$root_gen_dir/chromeos/chromeos_media_app_resources.pak",
"$root_gen_dir/chromeos/chromeos_print_management_resources.pak",
"$root_gen_dir/chromeos/chromeos_resources.pak",
"$root_gen_dir/third_party/ink/ink_resources.pak",
"$root_gen_dir/ui/file_manager/file_manager_resources.pak",
......@@ -178,6 +179,7 @@ template("chrome_extra_paks") {
"//chromeos/resources:help_app_resources",
"//chromeos/resources:media_app_bundle_resources",
"//chromeos/resources:media_app_resources",
"//chromeos/resources:print_management_resources",
"//third_party/ink:ink_resources",
"//ui/file_manager:resources",
]
......
......@@ -298,6 +298,7 @@ js2gtest("browser_tests_js_mojo_lite_webui") {
"chromeos/crostini_installer_browsertest.js",
"chromeos/crostini_upgrader_browsertest.js",
"chromeos/machine_learning_internals_browsertest.js",
"chromeos/print_management/print_management_browsertest.js",
"multidevice_setup/multidevice_setup_browsertest.js",
]
deps += [ "//chromeos/services/machine_learning/public/cpp:test_support" ]
......
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
/**
* @fileoverview Test suite for chrome://print-management.
*/
GEN_INCLUDE(['//chrome/test/data/webui/polymer_browser_test_base.js']);
GEN('#include "chromeos/constants/chromeos_features.h"');
/**
* @constructor
* @extends {PolymerTest}
*/
function PrintManagementBrowserTest() {}
PrintManagementBrowserTest.prototype = {
__proto__: PolymerTest.prototype,
browsePreload: 'chrome://print-management/test_loader.html?module=chromeos/' +
'print_management/print_management_test.js',
extraLibraries: [
'//third_party/mocha/mocha.js',
'//chrome/test/data/webui/mocha_adapter.js',
],
featureList: {
enabled: [
'chromeos::features::kPrintJobManagementApp',
]
},
};
TEST_F('PrintManagementBrowserTest', 'All', function() {
mocha.run();
});
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// TODO(jimmyxgong): use es6 module for mojo binding crbug/1004256
import 'chrome://resources/mojo/mojo/public/js/mojo_bindings_lite.js';
import 'chrome://print-management/print_management.js';
suite('PrintManagementTest', () => {
/** @type {?PrintManagementElement} */
let page = null;
setup(function() {
PolymerTest.clearBody();
page = document.createElement('print-management');
document.body.appendChild(page);
});
teardown(function() {
page.remove();
page = null;
});
test('MainPageLoaded', () => {
// TODO(jimmyxgong): Remove this stub test once the app has more
// capabilities to test.
assertEquals('Print Management', page.$$('#header').textContent);
});
});
\ No newline at end of file
......@@ -37,6 +37,7 @@ group("closure_compile") {
"//chromeos/components/help_app_ui:closure_compile",
"//chromeos/components/media_app_ui:closure_compile",
"//chromeos/components/multidevice/debug_webui/resources:closure_compile",
"//chromeos/components/print_management:closure_compile",
]
if (!is_official_build) {
......
# Copyright 2020 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
assert(is_chromeos, "Print Management is Chrome OS only")
static_library("print_management") {
sources = [
"print_management_ui.cc",
"print_management_ui.h",
"url_constants.cc",
"url_constants.h",
]
deps = [
"//chromeos/constants",
"//chromeos/resources:print_management_resources",
"//content/public/browser",
"//ui/resources",
"//ui/webui",
]
}
group("closure_compile") {
deps = [ "resources:closure_compile_module" ]
}
include_rules = [
"-chrome",
"+chromeos/grit/chromeos_print_management_resources.h",
"+content/public/browser",
"+ui/resources",
"+ui/webui",
]
\ No newline at end of file
# Primary OWNERS
baileyberro@chromium.org
jimmyxgong@chromium.org
# Backup OWNERS
khorimoto@chromium.org
zentaro@chromium.org
# COMPONENT: OS>Systems>Printing
\ No newline at end of file
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chromeos/components/print_management/print_management_ui.h"
#include "base/memory/ptr_util.h"
#include "chromeos/components/print_management/url_constants.h"
#include "chromeos/grit/chromeos_print_management_resources.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_ui.h"
#include "content/public/browser/web_ui_data_source.h"
#include "ui/resources/grit/webui_resources.h"
namespace chromeos {
PrintManagementUI::PrintManagementUI(content::WebUI* web_ui)
: ui::MojoWebUIController(web_ui) {
auto html_source = base::WrapUnique(
content::WebUIDataSource::Create(kChromeUIPrintManagementHost));
html_source->OverrideContentSecurityPolicyScriptSrc(
"script-src chrome://resources chrome://test 'self';");
html_source->AddResourcePath("print_management.js", IDR_PRINT_MANAGEMENT_JS);
html_source->AddResourcePath("test_loader.js", IDR_WEBUI_JS_TEST_LOADER);
html_source->AddResourcePath("test_loader.html", IDR_WEBUI_HTML_TEST_LOADER);
html_source->SetDefaultResource(IDR_PRINT_MANAGEMENT_INDEX_HTML);
content::WebUIDataSource::Add(web_ui->GetWebContents()->GetBrowserContext(),
html_source.release());
}
PrintManagementUI::~PrintManagementUI() = default;
} // namespace chromeos
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ui/webui/mojo_web_ui_controller.h"
#ifndef CHROMEOS_COMPONENTS_PRINT_MANAGEMENT_PRINT_MANAGEMENT_UI_H_
#define CHROMEOS_COMPONENTS_PRINT_MANAGEMENT_PRINT_MANAGEMENT_UI_H_
namespace chromeos {
// The WebUI for chrome://print-management/.
class PrintManagementUI : public ui::MojoWebUIController {
public:
explicit PrintManagementUI(content::WebUI* web_ui);
~PrintManagementUI() override;
PrintManagementUI(const PrintManagementUI&) = delete;
PrintManagementUI& operator=(const PrintManagementUI&) = delete;
};
} // namespace chromeos
#endif // CHROMEOS_COMPONENTS_PRINT_MANAGEMENT_PRINT_MANAGEMENT_UI_H_
# Copyright 2020 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//third_party/closure_compiler/compile_js.gni")
import("//tools/grit/grit_rule.gni")
import("//tools/grit/repack.gni")
import("//tools/polymer/polymer.gni")
js_type_check("closure_compile_module") {
is_polymer3 = true
deps = [ ":print_management" ]
}
js_library("print_management") {
deps = [
"//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled",
]
}
polymer_modulizer("print_management") {
js_file = "print_management.js"
html_file = "print_management.html"
html_type = "v3-ready"
}
group("polymer3_elements") {
deps = [ ":print_management_module" ]
}
<!-- Copyright 2020 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file. -->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Print Management</title>
</head>
<body>
<print-management></print-management>
<script type="module" src="print_management.js"></script>
<!-- Below mojo script required to run browser tests -->
<script src="chrome://resources/mojo/mojo/public/js/mojo_bindings_lite.js">
</script>
</body>
</html>
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import {html, Polymer} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js';
/**
* @fileoverview
* 'print-management' is used as the main app to display print jobs.
*/
Polymer({
is: 'print-management',
_template: html`{__html_template__}`,
/** @override */
ready() {
// TODO(jimmyxgong): Remove this once the app has more capabilities.
this.$$('#header').textContent = 'Print Management';
},
});
<?xml version="1.0" encoding="UTF-8"?>
<grit latest_public_release="0" current_release="1" output_all_resource_defines="false">
<outputs>
<output filename="grit/chromeos_print_management_resources.h" type="rc_header">
<emit emit_type='prepend'></emit>
</output>
<output filename="grit/chromeos_print_management_resources_map.cc"
type="resource_file_map_source" />
<output filename="grit/chromeos_print_management_resources_map.h"
type="resource_map_header" />
<output filename="chromeos_print_management_resources.pak" type="data_package" />
</outputs>
<release seq="1">
<includes>
<!-- Privileged app host contents. -->
<include name="IDR_PRINT_MANAGEMENT_INDEX_HTML" file="index.html" type="BINDATA" compress="gzip" />
<include name="IDR_PRINT_MANAGEMENT_JS" file="${root_gen_dir}/chromeos/components/print_management/resources/print_management.js" use_base_dir="false" compress="gzip" type="BINDATA"/>
</includes>
</release>
</grit>
\ No newline at end of file
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chromeos/components/print_management/url_constants.h"
namespace chromeos {
const char kChromeUIPrintManagementHost[] = "print-management";
} // namespace chromeos
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROMEOS_COMPONENTS_PRINT_MANAGEMENT_URL_CONSTANTS_H_
#define CHROMEOS_COMPONENTS_PRINT_MANAGEMENT_URL_CONSTANTS_H_
namespace chromeos {
extern const char kChromeUIPrintManagementHost[];
} // namespace chromeos
#endif // CHROMEOS_COMPONENTS_PRINT_MANAGEMENT_URL_CONSTANTS_H_
......@@ -143,3 +143,26 @@ grit("media_app_bundle_resources") {
]
output_dir = "$root_gen_dir/chromeos"
}
grit("print_management_resources") {
source =
"../components/print_management/resources/print_management_resources.grd"
source_is_generated = true
deps = [ "../components/print_management/resources:polymer3_elements" ]
outputs = [
"grit/chromeos_print_management_resources.h",
"grit/chromeos_print_management_resources_map.cc",
"grit/chromeos_print_management_resources_map.h",
"chromeos_print_management_resources.pak",
]
grit_flags = [
"-E",
"root_gen_dir=" + rebase_path(root_gen_dir, root_build_dir),
]
output_dir = "$root_gen_dir/chromeos"
}
......@@ -304,13 +304,16 @@
"chromeos/components/media_app_ui/resources/mock/media_app_bundle_mock_resources.grd": {
"includes": [2580],
},
"chromeos/components/sample_system_web_app_ui/resources/sample_system_web_app_resources.grd": {
"chromeos/components/print_management/resources/print_management_resources.grd": {
"META": {"join": 2},
"includes": [2600],
},
"chromeos/resources/chromeos_resources.grd": {
"chromeos/components/sample_system_web_app_ui/resources/sample_system_web_app_resources.grd": {
"includes": [2620],
},
"chromeos/resources/chromeos_resources.grd": {
"includes": [2640],
},
# END chromeos/ section.
# START components/ section.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment