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 "chrome/browser/extensions/app_notification_manager.h" | 8 #include "chrome/browser/extensions/app_notification_manager.h" |
9 #include "chrome/browser/extensions/extension_service.h" | 9 #include "chrome/browser/extensions/extension_service.h" |
10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 EXTENSION_FUNCTION_VALIDATE(details->GetString(kLinkTextKey, | 65 EXTENSION_FUNCTION_VALIDATE(details->GetString(kLinkTextKey, |
66 &link_text)); | 66 &link_text)); |
67 item->set_link_text(link_text); | 67 item->set_link_text(link_text); |
68 } | 68 } |
69 | 69 |
70 AppNotificationManager* manager = | 70 AppNotificationManager* manager = |
71 profile()->GetExtensionService()->app_notification_manager(); | 71 profile()->GetExtensionService()->app_notification_manager(); |
72 | 72 |
73 manager->Add(item.release()); | 73 manager->Add(item.release()); |
74 | 74 |
75 content::NotificationService::current()->Notify( | |
76 chrome::NOTIFICATION_APP_NOTIFICATION_STATE_CHANGED, | |
77 content::Source<Profile>(profile_), | |
78 content::Details<const std::string>(&id)); | |
79 | |
80 return true; | 75 return true; |
81 } | 76 } |
82 | 77 |
83 bool AppClearAllNotificationsFunction::RunImpl() { | 78 bool AppClearAllNotificationsFunction::RunImpl() { |
84 std::string id = extension_id(); | 79 std::string id = extension_id(); |
85 DictionaryValue* details = NULL; | 80 DictionaryValue* details = NULL; |
86 if (args_->GetDictionary(0, &details) && details->HasKey(kExtensionIdKey)) { | 81 if (args_->GetDictionary(0, &details) && details->HasKey(kExtensionIdKey)) { |
87 EXTENSION_FUNCTION_VALIDATE(details->GetString(kExtensionIdKey, &id)); | 82 EXTENSION_FUNCTION_VALIDATE(details->GetString(kExtensionIdKey, &id)); |
88 if (!profile()->GetExtensionService()->GetExtensionById(id, true)) { | 83 if (!profile()->GetExtensionService()->GetExtensionById(id, true)) { |
89 error_ = kInvalidExtensionIdError; | 84 error_ = kInvalidExtensionIdError; |
90 return false; | 85 return false; |
91 } | 86 } |
92 } | 87 } |
93 | 88 |
94 AppNotificationManager* manager = | 89 AppNotificationManager* manager = |
95 profile()->GetExtensionService()->app_notification_manager(); | 90 profile()->GetExtensionService()->app_notification_manager(); |
96 manager->ClearAll(id); | 91 manager->ClearAll(id); |
97 content::NotificationService::current()->Notify( | |
98 chrome::NOTIFICATION_APP_NOTIFICATION_STATE_CHANGED, | |
99 content::Source<Profile>(profile_), | |
100 content::Details<const std::string>(&id)); | |
101 return true; | 92 return true; |
102 } | 93 } |
OLD | NEW |