Home | History | Annotate | Download | only in browser
      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 EXTENSIONS_BROWSER_EXTENSIONS_BROWSER_CLIENT_H_
      6 #define EXTENSIONS_BROWSER_EXTENSIONS_BROWSER_CLIENT_H_
      7 
      8 #include "base/memory/scoped_ptr.h"
      9 
     10 class CommandLine;
     11 class PrefService;
     12 
     13 namespace content {
     14 class BrowserContext;
     15 class JavaScriptDialogManager;
     16 }
     17 
     18 namespace extensions {
     19 
     20 class AppSorting;
     21 
     22 // Interface to allow the extensions module to make browser-process-specific
     23 // queries of the embedder. Should be Set() once in the browser process.
     24 //
     25 // NOTE: Methods that do not require knowledge of browser concepts should be
     26 // added in ExtensionsClient (extensions/common/extensions_client.h) even if
     27 // they are only used in the browser process.
     28 class ExtensionsBrowserClient {
     29  public:
     30   virtual ~ExtensionsBrowserClient() {}
     31 
     32   // Returns true if the embedder has started shutting down.
     33   virtual bool IsShuttingDown() = 0;
     34 
     35   // Returns true if extensions have been disabled (e.g. via a command-line flag
     36   // or preference).
     37   virtual bool AreExtensionsDisabled(const CommandLine& command_line,
     38                                      content::BrowserContext* context) = 0;
     39 
     40   // Returns true if the |context| is known to the embedder.
     41   virtual bool IsValidContext(content::BrowserContext* context) = 0;
     42 
     43   // Returns true if the BrowserContexts could be considered equivalent, for
     44   // example, if one is an off-the-record context owned by the other.
     45   virtual bool IsSameContext(content::BrowserContext* first,
     46                              content::BrowserContext* second) = 0;
     47 
     48   // Returns true if |context| has an off-the-record context associated with it.
     49   virtual bool HasOffTheRecordContext(content::BrowserContext* context) = 0;
     50 
     51   // Returns the off-the-record context associated with |context|. If |context|
     52   // is already off-the-record, returns |context|.
     53   // WARNING: This may create a new off-the-record context. To avoid creating
     54   // another context, check HasOffTheRecordContext() first.
     55   virtual content::BrowserContext* GetOffTheRecordContext(
     56       content::BrowserContext* context) = 0;
     57 
     58   // Return the original "recording" context. This method returns |context| if
     59   // |context| is not incognito.
     60   virtual content::BrowserContext* GetOriginalContext(
     61       content::BrowserContext* context) = 0;
     62 
     63   // Returns the PrefService associated with |context|.
     64   virtual PrefService* GetPrefServiceForContext(
     65       content::BrowserContext* context) = 0;
     66 
     67   // Returns true if loading background pages should be deferred.
     68   virtual bool DeferLoadingBackgroundHosts(
     69       content::BrowserContext* context) const = 0;
     70 
     71   virtual bool IsBackgroundPageAllowed(
     72       content::BrowserContext* context) const = 0;
     73 
     74   // Returns true if the client version has updated since the last run. Called
     75   // once each time the extensions system is loaded per browser_context. The
     76   // implementation may wish to use the BrowserContext to record the current
     77   // version for later comparison.
     78   virtual bool DidVersionUpdate(content::BrowserContext* context) = 0;
     79 
     80   // Creates a new AppSorting instance.
     81   virtual scoped_ptr<AppSorting> CreateAppSorting() = 0;
     82 
     83   // Return true if the system is run in forced app mode.
     84   virtual bool IsRunningInForcedAppMode() = 0;
     85 
     86   // Returns the embedder's JavaScriptDialogManager or NULL if the embedder
     87   // does not support JavaScript dialogs.
     88   virtual content::JavaScriptDialogManager* GetJavaScriptDialogManager() = 0;
     89 
     90   // Returns the single instance of |this|.
     91   static ExtensionsBrowserClient* Get();
     92 
     93   // Initialize the single instance.
     94   static void Set(ExtensionsBrowserClient* client);
     95 };
     96 
     97 }  // namespace extensions
     98 
     99 #endif  // EXTENSIONS_BROWSER_EXTENSIONS_BROWSER_CLIENT_H_
    100