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