mirror of
https://github.com/electron/electron.git
synced 2026-05-02 03:00:22 -04:00
* chore: bump chromium in DEPS to 95.0.4620.0
* chore: update patches
* 3076261: Move args_ to private in ExtensionFunction
https://chromium-review.googlesource.com/c/chromium/src/+/3076261
* [GURL -> SiteForCookies] content/public/browser/content_browser_client.h
https://chromium-review.googlesource.com/c/chromium/src/+/3107759
* chore: fix -Wunreachable-code-return in node
* Tracing to diagnose ContentScriptTracker-related bad message reports
https://chromium-review.googlesource.com/c/chromium/src/+/3057922
* chore: bump chromium in DEPS to 95.0.4621.0
* chore: update patches
* Remove title from the URL format on Windows.
https://chromium-review.googlesource.com/c/chromium/src/+/3108445
* chore: bump chromium in DEPS to 95.0.4623.0
* Revert "chore: disable v8 oilpan"
This reverts commit 5d255cf1d8e8efbb906047937a713279e5f800d0.
(cherry picked from commit ba5cde4da2)
* Change file paths in network context params to be relative.
https://chromium-review.googlesource.com/c/chromium/src/+/3092927
* Code Health: Rename/replace content::WebUI::RegisterMessageCallback().
https://chromium-review.googlesource.com/c/chromium/src/+/3104691
* Migrate CanExecuteContentScriptSync to Mojo
https://chromium-review.googlesource.com/c/chromium/src/+/3108452
* chore: update patches
* remove unreachable code
* Revert "Revert "chore: disable v8 oilpan""
This reverts commit fef495c0294e21760df51bddb5f7bf1ec9ed5f1e.
* fixup mas patch
* Reland "[include] Split out v8.h"
https://chromium-review.googlesource.com/c/v8/v8/+/3113629
* chore: bump chromium in DEPS to 95.0.4624.0
* chore: bump chromium in DEPS to 95.0.4625.0
* chore: bump chromium in DEPS to 95.0.4626.0
* 3033504: Pass NavigationDownloadPolicy in CreateNewWindowParams
https://chromium-review.googlesource.com/c/chromium/src/+/3033504
* 3058038: Introduce TestPrintingContext & test UpdatePrintSettings
https://chromium-review.googlesource.com/c/chromium/src/+/3058038
* 3114943: [Conditional Focus][#4] Add tests and remove flag gating
https://chromium-review.googlesource.com/c/chromium/src/+/3114943
* chore: update patch indices
* chore: bump chromium in DEPS to 95.0.4627.0
* chore: update patches
* 3093591: ozone: webpagepopups: calculate anchor for menu bounds. 4/*
https://chromium-review.googlesource.com/c/chromium/src/+/3093591
* 3110414: [PA] Remove the leading cookie
https://chromium-review.googlesource.com/c/chromium/src/+/3110414
* chore: update patches
* 3076261: Move args_ to private in ExtensionFunction
https://chromium-review.googlesource.com/c/chromium/src/+/3076261
* 3113629: Reland "[include] Split out v8.h"
https://chromium-review.googlesource.com/c/v8/v8/+/3113629
* chore: bump chromium in DEPS to 95.0.4628.0
* chore: update patches
* chore: bump chromium in DEPS to 95.0.4629.0
* chore: update patches
* Fix chrome root store codegen for cross-compile builds.
https://chromium-review.googlesource.com/c/chromium/src/+/3133701
Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com>
Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>
Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com>
Co-authored-by: deepak1556 <hop2deep@gmail.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
110 lines
3.8 KiB
C++
110 lines
3.8 KiB
C++
// Copyright 2015 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 "shell/browser/extensions/api/resources_private/resources_private_api.h"
|
|
|
|
#include <memory>
|
|
#include <string>
|
|
#include <utility>
|
|
|
|
#include "base/values.h"
|
|
#include "chrome/browser/browser_process.h"
|
|
#include "chrome/common/extensions/api/resources_private.h"
|
|
#include "chrome/grit/generated_resources.h"
|
|
#include "components/strings/grit/components_strings.h"
|
|
#include "components/zoom/page_zoom_constants.h"
|
|
#include "pdf/buildflags.h"
|
|
#include "printing/buildflags/buildflags.h"
|
|
#include "ui/base/l10n/l10n_util.h"
|
|
#include "ui/base/webui/web_ui_util.h"
|
|
|
|
#if BUILDFLAG(ENABLE_PDF)
|
|
#include "pdf/pdf_features.h"
|
|
#endif // BUILDFLAG(ENABLE_PDF)
|
|
|
|
// To add a new component to this API, simply:
|
|
// 1. Add your component to the Component enum in
|
|
// chrome/common/extensions/api/resources_private.idl
|
|
// 2. Create an AddStringsForMyComponent(base::DictionaryValue * dict) method.
|
|
// 3. Tie in that method to the switch statement in Run()
|
|
|
|
namespace extensions {
|
|
|
|
namespace {
|
|
|
|
void AddStringsForPdf(base::DictionaryValue* dict) {
|
|
#if BUILDFLAG(ENABLE_PDF)
|
|
static constexpr webui::LocalizedString kPdfResources[] = {
|
|
{"passwordDialogTitle", IDS_PDF_PASSWORD_DIALOG_TITLE},
|
|
{"passwordPrompt", IDS_PDF_NEED_PASSWORD},
|
|
{"passwordSubmit", IDS_PDF_PASSWORD_SUBMIT},
|
|
{"thumbnailPageAriaLabel", IDS_PDF_THUMBNAIL_PAGE_ARIA_LABEL},
|
|
{"passwordInvalid", IDS_PDF_PASSWORD_INVALID},
|
|
{"pageLoading", IDS_PDF_PAGE_LOADING},
|
|
{"pageLoadFailed", IDS_PDF_PAGE_LOAD_FAILED},
|
|
{"errorDialogTitle", IDS_PDF_ERROR_DIALOG_TITLE},
|
|
{"pageReload", IDS_PDF_PAGE_RELOAD_BUTTON},
|
|
{"bookmarks", IDS_PDF_BOOKMARKS},
|
|
{"labelPageNumber", IDS_PDF_LABEL_PAGE_NUMBER},
|
|
{"tooltipRotateCW", IDS_PDF_TOOLTIP_ROTATE_CW},
|
|
{"tooltipDownload", IDS_PDF_TOOLTIP_DOWNLOAD},
|
|
{"tooltipPrint", IDS_PDF_TOOLTIP_PRINT},
|
|
{"tooltipFitToPage", IDS_PDF_TOOLTIP_FIT_PAGE},
|
|
{"tooltipFitToWidth", IDS_PDF_TOOLTIP_FIT_WIDTH},
|
|
{"tooltipZoomIn", IDS_PDF_TOOLTIP_ZOOM_IN},
|
|
{"tooltipZoomOut", IDS_PDF_TOOLTIP_ZOOM_OUT},
|
|
};
|
|
for (const auto& resource : kPdfResources)
|
|
dict->SetString(resource.name, l10n_util::GetStringUTF16(resource.id));
|
|
|
|
dict->SetString("presetZoomFactors", zoom::GetPresetZoomFactorsAsJSON());
|
|
#endif // BUILDFLAG(ENABLE_PDF)
|
|
}
|
|
|
|
void AddAdditionalDataForPdf(base::DictionaryValue* dict) {
|
|
#if BUILDFLAG(ENABLE_PDF)
|
|
dict->SetKey("pdfAnnotationsEnabled", base::Value(false));
|
|
dict->SetKey("printingEnabled", base::Value(true));
|
|
#endif // BUILDFLAG(ENABLE_PDF)
|
|
}
|
|
|
|
} // namespace
|
|
|
|
namespace get_strings = api::resources_private::GetStrings;
|
|
|
|
ResourcesPrivateGetStringsFunction::ResourcesPrivateGetStringsFunction() =
|
|
default;
|
|
|
|
ResourcesPrivateGetStringsFunction::~ResourcesPrivateGetStringsFunction() =
|
|
default;
|
|
|
|
ExtensionFunction::ResponseAction ResourcesPrivateGetStringsFunction::Run() {
|
|
std::unique_ptr<get_strings::Params> params(
|
|
get_strings::Params::Create(args()));
|
|
auto dict = std::make_unique<base::DictionaryValue>();
|
|
|
|
api::resources_private::Component component = params->component;
|
|
|
|
switch (component) {
|
|
case api::resources_private::COMPONENT_PDF:
|
|
AddStringsForPdf(dict.get());
|
|
AddAdditionalDataForPdf(dict.get());
|
|
break;
|
|
case api::resources_private::COMPONENT_IDENTITY:
|
|
NOTREACHED();
|
|
break;
|
|
case api::resources_private::COMPONENT_NONE:
|
|
NOTREACHED();
|
|
break;
|
|
}
|
|
|
|
const std::string& app_locale = g_browser_process->GetApplicationLocale();
|
|
webui::SetLoadTimeDataDefaults(app_locale, dict.get());
|
|
|
|
return RespondNow(
|
|
OneArgument(base::Value::FromUniquePtrValue(std::move(dict))));
|
|
}
|
|
|
|
} // namespace extensions
|