* chore: bump chromium in DEPS to 133.0.6836.0 * chore: bump chromium in DEPS to 133.0.6838.0 * chore: update patches * 6006096: [Sync ESB] Integrate Chrome Toast UI https://chromium-review.googlesource.com/c/chromium/src/+/6006096 * Confine enable_device_bound_sessions buildflag to //net https://chromium-review.googlesource.com/c/chromium/src/+/6014679 * revert [api] Delete deprecated struct FastApiTypedArray https://chromium-review.googlesource.com/c/v8/v8/+/5982984 Also https://chromium-review.googlesource.com/c/v8/v8/+/5979766/1 * fixup revert [api] Delete deprecated struct FastApiTypedArray * Migrate remaining NOTREACHED()s in chrome/ https://chromium-review.googlesource.com/c/chromium/src/+/5998172 * [Reland][Extensions] Remove ExtensionHostDelegate::GetJavaScriptDialogManager() https://chromium-review.googlesource.com/c/chromium/src/+/6020106 * Remove NOTREACHED_IN_MIGRATION() https://chromium-review.googlesource.com/c/chromium/src/+/6021996 * Remove Lock screen apps [#8] : remove lock screen extension https://chromium-review.googlesource.com/c/chromium/src/+/6005846 * Reland "Add CrashReporterClient::GetProductInfo(ProductInfo*)" https://chromium-review.googlesource.com/c/chromium/src/+/6012631 * Ozone/Wayland: remove lacros specific window states https://chromium-review.googlesource.com/c/chromium/src/+/6011215 * chore: bump chromium in DEPS to 133.0.6840.0 * chore: bump chromium in DEPS to 133.0.6841.0 * chore: bump chromium in DEPS to 133.0.6844.0 * implement virtual WebContents::CanUserEnterFullscreen * OnSearchifyStateChange -> OnSearchifyStarted * regen libc++ filenames * chore: bump chromium in DEPS to 133.0.6846.0 * chore: update patches --------- 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: Samuel Maddock <smaddock@slack-corp.com>
		
			
				
	
	
		
			84 lines
		
	
	
	
		
			3.1 KiB
			
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			84 lines
		
	
	
	
		
			3.1 KiB
			
		
	
	
	
		
			C++
		
	
	
	
	
	
// Copyright (c) 2015 Slack Technologies, Inc.
 | 
						|
// Use of this source code is governed by the MIT license that can be
 | 
						|
// found in the LICENSE file.
 | 
						|
 | 
						|
#include "shell/browser/electron_pdf_document_helper_client.h"
 | 
						|
 | 
						|
#include "chrome/browser/pdf/pdf_viewer_stream_manager.h"
 | 
						|
#include "chrome/common/content_restriction.h"
 | 
						|
#include "components/pdf/browser/pdf_frame_util.h"
 | 
						|
#include "content/public/browser/render_frame_host.h"
 | 
						|
#include "content/public/browser/web_contents.h"
 | 
						|
#include "extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest.h"
 | 
						|
#include "pdf/content_restriction.h"
 | 
						|
#include "pdf/pdf_features.h"
 | 
						|
#include "shell/browser/api/electron_api_web_contents.h"
 | 
						|
 | 
						|
ElectronPDFDocumentHelperClient::ElectronPDFDocumentHelperClient() = default;
 | 
						|
ElectronPDFDocumentHelperClient::~ElectronPDFDocumentHelperClient() = default;
 | 
						|
 | 
						|
void ElectronPDFDocumentHelperClient::UpdateContentRestrictions(
 | 
						|
    content::RenderFrameHost* render_frame_host,
 | 
						|
    int content_restrictions) {
 | 
						|
  // UpdateContentRestrictions potentially gets called twice from
 | 
						|
  // pdf/pdf_view_web_plugin.cc. The first time it is potentially called is
 | 
						|
  // when loading starts and it is called with a restriction on printing. The
 | 
						|
  // second time it is called is when loading is finished and if printing is
 | 
						|
  // allowed there won't be a printing restriction passed, so we can use this
 | 
						|
  // second call to notify that the pdf document is ready to print.
 | 
						|
  if (!(content_restrictions & chrome_pdf::kContentRestrictionPrint)) {
 | 
						|
    // It's a WebView - emit the event on the WebView webContents.
 | 
						|
    auto* guest_view = extensions::MimeHandlerViewGuest::FromRenderFrameHost(
 | 
						|
        render_frame_host);
 | 
						|
    if (guest_view) {
 | 
						|
      auto* gv_api_wc =
 | 
						|
          electron::api::WebContents::From(guest_view->embedder_web_contents());
 | 
						|
      if (gv_api_wc)
 | 
						|
        gv_api_wc->PDFReadyToPrint();
 | 
						|
      return;
 | 
						|
    }
 | 
						|
 | 
						|
    auto* wc = content::WebContents::FromRenderFrameHost(render_frame_host);
 | 
						|
    if (wc) {
 | 
						|
      auto* api_wc =
 | 
						|
          electron::api::WebContents::From(wc->GetOuterWebContents());
 | 
						|
      if (api_wc)
 | 
						|
        api_wc->PDFReadyToPrint();
 | 
						|
    }
 | 
						|
  }
 | 
						|
}
 | 
						|
 | 
						|
void ElectronPDFDocumentHelperClient::SetPluginCanSave(
 | 
						|
    content::RenderFrameHost* render_frame_host,
 | 
						|
    bool can_save) {
 | 
						|
  if (chrome_pdf::features::IsOopifPdfEnabled()) {
 | 
						|
    auto* pdf_viewer_stream_manager =
 | 
						|
        pdf::PdfViewerStreamManager::FromWebContents(
 | 
						|
            content::WebContents::FromRenderFrameHost(render_frame_host));
 | 
						|
    if (!pdf_viewer_stream_manager) {
 | 
						|
      return;
 | 
						|
    }
 | 
						|
 | 
						|
    content::RenderFrameHost* embedder_host =
 | 
						|
        pdf_frame_util::GetEmbedderHost(render_frame_host);
 | 
						|
    CHECK(embedder_host);
 | 
						|
 | 
						|
    pdf_viewer_stream_manager->SetPluginCanSave(embedder_host, can_save);
 | 
						|
    return;
 | 
						|
  }
 | 
						|
 | 
						|
  auto* guest_view =
 | 
						|
      extensions::MimeHandlerViewGuest::FromRenderFrameHost(render_frame_host);
 | 
						|
  if (guest_view) {
 | 
						|
    guest_view->SetPluginCanSave(can_save);
 | 
						|
  }
 | 
						|
}
 | 
						|
 | 
						|
#if BUILDFLAG(ENABLE_SCREEN_AI_SERVICE)
 | 
						|
void ElectronPDFDocumentHelperClient::OnSearchifyStarted(
 | 
						|
    content::WebContents* contents) {
 | 
						|
  // TODO(crbug.com/360803943): Add test.
 | 
						|
  // Show the promo only when ScreenAI component is available and OCR can be
 | 
						|
  // done.
 | 
						|
}
 | 
						|
#endif
 |