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

Side by Side Diff: chrome/browser/extensions/extension_module.cc

Issue 9791011: Add experimental.alarms API to allow lazy background pages to (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 8 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
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/extension_module.h" 5 #include "chrome/browser/extensions/extension_module.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "chrome/browser/browser_process.h"
10 #include "chrome/browser/extensions/extension_event_router.h"
9 #include "chrome/browser/extensions/extension_prefs.h" 11 #include "chrome/browser/extensions/extension_prefs.h"
10 #include "chrome/browser/extensions/extension_service.h" 12 #include "chrome/browser/extensions/extension_service.h"
11 #include "chrome/browser/profiles/profile.h" 13 #include "chrome/browser/profiles/profile.h"
12 14
15 namespace {
16
17 const char kOnInstalledEvent[] = "experimental.extension.onInstalled";
18
19 }
20
21 // static
22 void ExtensionModuleEventRouter::DispatchOnInstalledEvent(
23 Profile* profile, const Extension* extension) {
24 // Special case: normally, extensions add their own lazy event listeners.
25 // However, since the extension has just been installed, it hasn't had a
26 // chance to register for events. So we register on its behalf. If the
27 // extension does not actually have a listener, the event will just be
28 // ignored.
29 ExtensionEventRouter* router = profile->GetExtensionEventRouter();
30 router->AddLazyEventListener(kOnInstalledEvent, extension->id());
31 router->DispatchEventToExtension(
32 extension->id(), kOnInstalledEvent, "[]", NULL, GURL());
33 }
34
13 ExtensionPrefs* SetUpdateUrlDataFunction::extension_prefs() { 35 ExtensionPrefs* SetUpdateUrlDataFunction::extension_prefs() {
14 return profile()->GetExtensionService()->extension_prefs(); 36 return profile()->GetExtensionService()->extension_prefs();
15 } 37 }
16 38
17 bool SetUpdateUrlDataFunction::RunImpl() { 39 bool SetUpdateUrlDataFunction::RunImpl() {
18 std::string data; 40 std::string data;
19 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &data)); 41 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &data));
20 42
21 extension_prefs()->SetUpdateUrlData(extension_id(), data); 43 extension_prefs()->SetUpdateUrlData(extension_id(), data);
22 return true; 44 return true;
23 } 45 }
24 46
25 bool IsAllowedIncognitoAccessFunction::RunImpl() { 47 bool IsAllowedIncognitoAccessFunction::RunImpl() {
26 ExtensionService* ext_service = profile()->GetExtensionService(); 48 ExtensionService* ext_service = profile()->GetExtensionService();
27 const Extension* extension = GetExtension(); 49 const Extension* extension = GetExtension();
28 50
29 result_.reset(Value::CreateBooleanValue( 51 result_.reset(Value::CreateBooleanValue(
30 ext_service->IsIncognitoEnabled(extension->id()))); 52 ext_service->IsIncognitoEnabled(extension->id())));
31 return true; 53 return true;
32 } 54 }
33 55
34 bool IsAllowedFileSchemeAccessFunction::RunImpl() { 56 bool IsAllowedFileSchemeAccessFunction::RunImpl() {
35 ExtensionService* ext_service = profile()->GetExtensionService(); 57 ExtensionService* ext_service = profile()->GetExtensionService();
36 const Extension* extension = GetExtension(); 58 const Extension* extension = GetExtension();
37 59
38 result_.reset(Value::CreateBooleanValue( 60 result_.reset(Value::CreateBooleanValue(
39 ext_service->AllowFileAccess(extension))); 61 ext_service->AllowFileAccess(extension)));
40 return true; 62 return true;
41 } 63 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_module.h ('k') | chrome/browser/extensions/lazy_background_task_queue.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698