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

Side by Side Diff: chrome/browser/extensions/api/alarms/alarm_manager.cc

Issue 18713004: Clear existing alarms when uninstalling extension. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 5 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/alarms/alarm_manager.h" 5 #include "chrome/browser/extensions/api/alarms/alarm_manager.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/json/json_writer.h" 8 #include "base/json/json_writer.h"
9 #include "base/lazy_instance.h" 9 #include "base/lazy_instance.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 } // namespace 90 } // namespace
91 91
92 // AlarmManager 92 // AlarmManager
93 93
94 AlarmManager::AlarmManager(Profile* profile) 94 AlarmManager::AlarmManager(Profile* profile)
95 : profile_(profile), 95 : profile_(profile),
96 clock_(new base::DefaultClock()), 96 clock_(new base::DefaultClock()),
97 delegate_(new DefaultAlarmDelegate(profile)) { 97 delegate_(new DefaultAlarmDelegate(profile)) {
98 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, 98 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED,
99 content::Source<Profile>(profile_)); 99 content::Source<Profile>(profile_));
100 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNINSTALLED,
101 content::Source<Profile>(profile_));
100 102
101 StateStore* storage = ExtensionSystem::Get(profile_)->state_store(); 103 StateStore* storage = ExtensionSystem::Get(profile_)->state_store();
102 if (storage) 104 if (storage)
103 storage->RegisterKey(kRegisteredAlarms); 105 storage->RegisterKey(kRegisteredAlarms);
104 } 106 }
105 107
106 AlarmManager::~AlarmManager() { 108 AlarmManager::~AlarmManager() {
107 } 109 }
108 110
109 void AlarmManager::AddAlarm(const std::string& extension_id, 111 void AlarmManager::AddAlarm(const std::string& extension_id,
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 const Extension* extension = 339 const Extension* extension =
338 content::Details<const Extension>(details).ptr(); 340 content::Details<const Extension>(details).ptr();
339 StateStore* storage = ExtensionSystem::Get(profile_)->state_store(); 341 StateStore* storage = ExtensionSystem::Get(profile_)->state_store();
340 if (storage) { 342 if (storage) {
341 storage->GetExtensionValue(extension->id(), kRegisteredAlarms, 343 storage->GetExtensionValue(extension->id(), kRegisteredAlarms,
342 base::Bind(&AlarmManager::ReadFromStorage, 344 base::Bind(&AlarmManager::ReadFromStorage,
343 AsWeakPtr(), extension->id())); 345 AsWeakPtr(), extension->id()));
344 } 346 }
345 break; 347 break;
346 } 348 }
349 case chrome::NOTIFICATION_EXTENSION_UNINSTALLED: {
350 const Extension* extension =
351 content::Details<const Extension>(details).ptr();
352 RemoveAllAlarms(extension->id());
353 break;
354 }
347 default: 355 default:
348 NOTREACHED(); 356 NOTREACHED();
349 break; 357 break;
350 } 358 }
351 } 359 }
352 360
353 // AlarmManager::Alarm 361 // AlarmManager::Alarm
354 362
355 Alarm::Alarm() 363 Alarm::Alarm()
356 : js_alarm(new api::alarms::Alarm()) { 364 : js_alarm(new api::alarms::Alarm()) {
(...skipping 30 matching lines...) Expand all
387 if (create_info.period_in_minutes.get()) { 395 if (create_info.period_in_minutes.get()) {
388 js_alarm->period_in_minutes.reset( 396 js_alarm->period_in_minutes.reset(
389 new double(*create_info.period_in_minutes)); 397 new double(*create_info.period_in_minutes));
390 } 398 }
391 } 399 }
392 400
393 Alarm::~Alarm() { 401 Alarm::~Alarm() {
394 } 402 }
395 403
396 } // namespace extensions 404 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698