Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / chrome / browser / extensions / api / module / module.cc
blob13bc0f0df12d6744a4753d76d29fe07e82572a9e
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
3 // found in the LICENSE file.
5 #include "chrome/browser/extensions/api/module/module.h"
7 #include <string>
9 #include "base/values.h"
10 #include "chrome/browser/extensions/extension_service.h"
11 #include "chrome/browser/extensions/extension_util.h"
12 #include "chrome/browser/profiles/profile.h"
13 #include "extensions/browser/extension_prefs.h"
14 #include "extensions/browser/extension_system.h"
15 #include "extensions/common/manifest_url_handlers.h"
17 namespace extensions {
19 namespace extension {
21 namespace {
23 // A preference for storing the extension's update URL data. If not empty, the
24 // the ExtensionUpdater will append a ap= parameter to the URL when checking if
25 // a new version of the extension is available.
26 const char kUpdateURLData[] = "update_url_data";
28 } // namespace
30 std::string GetUpdateURLData(const ExtensionPrefs* prefs,
31 const std::string& extension_id) {
32 std::string data;
33 prefs->ReadPrefAsString(extension_id, kUpdateURLData, &data);
34 return data;
37 } // namespace extension
39 bool ExtensionSetUpdateUrlDataFunction::RunSync() {
40 std::string data;
41 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &data));
43 if (ManifestURL::UpdatesFromGallery(extension())) {
44 return false;
47 ExtensionPrefs::Get(GetProfile())->UpdateExtensionPref(
48 extension_id(), extension::kUpdateURLData, new base::StringValue(data));
49 return true;
52 bool ExtensionIsAllowedIncognitoAccessFunction::RunSync() {
53 SetResult(new base::FundamentalValue(
54 util::IsIncognitoEnabled(extension_id(), GetProfile())));
55 return true;
58 bool ExtensionIsAllowedFileSchemeAccessFunction::RunSync() {
59 SetResult(new base::FundamentalValue(
60 util::AllowFileAccess(extension_id(), GetProfile())));
61 return true;
64 } // namespace extensions