1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef CHROME_COMMON_CHROME_CONTENT_CLIENT_H_ 6 #define CHROME_COMMON_CHROME_CONTENT_CLIENT_H_ 7 8 #include <memory> 9 #include <set> 10 #include <string> 11 #include <vector> 12 13 #include "base/compiler_specific.h" 14 #include "base/files/file_path.h" 15 #include "base/synchronization/lock.h" 16 #include "build/build_config.h" 17 #include "chrome/common/buildflags.h" 18 #include "components/nacl/common/buildflags.h" 19 #include "content/public/common/content_client.h" 20 #include "pdf/buildflags.h" 21 #include "ppapi/buildflags/buildflags.h" 22 23 #if BUILDFLAG(ENABLE_PLUGINS) 24 #include "content/public/common/pepper_plugin_info.h" 25 #endif 26 27 namespace embedder_support { 28 class OriginTrialPolicyImpl; 29 } 30 31 class ChromeContentClient : public content::ContentClient { 32 public: 33 #if defined(GOOGLE_CHROME_BUILD) 34 // |kNotPresent| is a placeholder plugin location for plugins that are not 35 // currently present in this installation of Chrome, but which can be fetched 36 // on-demand and therefore should still appear in navigator.plugins. 37 static const base::FilePath::CharType kNotPresent[]; 38 #endif 39 40 #if BUILDFLAG(ENABLE_NACL) 41 static const base::FilePath::CharType kNaClPluginFileName[]; 42 #endif 43 44 static const char kPDFExtensionPluginName[]; 45 static const char kPDFInternalPluginName[]; 46 static const base::FilePath::CharType kPDFPluginPath[]; 47 48 ChromeContentClient(); 49 ~ChromeContentClient() override; 50 51 // The methods below are called by child processes to set the function 52 // pointers for built-in plugins. We avoid linking these plugins into 53 // chrome_common because then on Windows we would ship them twice because of 54 // the split DLL. 55 #if BUILDFLAG(ENABLE_NACL) 56 static void SetNaClEntryFunctions( 57 content::PepperPluginInfo::GetInterfaceFunc get_interface, 58 content::PepperPluginInfo::PPP_InitializeModuleFunc initialize_module, 59 content::PepperPluginInfo::PPP_ShutdownModuleFunc shutdown_module); 60 #endif 61 62 #if BUILDFLAG(ENABLE_PLUGINS) && BUILDFLAG(ENABLE_PDF) 63 static void SetPDFEntryFunctions( 64 content::PepperPluginInfo::GetInterfaceFunc get_interface, 65 content::PepperPluginInfo::PPP_InitializeModuleFunc initialize_module, 66 content::PepperPluginInfo::PPP_ShutdownModuleFunc shutdown_module); 67 #endif 68 69 #if BUILDFLAG(ENABLE_PLUGINS) 70 // This returns the most recent plugin based on the plugin versions. In the 71 // event of a tie, a debug plugin will be considered more recent than a 72 // non-debug plugin. 73 // It does not make sense to call this on a vector that contains more than one 74 // plugin type. This function may return a nullptr if given an empty vector. 75 // The method is only visible for testing purposes. 76 static content::PepperPluginInfo* FindMostRecentPlugin( 77 const std::vector<std::unique_ptr<content::PepperPluginInfo>>& plugins); 78 #endif 79 80 void SetActiveURL(const GURL& url, std::string top_origin) override; 81 void SetGpuInfo(const gpu::GPUInfo& gpu_info) override; 82 void AddPepperPlugins( 83 std::vector<content::PepperPluginInfo>* plugins) override; 84 void AddContentDecryptionModules( 85 std::vector<content::CdmInfo>* cdms, 86 std::vector<media::CdmHostFilePath>* cdm_host_file_paths) override; 87 void AddAdditionalSchemes(Schemes* schemes) override; 88 base::string16 GetLocalizedString(int message_id) override; 89 base::string16 GetLocalizedString(int message_id, 90 const base::string16& replacement) override; 91 base::StringPiece GetDataResource(int resource_id, 92 ui::ScaleFactor scale_factor) override; 93 base::RefCountedMemory* GetDataResourceBytes(int resource_id) override; 94 gfx::Image& GetNativeImageNamed(int resource_id) override; 95 std::string GetProcessTypeNameInEnglish(int type) override; 96 blink::OriginTrialPolicy* GetOriginTrialPolicy() override; 97 #if defined(OS_ANDROID) 98 media::MediaDrmBridgeClient* GetMediaDrmBridgeClient() override; 99 #endif // OS_ANDROID 100 void ExposeInterfacesToBrowser( 101 scoped_refptr<base::SequencedTaskRunner> io_task_runner, 102 mojo::BinderMap* binders) override; 103 104 private: 105 // Used to lock when |origin_trial_policy_| is initialized. 106 base::Lock origin_trial_policy_lock_; 107 std::unique_ptr<embedder_support::OriginTrialPolicyImpl> origin_trial_policy_; 108 }; 109 110 #endif // CHROME_COMMON_CHROME_CONTENT_CLIENT_H_ 111