[email protected] | 9fe4204 | 2013-10-29 21:13:33 | [diff] [blame] | 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 | #include "extensions/browser/extensions_browser_client.h" |
| 6 | |
wittman | b3ee048 | 2015-06-24 17:47:40 | [diff] [blame] | 7 | #include "base/logging.h" |
asargent | 631a99a | 2015-10-15 21:51:48 | [diff] [blame] | 8 | #include "components/update_client/update_client.h" |
rdevlin.cronin | 1790e82 | 2016-04-05 21:03:35 | [diff] [blame] | 9 | #include "extensions/browser/extension_api_frame_id_map.h" |
wittman | b3ee048 | 2015-06-24 17:47:40 | [diff] [blame] | 10 | #include "extensions/browser/extension_error.h" |
[email protected] | 9fe4204 | 2013-10-29 21:13:33 | [diff] [blame] | 11 | |
| 12 | namespace extensions { |
| 13 | |
| 14 | namespace { |
| 15 | |
Jens Widell | c268827 | 2018-02-02 09:08:31 | [diff] [blame] | 16 | ExtensionsBrowserClient* g_extension_browser_client = NULL; |
[email protected] | 9fe4204 | 2013-10-29 21:13:33 | [diff] [blame] | 17 | |
| 18 | } // namespace |
| 19 | |
Devlin Cronin | bc8177d | 2018-08-23 03:51:09 | [diff] [blame] | 20 | ExtensionsBrowserClient::ExtensionsBrowserClient() {} |
| 21 | ExtensionsBrowserClient::~ExtensionsBrowserClient() = default; |
| 22 | |
| 23 | ExtensionsBrowserClient* ExtensionsBrowserClient::Get() { |
| 24 | return g_extension_browser_client; |
| 25 | } |
| 26 | |
| 27 | void ExtensionsBrowserClient::Set(ExtensionsBrowserClient* client) { |
| 28 | g_extension_browser_client = client; |
| 29 | } |
| 30 | |
| 31 | void ExtensionsBrowserClient::RegisterExtensionFunctions( |
| 32 | ExtensionFunctionRegistry* registry) { |
| 33 | for (const auto& provider : providers_) |
| 34 | provider->RegisterExtensionFunctions(registry); |
| 35 | } |
| 36 | |
| 37 | void ExtensionsBrowserClient::AddAPIProvider( |
| 38 | std::unique_ptr<ExtensionsBrowserAPIProvider> provider) { |
| 39 | providers_.push_back(std::move(provider)); |
| 40 | } |
| 41 | |
asargent | 631a99a | 2015-10-15 21:51:48 | [diff] [blame] | 42 | scoped_refptr<update_client::UpdateClient> |
| 43 | ExtensionsBrowserClient::CreateUpdateClient(content::BrowserContext* context) { |
| 44 | return scoped_refptr<update_client::UpdateClient>(nullptr); |
| 45 | } |
| 46 | |
juncai | 17fc853 | 2016-06-02 06:45:50 | [diff] [blame] | 47 | std::unique_ptr<content::BluetoothChooser> |
| 48 | ExtensionsBrowserClient::CreateBluetoothChooser( |
| 49 | content::RenderFrameHost* frame, |
| 50 | const content::BluetoothChooser::EventHandler& event_handler) { |
| 51 | return nullptr; |
| 52 | } |
| 53 | |
dcheng | f5d24108 | 2016-04-21 03:43:11 | [diff] [blame] | 54 | void ExtensionsBrowserClient::ReportError( |
| 55 | content::BrowserContext* context, |
| 56 | std::unique_ptr<ExtensionError> error) { |
wittman | b3ee048 | 2015-06-24 17:47:40 | [diff] [blame] | 57 | LOG(ERROR) << error->GetDebugString(); |
| 58 | } |
| 59 | |
rdevlin.cronin | 6fba7ec | 2016-06-24 16:15:05 | [diff] [blame] | 60 | bool ExtensionsBrowserClient::IsActivityLoggingEnabled( |
| 61 | content::BrowserContext* context) { |
| 62 | return false; |
| 63 | } |
| 64 | |
Ken Rockot | 06d07e3 | 2018-02-27 16:24:22 | [diff] [blame] | 65 | void ExtensionsBrowserClient::GetTabAndWindowIdForWebContents( |
| 66 | content::WebContents* web_contents, |
| 67 | int* tab_id, |
| 68 | int* window_id) { |
| 69 | *tab_id = -1; |
| 70 | *window_id = -1; |
| 71 | } |
| 72 | |
Minh X. Nguyen | 3bfb3228 | 2017-11-09 17:11:14 | [diff] [blame] | 73 | bool ExtensionsBrowserClient::IsExtensionEnabled( |
| 74 | const std::string& extension_id, |
| 75 | content::BrowserContext* context) const { |
| 76 | return false; |
| 77 | } |
| 78 | |
John Abd-El-Malek | 04bfa853 | 2018-07-12 05:28:22 | [diff] [blame] | 79 | bool ExtensionsBrowserClient::IsWebUIAllowedToMakeNetworkRequests( |
| 80 | const url::Origin& origin) { |
| 81 | return false; |
| 82 | } |
| 83 | |
John Abd-El-Malek | ebbb0df2 | 2018-08-23 19:11:32 | [diff] [blame] | 84 | network::mojom::NetworkContext* |
| 85 | ExtensionsBrowserClient::GetSystemNetworkContext() { |
| 86 | return nullptr; |
| 87 | } |
| 88 | |
Clark DuVall | 2cf99249e | 2018-09-19 19:11:51 | [diff] [blame] | 89 | UserScriptListener* ExtensionsBrowserClient::GetUserScriptListener() { |
| 90 | return nullptr; |
| 91 | } |
| 92 | |
Yutaka Hirano | 968d625 | 2018-12-04 05:09:31 | [diff] [blame] | 93 | std::string ExtensionsBrowserClient::GetUserAgent() const { |
| 94 | return std::string(); |
| 95 | } |
| 96 | |
Lukasz Anforowicz | feddf7e3 | 2019-09-18 22:13:23 | [diff] [blame] | 97 | bool ExtensionsBrowserClient::ShouldSchemeBypassNavigationChecks( |
| 98 | const std::string& scheme) const { |
| 99 | return false; |
| 100 | } |
| 101 | |
Takashi Toyoshima | 12844146 | 2019-10-16 04:19:17 | [diff] [blame] | 102 | bool ExtensionsBrowserClient::ShouldForceWebRequestExtraHeaders( |
| 103 | content::BrowserContext* context) const { |
| 104 | return false; |
| 105 | } |
| 106 | |
[email protected] | 9fe4204 | 2013-10-29 21:13:33 | [diff] [blame] | 107 | } // namespace extensions |