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

Side by Side Diff: extensions/browser/runtime_data.cc

Issue 131743021: app_shell: Extract extension runtime data from ExtensionService (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rename, bitmask (runtime_data) Created 6 years, 11 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 | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "extensions/browser/runtime_data.h"
6
7 #include "extensions/common/extension.h"
8 #include "extensions/common/manifest_handlers/background_info.h"
9
10 namespace extensions {
11
12 RuntimeData::RuntimeData() {}
13
14 RuntimeData::~RuntimeData() {}
15
16 void RuntimeData::Erase(const Extension* extension) {
17 extension_flags_.erase(extension->id());
18 }
19
20 void RuntimeData::ClearAll() {
21 extension_flags_.clear();
22 }
23
24 bool RuntimeData::IsBackgroundPageReady(const Extension* extension) const {
25 if (!BackgroundInfo::HasPersistentBackgroundPage(extension))
26 return true;
27 return GetFlag(extension, BACKGROUND_PAGE_READY);
28 }
29
30 void RuntimeData::SetBackgroundPageReady(const Extension* extension,
31 bool value) {
32 SetFlag(extension, BACKGROUND_PAGE_READY, value);
33 }
34
35 bool RuntimeData::IsBeingUpgraded(const Extension* extension) const {
36 return GetFlag(extension, BEING_UPGRADED);
37 }
38
39 void RuntimeData::SetBeingUpgraded(const Extension* extension, bool value) {
40 SetFlag(extension, BEING_UPGRADED, value);
41 }
42
43 bool RuntimeData::HasUsedWebRequest(const Extension* extension) const {
44 return GetFlag(extension, HAS_USED_WEBREQUEST);
45 }
46
47 void RuntimeData::SetHasUsedWebRequest(const Extension* extension, bool value) {
48 SetFlag(extension, HAS_USED_WEBREQUEST, value);
49 }
50
51 bool RuntimeData::GetFlag(const Extension* extension, RuntimeFlag flag) const {
52 ExtensionFlagsMap::const_iterator it = extension_flags_.find(extension->id());
53 if (it == extension_flags_.end())
54 return false;
55 return it->second & flag;
56 }
57
58 void RuntimeData::SetFlag(const Extension* extension,
59 RuntimeFlag flag,
60 bool value) {
61 if (value)
62 extension_flags_[extension->id()] |= flag;
63 else
64 extension_flags_[extension->id()] &= ~flag;
65 }
66
67 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698