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