PageRenderTime 304ms CodeModel.GetById 28ms RepoModel.GetById 0ms app.codeStats 0ms

/content/public/browser/content_browser_client.cc

https://gitlab.com/jonnialva90/iridium-browser
C++ | 397 lines | 322 code | 67 blank | 8 comment | 0 complexity | d9de0e4c527081345c86b9cf87c845d3 MD5 | raw file
  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. #include "content/public/browser/content_browser_client.h"
  5. #include "base/files/file_path.h"
  6. #include "content/public/browser/client_certificate_delegate.h"
  7. #include "content/public/common/sandbox_type.h"
  8. #include "ui/gfx/image/image_skia.h"
  9. #include "url/gurl.h"
  10. namespace content {
  11. BrowserMainParts* ContentBrowserClient::CreateBrowserMainParts(
  12. const MainFunctionParams& parameters) {
  13. return nullptr;
  14. }
  15. void ContentBrowserClient::PostAfterStartupTask(
  16. const tracked_objects::Location& from_here,
  17. const scoped_refptr<base::TaskRunner>& task_runner,
  18. const base::Closure& task) {
  19. task_runner->PostTask(from_here, task);
  20. }
  21. WebContentsViewDelegate* ContentBrowserClient::GetWebContentsViewDelegate(
  22. WebContents* web_contents) {
  23. return nullptr;
  24. }
  25. GURL ContentBrowserClient::GetEffectiveURL(BrowserContext* browser_context,
  26. const GURL& url) {
  27. return url;
  28. }
  29. bool ContentBrowserClient::ShouldUseProcessPerSite(
  30. BrowserContext* browser_context, const GURL& effective_url) {
  31. return false;
  32. }
  33. bool ContentBrowserClient::ShouldLockToOrigin(BrowserContext* browser_context,
  34. const GURL& effective_url) {
  35. return true;
  36. }
  37. bool ContentBrowserClient::LogWebUIUrl(const GURL& web_ui_url) const {
  38. return false;
  39. }
  40. net::URLRequestContextGetter* ContentBrowserClient::CreateRequestContext(
  41. BrowserContext* browser_context,
  42. ProtocolHandlerMap* protocol_handlers,
  43. URLRequestInterceptorScopedVector request_interceptors) {
  44. return nullptr;
  45. }
  46. net::URLRequestContextGetter*
  47. ContentBrowserClient::CreateRequestContextForStoragePartition(
  48. BrowserContext* browser_context,
  49. const base::FilePath& partition_path,
  50. bool in_memory,
  51. ProtocolHandlerMap* protocol_handlers,
  52. URLRequestInterceptorScopedVector request_interceptors) {
  53. return nullptr;
  54. }
  55. bool ContentBrowserClient::IsHandledURL(const GURL& url) {
  56. return false;
  57. }
  58. bool ContentBrowserClient::CanCommitURL(RenderProcessHost* process_host,
  59. const GURL& site_url) {
  60. return true;
  61. }
  62. bool ContentBrowserClient::IsIllegalOrigin(ResourceContext* resource_context,
  63. int child_process_id,
  64. const GURL& origin) {
  65. return false;
  66. }
  67. bool ContentBrowserClient::ShouldAllowOpenURL(SiteInstance* site_instance,
  68. const GURL& url) {
  69. return true;
  70. }
  71. bool ContentBrowserClient::IsSuitableHost(RenderProcessHost* process_host,
  72. const GURL& site_url) {
  73. return true;
  74. }
  75. bool ContentBrowserClient::MayReuseHost(RenderProcessHost* process_host) {
  76. return true;
  77. }
  78. bool ContentBrowserClient::ShouldTryToUseExistingProcessHost(
  79. BrowserContext* browser_context, const GURL& url) {
  80. return false;
  81. }
  82. bool ContentBrowserClient::ShouldSwapBrowsingInstancesForNavigation(
  83. SiteInstance* site_instance,
  84. const GURL& current_url,
  85. const GURL& new_url) {
  86. return false;
  87. }
  88. bool ContentBrowserClient::ShouldSwapProcessesForRedirect(
  89. ResourceContext* resource_context, const GURL& current_url,
  90. const GURL& new_url) {
  91. return false;
  92. }
  93. bool ContentBrowserClient::ShouldAssignSiteForURL(const GURL& url) {
  94. return true;
  95. }
  96. std::string ContentBrowserClient::GetCanonicalEncodingNameByAliasName(
  97. const std::string& alias_name) {
  98. return std::string();
  99. }
  100. std::string ContentBrowserClient::GetApplicationLocale() {
  101. return "en-US";
  102. }
  103. std::string ContentBrowserClient::GetAcceptLangs(BrowserContext* context) {
  104. return std::string();
  105. }
  106. const gfx::ImageSkia* ContentBrowserClient::GetDefaultFavicon() {
  107. static gfx::ImageSkia* empty = new gfx::ImageSkia();
  108. return empty;
  109. }
  110. bool ContentBrowserClient::AllowAppCache(const GURL& manifest_url,
  111. const GURL& first_party,
  112. ResourceContext* context) {
  113. return true;
  114. }
  115. bool ContentBrowserClient::AllowServiceWorker(const GURL& scope,
  116. const GURL& document_url,
  117. content::ResourceContext* context,
  118. int render_process_id,
  119. int render_frame_id) {
  120. return true;
  121. }
  122. bool ContentBrowserClient::AllowGetCookie(const GURL& url,
  123. const GURL& first_party,
  124. const net::CookieList& cookie_list,
  125. ResourceContext* context,
  126. int render_process_id,
  127. int render_frame_id) {
  128. return true;
  129. }
  130. bool ContentBrowserClient::AllowSetCookie(const GURL& url,
  131. const GURL& first_party,
  132. const std::string& cookie_line,
  133. ResourceContext* context,
  134. int render_process_id,
  135. int render_frame_id,
  136. net::CookieOptions* options) {
  137. return true;
  138. }
  139. bool ContentBrowserClient::AllowSaveLocalState(ResourceContext* context) {
  140. return true;
  141. }
  142. bool ContentBrowserClient::AllowWorkerDatabase(
  143. const GURL& url,
  144. const base::string16& name,
  145. const base::string16& display_name,
  146. unsigned long estimated_size,
  147. ResourceContext* context,
  148. const std::vector<std::pair<int, int> >& render_frames) {
  149. return true;
  150. }
  151. void ContentBrowserClient::AllowWorkerFileSystem(
  152. const GURL& url,
  153. ResourceContext* context,
  154. const std::vector<std::pair<int, int> >& render_frames,
  155. base::Callback<void(bool)> callback) {
  156. callback.Run(true);
  157. }
  158. bool ContentBrowserClient::AllowWorkerIndexedDB(
  159. const GURL& url,
  160. const base::string16& name,
  161. ResourceContext* context,
  162. const std::vector<std::pair<int, int> >& render_frames) {
  163. return true;
  164. }
  165. #if defined(ENABLE_WEBRTC)
  166. bool ContentBrowserClient::AllowWebRTCIdentityCache(const GURL& url,
  167. const GURL& first_party_url,
  168. ResourceContext* context) {
  169. return true;
  170. }
  171. #endif // defined(ENABLE_WEBRTC)
  172. QuotaPermissionContext* ContentBrowserClient::CreateQuotaPermissionContext() {
  173. return nullptr;
  174. }
  175. void ContentBrowserClient::SelectClientCertificate(
  176. WebContents* web_contents,
  177. net::SSLCertRequestInfo* cert_request_info,
  178. scoped_ptr<ClientCertificateDelegate> delegate) {
  179. }
  180. net::URLRequestContext* ContentBrowserClient::OverrideRequestContextForURL(
  181. const GURL& url, ResourceContext* context) {
  182. return nullptr;
  183. }
  184. std::string ContentBrowserClient::GetStoragePartitionIdForSite(
  185. BrowserContext* browser_context,
  186. const GURL& site) {
  187. return std::string();
  188. }
  189. bool ContentBrowserClient::IsValidStoragePartitionId(
  190. BrowserContext* browser_context,
  191. const std::string& partition_id) {
  192. // Since the GetStoragePartitionIdForChildProcess() only generates empty
  193. // strings, we should only ever see empty strings coming back.
  194. return partition_id.empty();
  195. }
  196. void ContentBrowserClient::GetStoragePartitionConfigForSite(
  197. BrowserContext* browser_context,
  198. const GURL& site,
  199. bool can_be_default,
  200. std::string* partition_domain,
  201. std::string* partition_name,
  202. bool* in_memory) {
  203. partition_domain->clear();
  204. partition_name->clear();
  205. *in_memory = false;
  206. }
  207. MediaObserver* ContentBrowserClient::GetMediaObserver() {
  208. return nullptr;
  209. }
  210. PlatformNotificationService*
  211. ContentBrowserClient::GetPlatformNotificationService() {
  212. return nullptr;
  213. }
  214. bool ContentBrowserClient::CanCreateWindow(
  215. const GURL& opener_url,
  216. const GURL& opener_top_level_frame_url,
  217. const GURL& source_origin,
  218. WindowContainerType container_type,
  219. const GURL& target_url,
  220. const Referrer& referrer,
  221. WindowOpenDisposition disposition,
  222. const blink::WebWindowFeatures& features,
  223. bool user_gesture,
  224. bool opener_suppressed,
  225. ResourceContext* context,
  226. int render_process_id,
  227. int opener_render_view_id,
  228. int opener_render_frame_id,
  229. bool* no_javascript_access) {
  230. *no_javascript_access = false;
  231. return true;
  232. }
  233. SpeechRecognitionManagerDelegate*
  234. ContentBrowserClient::CreateSpeechRecognitionManagerDelegate() {
  235. return nullptr;
  236. }
  237. net::NetLog* ContentBrowserClient::GetNetLog() {
  238. return nullptr;
  239. }
  240. AccessTokenStore* ContentBrowserClient::CreateAccessTokenStore() {
  241. return nullptr;
  242. }
  243. bool ContentBrowserClient::IsFastShutdownPossible() {
  244. return true;
  245. }
  246. base::FilePath ContentBrowserClient::GetDefaultDownloadDirectory() {
  247. return base::FilePath();
  248. }
  249. std::string ContentBrowserClient::GetDefaultDownloadName() {
  250. return std::string();
  251. }
  252. base::FilePath ContentBrowserClient::GetShaderDiskCacheDirectory() {
  253. return base::FilePath();
  254. }
  255. BrowserPpapiHost*
  256. ContentBrowserClient::GetExternalBrowserPpapiHost(int plugin_process_id) {
  257. return nullptr;
  258. }
  259. bool ContentBrowserClient::AllowPepperSocketAPI(
  260. BrowserContext* browser_context,
  261. const GURL& url,
  262. bool private_api,
  263. const SocketPermissionRequest* params) {
  264. return false;
  265. }
  266. ui::SelectFilePolicy* ContentBrowserClient::CreateSelectFilePolicy(
  267. WebContents* web_contents) {
  268. return nullptr;
  269. }
  270. LocationProvider* ContentBrowserClient::OverrideSystemLocationProvider() {
  271. return nullptr;
  272. }
  273. DevToolsManagerDelegate* ContentBrowserClient::GetDevToolsManagerDelegate() {
  274. return nullptr;
  275. }
  276. TracingDelegate* ContentBrowserClient::GetTracingDelegate() {
  277. return nullptr;
  278. }
  279. bool ContentBrowserClient::IsNPAPIEnabled() {
  280. return false;
  281. }
  282. bool ContentBrowserClient::IsPluginAllowedToCallRequestOSFileHandle(
  283. BrowserContext* browser_context,
  284. const GURL& url) {
  285. return false;
  286. }
  287. bool ContentBrowserClient::IsPluginAllowedToUseDevChannelAPIs(
  288. BrowserContext* browser_context,
  289. const GURL& url) {
  290. return false;
  291. }
  292. PresentationServiceDelegate*
  293. ContentBrowserClient::GetPresentationServiceDelegate(
  294. WebContents* web_contents) {
  295. return nullptr;
  296. }
  297. void ContentBrowserClient::OpenURL(
  298. content::BrowserContext* browser_context,
  299. const content::OpenURLParams& params,
  300. const base::Callback<void(content::WebContents*)>& callback) {
  301. callback.Run(nullptr);
  302. }
  303. ScopedVector<NavigationThrottle>
  304. ContentBrowserClient::CreateThrottlesForNavigation(
  305. NavigationHandle* navigation_handle) {
  306. return ScopedVector<NavigationThrottle>();
  307. }
  308. #if defined(OS_WIN)
  309. const wchar_t* ContentBrowserClient::GetResourceDllName() {
  310. return nullptr;
  311. }
  312. base::string16 ContentBrowserClient::GetAppContainerSidForSandboxType(
  313. int sandbox_type) const {
  314. // Embedders should override this method and return different SIDs for each
  315. // sandbox type. Note: All content level tests will run child processes in the
  316. // same AppContainer.
  317. return base::string16(
  318. L"S-1-15-2-3251537155-1984446955-2931258699-841473695-1938553385-"
  319. L"924012148-129201922");
  320. }
  321. #endif
  322. #if defined(VIDEO_HOLE)
  323. ExternalVideoSurfaceContainer*
  324. ContentBrowserClient::OverrideCreateExternalVideoSurfaceContainer(
  325. WebContents* web_contents) {
  326. NOTREACHED() << "Hole-punching is not supported. See crbug.com/469348.";
  327. return nullptr;
  328. }
  329. #endif
  330. } // namespace content