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"
|
|
|
|
|
|
|
|
#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"
|
2012-05-18 17:04:56 +02:00
|
|
|
#include "ui/base/resource/resource_bundle.h"
|
2015-08-26 00:33:31 +02:00
|
|
|
#include "url/url_util.h"
|
2012-04-03 03:34:16 +02:00
|
|
|
|
2012-05-18 17:04:56 +02:00
|
|
|
class CefContentClient : public content::ContentClient,
|
|
|
|
public ui::ResourceBundle::Delegate {
|
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;
|
2014-11-12 20:25:15 +01:00
|
|
|
void AddAdditionalSchemes(
|
2015-08-26 00:33:31 +02:00
|
|
|
std::vector<url::SchemeWithType>* standard_schemes,
|
2014-11-12 20:25:15 +01:00
|
|
|
std::vector<std::string>* savable_schemes) override;
|
|
|
|
std::string GetUserAgent() const override;
|
|
|
|
base::string16 GetLocalizedString(int message_id) const override;
|
|
|
|
base::StringPiece GetDataResource(
|
2012-05-31 17:19:33 +02:00
|
|
|
int resource_id,
|
2014-11-12 20:25:15 +01:00
|
|
|
ui::ScaleFactor scale_factor) const override;
|
|
|
|
gfx::Image& GetNativeImageNamed(int resource_id) const override;
|
2012-04-03 03:34:16 +02:00
|
|
|
|
2013-06-05 01:37:26 +02:00
|
|
|
struct SchemeInfo {
|
|
|
|
std::string scheme_name;
|
2015-08-14 16:41:08 +02:00
|
|
|
|
|
|
|
// Registers a non-HTTP URL scheme which can be sent CORS requests.
|
2013-06-05 01:37:26 +02:00
|
|
|
bool is_standard;
|
2015-08-14 16:41:08 +02:00
|
|
|
|
|
|
|
// Registers a URL scheme that can be saved to disk.
|
2015-07-16 23:40:01 +02:00
|
|
|
bool is_savable;
|
2015-08-14 16:41:08 +02:00
|
|
|
|
|
|
|
// Registers a URL scheme to be treated as a local scheme (i.e., with the
|
|
|
|
// same security rules as those applied to "file" URLs). This means that
|
|
|
|
// 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
|
|
|
|
|
|
|
// Registers a URL scheme to be treated as display-isolated. This means
|
|
|
|
// that pages cannot display these URLs unless they are from the same
|
|
|
|
// scheme. For example, pages in other origin cannot create iframes or
|
|
|
|
// hyperlinks to URLs with the scheme. For schemes that must be accessible
|
|
|
|
// from other schemes set this value to false and use CORS
|
|
|
|
// "Access-Control-Allow-Origin" headers to further restrict access.
|
2013-06-05 01:37:26 +02:00
|
|
|
bool is_display_isolated;
|
|
|
|
};
|
|
|
|
typedef std::list<SchemeInfo> SchemeInfoList;
|
|
|
|
|
|
|
|
// Custom scheme registration.
|
|
|
|
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; }
|
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);
|
|
|
|
|
2012-04-03 03:34:16 +02:00
|
|
|
private:
|
2012-05-18 17:04:56 +02:00
|
|
|
// ui::ResourceBundle::Delegate methods.
|
2014-11-12 20:25:15 +01:00
|
|
|
base::FilePath GetPathForResourcePack(
|
2013-02-23 01:43:28 +01:00
|
|
|
const base::FilePath& pack_path,
|
2014-11-12 20:25:15 +01:00
|
|
|
ui::ScaleFactor scale_factor) override;
|
|
|
|
base::FilePath GetPathForLocalePack(
|
2013-02-23 01:43:28 +01:00
|
|
|
const base::FilePath& pack_path,
|
2014-11-12 20:25:15 +01:00
|
|
|
const std::string& locale) override;
|
|
|
|
gfx::Image GetImageNamed(int resource_id) override;
|
2016-02-05 01:49:19 +01:00
|
|
|
gfx::Image GetNativeImageNamed(int resource_id) override;
|
2014-11-12 20:25:15 +01:00
|
|
|
base::RefCountedStaticMemory* LoadDataResourceBytes(
|
2012-05-31 17:19:33 +02:00
|
|
|
int resource_id,
|
2014-11-12 20:25:15 +01:00
|
|
|
ui::ScaleFactor scale_factor) override;
|
|
|
|
bool GetRawDataResource(int resource_id,
|
|
|
|
ui::ScaleFactor scale_factor,
|
|
|
|
base::StringPiece* value) override;
|
|
|
|
bool GetLocalizedString(int message_id,
|
|
|
|
base::string16* value) override;
|
|
|
|
scoped_ptr<gfx::Font> GetFont(
|
|
|
|
ui::ResourceBundle::FontStyle style) override;
|
2012-05-18 17:04:56 +02:00
|
|
|
|
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_;
|
2015-08-26 00:33:31 +02:00
|
|
|
|
|
|
|
std::vector<std::string> standard_schemes_;
|
2012-04-03 03:34:16 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // CEF_LIBCEF_COMMON_CONTENT_CLIENT_H_
|