Upstream version 9.37.195.0
[platform/framework/web/crosswalk.git] / src / extensions / browser / test_extensions_browser_client.cc
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 #include "extensions/browser/test_extensions_browser_client.h"
6
7 #include "content/public/browser/browser_context.h"
8 #include "extensions/browser/app_sorting.h"
9 #include "extensions/browser/extension_host_delegate.h"
10 #include "extensions/browser/test_runtime_api_delegate.h"
11
12 using content::BrowserContext;
13
14 namespace extensions {
15
16 TestExtensionsBrowserClient::TestExtensionsBrowserClient(
17     BrowserContext* main_context)
18     : main_context_(main_context), incognito_context_(NULL) {
19   DCHECK(main_context_);
20   DCHECK(!main_context_->IsOffTheRecord());
21 }
22
23 TestExtensionsBrowserClient::~TestExtensionsBrowserClient() {}
24
25 void TestExtensionsBrowserClient::SetIncognitoContext(BrowserContext* context) {
26   // If a context is provided it must be off-the-record.
27   DCHECK(!context || context->IsOffTheRecord());
28   incognito_context_ = context;
29 }
30
31 bool TestExtensionsBrowserClient::IsShuttingDown() { return false; }
32
33 bool TestExtensionsBrowserClient::AreExtensionsDisabled(
34     const base::CommandLine& command_line,
35     BrowserContext* context) {
36   return false;
37 }
38
39 bool TestExtensionsBrowserClient::IsValidContext(BrowserContext* context) {
40   return context == main_context_ ||
41          (incognito_context_ && context == incognito_context_);
42 }
43
44 bool TestExtensionsBrowserClient::IsSameContext(BrowserContext* first,
45                                                 BrowserContext* second) {
46   DCHECK(first);
47   DCHECK(second);
48   return first == second ||
49          (first == main_context_ && second == incognito_context_) ||
50          (first == incognito_context_ && second == main_context_);
51 }
52
53 bool TestExtensionsBrowserClient::HasOffTheRecordContext(
54     BrowserContext* context) {
55   return context == main_context_ && incognito_context_ != NULL;
56 }
57
58 BrowserContext* TestExtensionsBrowserClient::GetOffTheRecordContext(
59     BrowserContext* context) {
60   if (context == main_context_)
61     return incognito_context_;
62   return NULL;
63 }
64
65 BrowserContext* TestExtensionsBrowserClient::GetOriginalContext(
66     BrowserContext* context) {
67   return main_context_;
68 }
69
70 bool TestExtensionsBrowserClient::IsGuestSession(
71     BrowserContext* context) const {
72   return false;
73 }
74
75 bool TestExtensionsBrowserClient::IsExtensionIncognitoEnabled(
76     const std::string& extension_id,
77     content::BrowserContext* context) const {
78   return false;
79 }
80
81 bool TestExtensionsBrowserClient::CanExtensionCrossIncognito(
82     const extensions::Extension* extension,
83     content::BrowserContext* context) const {
84   return false;
85 }
86
87 bool TestExtensionsBrowserClient::IsWebViewRequest(
88     net::URLRequest* request) const {
89   return false;
90 }
91
92 net::URLRequestJob*
93 TestExtensionsBrowserClient::MaybeCreateResourceBundleRequestJob(
94     net::URLRequest* request,
95     net::NetworkDelegate* network_delegate,
96     const base::FilePath& directory_path,
97     const std::string& content_security_policy,
98     bool send_cors_header) {
99   return NULL;
100 }
101
102 bool TestExtensionsBrowserClient::AllowCrossRendererResourceLoad(
103     net::URLRequest* request,
104     bool is_incognito,
105     const Extension* extension,
106     InfoMap* extension_info_map) {
107   return false;
108 }
109
110 PrefService* TestExtensionsBrowserClient::GetPrefServiceForContext(
111     BrowserContext* context) {
112   return NULL;
113 }
114
115 void TestExtensionsBrowserClient::GetEarlyExtensionPrefsObservers(
116     content::BrowserContext* context,
117     std::vector<ExtensionPrefsObserver*>* observers) const {}
118
119 bool TestExtensionsBrowserClient::DeferLoadingBackgroundHosts(
120     BrowserContext* context) const {
121   return false;
122 }
123
124 bool TestExtensionsBrowserClient::IsBackgroundPageAllowed(
125     BrowserContext* context) const {
126   return true;
127 }
128
129 scoped_ptr<ExtensionHostDelegate>
130 TestExtensionsBrowserClient::CreateExtensionHostDelegate() {
131   return scoped_ptr<ExtensionHostDelegate>();
132 }
133
134 bool TestExtensionsBrowserClient::DidVersionUpdate(BrowserContext* context) {
135   return false;
136 }
137
138 void TestExtensionsBrowserClient::PermitExternalProtocolHandler() {
139 }
140
141 scoped_ptr<AppSorting> TestExtensionsBrowserClient::CreateAppSorting() {
142   return scoped_ptr<AppSorting>();
143 }
144
145 bool TestExtensionsBrowserClient::IsRunningInForcedAppMode() { return false; }
146
147 ApiActivityMonitor* TestExtensionsBrowserClient::GetApiActivityMonitor(
148     BrowserContext* context) {
149   return NULL;
150 }
151
152 ExtensionSystemProvider*
153 TestExtensionsBrowserClient::GetExtensionSystemFactory() {
154   // Tests requiring an extension system should override this function.
155   NOTREACHED();
156   return NULL;
157 }
158
159 void TestExtensionsBrowserClient::RegisterExtensionFunctions(
160     ExtensionFunctionRegistry* registry) const {}
161
162 scoped_ptr<RuntimeAPIDelegate>
163 TestExtensionsBrowserClient::CreateRuntimeAPIDelegate(
164     content::BrowserContext* context) const {
165   return scoped_ptr<RuntimeAPIDelegate>(new TestRuntimeAPIDelegate());
166 }
167
168 ComponentExtensionResourceManager*
169 TestExtensionsBrowserClient::GetComponentExtensionResourceManager() {
170   return NULL;
171 }
172
173 }  // namespace extensions