1 // Copyright 2013 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 CONTENT_SHELL_BROWSER_SHELL_CONTENT_BROWSER_CLIENT_H_ 6 #define CONTENT_SHELL_BROWSER_SHELL_CONTENT_BROWSER_CLIENT_H_ 7 8 #include <string> 9 10 #include "base/compiler_specific.h" 11 #include "base/files/file_path.h" 12 #include "base/memory/scoped_ptr.h" 13 #include "content/public/browser/content_browser_client.h" 14 #include "content/shell/browser/shell_speech_recognition_manager_delegate.h" 15 16 namespace content { 17 18 class ShellBrowserContext; 19 class ShellBrowserMainParts; 20 class ShellResourceDispatcherHostDelegate; 21 22 class ShellContentBrowserClient : public ContentBrowserClient { 23 public: 24 // Gets the current instance. 25 static ShellContentBrowserClient* Get(); 26 27 static void SetSwapProcessesForRedirect(bool swap); 28 29 ShellContentBrowserClient(); 30 virtual ~ShellContentBrowserClient(); 31 32 // ContentBrowserClient overrides. 33 virtual BrowserMainParts* CreateBrowserMainParts( 34 const MainFunctionParams& parameters) OVERRIDE; 35 virtual void RenderProcessWillLaunch(RenderProcessHost* host) OVERRIDE; 36 virtual net::URLRequestContextGetter* CreateRequestContext( 37 BrowserContext* browser_context, 38 ProtocolHandlerMap* protocol_handlers, 39 URLRequestInterceptorScopedVector request_interceptors) OVERRIDE; 40 virtual net::URLRequestContextGetter* CreateRequestContextForStoragePartition( 41 BrowserContext* browser_context, 42 const base::FilePath& partition_path, 43 bool in_memory, 44 ProtocolHandlerMap* protocol_handlers, 45 URLRequestInterceptorScopedVector request_interceptors) OVERRIDE; 46 virtual bool IsHandledURL(const GURL& url) OVERRIDE; 47 virtual void AppendExtraCommandLineSwitches(base::CommandLine* command_line, 48 int child_process_id) OVERRIDE; 49 virtual void OverrideWebkitPrefs(RenderViewHost* render_view_host, 50 const GURL& url, 51 WebPreferences* prefs) OVERRIDE; 52 virtual void ResourceDispatcherHostCreated() OVERRIDE; 53 virtual AccessTokenStore* CreateAccessTokenStore() OVERRIDE; 54 virtual std::string GetDefaultDownloadName() OVERRIDE; 55 virtual WebContentsViewDelegate* GetWebContentsViewDelegate( 56 WebContents* web_contents) OVERRIDE; 57 virtual QuotaPermissionContext* CreateQuotaPermissionContext() OVERRIDE; 58 virtual SpeechRecognitionManagerDelegate* 59 GetSpeechRecognitionManagerDelegate() OVERRIDE; 60 virtual net::NetLog* GetNetLog() OVERRIDE; 61 virtual bool ShouldSwapProcessesForRedirect(ResourceContext* resource_context, 62 const GURL& current_url, 63 const GURL& new_url) OVERRIDE; 64 65 #if defined(OS_POSIX) && !defined(OS_MACOSX) 66 virtual void GetAdditionalMappedFilesForChildProcess( 67 const base::CommandLine& command_line, 68 int child_process_id, 69 std::vector<FileDescriptorInfo>* mappings) OVERRIDE; 70 #endif 71 #if defined(OS_WIN) 72 virtual void PreSpawnRenderer(sandbox::TargetPolicy* policy, 73 bool* success) OVERRIDE; 74 #endif 75 76 ShellBrowserContext* browser_context(); 77 ShellBrowserContext* off_the_record_browser_context(); 78 ShellResourceDispatcherHostDelegate* resource_dispatcher_host_delegate() { 79 return resource_dispatcher_host_delegate_.get(); 80 } 81 ShellBrowserMainParts* shell_browser_main_parts() { 82 return shell_browser_main_parts_; 83 } 84 85 private: 86 ShellBrowserContext* ShellBrowserContextForBrowserContext( 87 BrowserContext* content_browser_context); 88 89 scoped_ptr<ShellResourceDispatcherHostDelegate> 90 resource_dispatcher_host_delegate_; 91 92 base::FilePath webkit_source_dir_; 93 94 ShellBrowserMainParts* shell_browser_main_parts_; 95 }; 96 97 } // namespace content 98 99 #endif // CONTENT_SHELL_BROWSER_SHELL_CONTENT_BROWSER_CLIENT_H_ 100