forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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/+/2066878 Reviewed-by: James Cook <jamescook@chromium.org> Reviewed-by: Samuel Huang <huangs@chromium.org> Reviewed-by: calamity <calamity@chromium.org> Reviewed-by: Scott Violet <sky@chromium.org> Reviewed-by: Kyle Horimoto <khorimoto@chromium.org> Reviewed-by: Bailey Berro <baileyberro@chromium.org> Reviewed-by: Zentaro Kavanagh <zentaro@chromium.org> Commit-Queue: jimmy gong <jimmyxgong@chromium.org> Cr-Commit-Position: refs/heads/master@{#748293}
- Loading branch information
Jimmy Gong
authored and
Commit Bot
committed
Mar 9, 2020
1 parent
9a51776
commit 5209c65
Showing
22 changed files
with
323 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
chrome/test/data/webui/chromeos/print_management/print_management_browsertest.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// 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(); | ||
}); |
29 changes: 29 additions & 0 deletions
29
chrome/test/data/webui/chromeos/print_management/print_management_test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// 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); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# 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" ] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
include_rules = [ | ||
"-chrome", | ||
"+chromeos/grit/chromeos_print_management_resources.h", | ||
"+content/public/browser", | ||
"+ui/resources", | ||
"+ui/webui", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Primary OWNERS | ||
baileyberro@chromium.org | ||
jimmyxgong@chromium.org | ||
|
||
# Backup OWNERS | ||
khorimoto@chromium.org | ||
zentaro@chromium.org | ||
|
||
# COMPONENT: OS>Systems>Printing |
35 changes: 35 additions & 0 deletions
35
chromeos/components/print_management/print_management_ui.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// 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 |
24 changes: 24 additions & 0 deletions
24
chromeos/components/print_management/print_management_ui.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// 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_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# 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" ] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<!-- 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> |
1 change: 1 addition & 0 deletions
1
chromeos/components/print_management/resources/print_management.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<div id="header"></div> |
22 changes: 22 additions & 0 deletions
22
chromeos/components/print_management/resources/print_management.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// 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'; | ||
}, | ||
|
||
}); |
20 changes: 20 additions & 0 deletions
20
chromeos/components/print_management/resources/print_management_resources.grd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// 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_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.