OLD | NEW |
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_app_api.h" | 5 #include "chrome/browser/extensions/extension_app_api.h" |
6 | 6 |
7 #include "base/values.h" | 7 #include "base/values.h" |
| 8 #include "base/time.h" |
8 #include "chrome/browser/extensions/app_notification_manager.h" | 9 #include "chrome/browser/extensions/app_notification_manager.h" |
9 #include "chrome/browser/extensions/extension_service.h" | 10 #include "chrome/browser/extensions/extension_service.h" |
10 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
11 #include "chrome/common/chrome_notification_types.h" | 12 #include "chrome/common/chrome_notification_types.h" |
12 #include "chrome/common/extensions/extension.h" | 13 #include "chrome/common/extensions/extension.h" |
13 #include "content/public/browser/notification_service.h" | 14 #include "content/public/browser/notification_service.h" |
14 | 15 |
15 const char kBodyTextKey[] = "bodyText"; | 16 const char kBodyTextKey[] = "bodyText"; |
16 const char kExtensionIdKey[] = "extensionId"; | 17 const char kExtensionIdKey[] = "extensionId"; |
17 const char kLinkTextKey[] = "linkText"; | 18 const char kLinkTextKey[] = "linkText"; |
(...skipping 22 matching lines...) Expand all Loading... |
40 | 41 |
41 std::string title; | 42 std::string title; |
42 if (details->HasKey(kTitleKey)) | 43 if (details->HasKey(kTitleKey)) |
43 EXTENSION_FUNCTION_VALIDATE(details->GetString(kTitleKey, &title)); | 44 EXTENSION_FUNCTION_VALIDATE(details->GetString(kTitleKey, &title)); |
44 | 45 |
45 std::string body; | 46 std::string body; |
46 if (details->HasKey(kBodyTextKey)) | 47 if (details->HasKey(kBodyTextKey)) |
47 EXTENSION_FUNCTION_VALIDATE(details->GetString(kBodyTextKey, &body)); | 48 EXTENSION_FUNCTION_VALIDATE(details->GetString(kBodyTextKey, &body)); |
48 | 49 |
49 scoped_ptr<AppNotification> item(new AppNotification( | 50 scoped_ptr<AppNotification> item(new AppNotification( |
50 true, "", id, title, body)); | 51 true, base::Time::Now(), "", id, title, body)); |
51 | 52 |
52 if (details->HasKey(kLinkUrlKey)) { | 53 if (details->HasKey(kLinkUrlKey)) { |
53 std::string link_url; | 54 std::string link_url; |
54 EXTENSION_FUNCTION_VALIDATE(details->GetString(kLinkUrlKey, &link_url)); | 55 EXTENSION_FUNCTION_VALIDATE(details->GetString(kLinkUrlKey, &link_url)); |
55 item->set_link_url(GURL(link_url)); | 56 item->set_link_url(GURL(link_url)); |
56 if (!item->link_url().is_valid()) { | 57 if (!item->link_url().is_valid()) { |
57 error_ = "Invalid url: " + link_url; | 58 error_ = "Invalid url: " + link_url; |
58 return false; | 59 return false; |
59 } | 60 } |
60 if (!details->HasKey(kLinkTextKey)) { | 61 if (!details->HasKey(kLinkTextKey)) { |
(...skipping 23 matching lines...) Expand all Loading... |
84 error_ = kInvalidExtensionIdError; | 85 error_ = kInvalidExtensionIdError; |
85 return false; | 86 return false; |
86 } | 87 } |
87 } | 88 } |
88 | 89 |
89 AppNotificationManager* manager = | 90 AppNotificationManager* manager = |
90 profile()->GetExtensionService()->app_notification_manager(); | 91 profile()->GetExtensionService()->app_notification_manager(); |
91 manager->ClearAll(id); | 92 manager->ClearAll(id); |
92 return true; | 93 return true; |
93 } | 94 } |
OLD | NEW |