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

Side by Side Diff: chrome/browser/extensions/api/notifications/notifications_api.cc

Issue 177003015: Pull AsyncApiFunction out of src/chrome (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase for storage_api Created 6 years, 9 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) 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/notifications/notifications_api.h" 5 #include "chrome/browser/extensions/api/notifications/notifications_api.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/guid.h" 8 #include "base/guid.h"
9 #include "base/rand_util.h" 9 #include "base/rand_util.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 std::string StripScopeFromIdentifier(const std::string& extension_id, 120 std::string StripScopeFromIdentifier(const std::string& extension_id,
121 const std::string& id) { 121 const std::string& id) {
122 size_t index_of_separator = extension_id.length() + 1; 122 size_t index_of_separator = extension_id.length() + 1;
123 DCHECK_LT(index_of_separator, id.length()); 123 DCHECK_LT(index_of_separator, id.length());
124 124
125 return id.substr(index_of_separator); 125 return id.substr(index_of_separator);
126 } 126 }
127 127
128 class NotificationsApiDelegate : public NotificationDelegate { 128 class NotificationsApiDelegate : public NotificationDelegate {
129 public: 129 public:
130 NotificationsApiDelegate(ApiFunction* api_function, 130 NotificationsApiDelegate(ChromeAsyncExtensionFunction* api_function,
131 Profile* profile, 131 Profile* profile,
132 const std::string& extension_id, 132 const std::string& extension_id,
133 const std::string& id) 133 const std::string& id)
134 : api_function_(api_function), 134 : api_function_(api_function),
135 profile_(profile), 135 profile_(profile),
136 extension_id_(extension_id), 136 extension_id_(extension_id),
137 id_(id), 137 id_(id),
138 scoped_id_(CreateScopedIdentifier(extension_id, id)), 138 scoped_id_(CreateScopedIdentifier(extension_id, id)),
139 process_id_(-1) { 139 process_id_(-1) {
140 DCHECK(api_function_.get()); 140 DCHECK(api_function_.get());
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 ExtensionSystem::Get(profile_)->event_router()->DispatchEventToExtension( 201 ExtensionSystem::Get(profile_)->event_router()->DispatchEventToExtension(
202 extension_id_, event.Pass()); 202 extension_id_, event.Pass());
203 } 203 }
204 204
205 scoped_ptr<base::ListValue> CreateBaseEventArgs() { 205 scoped_ptr<base::ListValue> CreateBaseEventArgs() {
206 scoped_ptr<base::ListValue> args(new base::ListValue()); 206 scoped_ptr<base::ListValue> args(new base::ListValue());
207 args->Append(new base::StringValue(id_)); 207 args->Append(new base::StringValue(id_));
208 return args.Pass(); 208 return args.Pass();
209 } 209 }
210 210
211 scoped_refptr<ApiFunction> api_function_; 211 scoped_refptr<ChromeAsyncExtensionFunction> api_function_;
212 Profile* profile_; 212 Profile* profile_;
213 const std::string extension_id_; 213 const std::string extension_id_;
214 const std::string id_; 214 const std::string id_;
215 const std::string scoped_id_; 215 const std::string scoped_id_;
216 int process_id_; 216 int process_id_;
217 217
218 DISALLOW_COPY_AND_ASSIGN(NotificationsApiDelegate); 218 DISALLOW_COPY_AND_ASSIGN(NotificationsApiDelegate);
219 }; 219 };
220 220
221 } // namespace 221 } // namespace
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after
620 ? api::notifications::PERMISSION_LEVEL_GRANTED 620 ? api::notifications::PERMISSION_LEVEL_GRANTED
621 : api::notifications::PERMISSION_LEVEL_DENIED; 621 : api::notifications::PERMISSION_LEVEL_DENIED;
622 622
623 SetResult(new base::StringValue(api::notifications::ToString(result))); 623 SetResult(new base::StringValue(api::notifications::ToString(result)));
624 SendResponse(true); 624 SendResponse(true);
625 625
626 return true; 626 return true;
627 } 627 }
628 628
629 } // namespace extensions 629 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/notifications/notifications_api.h ('k') | chrome/browser/extensions/api/serial/serial_api.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698