2015-07-16 23:40:01 +02:00
|
|
|
// Copyright 2015 The Chromium Embedded Framework Authors.
|
|
|
|
// Portions copyright 2014 The Chromium Authors. All rights reserved.
|
2012-04-03 03:34:16 +02:00
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
|
|
|
#ifndef CEF_LIBCEF_COMMON_CONTENT_CLIENT_H_
|
|
|
|
#define CEF_LIBCEF_COMMON_CONTENT_CLIENT_H_
|
|
|
|
#pragma once
|
|
|
|
|
2013-06-05 01:37:26 +02:00
|
|
|
#include <list>
|
2012-04-03 03:34:16 +02:00
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include "include/cef_app.h"
|
2019-09-04 17:13:32 +02:00
|
|
|
#include "libcef/common/resource_bundle_delegate.h"
|
2012-04-03 03:34:16 +02:00
|
|
|
|
|
|
|
#include "base/compiler_specific.h"
|
|
|
|
#include "content/public/common/content_client.h"
|
2015-07-16 23:40:01 +02:00
|
|
|
#include "content/public/common/pepper_plugin_info.h"
|
2015-08-26 00:33:31 +02:00
|
|
|
#include "url/url_util.h"
|
2012-04-03 03:34:16 +02:00
|
|
|
|
2019-09-04 17:13:32 +02:00
|
|
|
class CefContentClient : public content::ContentClient {
|
2012-04-03 03:34:16 +02:00
|
|
|
public:
|
2015-07-16 23:40:01 +02:00
|
|
|
static const char kPDFPluginPath[];
|
|
|
|
|
2012-04-03 03:34:16 +02:00
|
|
|
explicit CefContentClient(CefRefPtr<CefApp> application);
|
2014-11-12 20:25:15 +01:00
|
|
|
~CefContentClient() override;
|
2012-04-03 03:34:16 +02:00
|
|
|
|
|
|
|
// Returns the singleton CefContentClient instance.
|
|
|
|
static CefContentClient* Get();
|
|
|
|
|
2012-05-18 17:04:56 +02:00
|
|
|
// content::ContentClient methods.
|
2015-03-25 22:22:47 +01:00
|
|
|
void AddPepperPlugins(
|
|
|
|
std::vector<content::PepperPluginInfo>* plugins) override;
|
2018-04-19 17:44:42 +02:00
|
|
|
void AddContentDecryptionModules(
|
|
|
|
std::vector<content::CdmInfo>* cdms,
|
|
|
|
std::vector<media::CdmHostFilePath>* cdm_host_file_paths) override;
|
2017-01-23 18:36:54 +01:00
|
|
|
void AddAdditionalSchemes(Schemes* schemes) override;
|
2019-09-04 17:13:32 +02:00
|
|
|
base::string16 GetLocalizedString(int message_id) override;
|
|
|
|
base::string16 GetLocalizedString(int message_id,
|
|
|
|
const base::string16& replacement) override;
|
|
|
|
base::StringPiece GetDataResource(int resource_id,
|
|
|
|
ui::ScaleFactor scale_factor) override;
|
|
|
|
base::RefCountedMemory* GetDataResourceBytes(int resource_id) override;
|
|
|
|
gfx::Image& GetNativeImageNamed(int resource_id) override;
|
2012-04-03 03:34:16 +02:00
|
|
|
|
2017-01-23 18:36:54 +01:00
|
|
|
// Values are registered with all processes (url/url_util.h) and with Blink
|
|
|
|
// (SchemeRegistry) unless otherwise indicated.
|
2013-06-05 01:37:26 +02:00
|
|
|
struct SchemeInfo {
|
2017-01-23 18:36:54 +01:00
|
|
|
// Lower-case ASCII scheme name.
|
2013-06-05 01:37:26 +02:00
|
|
|
std::string scheme_name;
|
2015-08-14 16:41:08 +02:00
|
|
|
|
2017-01-23 18:36:54 +01:00
|
|
|
// A scheme that is subject to URL canonicalization and parsing rules as
|
|
|
|
// defined in the Common Internet Scheme Syntax RFC 1738 Section 3.1
|
|
|
|
// available at http://www.ietf.org/rfc/rfc1738.txt.
|
|
|
|
// This value is not registered with Blink.
|
2013-06-05 01:37:26 +02:00
|
|
|
bool is_standard;
|
2015-08-14 16:41:08 +02:00
|
|
|
|
2017-01-23 18:36:54 +01:00
|
|
|
// A scheme that will be treated the same as "file". For example, normal
|
|
|
|
// pages cannot link to or access URLs of this scheme.
|
2013-06-05 01:37:26 +02:00
|
|
|
bool is_local;
|
2015-08-14 16:41:08 +02:00
|
|
|
|
2017-01-23 18:36:54 +01:00
|
|
|
// A scheme that can only be displayed from other content hosted with the
|
|
|
|
// same scheme. For example, pages in other origins cannot create iframes or
|
2015-08-14 16:41:08 +02:00
|
|
|
// hyperlinks to URLs with the scheme. For schemes that must be accessible
|
2017-01-23 18:36:54 +01:00
|
|
|
// from other schemes set this value to false, set |is_cors_enabled| to
|
|
|
|
// true, and use CORS "Access-Control-Allow-Origin" headers to further
|
|
|
|
// restrict access.
|
|
|
|
// This value is registered with Blink only.
|
2013-06-05 01:37:26 +02:00
|
|
|
bool is_display_isolated;
|
2017-05-17 11:29:28 +02:00
|
|
|
|
2017-01-23 18:36:54 +01:00
|
|
|
// A scheme that will be treated the same as "https". For example, loading
|
|
|
|
// this scheme from other secure schemes will not trigger mixed content
|
|
|
|
// warnings.
|
|
|
|
bool is_secure;
|
|
|
|
|
|
|
|
// A scheme that can be sent CORS requests. This value should be true in
|
|
|
|
// most cases where |is_standard| is true.
|
|
|
|
bool is_cors_enabled;
|
2017-03-03 23:37:23 +01:00
|
|
|
|
|
|
|
// A scheme that can bypass Content-Security-Policy (CSP) checks. This value
|
|
|
|
// should be false in most cases where |is_standard| is true.
|
|
|
|
bool is_csp_bypassing;
|
2019-02-04 23:31:31 +01:00
|
|
|
|
|
|
|
// A scheme that can perform fetch request.
|
|
|
|
bool is_fetch_enabled;
|
2013-06-05 01:37:26 +02:00
|
|
|
};
|
|
|
|
typedef std::list<SchemeInfo> SchemeInfoList;
|
|
|
|
|
2017-01-23 18:36:54 +01:00
|
|
|
// Custom scheme information will be registered first with all processes
|
|
|
|
// (url/url_util.h) via CefContentClient::AddAdditionalSchemes which calls
|
|
|
|
// AddCustomScheme, and second with Blink (SchemeRegistry) via
|
|
|
|
// CefContentRendererClient::WebKitInitialized which calls GetCustomSchemes.
|
2013-06-05 01:37:26 +02:00
|
|
|
void AddCustomScheme(const SchemeInfo& scheme_info);
|
|
|
|
const SchemeInfoList* GetCustomSchemes();
|
|
|
|
bool HasCustomScheme(const std::string& scheme_name);
|
|
|
|
|
2012-04-03 03:34:16 +02:00
|
|
|
CefRefPtr<CefApp> application() const { return application_; }
|
|
|
|
|
|
|
|
void set_pack_loading_disabled(bool val) { pack_loading_disabled_ = val; }
|
|
|
|
bool pack_loading_disabled() const { return pack_loading_disabled_; }
|
2012-05-18 17:04:56 +02:00
|
|
|
void set_allow_pack_file_load(bool val) { allow_pack_file_load_ = val; }
|
2019-09-04 17:13:32 +02:00
|
|
|
bool allow_pack_file_load() { return allow_pack_file_load_; }
|
2012-04-03 03:34:16 +02:00
|
|
|
|
2015-07-16 23:40:01 +02:00
|
|
|
static void SetPDFEntryFunctions(
|
|
|
|
content::PepperPluginInfo::GetInterfaceFunc get_interface,
|
|
|
|
content::PepperPluginInfo::PPP_InitializeModuleFunc initialize_module,
|
|
|
|
content::PepperPluginInfo::PPP_ShutdownModuleFunc shutdown_module);
|
|
|
|
|
2019-09-04 17:13:32 +02:00
|
|
|
CefResourceBundleDelegate* GetCefResourceBundleDelegate() {
|
|
|
|
return &resource_bundle_delegate_;
|
|
|
|
}
|
2012-05-18 17:04:56 +02:00
|
|
|
|
2019-09-04 17:13:32 +02:00
|
|
|
private:
|
2012-04-03 03:34:16 +02:00
|
|
|
CefRefPtr<CefApp> application_;
|
|
|
|
bool pack_loading_disabled_;
|
2012-05-18 17:04:56 +02:00
|
|
|
bool allow_pack_file_load_;
|
2013-06-05 01:37:26 +02:00
|
|
|
|
|
|
|
// Custom schemes handled by the client.
|
|
|
|
SchemeInfoList scheme_info_list_;
|
|
|
|
bool scheme_info_list_locked_;
|
2019-09-04 17:13:32 +02:00
|
|
|
|
|
|
|
CefResourceBundleDelegate resource_bundle_delegate_;
|
2012-04-03 03:34:16 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // CEF_LIBCEF_COMMON_CONTENT_CLIENT_H_
|