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 #include "chrome/browser/extensions/chrome_extensions_browser_client.h" | 5 #include "chrome/browser/extensions/chrome_extensions_browser_client.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/version.h" | 8 #include "base/version.h" |
9 #include "chrome/browser/app_mode/app_mode_utils.h" | 9 #include "chrome/browser/app_mode/app_mode_utils.h" |
10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 } // namespace | 27 } // namespace |
28 | 28 |
29 ChromeExtensionsBrowserClient::ChromeExtensionsBrowserClient() {} | 29 ChromeExtensionsBrowserClient::ChromeExtensionsBrowserClient() {} |
30 | 30 |
31 ChromeExtensionsBrowserClient::~ChromeExtensionsBrowserClient() {} | 31 ChromeExtensionsBrowserClient::~ChromeExtensionsBrowserClient() {} |
32 | 32 |
33 bool ChromeExtensionsBrowserClient::IsShuttingDown() { | 33 bool ChromeExtensionsBrowserClient::IsShuttingDown() { |
34 return g_browser_process->IsShuttingDown(); | 34 return g_browser_process->IsShuttingDown(); |
35 } | 35 } |
36 | 36 |
| 37 bool ChromeExtensionsBrowserClient::AreExtensionsDisabled( |
| 38 const CommandLine& command_line, |
| 39 content::BrowserContext* context) { |
| 40 Profile* profile = static_cast<Profile*>(context); |
| 41 return command_line.HasSwitch(switches::kDisableExtensions) || |
| 42 profile->GetPrefs()->GetBoolean(prefs::kDisableExtensions); |
| 43 } |
| 44 |
37 bool ChromeExtensionsBrowserClient::IsValidContext( | 45 bool ChromeExtensionsBrowserClient::IsValidContext( |
38 content::BrowserContext* context) { | 46 content::BrowserContext* context) { |
39 Profile* profile = static_cast<Profile*>(context); | 47 Profile* profile = static_cast<Profile*>(context); |
40 return g_browser_process->profile_manager()->IsValidProfile(profile); | 48 return g_browser_process->profile_manager()->IsValidProfile(profile); |
41 } | 49 } |
42 | 50 |
43 bool ChromeExtensionsBrowserClient::IsSameContext( | 51 bool ChromeExtensionsBrowserClient::IsSameContext( |
44 content::BrowserContext* first, | 52 content::BrowserContext* first, |
45 content::BrowserContext* second) { | 53 content::BrowserContext* second) { |
46 return static_cast<Profile*>(first)->IsSameProfile( | 54 return static_cast<Profile*>(first)->IsSameProfile( |
47 static_cast<Profile*>(second)); | 55 static_cast<Profile*>(second)); |
48 } | 56 } |
49 | 57 |
50 bool ChromeExtensionsBrowserClient::HasOffTheRecordContext( | 58 bool ChromeExtensionsBrowserClient::HasOffTheRecordContext( |
51 content::BrowserContext* context) { | 59 content::BrowserContext* context) { |
52 return static_cast<Profile*>(context)->HasOffTheRecordProfile(); | 60 return static_cast<Profile*>(context)->HasOffTheRecordProfile(); |
53 } | 61 } |
54 | 62 |
55 content::BrowserContext* ChromeExtensionsBrowserClient::GetOffTheRecordContext( | 63 content::BrowserContext* ChromeExtensionsBrowserClient::GetOffTheRecordContext( |
56 content::BrowserContext* context) { | 64 content::BrowserContext* context) { |
57 return static_cast<Profile*>(context)->GetOffTheRecordProfile(); | 65 return static_cast<Profile*>(context)->GetOffTheRecordProfile(); |
58 } | 66 } |
59 | 67 |
60 content::BrowserContext* ChromeExtensionsBrowserClient::GetOriginalContext( | 68 content::BrowserContext* ChromeExtensionsBrowserClient::GetOriginalContext( |
61 content::BrowserContext* context) { | 69 content::BrowserContext* context) { |
62 return static_cast<Profile*>(context)->GetOriginalProfile(); | 70 return static_cast<Profile*>(context)->GetOriginalProfile(); |
63 } | 71 } |
64 | 72 |
| 73 PrefService* ChromeExtensionsBrowserClient::GetPrefServiceForContext( |
| 74 content::BrowserContext* context) { |
| 75 return static_cast<Profile*>(context)->GetPrefs(); |
| 76 } |
| 77 |
65 bool ChromeExtensionsBrowserClient::DeferLoadingBackgroundHosts( | 78 bool ChromeExtensionsBrowserClient::DeferLoadingBackgroundHosts( |
66 content::BrowserContext* context) const { | 79 content::BrowserContext* context) const { |
67 Profile* profile = static_cast<Profile*>(context); | 80 Profile* profile = static_cast<Profile*>(context); |
68 | 81 |
69 // The profile may not be valid yet if it is still being initialized. | 82 // The profile may not be valid yet if it is still being initialized. |
70 // In that case, defer loading, since it depends on an initialized profile. | 83 // In that case, defer loading, since it depends on an initialized profile. |
71 // http://crbug.com/222473 | 84 // http://crbug.com/222473 |
72 if (!g_browser_process->profile_manager()->IsValidProfile(profile)) | 85 if (!g_browser_process->profile_manager()->IsValidProfile(profile)) |
73 return true; | 86 return true; |
74 | 87 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 bool ChromeExtensionsBrowserClient::IsRunningInForcedAppMode() { | 135 bool ChromeExtensionsBrowserClient::IsRunningInForcedAppMode() { |
123 return chrome::IsRunningInForcedAppMode(); | 136 return chrome::IsRunningInForcedAppMode(); |
124 } | 137 } |
125 | 138 |
126 // static | 139 // static |
127 ChromeExtensionsBrowserClient* ChromeExtensionsBrowserClient::GetInstance() { | 140 ChromeExtensionsBrowserClient* ChromeExtensionsBrowserClient::GetInstance() { |
128 return g_client.Pointer(); | 141 return g_client.Pointer(); |
129 } | 142 } |
130 | 143 |
131 } // namespace extensions | 144 } // namespace extensions |
OLD | NEW |