Commit 14a93834 authored by Jimmy Gong's avatar Jimmy Gong Committed by Commit Bot

Launch print management app from settings

- Launching the app is behind a feature flag.

Screenshot of changes: https://screenshot.googleplex.com/oaYDOJUKfNt

Bug: 1053704
Change-Id: I54e764e846e0fda7671908f24f732e83de14cfea
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2194855
Commit-Queue: jimmy gong <jimmyxgong@chromium.org>
Reviewed-by: default avatarTom Sepez <tsepez@chromium.org>
Reviewed-by: default avatarKyle Horimoto <khorimoto@chromium.org>
Reviewed-by: default avatarLei Zhang <thestig@chromium.org>
Reviewed-by: default avatarBailey Berro <baileyberro@chromium.org>
Cr-Commit-Position: refs/heads/master@{#768948}
parent f863bba1
...@@ -847,6 +847,15 @@ ...@@ -847,6 +847,15 @@
<message name="IDS_OS_SETTINGS_TAG_PRINTING_SAVED_PRINTERS" desc="Text for search result item which, when clicked, navigates the user to printer settings, with the option to edit saved printers."> <message name="IDS_OS_SETTINGS_TAG_PRINTING_SAVED_PRINTERS" desc="Text for search result item which, when clicked, navigates the user to printer settings, with the option to edit saved printers.">
Saved printers Saved printers
</message> </message>
<message name="IDS_OS_SETTINGS_TAG_PRINT_MANAGEMENT" desc="text for search result item which, when clicked, naviagets the user to the printing section to open the print jobs app. alternate phrase for: 'Print Management', 'Print History'">
Print jobs
</message>
<message name="IDS_OS_SETTINGS_TAG_PRINT_MANAGEMENT_ALT1" desc="text for search result item which, when clicked, naviagets the user to the printing section to open the print jobs app. alternate phrase for: 'Print Jobs', 'Print History'">
Print management
</message>
<message name="IDS_OS_SETTINGS_TAG_PRINT_MANAGEMENT_ALT2" desc="text for search result item which, when clicked, naviagets the user to the printing section to open the print jobs app. alternate phrase for: 'Print Management', 'Print Jobs'">
Print history
</message>
<!-- Accessibility section. --> <!-- Accessibility section. -->
<message name="IDS_OS_SETTINGS_TAG_A11Y" desc="Text for search result item which, when clicked, navigates the user to accessibility (a.k.a. a11y) settings. Alternate phrase for: 'A11y'"> <message name="IDS_OS_SETTINGS_TAG_A11Y" desc="Text for search result item which, when clicked, navigates the user to accessibility (a.k.a. a11y) settings. Alternate phrase for: 'A11y'">
......
...@@ -1602,6 +1602,12 @@ ...@@ -1602,6 +1602,12 @@
<message name="IDS_SETTINGS_PRINTING_CUPS_PRINT_SERVER_REACHABLE_BUT_CANNOT_ADD" desc="Message shown on the print server dialog when we are able to reach the print server but still ran into some error with adding the print server."> <message name="IDS_SETTINGS_PRINTING_CUPS_PRINT_SERVER_REACHABLE_BUT_CANNOT_ADD" desc="Message shown on the print server dialog when we are able to reach the print server but still ran into some error with adding the print server.">
Couldn't add the print server. Please check the server's configuration and try again. Couldn't add the print server. Please check the server's configuration and try again.
</message> </message>
<message name="IDS_SETTINGS_PRINTING_PRINT_JOBS_LAUNCH_APP_TITLE_LABEL" desc="Label for launching the print management app from the os settings page.">
Print jobs
</message>
<message name="IDS_SETTINGS_PRINTING_PRINT_JOBS_LAUNCH_APP_SUBLABEL" desc="Sub-label that describes that the print management app lets users view and manage their print jobs.">
View and manage print jobs
</message>
<!-- Internet page (OS settings) --> <!-- Internet page (OS settings) -->
<message name="IDS_SETTINGS_INTERNET_ADD_CONNECTION" desc="Settings > Internet > Add connection expanding section label."> <message name="IDS_SETTINGS_INTERNET_ADD_CONNECTION" desc="Settings > Internet > Add connection expanding section label.">
......
0207fbde915813b8cb0702f7f6418ff2b8df16e7
\ No newline at end of file
0207fbde915813b8cb0702f7f6418ff2b8df16e7
\ No newline at end of file
...@@ -212,6 +212,11 @@ cr.define('settings', function() { ...@@ -212,6 +212,11 @@ cr.define('settings', function() {
* @return {!Promise<!CupsPrintersList>} * @return {!Promise<!CupsPrintersList>}
*/ */
queryPrintServer(serverUrl) {} queryPrintServer(serverUrl) {}
/**
* Opens the print management app in its own window.
*/
openPrintManagementApp() {}
} }
/** /**
...@@ -297,6 +302,11 @@ cr.define('settings', function() { ...@@ -297,6 +302,11 @@ cr.define('settings', function() {
queryPrintServer(serverUrl) { queryPrintServer(serverUrl) {
return cr.sendWithPromise('queryPrintServer', serverUrl); return cr.sendWithPromise('queryPrintServer', serverUrl);
} }
/** @override */
openPrintManagementApp() {
chrome.send('openPrintManagementApp');
}
} }
cr.addSingletonGetter(CupsPrintersBrowserProxyImpl); cr.addSingletonGetter(CupsPrintersBrowserProxyImpl);
......
<link rel="import" href="chrome://resources/html/polymer.html"> <link rel="import" href="chrome://resources/html/polymer.html">
<link rel="import" href="chrome://resources/js/assert.js">
<link rel="import" href="chrome://resources/html/load_time_data.html"> <link rel="import" href="chrome://resources/html/load_time_data.html">
<link rel="import" href="../os_route.html"> <link rel="import" href="../os_route.html">
<link rel="import" href="../../router.html"> <link rel="import" href="../../router.html">
<link rel="import" href="../../settings_page/settings_animated_pages.html"> <link rel="import" href="../../settings_page/settings_animated_pages.html">
<link rel="import" href="../../settings_page/settings_subpage.html"> <link rel="import" href="../../settings_page/settings_subpage.html">
<link rel="import" href="../../settings_shared_css.html"> <link rel="import" href="../../settings_shared_css.html">
<link rel="import" href="cups_printers_browser_proxy.html">
<link rel="import" href="cups_printers.html"> <link rel="import" href="cups_printers.html">
<dom-module id="os-settings-printing-page"> <dom-module id="os-settings-printing-page">
...@@ -18,6 +20,14 @@ ...@@ -18,6 +20,14 @@
on-click="onTapCupsPrinters_" on-click="onTapCupsPrinters_"
role-description="$i18n{subpageArrowRoleDescription}"> role-description="$i18n{subpageArrowRoleDescription}">
</cr-link-row> </cr-link-row>
<template is="dom-if" if="[[isPrintManagementEnabled_]]">
<cr-link-row class="hr" id="printManagement"
on-click="onOpenPrintManagement_"
label="$i18n{printJobsTitle}"
sub-label="$i18n{printJobsSublabel}"
external>
</cr-link-row>
</template>
</div> </div>
<template is="dom-if" route-path="/cupsPrinters"> <template is="dom-if" route-path="/cupsPrinters">
<settings-subpage <settings-subpage
......
...@@ -28,10 +28,24 @@ Polymer({ ...@@ -28,10 +28,24 @@ Polymer({
return map; return map;
}, },
}, },
isPrintManagementEnabled_: {
type: Boolean,
value: function() {
return loadTimeData.getBoolean('printManagementEnabled');
}
},
}, },
/** @private */ /** @private */
onTapCupsPrinters_() { onTapCupsPrinters_() {
settings.Router.getInstance().navigateTo(settings.routes.CUPS_PRINTERS); settings.Router.getInstance().navigateTo(settings.routes.CUPS_PRINTERS);
}, },
/** @private */
onOpenPrintManagement_() {
assert(this.isPrintManagementEnabled_);
settings.CupsPrintersBrowserProxyImpl.getInstance()
.openPrintManagementApp();
}
}); });
...@@ -39,12 +39,14 @@ ...@@ -39,12 +39,14 @@
#include "chrome/browser/ui/scoped_tabbed_browser_displayer.h" #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h"
#include "chrome/browser/ui/singleton_tabs.h" #include "chrome/browser/ui/singleton_tabs.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h" #include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/browser/ui/web_applications/system_web_app_ui_utils.h"
#include "chrome/browser/ui/webui/bookmarks/bookmarks_ui.h" #include "chrome/browser/ui/webui/bookmarks/bookmarks_ui.h"
#include "chrome/browser/ui/webui/settings/site_settings_helper.h" #include "chrome/browser/ui/webui/settings/site_settings_helper.h"
#include "chrome/browser/web_applications/components/app_registrar.h" #include "chrome/browser/web_applications/components/app_registrar.h"
#include "chrome/browser/web_applications/components/web_app_constants.h" #include "chrome/browser/web_applications/components/web_app_constants.h"
#include "chrome/browser/web_applications/components/web_app_id.h" #include "chrome/browser/web_applications/components/web_app_id.h"
#include "chrome/browser/web_applications/components/web_app_provider_base.h" #include "chrome/browser/web_applications/components/web_app_provider_base.h"
#include "chrome/browser/web_applications/system_web_app_manager.h"
#include "chrome/common/channel_info.h" #include "chrome/common/channel_info.h"
#include "chrome/common/chrome_features.h" #include "chrome/common/chrome_features.h"
#include "chrome/common/chrome_switches.h" #include "chrome/common/chrome_switches.h"
...@@ -498,6 +500,13 @@ void ShowAppManagementPage(Profile* profile, ...@@ -498,6 +500,13 @@ void ShowAppManagementPage(Profile* profile,
sub_page); sub_page);
} }
void ShowPrintManagementApp(Profile* profile) {
DCHECK(
base::FeatureList::IsEnabled(chromeos::features::kPrintJobManagementApp));
LaunchSystemWebApp(profile, web_app::SystemAppType::PRINT_MANAGEMENT,
GURL(chrome::kChromeUIPrintManagementUrl));
}
GURL GetOSSettingsUrl(const std::string& sub_page) { GURL GetOSSettingsUrl(const std::string& sub_page) {
DCHECK(sub_page.empty() || chromeos::settings::IsOSSettingsSubPage(sub_page)) DCHECK(sub_page.empty() || chromeos::settings::IsOSSettingsSubPage(sub_page))
<< sub_page; << sub_page;
......
...@@ -142,6 +142,8 @@ GURL GetOSSettingsUrl(const std::string& sub_page); ...@@ -142,6 +142,8 @@ GURL GetOSSettingsUrl(const std::string& sub_page);
void ShowAppManagementPage(Profile* profile, void ShowAppManagementPage(Profile* profile,
const std::string& app_id, const std::string& app_id,
AppManagementEntryPoint entry_point); AppManagementEntryPoint entry_point);
void ShowPrintManagementApp(Profile* profile);
#endif #endif
#if !defined(OS_ANDROID) && !defined(OS_CHROMEOS) #if !defined(OS_ANDROID) && !defined(OS_CHROMEOS)
......
...@@ -148,6 +148,7 @@ enum Setting { ...@@ -148,6 +148,7 @@ enum Setting {
// Printing section. // Printing section.
kAddPrinter = 1400, kAddPrinter = 1400,
kSavedPrinters = 1401, kSavedPrinters = 1401,
kPrintJobs = 1402,
// Accessibility section. // Accessibility section.
kA11yQuickSettings = 1500, kA11yQuickSettings = 1500,
......
...@@ -37,10 +37,12 @@ ...@@ -37,10 +37,12 @@
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser_finder.h" #include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/browser_window.h" #include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/chrome_pages.h"
#include "chrome/browser/ui/chrome_select_file_policy.h" #include "chrome/browser/ui/chrome_select_file_policy.h"
#include "chrome/browser/ui/webui/settings/chromeos/server_printer_url_util.h" #include "chrome/browser/ui/webui/settings/chromeos/server_printer_url_util.h"
#include "chrome/common/chrome_paths.h" #include "chrome/common/chrome_paths.h"
#include "chrome/common/pref_names.h" #include "chrome/common/pref_names.h"
#include "chromeos/constants/chromeos_features.h"
#include "chromeos/dbus/dbus_thread_manager.h" #include "chromeos/dbus/dbus_thread_manager.h"
#include "chromeos/dbus/debug_daemon/debug_daemon_client.h" #include "chromeos/dbus/debug_daemon/debug_daemon_client.h"
#include "chromeos/printing/ppd_line_reader.h" #include "chromeos/printing/ppd_line_reader.h"
...@@ -361,6 +363,13 @@ void CupsPrintersHandler::RegisterMessages() { ...@@ -361,6 +363,13 @@ void CupsPrintersHandler::RegisterMessages() {
"queryPrintServer", "queryPrintServer",
base::BindRepeating(&CupsPrintersHandler::HandleQueryPrintServer, base::BindRepeating(&CupsPrintersHandler::HandleQueryPrintServer,
base::Unretained(this))); base::Unretained(this)));
if (base::FeatureList::IsEnabled(
chromeos::features::kPrintJobManagementApp)) {
web_ui()->RegisterMessageCallback(
"openPrintManagementApp",
base::BindRepeating(&CupsPrintersHandler::HandleOpenPrintManagementApp,
base::Unretained(this)));
}
} }
void CupsPrintersHandler::OnJavascriptAllowed() { void CupsPrintersHandler::OnJavascriptAllowed() {
...@@ -1314,5 +1323,13 @@ void CupsPrintersHandler::OnQueryPrintServerCompleted( ...@@ -1314,5 +1323,13 @@ void CupsPrintersHandler::OnQueryPrintServerCompleted(
ResolveJavascriptCallback(base::Value(callback_id), result_dict); ResolveJavascriptCallback(base::Value(callback_id), result_dict);
} }
void CupsPrintersHandler::HandleOpenPrintManagementApp(
const base::ListValue* args) {
DCHECK(args->empty());
DCHECK(
base::FeatureList::IsEnabled(chromeos::features::kPrintJobManagementApp));
chrome::ShowPrintManagementApp(profile_);
}
} // namespace settings } // namespace settings
} // namespace chromeos } // namespace chromeos
...@@ -233,6 +233,8 @@ class CupsPrintersHandler : public ::settings::SettingsPageUIHandler, ...@@ -233,6 +233,8 @@ class CupsPrintersHandler : public ::settings::SettingsPageUIHandler,
const GURL& server_url, const GURL& server_url,
std::vector<PrinterDetector::DetectedPrinter>&& returned_printers); std::vector<PrinterDetector::DetectedPrinter>&& returned_printers);
void HandleOpenPrintManagementApp(const base::ListValue* args);
Profile* profile_; Profile* profile_;
// Discovery support. discovery_active_ tracks whether or not the UI // Discovery support. discovery_active_ tracks whether or not the UI
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "chrome/common/chrome_features.h" #include "chrome/common/chrome_features.h"
#include "chrome/common/url_constants.h" #include "chrome/common/url_constants.h"
#include "chrome/grit/generated_resources.h" #include "chrome/grit/generated_resources.h"
#include "chromeos/constants/chromeos_features.h"
#include "content/public/browser/web_ui_data_source.h" #include "content/public/browser/web_ui_data_source.h"
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
#include "ui/base/webui/web_ui_util.h" #include "ui/base/webui/web_ui_util.h"
...@@ -49,6 +50,25 @@ const std::vector<SearchConcept>& GetPrintingSearchConcepts() { ...@@ -49,6 +50,25 @@ const std::vector<SearchConcept>& GetPrintingSearchConcepts() {
return *tags; return *tags;
} }
const std::vector<SearchConcept>& GetPrintingManagementSearchConcepts() {
static const base::NoDestructor<std::vector<SearchConcept>> tags({
{IDS_OS_SETTINGS_TAG_PRINT_MANAGEMENT,
mojom::kPrintingSectionPath,
mojom::SearchResultIcon::kPrinter,
mojom::SearchResultDefaultRank::kMedium,
mojom::SearchResultType::kSetting,
{.setting = mojom::Setting::kPrintJobs},
{IDS_OS_SETTINGS_TAG_PRINT_MANAGEMENT_ALT1,
IDS_OS_SETTINGS_TAG_PRINT_MANAGEMENT_ALT2, SearchConcept::kAltTagEnd}},
});
return *tags;
}
bool IsPrintManagementEnabled() {
return base::FeatureList::IsEnabled(
chromeos::features::kPrintJobManagementApp);
}
} // namespace } // namespace
PrintingSection::PrintingSection(Profile* profile, PrintingSection::PrintingSection(Profile* profile,
...@@ -57,6 +77,8 @@ PrintingSection::PrintingSection(Profile* profile, ...@@ -57,6 +77,8 @@ PrintingSection::PrintingSection(Profile* profile,
: OsSettingsSection(profile, search_tag_registry), : OsSettingsSection(profile, search_tag_registry),
printers_manager_(printers_manager) { printers_manager_(printers_manager) {
registry()->AddSearchTags(GetPrintingSearchConcepts()); registry()->AddSearchTags(GetPrintingSearchConcepts());
if (IsPrintManagementEnabled())
registry()->AddSearchTags(GetPrintingManagementSearchConcepts());
} }
PrintingSection::~PrintingSection() = default; PrintingSection::~PrintingSection() = default;
...@@ -77,6 +99,10 @@ void PrintingSection::AddLoadTimeData(content::WebUIDataSource* html_source) { ...@@ -77,6 +99,10 @@ void PrintingSection::AddLoadTimeData(content::WebUIDataSource* html_source) {
{"savePrinterAria", IDS_SETTINGS_PRINTING_CUPS_PRINTER_SAVE_BUTTON_ARIA}, {"savePrinterAria", IDS_SETTINGS_PRINTING_CUPS_PRINTER_SAVE_BUTTON_ARIA},
{"searchLabel", IDS_SETTINGS_PRINTING_CUPS_SEARCH_LABEL}, {"searchLabel", IDS_SETTINGS_PRINTING_CUPS_SEARCH_LABEL},
{"noSearchResults", IDS_SEARCH_NO_RESULTS}, {"noSearchResults", IDS_SEARCH_NO_RESULTS},
{"printJobsTitle",
IDS_SETTINGS_PRINTING_PRINT_JOBS_LAUNCH_APP_TITLE_LABEL},
{"printJobsSublabel",
IDS_SETTINGS_PRINTING_PRINT_JOBS_LAUNCH_APP_SUBLABEL},
{"printerDetailsTitle", IDS_SETTINGS_PRINTING_CUPS_PRINTER_DETAILS_TITLE}, {"printerDetailsTitle", IDS_SETTINGS_PRINTING_CUPS_PRINTER_DETAILS_TITLE},
{"printerName", IDS_SETTINGS_PRINTING_CUPS_PRINTER_DETAILS_NAME}, {"printerName", IDS_SETTINGS_PRINTING_CUPS_PRINTER_DETAILS_NAME},
{"printerModel", IDS_SETTINGS_PRINTING_CUPS_PRINTER_DETAILS_MODEL}, {"printerModel", IDS_SETTINGS_PRINTING_CUPS_PRINTER_DETAILS_MODEL},
...@@ -212,6 +238,7 @@ void PrintingSection::AddLoadTimeData(content::WebUIDataSource* html_source) { ...@@ -212,6 +238,7 @@ void PrintingSection::AddLoadTimeData(content::WebUIDataSource* html_source) {
html_source->AddBoolean( html_source->AddBoolean(
"consumerPrintServerUiEnabled", "consumerPrintServerUiEnabled",
base::FeatureList::IsEnabled(::features::kPrintServerUi)); base::FeatureList::IsEnabled(::features::kPrintServerUi));
html_source->AddBoolean("printManagementEnabled", IsPrintManagementEnabled());
} }
void PrintingSection::AddHandlers(content::WebUI* web_ui) { void PrintingSection::AddHandlers(content::WebUI* web_ui) {
......
...@@ -254,6 +254,7 @@ const char kChromeUIOobeHost[] = "oobe"; ...@@ -254,6 +254,7 @@ const char kChromeUIOobeHost[] = "oobe";
const char kChromeUIOobeURL[] = "chrome://oobe/"; const char kChromeUIOobeURL[] = "chrome://oobe/";
const char kChromeUIPasswordChangeHost[] = "password-change"; const char kChromeUIPasswordChangeHost[] = "password-change";
const char kChromeUIPasswordChangeUrl[] = "chrome://password-change"; const char kChromeUIPasswordChangeUrl[] = "chrome://password-change";
const char kChromeUIPrintManagementUrl[] = "chrome://print-management";
const char kChromeUIPowerHost[] = "power"; const char kChromeUIPowerHost[] = "power";
const char kChromeUIScreenlockIconHost[] = "screenlock-icon"; const char kChromeUIScreenlockIconHost[] = "screenlock-icon";
const char kChromeUIScreenlockIconURL[] = "chrome://screenlock-icon/"; const char kChromeUIScreenlockIconURL[] = "chrome://screenlock-icon/";
......
...@@ -254,6 +254,7 @@ extern const char kChromeUIOobeHost[]; ...@@ -254,6 +254,7 @@ extern const char kChromeUIOobeHost[];
extern const char kChromeUIOobeURL[]; extern const char kChromeUIOobeURL[];
extern const char kChromeUIPasswordChangeHost[]; extern const char kChromeUIPasswordChangeHost[];
extern const char kChromeUIPasswordChangeUrl[]; extern const char kChromeUIPasswordChangeUrl[];
extern const char kChromeUIPrintManagementUrl[];
extern const char kChromeUIPowerHost[]; extern const char kChromeUIPowerHost[];
extern const char kChromeUIScreenlockIconHost[]; extern const char kChromeUIScreenlockIconHost[];
extern const char kChromeUIScreenlockIconURL[]; extern const char kChromeUIScreenlockIconURL[];
......
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