Home | History | Annotate | Download | only in shell
      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 CONTENT_SHELL_SHELL_CONTENT_BROWSER_CLIENT_H_
      6 #define CONTENT_SHELL_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 "base/platform_file.h"
     14 #include "content/public/browser/content_browser_client.h"
     15 #include "content/public/browser/notification_observer.h"
     16 #include "content/public/browser/notification_registrar.h"
     17 
     18 namespace content {
     19 
     20 class ShellBrowserContext;
     21 class ShellBrowserMainParts;
     22 class ShellResourceDispatcherHostDelegate;
     23 
     24 class ShellContentBrowserClient : public ContentBrowserClient,
     25                                   public NotificationObserver {
     26  public:
     27   // Gets the current instance.
     28   static ShellContentBrowserClient* Get();
     29 
     30   static void SetSwapProcessesForRedirect(bool swap);
     31 
     32   ShellContentBrowserClient();
     33   virtual ~ShellContentBrowserClient();
     34 
     35   // ContentBrowserClient overrides.
     36   virtual BrowserMainParts* CreateBrowserMainParts(
     37       const MainFunctionParams& parameters) OVERRIDE;
     38   virtual void RenderProcessHostCreated(RenderProcessHost* host) OVERRIDE;
     39   virtual net::URLRequestContextGetter* CreateRequestContext(
     40       BrowserContext* browser_context,
     41       ProtocolHandlerMap* protocol_handlers) OVERRIDE;
     42   virtual net::URLRequestContextGetter* CreateRequestContextForStoragePartition(
     43       BrowserContext* browser_context,
     44       const base::FilePath& partition_path,
     45       bool in_memory,
     46       ProtocolHandlerMap* protocol_handlers) OVERRIDE;
     47   virtual bool IsHandledURL(const GURL& url) OVERRIDE;
     48   virtual void AppendExtraCommandLineSwitches(CommandLine* command_line,
     49                                               int child_process_id) OVERRIDE;
     50   virtual void OverrideWebkitPrefs(RenderViewHost* render_view_host,
     51                                    const GURL& url,
     52                                    WebPreferences* prefs) OVERRIDE;
     53   virtual void ResourceDispatcherHostCreated() OVERRIDE;
     54   virtual AccessTokenStore* CreateAccessTokenStore() OVERRIDE;
     55   virtual std::string GetDefaultDownloadName() OVERRIDE;
     56   virtual bool SupportsBrowserPlugin(content::BrowserContext* browser_context,
     57                                      const GURL& url) OVERRIDE;
     58   virtual WebContentsViewDelegate* GetWebContentsViewDelegate(
     59       WebContents* web_contents) OVERRIDE;
     60   virtual QuotaPermissionContext* CreateQuotaPermissionContext() OVERRIDE;
     61   virtual net::NetLog* GetNetLog() OVERRIDE;
     62   virtual bool ShouldSwapProcessesForRedirect(ResourceContext* resource_context,
     63                                               const GURL& current_url,
     64                                               const GURL& new_url) OVERRIDE;
     65 
     66 #if defined(OS_ANDROID)
     67   virtual void GetAdditionalMappedFilesForChildProcess(
     68       const CommandLine& command_line,
     69       int child_process_id,
     70       std::vector<content::FileDescriptorInfo>* mappings) OVERRIDE;
     71 #endif
     72 
     73   // NotificationObserver implementation.
     74   virtual void Observe(int type,
     75                        const NotificationSource& source,
     76                        const NotificationDetails& details) OVERRIDE;
     77 
     78   ShellBrowserContext* browser_context();
     79   ShellBrowserContext* off_the_record_browser_context();
     80   ShellResourceDispatcherHostDelegate* resource_dispatcher_host_delegate() {
     81     return resource_dispatcher_host_delegate_.get();
     82   }
     83   ShellBrowserMainParts* shell_browser_main_parts() {
     84     return shell_browser_main_parts_;
     85   }
     86 
     87  private:
     88   ShellBrowserContext* ShellBrowserContextForBrowserContext(
     89       BrowserContext* content_browser_context);
     90 
     91   scoped_ptr<ShellResourceDispatcherHostDelegate>
     92       resource_dispatcher_host_delegate_;
     93 
     94   base::FilePath webkit_source_dir_;
     95 
     96   ShellBrowserMainParts* shell_browser_main_parts_;
     97 
     98   NotificationRegistrar registrar_;
     99 };
    100 
    101 }  // namespace content
    102 
    103 #endif  // CONTENT_SHELL_SHELL_CONTENT_BROWSER_CLIENT_H_
    104