OLD | NEW |
(Empty) | |
| 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 |
| 10 using content::BrowserContext; |
| 11 |
| 12 namespace extensions { |
| 13 |
| 14 TestExtensionsBrowserClient::TestExtensionsBrowserClient( |
| 15 BrowserContext* main_context) |
| 16 : main_context_(main_context), incognito_context_(NULL) { |
| 17 DCHECK(main_context_); |
| 18 DCHECK(!main_context_->IsOffTheRecord()); |
| 19 } |
| 20 |
| 21 TestExtensionsBrowserClient::~TestExtensionsBrowserClient() {} |
| 22 |
| 23 void TestExtensionsBrowserClient::SetIncognitoContext(BrowserContext* context) { |
| 24 // If a context is provided it must be off-the-record. |
| 25 DCHECK(!context || context->IsOffTheRecord()); |
| 26 incognito_context_ = context; |
| 27 } |
| 28 |
| 29 bool TestExtensionsBrowserClient::IsShuttingDown() { return false; } |
| 30 |
| 31 bool TestExtensionsBrowserClient::AreExtensionsDisabled( |
| 32 const CommandLine& command_line, |
| 33 BrowserContext* context) { |
| 34 return false; |
| 35 } |
| 36 |
| 37 bool TestExtensionsBrowserClient::IsValidContext(BrowserContext* context) { |
| 38 return context == main_context_ || |
| 39 (incognito_context_ && context == incognito_context_); |
| 40 } |
| 41 |
| 42 bool TestExtensionsBrowserClient::IsSameContext(BrowserContext* first, |
| 43 BrowserContext* second) { |
| 44 DCHECK(first); |
| 45 DCHECK(second); |
| 46 return first == second || |
| 47 (first == main_context_ && second == incognito_context_) || |
| 48 (first == incognito_context_ && second == main_context_); |
| 49 } |
| 50 |
| 51 bool TestExtensionsBrowserClient::HasOffTheRecordContext( |
| 52 BrowserContext* context) { |
| 53 return context == main_context_ && incognito_context_ != NULL; |
| 54 } |
| 55 |
| 56 BrowserContext* TestExtensionsBrowserClient::GetOffTheRecordContext( |
| 57 BrowserContext* context) { |
| 58 if (context == main_context_) |
| 59 return incognito_context_; |
| 60 return NULL; |
| 61 } |
| 62 |
| 63 BrowserContext* TestExtensionsBrowserClient::GetOriginalContext( |
| 64 BrowserContext* context) { |
| 65 return main_context_; |
| 66 } |
| 67 |
| 68 bool TestExtensionsBrowserClient::IsGuestSession( |
| 69 BrowserContext* context) const { |
| 70 return false; |
| 71 } |
| 72 |
| 73 bool TestExtensionsBrowserClient::IsExtensionIncognitoEnabled( |
| 74 const std::string& extension_id, |
| 75 content::BrowserContext* context) const { |
| 76 return false; |
| 77 } |
| 78 |
| 79 bool TestExtensionsBrowserClient::CanExtensionCrossIncognito( |
| 80 const extensions::Extension* extension, |
| 81 content::BrowserContext* context) const { |
| 82 return false; |
| 83 } |
| 84 |
| 85 PrefService* TestExtensionsBrowserClient::GetPrefServiceForContext( |
| 86 BrowserContext* context) { |
| 87 return NULL; |
| 88 } |
| 89 |
| 90 bool TestExtensionsBrowserClient::DeferLoadingBackgroundHosts( |
| 91 BrowserContext* context) const { |
| 92 return false; |
| 93 } |
| 94 |
| 95 bool TestExtensionsBrowserClient::IsBackgroundPageAllowed( |
| 96 BrowserContext* context) const { |
| 97 return true; |
| 98 } |
| 99 |
| 100 void TestExtensionsBrowserClient::OnExtensionHostCreated( |
| 101 content::WebContents* web_contents) {} |
| 102 |
| 103 void TestExtensionsBrowserClient::OnRenderViewCreatedForBackgroundPage( |
| 104 ExtensionHost* host) {} |
| 105 |
| 106 bool TestExtensionsBrowserClient::DidVersionUpdate(BrowserContext* context) { |
| 107 return false; |
| 108 } |
| 109 |
| 110 scoped_ptr<AppSorting> TestExtensionsBrowserClient::CreateAppSorting() { |
| 111 return scoped_ptr<AppSorting>(); |
| 112 } |
| 113 |
| 114 bool TestExtensionsBrowserClient::IsRunningInForcedAppMode() { return false; } |
| 115 |
| 116 content::JavaScriptDialogManager* |
| 117 TestExtensionsBrowserClient::GetJavaScriptDialogManager() { |
| 118 return NULL; |
| 119 } |
| 120 |
| 121 ApiActivityMonitor* TestExtensionsBrowserClient::GetApiActivityMonitor( |
| 122 BrowserContext* context) { |
| 123 return NULL; |
| 124 } |
| 125 |
| 126 ExtensionSystemProvider* |
| 127 TestExtensionsBrowserClient::GetExtensionSystemFactory() { |
| 128 // Tests requiring an extension system should override this function. |
| 129 NOTREACHED(); |
| 130 return NULL; |
| 131 } |
| 132 |
| 133 void TestExtensionsBrowserClient::RegisterExtensionFunctions( |
| 134 ExtensionFunctionRegistry* registry) const {} |
| 135 |
| 136 } // namespace extensions |
OLD | NEW |