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