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

Side by Side Diff: chrome/browser/extensions/extension_management_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/extension_management_api.h" 5 #include "chrome/browser/extensions/extension_management_api.h"
6 6
7 #include <map> 7 #include <map>
8 #include <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after
562 event_name = events::kOnExtensionEnabled; 562 event_name = events::kOnExtensionEnabled;
563 break; 563 break;
564 case chrome::NOTIFICATION_EXTENSION_UNLOADED: 564 case chrome::NOTIFICATION_EXTENSION_UNLOADED:
565 event_name = events::kOnExtensionDisabled; 565 event_name = events::kOnExtensionDisabled;
566 break; 566 break;
567 default: 567 default:
568 NOTREACHED(); 568 NOTREACHED();
569 return; 569 return;
570 } 570 }
571 571
572 ListValue args; 572 ListValue* args = new ListValue();
573 if (event_name == events::kOnExtensionUninstalled) { 573 if (event_name == events::kOnExtensionUninstalled) {
574 args.Append(Value::CreateStringValue( 574 args->Append(Value::CreateStringValue(
575 *content::Details<const std::string>(details).ptr())); 575 *content::Details<const std::string>(details).ptr()));
576 } else { 576 } else {
577 const Extension* extension = NULL; 577 const Extension* extension = NULL;
578 if (event_name == events::kOnExtensionDisabled) { 578 if (event_name == events::kOnExtensionDisabled) {
579 extension = content::Details<extensions::UnloadedExtensionInfo>( 579 extension = content::Details<extensions::UnloadedExtensionInfo>(
580 details)->extension; 580 details)->extension;
581 } else { 581 } else {
582 extension = content::Details<const Extension>(details).ptr(); 582 extension = content::Details<const Extension>(details).ptr();
583 } 583 }
584 CHECK(extension); 584 CHECK(extension);
585 ExtensionService* service = profile->GetExtensionService(); 585 ExtensionService* service = profile->GetExtensionService();
586 args.Append(CreateExtensionInfo(*extension, service)); 586 args->Append(CreateExtensionInfo(*extension, service));
587 } 587 }
588 588
589 std::string args_json;
590 base::JSONWriter::Write(&args, &args_json);
591
592 profile->GetExtensionEventRouter()->DispatchEventToRenderers( 589 profile->GetExtensionEventRouter()->DispatchEventToRenderers(
593 event_name, args_json, NULL, GURL(), extensions::EventFilteringInfo()); 590 event_name, args, NULL, GURL(), extensions::EventFilteringInfo());
594 } 591 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698