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

Side by Side Diff: chrome/browser/extensions/api/downloads/downloads_api.cc

Issue 10694085: Refactor extension event distribution to use Values instead of JSON strings. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase and review changes. Created 8 years, 5 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/downloads/downloads_api.h" 5 #include "chrome/browser/extensions/api/downloads/downloads_api.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cctype> 8 #include <cctype>
9 #include <iterator> 9 #include <iterator>
10 #include <set> 10 #include <set>
(...skipping 1064 matching lines...) Expand 10 before | Expand all | Expand 10 after
1075 void ExtensionDownloadsEventRouter::ManagerGoingDown( 1075 void ExtensionDownloadsEventRouter::ManagerGoingDown(
1076 DownloadManager* manager) { 1076 DownloadManager* manager) {
1077 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 1077 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
1078 manager_->RemoveObserver(this); 1078 manager_->RemoveObserver(this);
1079 manager_ = NULL; 1079 manager_ = NULL;
1080 } 1080 }
1081 1081
1082 void ExtensionDownloadsEventRouter::DispatchEvent( 1082 void ExtensionDownloadsEventRouter::DispatchEvent(
1083 const char* event_name, base::Value* arg) { 1083 const char* event_name, base::Value* arg) {
1084 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 1084 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
1085 base::ListValue args; 1085 base::ListValue* args = new base::ListValue();
1086 args.Append(arg); 1086 args->Append(arg);
1087 std::string json_args; 1087 std::string json_args;
1088 base::JSONWriter::Write(&args, &json_args); 1088 base::JSONWriter::Write(args, &json_args);
1089
1089 profile_->GetExtensionEventRouter()->DispatchEventToRenderers( 1090 profile_->GetExtensionEventRouter()->DispatchEventToRenderers(
miket_OOO 2012/07/10 22:33:19 Similar comment about future understanding of owne
1090 event_name, 1091 event_name,
1091 json_args, 1092 args,
1092 profile_, 1093 profile_,
1093 GURL(), 1094 GURL(),
1094 extensions::EventFilteringInfo()); 1095 extensions::EventFilteringInfo());
1095 1096
1096 DownloadsNotificationSource notification_source; 1097 DownloadsNotificationSource notification_source;
1097 notification_source.event_name = event_name; 1098 notification_source.event_name = event_name;
1098 notification_source.profile = profile_; 1099 notification_source.profile = profile_;
1099 content::NotificationService::current()->Notify( 1100 content::NotificationService::current()->Notify(
1100 chrome::NOTIFICATION_EXTENSION_DOWNLOADS_EVENT, 1101 chrome::NOTIFICATION_EXTENSION_DOWNLOADS_EVENT,
1101 content::Source<DownloadsNotificationSource>(&notification_source), 1102 content::Source<DownloadsNotificationSource>(&notification_source),
1102 content::Details<std::string>(&json_args)); 1103 content::Details<std::string>(&json_args));
1103 } 1104 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698