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 APPS_SHELL_BROWSER_SHELL_CONTENT_BROWSER_CLIENT_H_ 6 #define APPS_SHELL_BROWSER_SHELL_CONTENT_BROWSER_CLIENT_H_ 7 8 #include "base/compiler_specific.h" 9 #include "content/public/browser/content_browser_client.h" 10 11 class GURL; 12 13 namespace content { 14 class BrowserContext; 15 } 16 17 namespace extensions { 18 class Extension; 19 } 20 21 namespace apps { 22 class ShellBrowserMainDelegate; 23 class ShellBrowserMainParts; 24 25 // Content module browser process support for app_shell. 26 class ShellContentBrowserClient : public content::ContentBrowserClient { 27 public: 28 explicit ShellContentBrowserClient( 29 ShellBrowserMainDelegate* browser_main_delegate); 30 virtual ~ShellContentBrowserClient(); 31 32 // Returns the single instance. 33 static ShellContentBrowserClient* Get(); 34 35 // Returns the single browser context for app_shell. 36 content::BrowserContext* GetBrowserContext(); 37 38 // content::ContentBrowserClient overrides. 39 virtual content::BrowserMainParts* CreateBrowserMainParts( 40 const content::MainFunctionParams& parameters) OVERRIDE; 41 virtual void RenderProcessWillLaunch( 42 content::RenderProcessHost* host) OVERRIDE; 43 virtual bool ShouldUseProcessPerSite(content::BrowserContext* browser_context, 44 const GURL& effective_url) OVERRIDE; 45 virtual net::URLRequestContextGetter* CreateRequestContext( 46 content::BrowserContext* browser_context, 47 content::ProtocolHandlerMap* protocol_handlers, 48 content::URLRequestInterceptorScopedVector request_interceptors) OVERRIDE; 49 // TODO(jamescook): Quota management? 50 // TODO(jamescook): Speech recognition? 51 virtual bool IsHandledURL(const GURL& url) OVERRIDE; 52 virtual void SiteInstanceGotProcess(content::SiteInstance* site_instance) 53 OVERRIDE; 54 virtual void SiteInstanceDeleting(content::SiteInstance* site_instance) 55 OVERRIDE; 56 virtual void AppendExtraCommandLineSwitches(base::CommandLine* command_line, 57 int child_process_id) OVERRIDE; 58 virtual void GetAdditionalAllowedSchemesForFileSystem( 59 std::vector<std::string>* additional_schemes) OVERRIDE; 60 61 private: 62 // Returns the extension or app associated with |site_instance| or NULL. 63 const extensions::Extension* GetExtension( 64 content::SiteInstance* site_instance); 65 66 // Owned by content::BrowserMainLoop. 67 ShellBrowserMainParts* browser_main_parts_; 68 69 // Owned by ShellBrowserMainParts. 70 ShellBrowserMainDelegate* browser_main_delegate_; 71 72 DISALLOW_COPY_AND_ASSIGN(ShellContentBrowserClient); 73 }; 74 75 } // namespace apps 76 77 #endif // APPS_SHELL_BROWSER_SHELL_CONTENT_BROWSER_CLIENT_H_ 78