Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(25)

Side by Side Diff: chrome/browser/extensions/api/module/module.cc

Issue 15051010: Move [Get|Set]UpdateURLData from ExtensionPrefs to ExtensionAPI (aka Module) (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Android Gypi Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 {
20
21 // A preference for storing the extension's update URL data. If not empty, the
22 // the ExtensionUpdater will append a ap= parameter to the URL when checking if
23 // a new version of the extension is available.
24 const char kUpdateURLData[] = "update_url_data";
25
26 } // namespace
27
28 std::string GetUpdateURLData(const ExtensionPrefs* prefs,
29 const std::string& extension_id) {
30 std::string data;
31 prefs->ReadPrefAsString(extension_id, kUpdateURLData, &data);
32 return data;
17 } 33 }
18 34
35 } // namespace extension
36
19 bool ExtensionSetUpdateUrlDataFunction::RunImpl() { 37 bool ExtensionSetUpdateUrlDataFunction::RunImpl() {
20 std::string data; 38 std::string data;
21 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &data)); 39 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &data));
22 40
23 extension_prefs()->SetUpdateUrlData(extension_id(), data); 41 ExtensionPrefs::Get(profile())->UpdateExtensionPref(
42 extension_id(),
43 extension::kUpdateURLData,
44 base::Value::CreateStringValue(data));
24 return true; 45 return true;
25 } 46 }
26 47
27 bool ExtensionIsAllowedIncognitoAccessFunction::RunImpl() { 48 bool ExtensionIsAllowedIncognitoAccessFunction::RunImpl() {
28 ExtensionService* ext_service = profile()->GetExtensionService(); 49 ExtensionService* ext_service =
50 ExtensionSystem::Get(profile())->extension_service();
29 const Extension* extension = GetExtension(); 51 const Extension* extension = GetExtension();
30 52
31 SetResult(Value::CreateBooleanValue( 53 SetResult(Value::CreateBooleanValue(
32 ext_service->IsIncognitoEnabled(extension->id()))); 54 ext_service->IsIncognitoEnabled(extension->id())));
33 return true; 55 return true;
34 } 56 }
35 57
36 bool ExtensionIsAllowedFileSchemeAccessFunction::RunImpl() { 58 bool ExtensionIsAllowedFileSchemeAccessFunction::RunImpl() {
37 ExtensionService* ext_service = profile()->GetExtensionService(); 59 ExtensionService* ext_service =
60 ExtensionSystem::Get(profile())->extension_service();
38 const Extension* extension = GetExtension(); 61 const Extension* extension = GetExtension();
39 62
40 SetResult(Value::CreateBooleanValue( 63 SetResult(Value::CreateBooleanValue(
41 ext_service->AllowFileAccess(extension))); 64 ext_service->AllowFileAccess(extension)));
42 return true; 65 return true;
43 } 66 }
44 67
45 } // namespace extensions 68 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/module/module.h ('k') | chrome/browser/extensions/extension_prefs.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698