Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/api/module/module.h" | 5 #include "chrome/browser/extensions/api/module/module.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/values.h" | |
| 9 #include "chrome/browser/extensions/extension_prefs.h" | 10 #include "chrome/browser/extensions/extension_prefs.h" |
| 10 #include "chrome/browser/extensions/extension_service.h" | 11 #include "chrome/browser/extensions/extension_service.h" |
| 12 #include "chrome/browser/extensions/extension_system.h" | |
| 11 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
| 12 | 14 |
| 13 namespace extensions { | 15 namespace extensions { |
| 14 | 16 |
| 15 ExtensionPrefs* ExtensionSetUpdateUrlDataFunction::extension_prefs() { | 17 namespace extension { |
| 16 return profile()->GetExtensionService()->extension_prefs(); | 18 |
| 19 namespace { | |
|
Yoyo Zhou
2013/05/16 18:39:09
newline after
| |
| 20 // A preference for storing the extension's update URL data. If not empty, the | |
| 21 // the ExtensionUpdater will append a ap= parameter to the URL when checking if | |
| 22 // a new version of the extension is available. | |
| 23 const char kUpdateURLData[] = "update_url_data"; | |
| 24 } // namespace | |
| 25 | |
| 26 std::string GetUpdateURLData(const ExtensionPrefs* prefs, | |
| 27 const std::string& extension_id) { | |
| 28 std::string data; | |
| 29 prefs->ReadPrefAsString(extension_id, kUpdateURLData, &data); | |
| 30 return data; | |
| 17 } | 31 } |
| 18 | 32 |
| 33 } // namespace extension | |
| 34 | |
| 19 bool ExtensionSetUpdateUrlDataFunction::RunImpl() { | 35 bool ExtensionSetUpdateUrlDataFunction::RunImpl() { |
| 20 std::string data; | 36 std::string data; |
| 21 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &data)); | 37 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &data)); |
| 22 | 38 |
| 23 extension_prefs()->SetUpdateUrlData(extension_id(), data); | 39 ExtensionSystem::Get(profile())->extension_prefs()->UpdateExtensionPref( |
| 40 extension_id(), | |
| 41 extension::kUpdateURLData, | |
| 42 base::Value::CreateStringValue(data)); | |
| 24 return true; | 43 return true; |
| 25 } | 44 } |
| 26 | 45 |
| 27 bool ExtensionIsAllowedIncognitoAccessFunction::RunImpl() { | 46 bool ExtensionIsAllowedIncognitoAccessFunction::RunImpl() { |
| 28 ExtensionService* ext_service = profile()->GetExtensionService(); | 47 ExtensionService* ext_service = |
| 48 ExtensionSystem::Get(profile())->extension_service(); | |
| 29 const Extension* extension = GetExtension(); | 49 const Extension* extension = GetExtension(); |
| 30 | 50 |
| 31 SetResult(Value::CreateBooleanValue( | 51 SetResult(Value::CreateBooleanValue( |
| 32 ext_service->IsIncognitoEnabled(extension->id()))); | 52 ext_service->IsIncognitoEnabled(extension->id()))); |
| 33 return true; | 53 return true; |
| 34 } | 54 } |
| 35 | 55 |
| 36 bool ExtensionIsAllowedFileSchemeAccessFunction::RunImpl() { | 56 bool ExtensionIsAllowedFileSchemeAccessFunction::RunImpl() { |
| 37 ExtensionService* ext_service = profile()->GetExtensionService(); | 57 ExtensionService* ext_service = |
| 58 ExtensionSystem::Get(profile())->extension_service(); | |
| 38 const Extension* extension = GetExtension(); | 59 const Extension* extension = GetExtension(); |
| 39 | 60 |
| 40 SetResult(Value::CreateBooleanValue( | 61 SetResult(Value::CreateBooleanValue( |
| 41 ext_service->AllowFileAccess(extension))); | 62 ext_service->AllowFileAccess(extension))); |
| 42 return true; | 63 return true; |
| 43 } | 64 } |
| 44 | 65 |
| 45 } // namespace extensions | 66 } // namespace extensions |
| OLD | NEW |