Home | History | Annotate | Download | only in browser
      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 // This interface is for managing the global services of the application. Each
      6 // service is lazily created when requested the first time. The service getters
      7 // will return NULL if the service is not available, so callers must check for
      8 // this condition.
      9 
     10 #ifndef CHROME_BROWSER_BROWSER_PROCESS_H_
     11 #define CHROME_BROWSER_BROWSER_PROCESS_H_
     12 
     13 #include <string>
     14 
     15 #include "base/basictypes.h"
     16 #include "base/memory/scoped_ptr.h"
     17 #include "chrome/browser/browser_process_platform_part.h"
     18 #include "chrome/browser/ui/host_desktop.h"
     19 
     20 class AutomationProviderList;
     21 class BackgroundModeManager;
     22 class BookmarkPromptController;
     23 class ChromeNetLog;
     24 class CRLSetFetcher;
     25 class ComponentUpdateService;
     26 class DownloadRequestLimiter;
     27 class DownloadStatusUpdater;
     28 class GLStringManager;
     29 class GpuModeManager;
     30 class IconManager;
     31 class IntranetRedirectDetector;
     32 class IOThread;
     33 class MetricsService;
     34 class NotificationUIManager;
     35 class PnaclComponentInstaller;
     36 class PrefRegistrySimple;
     37 class PrefService;
     38 class Profile;
     39 class ProfileManager;
     40 class RenderWidgetSnapshotTaker;
     41 class SafeBrowsingService;
     42 class StatusTray;
     43 class WatchDogThread;
     44 #if defined(ENABLE_WEBRTC)
     45 class WebRtcLogUploader;
     46 #endif
     47 
     48 namespace chrome {
     49 class MediaFileSystemRegistry;
     50 class StorageMonitor;
     51 }
     52 
     53 namespace chrome_variations {
     54 class VariationsService;
     55 }
     56 
     57 namespace extensions {
     58 class EventRouterForwarder;
     59 }
     60 
     61 namespace message_center {
     62 class MessageCenter;
     63 }
     64 
     65 namespace net {
     66 class URLRequestContextGetter;
     67 }
     68 
     69 namespace policy {
     70 class BrowserPolicyConnector;
     71 class PolicyService;
     72 }
     73 
     74 namespace prerender {
     75 class PrerenderTracker;
     76 }
     77 
     78 namespace printing {
     79 class BackgroundPrintingManager;
     80 class PrintJobManager;
     81 class PrintPreviewDialogController;
     82 }
     83 
     84 namespace safe_browsing {
     85 class ClientSideDetectionService;
     86 }
     87 
     88 // NOT THREAD SAFE, call only from the main thread.
     89 // These functions shouldn't return NULL unless otherwise noted.
     90 class BrowserProcess {
     91  public:
     92   BrowserProcess();
     93   virtual ~BrowserProcess();
     94 
     95   // Called when the ResourceDispatcherHost object is created by content.
     96   virtual void ResourceDispatcherHostCreated() = 0;
     97 
     98   // Invoked when the user is logging out/shutting down. When logging off we may
     99   // not have enough time to do a normal shutdown. This method is invoked prior
    100   // to normal shutdown and saves any state that must be saved before we are
    101   // continue shutdown.
    102   virtual void EndSession() = 0;
    103 
    104   // Services: any of these getters may return NULL
    105   virtual MetricsService* metrics_service() = 0;
    106   virtual ProfileManager* profile_manager() = 0;
    107   virtual PrefService* local_state() = 0;
    108   virtual net::URLRequestContextGetter* system_request_context() = 0;
    109   virtual chrome_variations::VariationsService* variations_service() = 0;
    110 
    111   virtual BrowserProcessPlatformPart* platform_part() = 0;
    112 
    113   virtual extensions::EventRouterForwarder*
    114       extension_event_router_forwarder() = 0;
    115 
    116   // Returns the manager for desktop notifications.
    117   virtual NotificationUIManager* notification_ui_manager() = 0;
    118 
    119   // MessageCenter is a global list of currently displayed notifications.
    120   virtual message_center::MessageCenter* message_center() = 0;
    121 
    122   // Returns the state object for the thread that we perform I/O
    123   // coordination on (network requests, communication with renderers,
    124   // etc.
    125   //
    126   // Can be NULL close to startup and shutdown.
    127   //
    128   // NOTE: If you want to post a task to the IO thread, use
    129   // BrowserThread::PostTask (or other variants).
    130   virtual IOThread* io_thread() = 0;
    131 
    132   // Returns the thread that is used for health check of all browser threads.
    133   virtual WatchDogThread* watchdog_thread() = 0;
    134 
    135   // Starts and manages the policy system.
    136   virtual policy::BrowserPolicyConnector* browser_policy_connector() = 0;
    137 
    138   // This is the main interface for chromium components to retrieve policy
    139   // information from the policy system.
    140   virtual policy::PolicyService* policy_service() = 0;
    141 
    142   virtual IconManager* icon_manager() = 0;
    143 
    144   virtual GLStringManager* gl_string_manager() = 0;
    145 
    146   virtual GpuModeManager* gpu_mode_manager() = 0;
    147 
    148   virtual RenderWidgetSnapshotTaker* GetRenderWidgetSnapshotTaker() = 0;
    149 
    150   virtual AutomationProviderList* GetAutomationProviderList() = 0;
    151 
    152   virtual void CreateDevToolsHttpProtocolHandler(
    153       chrome::HostDesktopType host_desktop_type,
    154       const std::string& ip,
    155       int port,
    156       const std::string& frontend_url) = 0;
    157 
    158   virtual unsigned int AddRefModule() = 0;
    159   virtual unsigned int ReleaseModule() = 0;
    160 
    161   virtual bool IsShuttingDown() = 0;
    162 
    163   virtual printing::PrintJobManager* print_job_manager() = 0;
    164   virtual printing::PrintPreviewDialogController*
    165       print_preview_dialog_controller() = 0;
    166   virtual printing::BackgroundPrintingManager*
    167       background_printing_manager() = 0;
    168 
    169   virtual IntranetRedirectDetector* intranet_redirect_detector() = 0;
    170 
    171   // Returns the locale used by the application.
    172   virtual const std::string& GetApplicationLocale() = 0;
    173   virtual void SetApplicationLocale(const std::string& locale) = 0;
    174 
    175   virtual DownloadStatusUpdater* download_status_updater() = 0;
    176   virtual DownloadRequestLimiter* download_request_limiter() = 0;
    177 
    178   // Returns the object that manages background applications.
    179   virtual BackgroundModeManager* background_mode_manager() = 0;
    180   virtual void set_background_mode_manager_for_test(
    181       scoped_ptr<BackgroundModeManager> manager) = 0;
    182 
    183   // Returns the StatusTray, which provides an API for displaying status icons
    184   // in the system status tray. Returns NULL if status icons are not supported
    185   // on this platform (or this is a unit test).
    186   virtual StatusTray* status_tray() = 0;
    187 
    188   // Returns the SafeBrowsing service.
    189   virtual SafeBrowsingService* safe_browsing_service() = 0;
    190 
    191   // Returns an object which handles communication with the SafeBrowsing
    192   // client-side detection servers.
    193   virtual safe_browsing::ClientSideDetectionService*
    194       safe_browsing_detection_service() = 0;
    195 
    196 #if (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS)
    197   // This will start a timer that, if Chrome is in persistent mode, will check
    198   // whether an update is available, and if that's the case, restart the
    199   // browser. Note that restart code will strip some of the command line keys
    200   // and all loose values from the cl this instance of Chrome was launched with,
    201   // and add the command line key that will force Chrome to start in the
    202   // background mode. For the full list of "blacklisted" keys, refer to
    203   // |kSwitchesToRemoveOnAutorestart| array in browser_process_impl.cc.
    204   virtual void StartAutoupdateTimer() = 0;
    205 #endif
    206 
    207   virtual ChromeNetLog* net_log() = 0;
    208 
    209   virtual prerender::PrerenderTracker* prerender_tracker() = 0;
    210 
    211   virtual ComponentUpdateService* component_updater() = 0;
    212 
    213   virtual CRLSetFetcher* crl_set_fetcher() = 0;
    214 
    215   virtual PnaclComponentInstaller* pnacl_component_installer() = 0;
    216 
    217   virtual BookmarkPromptController* bookmark_prompt_controller() = 0;
    218 
    219   virtual chrome::MediaFileSystemRegistry* media_file_system_registry() = 0;
    220 
    221   virtual chrome::StorageMonitor* storage_monitor() = 0;
    222 
    223   virtual bool created_local_state() const = 0;
    224 
    225 #if defined(ENABLE_WEBRTC)
    226   virtual WebRtcLogUploader* webrtc_log_uploader() = 0;
    227 #endif
    228 
    229  private:
    230   DISALLOW_COPY_AND_ASSIGN(BrowserProcess);
    231 };
    232 
    233 extern BrowserProcess* g_browser_process;
    234 
    235 #endif  // CHROME_BROWSER_BROWSER_PROCESS_H_
    236