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_app_api.cc

Issue 8382010: Some fixups for app notifications: (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 2 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_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
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 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/app_notification_manager_sync_unittest.cc ('k') | chrome/browser/resources/ntp4/apps_page.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698