| 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 SetCurrentChannel(chrome::VersionInfo::GetChannel()); | 55 SetCurrentChannel(chrome::VersionInfo::GetChannel()); |
| 56 } | 56 } |
| 57 | 57 |
| 58 ChromeExtensionsBrowserClient::~ChromeExtensionsBrowserClient() {} | 58 ChromeExtensionsBrowserClient::~ChromeExtensionsBrowserClient() {} |
| 59 | 59 |
| 60 bool ChromeExtensionsBrowserClient::IsShuttingDown() { | 60 bool ChromeExtensionsBrowserClient::IsShuttingDown() { |
| 61 return g_browser_process->IsShuttingDown(); | 61 return g_browser_process->IsShuttingDown(); |
| 62 } | 62 } |
| 63 | 63 |
| 64 bool ChromeExtensionsBrowserClient::AreExtensionsDisabled( | 64 bool ChromeExtensionsBrowserClient::AreExtensionsDisabled( |
| 65 const CommandLine& command_line, | 65 const base::CommandLine& command_line, |
| 66 content::BrowserContext* context) { | 66 content::BrowserContext* context) { |
| 67 Profile* profile = static_cast<Profile*>(context); | 67 Profile* profile = static_cast<Profile*>(context); |
| 68 return command_line.HasSwitch(switches::kDisableExtensions) || | 68 return command_line.HasSwitch(switches::kDisableExtensions) || |
| 69 profile->GetPrefs()->GetBoolean(prefs::kDisableExtensions); | 69 profile->GetPrefs()->GetBoolean(prefs::kDisableExtensions); |
| 70 } | 70 } |
| 71 | 71 |
| 72 bool ChromeExtensionsBrowserClient::IsValidContext( | 72 bool ChromeExtensionsBrowserClient::IsValidContext( |
| 73 content::BrowserContext* context) { | 73 content::BrowserContext* context) { |
| 74 Profile* profile = static_cast<Profile*>(context); | 74 Profile* profile = static_cast<Profile*>(context); |
| 75 return g_browser_process->profile_manager()->IsValidProfile(profile); | 75 return g_browser_process->profile_manager()->IsValidProfile(profile); |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 bool ChromeExtensionsBrowserClient::DidVersionUpdate( | 169 bool ChromeExtensionsBrowserClient::DidVersionUpdate( |
| 170 content::BrowserContext* context) { | 170 content::BrowserContext* context) { |
| 171 Profile* profile = static_cast<Profile*>(context); | 171 Profile* profile = static_cast<Profile*>(context); |
| 172 | 172 |
| 173 // Unit tests may not provide prefs; assume everything is up-to-date. | 173 // Unit tests may not provide prefs; assume everything is up-to-date. |
| 174 ExtensionPrefs* extension_prefs = ExtensionPrefs::Get(profile); | 174 ExtensionPrefs* extension_prefs = ExtensionPrefs::Get(profile); |
| 175 if (!extension_prefs) | 175 if (!extension_prefs) |
| 176 return false; | 176 return false; |
| 177 | 177 |
| 178 // If we're inside a browser test, then assume prefs are all up-to-date. | 178 // If we're inside a browser test, then assume prefs are all up-to-date. |
| 179 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kTestType)) | 179 if (base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kTestType)) |
| 180 return false; | 180 return false; |
| 181 | 181 |
| 182 PrefService* pref_service = extension_prefs->pref_service(); | 182 PrefService* pref_service = extension_prefs->pref_service(); |
| 183 base::Version last_version; | 183 base::Version last_version; |
| 184 if (pref_service->HasPrefPath(pref_names::kLastChromeVersion)) { | 184 if (pref_service->HasPrefPath(pref_names::kLastChromeVersion)) { |
| 185 std::string last_version_str = | 185 std::string last_version_str = |
| 186 pref_service->GetString(pref_names::kLastChromeVersion); | 186 pref_service->GetString(pref_names::kLastChromeVersion); |
| 187 last_version = base::Version(last_version_str); | 187 last_version = base::Version(last_version_str); |
| 188 } | 188 } |
| 189 | 189 |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 #if defined(OS_CHROMEOS) | 274 #if defined(OS_CHROMEOS) |
| 275 extension_cache_.reset(new ExtensionCacheImpl()); | 275 extension_cache_.reset(new ExtensionCacheImpl()); |
| 276 #else | 276 #else |
| 277 extension_cache_.reset(new NullExtensionCache()); | 277 extension_cache_.reset(new NullExtensionCache()); |
| 278 #endif | 278 #endif |
| 279 } | 279 } |
| 280 return extension_cache_.get(); | 280 return extension_cache_.get(); |
| 281 } | 281 } |
| 282 | 282 |
| 283 bool ChromeExtensionsBrowserClient::IsBackgroundUpdateAllowed() { | 283 bool ChromeExtensionsBrowserClient::IsBackgroundUpdateAllowed() { |
| 284 return !CommandLine::ForCurrentProcess()->HasSwitch( | 284 return !base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 285 switches::kDisableBackgroundNetworking); | 285 switches::kDisableBackgroundNetworking); |
| 286 } | 286 } |
| 287 | 287 |
| 288 bool ChromeExtensionsBrowserClient::IsMinBrowserVersionSupported( | 288 bool ChromeExtensionsBrowserClient::IsMinBrowserVersionSupported( |
| 289 const std::string& min_version) { | 289 const std::string& min_version) { |
| 290 chrome::VersionInfo version_info; | 290 chrome::VersionInfo version_info; |
| 291 base::Version browser_version = base::Version(version_info.Version()); | 291 base::Version browser_version = base::Version(version_info.Version()); |
| 292 Version browser_min_version(min_version); | 292 Version browser_min_version(min_version); |
| 293 if (browser_version.IsValid() && browser_min_version.IsValid() && | 293 if (browser_version.IsValid() && browser_min_version.IsValid() && |
| 294 browser_min_version.CompareTo(browser_version) > 0) { | 294 browser_min_version.CompareTo(browser_version) > 0) { |
| 295 return false; | 295 return false; |
| 296 } | 296 } |
| 297 return true; | 297 return true; |
| 298 } | 298 } |
| 299 | 299 |
| 300 } // namespace extensions | 300 } // namespace extensions |
| OLD | NEW |