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

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

Issue 61323002: Fix broken threading model in CheckDesktopNotificationPermission (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Even more merge conflicts.. Created 7 years, 1 month 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
« no previous file with comments | « extensions/browser/info_map.h ('k') | extensions/browser/info_map_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "extensions/browser/info_map.h" 5 #include "extensions/browser/info_map.h"
6 6
7 #include "chrome/common/extensions/extension.h" 7 #include "chrome/common/extensions/extension.h"
8 #include "chrome/common/extensions/extension_set.h" 8 #include "chrome/common/extensions/extension_set.h"
9 #include "content/public/browser/browser_thread.h" 9 #include "content/public/browser/browser_thread.h"
10 #include "extensions/common/constants.h" 10 #include "extensions/common/constants.h"
(...skipping 11 matching lines...) Expand all
22 22
23 } // namespace 23 } // namespace
24 24
25 struct InfoMap::ExtraData { 25 struct InfoMap::ExtraData {
26 // When the extension was installed. 26 // When the extension was installed.
27 base::Time install_time; 27 base::Time install_time;
28 28
29 // True if the user has allowed this extension to run in incognito mode. 29 // True if the user has allowed this extension to run in incognito mode.
30 bool incognito_enabled; 30 bool incognito_enabled;
31 31
32 // True if the user has disabled notifications for this extension manually.
33 bool notifications_disabled;
34
32 ExtraData(); 35 ExtraData();
33 ~ExtraData(); 36 ~ExtraData();
34 }; 37 };
35 38
36 InfoMap::ExtraData::ExtraData() : incognito_enabled(false) {} 39 InfoMap::ExtraData::ExtraData() : incognito_enabled(false) {}
37 40
38 InfoMap::ExtraData::~ExtraData() {} 41 InfoMap::ExtraData::~ExtraData() {}
39 42
40 InfoMap::InfoMap() : signin_process_id_(-1) {} 43 InfoMap::InfoMap() : signin_process_id_(-1) {}
41 44
42 const ProcessMap& InfoMap::process_map() const { return process_map_; } 45 const ProcessMap& InfoMap::process_map() const { return process_map_; }
43 46
44 void InfoMap::AddExtension(const Extension* extension, 47 void InfoMap::AddExtension(const Extension* extension,
45 base::Time install_time, 48 base::Time install_time,
46 bool incognito_enabled) { 49 bool incognito_enabled,
50 bool notifications_disabled) {
47 CheckOnValidThread(); 51 CheckOnValidThread();
48 extensions_.Insert(extension); 52 extensions_.Insert(extension);
49 disabled_extensions_.Remove(extension->id()); 53 disabled_extensions_.Remove(extension->id());
50 54
51 extra_data_[extension->id()].install_time = install_time; 55 extra_data_[extension->id()].install_time = install_time;
52 extra_data_[extension->id()].incognito_enabled = incognito_enabled; 56 extra_data_[extension->id()].incognito_enabled = incognito_enabled;
57 extra_data_[extension->id()].notifications_disabled = notifications_disabled;
53 } 58 }
54 59
55 void InfoMap::RemoveExtension(const std::string& extension_id, 60 void InfoMap::RemoveExtension(const std::string& extension_id,
56 const UnloadedExtensionInfo::Reason reason) { 61 const UnloadedExtensionInfo::Reason reason) {
57 CheckOnValidThread(); 62 CheckOnValidThread();
58 const Extension* extension = extensions_.GetByID(extension_id); 63 const Extension* extension = extensions_.GetByID(extension_id);
59 extra_data_.erase(extension_id); // we don't care about disabled extra data 64 extra_data_.erase(extension_id); // we don't care about disabled extra data
60 bool was_uninstalled = (reason != UnloadedExtensionInfo::REASON_DISABLE && 65 bool was_uninstalled = (reason != UnloadedExtensionInfo::REASON_DISABLE &&
61 reason != UnloadedExtensionInfo::REASON_TERMINATE); 66 reason != UnloadedExtensionInfo::REASON_TERMINATE);
62 if (extension) { 67 if (extension) {
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 } 169 }
165 170
166 void InfoMap::SetSigninProcess(int process_id) { 171 void InfoMap::SetSigninProcess(int process_id) {
167 signin_process_id_ = process_id; 172 signin_process_id_ = process_id;
168 } 173 }
169 174
170 bool InfoMap::IsSigninProcess(int process_id) const { 175 bool InfoMap::IsSigninProcess(int process_id) const {
171 return process_id == signin_process_id_; 176 return process_id == signin_process_id_;
172 } 177 }
173 178
179 void InfoMap::SetNotificationsDisabled(
180 const std::string& extension_id,
181 bool notifications_disabled) {
182 ExtraDataMap::iterator iter = extra_data_.find(extension_id);
183 if (iter != extra_data_.end())
184 iter->second.notifications_disabled = notifications_disabled;
185 }
186
187 bool InfoMap::AreNotificationsDisabled(
188 const std::string& extension_id) const {
189 ExtraDataMap::const_iterator iter = extra_data_.find(extension_id);
190 if (iter != extra_data_.end())
191 return iter->second.notifications_disabled;
192 return false;
193 }
194
174 InfoMap::~InfoMap() { 195 InfoMap::~InfoMap() {
175 if (quota_service_) { 196 if (quota_service_) {
176 BrowserThread::DeleteSoon( 197 BrowserThread::DeleteSoon(
177 BrowserThread::IO, FROM_HERE, quota_service_.release()); 198 BrowserThread::IO, FROM_HERE, quota_service_.release());
178 } 199 }
179 } 200 }
180 201
181 } // namespace extensions 202 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/browser/info_map.h ('k') | extensions/browser/info_map_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698