OLD | NEW |
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/app/app_api.h" | 5 #include "chrome/browser/extensions/api/app/app_api.h" |
6 | 6 |
7 #include "base/values.h" | 7 #include "base/values.h" |
8 #include "base/time.h" | 8 #include "base/time.h" |
9 #include "chrome/browser/extensions/app_notification_manager.h" | 9 #include "chrome/browser/extensions/app_notification_manager.h" |
| 10 #include "chrome/browser/extensions/extension_event_router.h" |
10 #include "chrome/browser/extensions/extension_service.h" | 11 #include "chrome/browser/extensions/extension_service.h" |
11 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
12 #include "chrome/common/chrome_notification_types.h" | 13 #include "chrome/common/chrome_notification_types.h" |
13 #include "chrome/common/extensions/extension.h" | 14 #include "chrome/common/extensions/extension.h" |
14 #include "chrome/common/extensions/extension_constants.h" | 15 #include "chrome/common/extensions/extension_constants.h" |
15 #include "content/public/browser/notification_service.h" | 16 #include "content/public/browser/notification_service.h" |
| 17 #include "googleurl/src/gurl.h" |
| 18 |
| 19 namespace { |
16 | 20 |
17 const char kBodyTextKey[] = "bodyText"; | 21 const char kBodyTextKey[] = "bodyText"; |
18 const char kExtensionIdKey[] = "extensionId"; | 22 const char kExtensionIdKey[] = "extensionId"; |
19 const char kLinkTextKey[] = "linkText"; | 23 const char kLinkTextKey[] = "linkText"; |
20 const char kLinkUrlKey[] = "linkUrl"; | 24 const char kLinkUrlKey[] = "linkUrl"; |
21 const char kTitleKey[] = "title"; | 25 const char kTitleKey[] = "title"; |
22 | 26 |
23 const char kInvalidExtensionIdError[] = | 27 const char kInvalidExtensionIdError[] = |
24 "Invalid extension id"; | 28 "Invalid extension id"; |
25 const char kMissingLinkTextError[] = | 29 const char kMissingLinkTextError[] = |
26 "You must specify linkText if you use linkUrl"; | 30 "You must specify linkText if you use linkUrl"; |
| 31 const char kOnLaunchedEvent[] = "experimental.app.onLaunched"; |
| 32 |
| 33 } // anonymous namespace |
| 34 |
| 35 namespace extensions { |
27 | 36 |
28 bool AppNotifyFunction::RunImpl() { | 37 bool AppNotifyFunction::RunImpl() { |
29 if (!include_incognito() && profile_->IsOffTheRecord()) { | 38 if (!include_incognito() && profile_->IsOffTheRecord()) { |
30 error_ = extension_misc::kAppNotificationsIncognitoError; | 39 error_ = extension_misc::kAppNotificationsIncognitoError; |
31 return false; | 40 return false; |
32 } | 41 } |
33 | 42 |
34 DictionaryValue* details; | 43 DictionaryValue* details; |
35 EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(0, &details)); | 44 EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(0, &details)); |
36 EXTENSION_FUNCTION_VALIDATE(details != NULL); | 45 EXTENSION_FUNCTION_VALIDATE(details != NULL); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 error_ = kInvalidExtensionIdError; | 105 error_ = kInvalidExtensionIdError; |
97 return false; | 106 return false; |
98 } | 107 } |
99 } | 108 } |
100 | 109 |
101 AppNotificationManager* manager = | 110 AppNotificationManager* manager = |
102 profile()->GetExtensionService()->app_notification_manager(); | 111 profile()->GetExtensionService()->app_notification_manager(); |
103 manager->ClearAll(id); | 112 manager->ClearAll(id); |
104 return true; | 113 return true; |
105 } | 114 } |
| 115 |
| 116 // static. |
| 117 void AppEventRouter::DispatchOnLaunchedEvent( |
| 118 Profile* profile, const Extension* extension) { |
| 119 profile->GetExtensionEventRouter()->DispatchEventToExtension( |
| 120 extension->id(), kOnLaunchedEvent, "[]", NULL, GURL()); |
| 121 } |
| 122 |
| 123 } // namespace extensions |
OLD | NEW |