| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 #ifndef EXTENSIONS_BROWSER_EXTENSION_PREFS_H_ | 5 #ifndef EXTENSIONS_BROWSER_EXTENSION_PREFS_H_ |
| 6 #define EXTENSIONS_BROWSER_EXTENSION_PREFS_H_ | 6 #define EXTENSIONS_BROWSER_EXTENSION_PREFS_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 // Returns true if the specified external extension was uninstalled by the | 166 // Returns true if the specified external extension was uninstalled by the |
| 167 // user. | 167 // user. |
| 168 bool IsExternalExtensionUninstalled(const std::string& id) const; | 168 bool IsExternalExtensionUninstalled(const std::string& id) const; |
| 169 | 169 |
| 170 // Checks whether |extension_id| is disabled. If there's no state pref for | 170 // Checks whether |extension_id| is disabled. If there's no state pref for |
| 171 // the extension, this will return false. Generally you should use | 171 // the extension, this will return false. Generally you should use |
| 172 // ExtensionService::IsExtensionEnabled instead. | 172 // ExtensionService::IsExtensionEnabled instead. |
| 173 bool IsExtensionDisabled(const std::string& id) const; | 173 bool IsExtensionDisabled(const std::string& id) const; |
| 174 | 174 |
| 175 // Get/Set the order that the browser actions appear in the toolbar. | 175 // Get/Set the order that the browser actions appear in the toolbar. |
| 176 ExtensionIdList GetToolbarOrder(); | 176 ExtensionIdList GetToolbarOrder() const; |
| 177 void SetToolbarOrder(const ExtensionIdList& extension_ids); | 177 void SetToolbarOrder(const ExtensionIdList& extension_ids); |
| 178 | 178 |
| 179 // Called when an extension is installed, so that prefs get created. | 179 // Called when an extension is installed, so that prefs get created. |
| 180 // If |page_ordinal| is invalid then a page will be found for the App. | 180 // If |page_ordinal| is invalid then a page will be found for the App. |
| 181 // |install_flags| are a bitmask of extension::InstallFlags. | 181 // |install_flags| are a bitmask of extension::InstallFlags. |
| 182 void OnExtensionInstalled(const Extension* extension, | 182 void OnExtensionInstalled(const Extension* extension, |
| 183 Extension::State initial_state, | 183 Extension::State initial_state, |
| 184 const syncer::StringOrdinal& page_ordinal, | 184 const syncer::StringOrdinal& page_ordinal, |
| 185 int install_flags, | 185 int install_flags, |
| 186 const std::string& install_parameter); | 186 const std::string& install_parameter); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 205 void SetExtensionState(const std::string& extension_id, Extension::State); | 205 void SetExtensionState(const std::string& extension_id, Extension::State); |
| 206 | 206 |
| 207 // Called to change the extension's BlacklistState. Currently only used for | 207 // Called to change the extension's BlacklistState. Currently only used for |
| 208 // non-malicious extensions. | 208 // non-malicious extensions. |
| 209 // TODO(oleg): replace SetExtensionBlacklisted by this function. | 209 // TODO(oleg): replace SetExtensionBlacklisted by this function. |
| 210 void SetExtensionBlacklistState(const std::string& extension_id, | 210 void SetExtensionBlacklistState(const std::string& extension_id, |
| 211 BlacklistState state); | 211 BlacklistState state); |
| 212 | 212 |
| 213 // Checks whether |extension_id| is marked as greylisted. | 213 // Checks whether |extension_id| is marked as greylisted. |
| 214 // TODO(oleg): Replace IsExtensionBlacklisted by this method. | 214 // TODO(oleg): Replace IsExtensionBlacklisted by this method. |
| 215 BlacklistState GetExtensionBlacklistState(const std::string& extension_id); | 215 BlacklistState GetExtensionBlacklistState( |
| 216 const std::string& extension_id) const; |
| 216 | 217 |
| 217 // Populates |out| with the ids of all installed extensions. | 218 // Populates |out| with the ids of all installed extensions. |
| 218 void GetExtensions(ExtensionIdList* out); | 219 void GetExtensions(ExtensionIdList* out) const; |
| 219 | 220 |
| 220 // ExtensionScopedPrefs methods: | 221 // ExtensionScopedPrefs methods: |
| 221 void UpdateExtensionPref(const std::string& id, | 222 void UpdateExtensionPref(const std::string& id, |
| 222 const std::string& key, | 223 const std::string& key, |
| 223 base::Value* value) override; | 224 base::Value* value) override; |
| 224 | 225 |
| 225 void DeleteExtensionPrefs(const std::string& id) override; | 226 void DeleteExtensionPrefs(const std::string& id) override; |
| 226 | 227 |
| 227 bool ReadPrefAsBoolean(const std::string& extension_id, | 228 bool ReadPrefAsBoolean(const std::string& extension_id, |
| 228 const std::string& pref_key, | 229 const std::string& pref_key, |
| (...skipping 12 matching lines...) Expand all Loading... |
| 241 const base::ListValue** out_value) const override; | 242 const base::ListValue** out_value) const override; |
| 242 | 243 |
| 243 bool ReadPrefAsDictionary( | 244 bool ReadPrefAsDictionary( |
| 244 const std::string& extension_id, | 245 const std::string& extension_id, |
| 245 const std::string& pref_key, | 246 const std::string& pref_key, |
| 246 const base::DictionaryValue** out_value) const override; | 247 const base::DictionaryValue** out_value) const override; |
| 247 | 248 |
| 248 bool HasPrefForExtension(const std::string& extension_id) const override; | 249 bool HasPrefForExtension(const std::string& extension_id) const override; |
| 249 | 250 |
| 250 // Did the extension ask to escalate its permission during an upgrade? | 251 // Did the extension ask to escalate its permission during an upgrade? |
| 251 bool DidExtensionEscalatePermissions(const std::string& id); | 252 bool DidExtensionEscalatePermissions(const std::string& id) const; |
| 252 | 253 |
| 253 // If |did_escalate| is true, the preferences for |extension| will be set to | 254 // If |did_escalate| is true, the preferences for |extension| will be set to |
| 254 // require the install warning when the user tries to enable. | 255 // require the install warning when the user tries to enable. |
| 255 void SetDidExtensionEscalatePermissions( | 256 void SetDidExtensionEscalatePermissions( |
| 256 const Extension* extension, | 257 const Extension* extension, |
| 257 bool did_escalate); | 258 bool did_escalate); |
| 258 | 259 |
| 259 // Getters and setters for disabled reason. | 260 // Getters and setters for disabled reason. |
| 260 int GetDisableReasons(const std::string& extension_id) const; | 261 int GetDisableReasons(const std::string& extension_id) const; |
| 261 bool HasDisableReason(const std::string& extension_id, | 262 bool HasDisableReason(const std::string& extension_id, |
| 262 Extension::DisableReason disable_reason) const; | 263 Extension::DisableReason disable_reason) const; |
| 263 void AddDisableReason(const std::string& extension_id, | 264 void AddDisableReason(const std::string& extension_id, |
| 264 Extension::DisableReason disable_reason); | 265 Extension::DisableReason disable_reason); |
| 265 void RemoveDisableReason(const std::string& extension_id, | 266 void RemoveDisableReason(const std::string& extension_id, |
| 266 Extension::DisableReason disable_reason); | 267 Extension::DisableReason disable_reason); |
| 267 void ClearDisableReasons(const std::string& extension_id); | 268 void ClearDisableReasons(const std::string& extension_id); |
| 268 | 269 |
| 269 // Gets the set of extensions that have been blacklisted in prefs. This will | 270 // Gets the set of extensions that have been blacklisted in prefs. This will |
| 270 // return only the blocked extensions, not the "greylist" extensions. | 271 // return only the blocked extensions, not the "greylist" extensions. |
| 271 // TODO(oleg): Make method names consistent here, in extension service and in | 272 // TODO(oleg): Make method names consistent here, in extension service and in |
| 272 // blacklist. | 273 // blacklist. |
| 273 std::set<std::string> GetBlacklistedExtensions(); | 274 std::set<std::string> GetBlacklistedExtensions() const; |
| 274 | 275 |
| 275 // Sets whether the extension with |id| is blacklisted. | 276 // Sets whether the extension with |id| is blacklisted. |
| 276 void SetExtensionBlacklisted(const std::string& extension_id, | 277 void SetExtensionBlacklisted(const std::string& extension_id, |
| 277 bool is_blacklisted); | 278 bool is_blacklisted); |
| 278 | 279 |
| 279 // Returns the version string for the currently installed extension, or | 280 // Returns the version string for the currently installed extension, or |
| 280 // the empty string if not found. | 281 // the empty string if not found. |
| 281 std::string GetVersionString(const std::string& extension_id); | 282 std::string GetVersionString(const std::string& extension_id) const; |
| 282 | 283 |
| 283 // Re-writes the extension manifest into the prefs. | 284 // Re-writes the extension manifest into the prefs. |
| 284 // Called to change the extension's manifest when it's re-localized. | 285 // Called to change the extension's manifest when it's re-localized. |
| 285 void UpdateManifest(const Extension* extension); | 286 void UpdateManifest(const Extension* extension); |
| 286 | 287 |
| 287 // Returns base extensions install directory. | 288 // Returns base extensions install directory. |
| 288 const base::FilePath& install_directory() const { return install_directory_; } | 289 const base::FilePath& install_directory() const { return install_directory_; } |
| 289 | 290 |
| 290 // Returns whether the extension with |id| has its blacklist bit set. | 291 // Returns whether the extension with |id| has its blacklist bit set. |
| 291 // | 292 // |
| 292 // WARNING: this only checks the extension's entry in prefs, so by definition | 293 // WARNING: this only checks the extension's entry in prefs, so by definition |
| 293 // can only check extensions that prefs knows about. There may be other | 294 // can only check extensions that prefs knows about. There may be other |
| 294 // sources of blacklist information, such as safebrowsing. You probably want | 295 // sources of blacklist information, such as safebrowsing. You probably want |
| 295 // to use Blacklist::GetBlacklistedIDs rather than this method. | 296 // to use Blacklist::GetBlacklistedIDs rather than this method. |
| 296 bool IsExtensionBlacklisted(const std::string& id) const; | 297 bool IsExtensionBlacklisted(const std::string& id) const; |
| 297 | 298 |
| 298 // Increment the count of how many times we prompted the user to acknowledge | 299 // Increment the count of how many times we prompted the user to acknowledge |
| 299 // the given extension, and return the new count. | 300 // the given extension, and return the new count. |
| 300 int IncrementAcknowledgePromptCount(const std::string& extension_id); | 301 int IncrementAcknowledgePromptCount(const std::string& extension_id); |
| 301 | 302 |
| 302 // Whether the user has acknowledged an external extension. | 303 // Whether the user has acknowledged an external extension. |
| 303 bool IsExternalExtensionAcknowledged(const std::string& extension_id); | 304 bool IsExternalExtensionAcknowledged(const std::string& extension_id) const; |
| 304 void AcknowledgeExternalExtension(const std::string& extension_id); | 305 void AcknowledgeExternalExtension(const std::string& extension_id); |
| 305 | 306 |
| 306 // Whether the user has acknowledged a blacklisted extension. | 307 // Whether the user has acknowledged a blacklisted extension. |
| 307 bool IsBlacklistedExtensionAcknowledged(const std::string& extension_id); | 308 bool IsBlacklistedExtensionAcknowledged( |
| 309 const std::string& extension_id) const; |
| 308 void AcknowledgeBlacklistedExtension(const std::string& extension_id); | 310 void AcknowledgeBlacklistedExtension(const std::string& extension_id); |
| 309 | 311 |
| 310 // Whether the external extension was installed during the first run | 312 // Whether the external extension was installed during the first run |
| 311 // of this profile. | 313 // of this profile. |
| 312 bool IsExternalInstallFirstRun(const std::string& extension_id); | 314 bool IsExternalInstallFirstRun(const std::string& extension_id) const; |
| 313 void SetExternalInstallFirstRun(const std::string& extension_id); | 315 void SetExternalInstallFirstRun(const std::string& extension_id); |
| 314 | 316 |
| 315 // Returns true if the extension notification code has already run for the | 317 // Returns true if the extension notification code has already run for the |
| 316 // first time for this profile. Currently we use this flag to mean that any | 318 // first time for this profile. Currently we use this flag to mean that any |
| 317 // extensions that would trigger notifications should get silently | 319 // extensions that would trigger notifications should get silently |
| 318 // acknowledged. This is a fuse. Calling it the first time returns false. | 320 // acknowledged. This is a fuse. Calling it the first time returns false. |
| 319 // Subsequent calls return true. It's not possible through an API to ever | 321 // Subsequent calls return true. It's not possible through an API to ever |
| 320 // reset it. Don't call it unless you mean it! | 322 // reset it. Don't call it unless you mean it! |
| 321 bool SetAlertSystemFirstRun(); | 323 bool SetAlertSystemFirstRun(); |
| 322 | 324 |
| 323 // Returns the last value set via SetLastPingDay. If there isn't such a | 325 // Returns the last value set via SetLastPingDay. If there isn't such a |
| 324 // pref, the returned Time will return true for is_null(). | 326 // pref, the returned Time will return true for is_null(). |
| 325 base::Time LastPingDay(const std::string& extension_id) const; | 327 base::Time LastPingDay(const std::string& extension_id) const; |
| 326 | 328 |
| 327 // The time stored is based on the server's perspective of day start time, not | 329 // The time stored is based on the server's perspective of day start time, not |
| 328 // the client's. | 330 // the client's. |
| 329 void SetLastPingDay(const std::string& extension_id, const base::Time& time); | 331 void SetLastPingDay(const std::string& extension_id, const base::Time& time); |
| 330 | 332 |
| 331 // Similar to the 2 above, but for the extensions blacklist. | 333 // Similar to the 2 above, but for the extensions blacklist. |
| 332 base::Time BlacklistLastPingDay() const; | 334 base::Time BlacklistLastPingDay() const; |
| 333 void SetBlacklistLastPingDay(const base::Time& time); | 335 void SetBlacklistLastPingDay(const base::Time& time); |
| 334 | 336 |
| 335 // Similar to LastPingDay/SetLastPingDay, but for sending "days since active" | 337 // Similar to LastPingDay/SetLastPingDay, but for sending "days since active" |
| 336 // ping. | 338 // ping. |
| 337 base::Time LastActivePingDay(const std::string& extension_id); | 339 base::Time LastActivePingDay(const std::string& extension_id) const; |
| 338 void SetLastActivePingDay(const std::string& extension_id, | 340 void SetLastActivePingDay(const std::string& extension_id, |
| 339 const base::Time& time); | 341 const base::Time& time); |
| 340 | 342 |
| 341 // A bit we use for determining if we should send the "days since active" | 343 // A bit we use for determining if we should send the "days since active" |
| 342 // ping. A value of true means the item has been active (launched) since the | 344 // ping. A value of true means the item has been active (launched) since the |
| 343 // last update check. | 345 // last update check. |
| 344 bool GetActiveBit(const std::string& extension_id); | 346 bool GetActiveBit(const std::string& extension_id) const; |
| 345 void SetActiveBit(const std::string& extension_id, bool active); | 347 void SetActiveBit(const std::string& extension_id, bool active); |
| 346 | 348 |
| 347 // Returns the granted permission set for the extension with |extension_id|, | 349 // Returns the granted permission set for the extension with |extension_id|, |
| 348 // and NULL if no preferences were found for |extension_id|. | 350 // and NULL if no preferences were found for |extension_id|. |
| 349 // This passes ownership of the returned set to the caller. | 351 // This passes ownership of the returned set to the caller. |
| 350 PermissionSet* GetGrantedPermissions(const std::string& extension_id); | 352 PermissionSet* GetGrantedPermissions(const std::string& extension_id) const; |
| 351 | 353 |
| 352 // Adds |permissions| to the granted permissions set for the extension with | 354 // Adds |permissions| to the granted permissions set for the extension with |
| 353 // |extension_id|. The new granted permissions set will be the union of | 355 // |extension_id|. The new granted permissions set will be the union of |
| 354 // |permissions| and the already granted permissions. | 356 // |permissions| and the already granted permissions. |
| 355 void AddGrantedPermissions(const std::string& extension_id, | 357 void AddGrantedPermissions(const std::string& extension_id, |
| 356 const PermissionSet* permissions); | 358 const PermissionSet* permissions); |
| 357 | 359 |
| 358 // As above, but subtracts the given |permissions| from the granted set. | 360 // As above, but subtracts the given |permissions| from the granted set. |
| 359 void RemoveGrantedPermissions(const std::string& extension_id, | 361 void RemoveGrantedPermissions(const std::string& extension_id, |
| 360 const PermissionSet* permissions); | 362 const PermissionSet* permissions); |
| 361 | 363 |
| 362 // Gets the active permission set for the specified extension. This may | 364 // Gets the active permission set for the specified extension. This may |
| 363 // differ from the permissions in the manifest due to the optional | 365 // differ from the permissions in the manifest due to the optional |
| 364 // permissions API. This passes ownership of the set to the caller. | 366 // permissions API. This passes ownership of the set to the caller. |
| 365 PermissionSet* GetActivePermissions(const std::string& extension_id); | 367 PermissionSet* GetActivePermissions(const std::string& extension_id) const; |
| 366 | 368 |
| 367 // Sets the active |permissions| for the extension with |extension_id|. | 369 // Sets the active |permissions| for the extension with |extension_id|. |
| 368 void SetActivePermissions(const std::string& extension_id, | 370 void SetActivePermissions(const std::string& extension_id, |
| 369 const PermissionSet* permissions); | 371 const PermissionSet* permissions); |
| 370 | 372 |
| 371 // Records whether or not this extension is currently running. | 373 // Records whether or not this extension is currently running. |
| 372 void SetExtensionRunning(const std::string& extension_id, bool is_running); | 374 void SetExtensionRunning(const std::string& extension_id, bool is_running); |
| 373 | 375 |
| 374 // Returns whether or not this extension is marked as running. This is used to | 376 // Returns whether or not this extension is marked as running. This is used to |
| 375 // restart apps across browser restarts. | 377 // restart apps across browser restarts. |
| 376 bool IsExtensionRunning(const std::string& extension_id); | 378 bool IsExtensionRunning(const std::string& extension_id) const; |
| 377 | 379 |
| 378 // Set/Get whether or not the app is active. Used to force a launch of apps | 380 // Set/Get whether or not the app is active. Used to force a launch of apps |
| 379 // that don't handle onRestarted() on a restart. We can only safely do that if | 381 // that don't handle onRestarted() on a restart. We can only safely do that if |
| 380 // the app was active when it was last running. | 382 // the app was active when it was last running. |
| 381 void SetIsActive(const std::string& extension_id, bool is_active); | 383 void SetIsActive(const std::string& extension_id, bool is_active); |
| 382 bool IsActive(const std::string& extension_id); | 384 bool IsActive(const std::string& extension_id) const; |
| 383 | 385 |
| 384 // Returns true if the user enabled this extension to be loaded in incognito | 386 // Returns true if the user enabled this extension to be loaded in incognito |
| 385 // mode. | 387 // mode. |
| 386 // | 388 // |
| 387 // IMPORTANT: you probably want to use extensions::util::IsIncognitoEnabled | 389 // IMPORTANT: you probably want to use extensions::util::IsIncognitoEnabled |
| 388 // instead of this method. | 390 // instead of this method. |
| 389 bool IsIncognitoEnabled(const std::string& extension_id) const; | 391 bool IsIncognitoEnabled(const std::string& extension_id) const; |
| 390 void SetIsIncognitoEnabled(const std::string& extension_id, bool enabled); | 392 void SetIsIncognitoEnabled(const std::string& extension_id, bool enabled); |
| 391 | 393 |
| 392 // Returns true if the user has chosen to allow this extension to inject | 394 // Returns true if the user has chosen to allow this extension to inject |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 443 scoped_ptr<ExtensionsInfo> GetAllDelayedInstallInfo() const; | 445 scoped_ptr<ExtensionsInfo> GetAllDelayedInstallInfo() const; |
| 444 | 446 |
| 445 // Returns true if the extension is an ephemeral app. | 447 // Returns true if the extension is an ephemeral app. |
| 446 bool IsEphemeralApp(const std::string& extension_id) const; | 448 bool IsEphemeralApp(const std::string& extension_id) const; |
| 447 | 449 |
| 448 // Promotes an ephemeral app to a regular installed app. | 450 // Promotes an ephemeral app to a regular installed app. |
| 449 void OnEphemeralAppPromoted(const std::string& extension_id); | 451 void OnEphemeralAppPromoted(const std::string& extension_id); |
| 450 | 452 |
| 451 // Returns true if the user repositioned the app on the app launcher via drag | 453 // Returns true if the user repositioned the app on the app launcher via drag |
| 452 // and drop. | 454 // and drop. |
| 453 bool WasAppDraggedByUser(const std::string& extension_id); | 455 bool WasAppDraggedByUser(const std::string& extension_id) const; |
| 454 | 456 |
| 455 // Sets a flag indicating that the user repositioned the app on the app | 457 // Sets a flag indicating that the user repositioned the app on the app |
| 456 // launcher by drag and dropping it. | 458 // launcher by drag and dropping it. |
| 457 void SetAppDraggedByUser(const std::string& extension_id); | 459 void SetAppDraggedByUser(const std::string& extension_id); |
| 458 | 460 |
| 459 // Returns true if there is an extension which controls the preference value | 461 // Returns true if there is an extension which controls the preference value |
| 460 // for |pref_key| *and* it is specific to incognito mode. | 462 // for |pref_key| *and* it is specific to incognito mode. |
| 461 bool HasIncognitoPrefValue(const std::string& pref_key); | 463 bool HasIncognitoPrefValue(const std::string& pref_key) const; |
| 462 | 464 |
| 463 // Returns the creation flags mask for the extension. | 465 // Returns the creation flags mask for the extension. |
| 464 int GetCreationFlags(const std::string& extension_id) const; | 466 int GetCreationFlags(const std::string& extension_id) const; |
| 465 | 467 |
| 466 // Returns the creation flags mask for a delayed install extension. | 468 // Returns the creation flags mask for a delayed install extension. |
| 467 int GetDelayedInstallCreationFlags(const std::string& extension_id) const; | 469 int GetDelayedInstallCreationFlags(const std::string& extension_id) const; |
| 468 | 470 |
| 469 // Returns true if the extension was installed from the Chrome Web Store. | 471 // Returns true if the extension was installed from the Chrome Web Store. |
| 470 bool IsFromWebStore(const std::string& extension_id) const; | 472 bool IsFromWebStore(const std::string& extension_id) const; |
| 471 | 473 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 503 // The underlying PrefService. | 505 // The underlying PrefService. |
| 504 PrefService* pref_service() const { return prefs_; } | 506 PrefService* pref_service() const { return prefs_; } |
| 505 | 507 |
| 506 // The underlying AppSorting. | 508 // The underlying AppSorting. |
| 507 AppSorting* app_sorting() const { return app_sorting_.get(); } | 509 AppSorting* app_sorting() const { return app_sorting_.get(); } |
| 508 | 510 |
| 509 // Schedules garbage collection of an extension's on-disk data on the next | 511 // Schedules garbage collection of an extension's on-disk data on the next |
| 510 // start of this ExtensionService. Applies only to extensions with isolated | 512 // start of this ExtensionService. Applies only to extensions with isolated |
| 511 // storage. | 513 // storage. |
| 512 void SetNeedsStorageGarbageCollection(bool value); | 514 void SetNeedsStorageGarbageCollection(bool value); |
| 513 bool NeedsStorageGarbageCollection(); | 515 bool NeedsStorageGarbageCollection() const; |
| 514 | 516 |
| 515 // Used by AppWindowGeometryCache to persist its cache. These methods | 517 // Used by AppWindowGeometryCache to persist its cache. These methods |
| 516 // should not be called directly. | 518 // should not be called directly. |
| 517 const base::DictionaryValue* GetGeometryCache( | 519 const base::DictionaryValue* GetGeometryCache( |
| 518 const std::string& extension_id) const; | 520 const std::string& extension_id) const; |
| 519 void SetGeometryCache(const std::string& extension_id, | 521 void SetGeometryCache(const std::string& extension_id, |
| 520 scoped_ptr<base::DictionaryValue> cache); | 522 scoped_ptr<base::DictionaryValue> cache); |
| 521 | 523 |
| 522 // Used for verification of installed extension ids. For the Set method, pass | 524 // Used for verification of installed extension ids. For the Set method, pass |
| 523 // null to remove the preference. | 525 // null to remove the preference. |
| 524 const base::DictionaryValue* GetInstallSignature(); | 526 const base::DictionaryValue* GetInstallSignature() const; |
| 525 void SetInstallSignature(const base::DictionaryValue* signature); | 527 void SetInstallSignature(const base::DictionaryValue* signature); |
| 526 | 528 |
| 527 // The installation parameter associated with the extension. | 529 // The installation parameter associated with the extension. |
| 528 std::string GetInstallParam(const std::string& extension_id) const; | 530 std::string GetInstallParam(const std::string& extension_id) const; |
| 529 void SetInstallParam(const std::string& extension_id, | 531 void SetInstallParam(const std::string& extension_id, |
| 530 const std::string& install_parameter); | 532 const std::string& install_parameter); |
| 531 | 533 |
| 532 // The total number of times we've disabled an extension due to corrupted | 534 // The total number of times we've disabled an extension due to corrupted |
| 533 // contents. | 535 // contents. |
| 534 int GetCorruptedDisableCount(); | 536 int GetCorruptedDisableCount() const; |
| 535 void IncrementCorruptedDisableCount(); | 537 void IncrementCorruptedDisableCount(); |
| 536 | 538 |
| 537 private: | 539 private: |
| 538 friend class ExtensionPrefsBlacklistedExtensions; // Unit test. | 540 friend class ExtensionPrefsBlacklistedExtensions; // Unit test. |
| 539 friend class ExtensionPrefsComponentExtension; // Unit test. | 541 friend class ExtensionPrefsComponentExtension; // Unit test. |
| 540 friend class ExtensionPrefsUninstallExtension; // Unit test. | 542 friend class ExtensionPrefsUninstallExtension; // Unit test. |
| 541 | 543 |
| 542 enum DisableReasonChange { | 544 enum DisableReasonChange { |
| 543 DISABLE_REASON_ADD, | 545 DISABLE_REASON_ADD, |
| 544 DISABLE_REASON_REMOVE, | 546 DISABLE_REASON_REMOVE, |
| (...skipping 22 matching lines...) Expand all Loading... |
| 567 // |extension| dictionary. | 569 // |extension| dictionary. |
| 568 scoped_ptr<ExtensionInfo> GetInstalledInfoHelper( | 570 scoped_ptr<ExtensionInfo> GetInstalledInfoHelper( |
| 569 const std::string& extension_id, | 571 const std::string& extension_id, |
| 570 const base::DictionaryValue* extension) const; | 572 const base::DictionaryValue* extension) const; |
| 571 | 573 |
| 572 // Interprets the list pref, |pref_key| in |extension_id|'s preferences, as a | 574 // Interprets the list pref, |pref_key| in |extension_id|'s preferences, as a |
| 573 // URLPatternSet. The |valid_schemes| specify how to parse the URLPatterns. | 575 // URLPatternSet. The |valid_schemes| specify how to parse the URLPatterns. |
| 574 bool ReadPrefAsURLPatternSet(const std::string& extension_id, | 576 bool ReadPrefAsURLPatternSet(const std::string& extension_id, |
| 575 const std::string& pref_key, | 577 const std::string& pref_key, |
| 576 URLPatternSet* result, | 578 URLPatternSet* result, |
| 577 int valid_schemes); | 579 int valid_schemes) const; |
| 578 | 580 |
| 579 // Converts |new_value| to a list of strings and sets the |pref_key| pref | 581 // Converts |new_value| to a list of strings and sets the |pref_key| pref |
| 580 // belonging to |extension_id|. | 582 // belonging to |extension_id|. |
| 581 void SetExtensionPrefURLPatternSet(const std::string& extension_id, | 583 void SetExtensionPrefURLPatternSet(const std::string& extension_id, |
| 582 const std::string& pref_key, | 584 const std::string& pref_key, |
| 583 const URLPatternSet& new_value); | 585 const URLPatternSet& new_value); |
| 584 | 586 |
| 585 // Read the boolean preference entry and return true if the preference exists | 587 // Read the boolean preference entry and return true if the preference exists |
| 586 // and the preference's value is true; false otherwise. | 588 // and the preference's value is true; false otherwise. |
| 587 bool ReadPrefAsBooleanAndReturn(const std::string& extension_id, | 589 bool ReadPrefAsBooleanAndReturn(const std::string& extension_id, |
| 588 const std::string& key) const; | 590 const std::string& key) const; |
| 589 | 591 |
| 590 // Interprets |pref_key| in |extension_id|'s preferences as an | 592 // Interprets |pref_key| in |extension_id|'s preferences as an |
| 591 // PermissionSet, and passes ownership of the set to the caller. | 593 // PermissionSet, and passes ownership of the set to the caller. |
| 592 PermissionSet* ReadPrefAsPermissionSet(const std::string& extension_id, | 594 PermissionSet* ReadPrefAsPermissionSet(const std::string& extension_id, |
| 593 const std::string& pref_key); | 595 const std::string& pref_key) const; |
| 594 | 596 |
| 595 // Converts the |new_value| to its value and sets the |pref_key| pref | 597 // Converts the |new_value| to its value and sets the |pref_key| pref |
| 596 // belonging to |extension_id|. | 598 // belonging to |extension_id|. |
| 597 void SetExtensionPrefPermissionSet(const std::string& extension_id, | 599 void SetExtensionPrefPermissionSet(const std::string& extension_id, |
| 598 const std::string& pref_key, | 600 const std::string& pref_key, |
| 599 const PermissionSet* new_value); | 601 const PermissionSet* new_value); |
| 600 | 602 |
| 601 // Returns an immutable dictionary for extension |id|'s prefs, or NULL if it | 603 // Returns an immutable dictionary for extension |id|'s prefs, or NULL if it |
| 602 // doesn't exist. | 604 // doesn't exist. |
| 603 const base::DictionaryValue* GetExtensionPref(const std::string& id) const; | 605 const base::DictionaryValue* GetExtensionPref(const std::string& id) const; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 628 // it matches |check_state|. | 630 // it matches |check_state|. |
| 629 bool DoesExtensionHaveState(const std::string& id, | 631 bool DoesExtensionHaveState(const std::string& id, |
| 630 Extension::State check_state) const; | 632 Extension::State check_state) const; |
| 631 | 633 |
| 632 // Reads the list of strings for |pref| from user prefs into | 634 // Reads the list of strings for |pref| from user prefs into |
| 633 // |id_container_out|. Returns false if the pref wasn't found in the user | 635 // |id_container_out|. Returns false if the pref wasn't found in the user |
| 634 // pref store. | 636 // pref store. |
| 635 template <class ExtensionIdContainer> | 637 template <class ExtensionIdContainer> |
| 636 bool GetUserExtensionPrefIntoContainer( | 638 bool GetUserExtensionPrefIntoContainer( |
| 637 const char* pref, | 639 const char* pref, |
| 638 ExtensionIdContainer* id_container_out); | 640 ExtensionIdContainer* id_container_out) const; |
| 639 | 641 |
| 640 // Writes the list of strings contained in |strings| to |pref| in prefs. | 642 // Writes the list of strings contained in |strings| to |pref| in prefs. |
| 641 template <class ExtensionIdContainer> | 643 template <class ExtensionIdContainer> |
| 642 void SetExtensionPrefFromContainer(const char* pref, | 644 void SetExtensionPrefFromContainer(const char* pref, |
| 643 const ExtensionIdContainer& strings); | 645 const ExtensionIdContainer& strings); |
| 644 | 646 |
| 645 // Helper function to populate |extension_dict| with the values needed | 647 // Helper function to populate |extension_dict| with the values needed |
| 646 // by a newly installed extension. Work is broken up between this | 648 // by a newly installed extension. Work is broken up between this |
| 647 // function and FinishExtensionInfoPrefs() to accomodate delayed | 649 // function and FinishExtensionInfoPrefs() to accommodate delayed |
| 648 // installations. | 650 // installations. |
| 649 // | 651 // |
| 650 // |install_flags| are a bitmask of extension::InstallFlags. | 652 // |install_flags| are a bitmask of extension::InstallFlags. |
| 651 void PopulateExtensionInfoPrefs(const Extension* extension, | 653 void PopulateExtensionInfoPrefs(const Extension* extension, |
| 652 const base::Time install_time, | 654 const base::Time install_time, |
| 653 Extension::State initial_state, | 655 Extension::State initial_state, |
| 654 int install_flags, | 656 int install_flags, |
| 655 const std::string& install_parameter, | 657 const std::string& install_parameter, |
| 656 base::DictionaryValue* extension_dict); | 658 base::DictionaryValue* extension_dict) const; |
| 657 | 659 |
| 658 void InitExtensionControlledPrefs(ExtensionPrefValueMap* value_map); | 660 void InitExtensionControlledPrefs(ExtensionPrefValueMap* value_map); |
| 659 | 661 |
| 660 // Helper function to complete initialization of the values in | 662 // Helper function to complete initialization of the values in |
| 661 // |extension_dict| for an extension install. Also see | 663 // |extension_dict| for an extension install. Also see |
| 662 // PopulateExtensionInfoPrefs(). | 664 // PopulateExtensionInfoPrefs(). |
| 663 void FinishExtensionInfoPrefs( | 665 void FinishExtensionInfoPrefs( |
| 664 const std::string& extension_id, | 666 const std::string& extension_id, |
| 665 const base::Time install_time, | 667 const base::Time install_time, |
| 666 bool needs_sort_ordinal, | 668 bool needs_sort_ordinal, |
| (...skipping 19 matching lines...) Expand all Loading... |
| 686 bool extensions_disabled_; | 688 bool extensions_disabled_; |
| 687 | 689 |
| 688 ObserverList<ExtensionPrefsObserver> observer_list_; | 690 ObserverList<ExtensionPrefsObserver> observer_list_; |
| 689 | 691 |
| 690 DISALLOW_COPY_AND_ASSIGN(ExtensionPrefs); | 692 DISALLOW_COPY_AND_ASSIGN(ExtensionPrefs); |
| 691 }; | 693 }; |
| 692 | 694 |
| 693 } // namespace extensions | 695 } // namespace extensions |
| 694 | 696 |
| 695 #endif // EXTENSIONS_BROWSER_EXTENSION_PREFS_H_ | 697 #endif // EXTENSIONS_BROWSER_EXTENSION_PREFS_H_ |
| OLD | NEW |