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

Side by Side Diff: chrome/browser/extensions/extension_management_api.cc

Issue 7799008: Fix crash on NTP related to multi-profile extensions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix sources for incognito Created 9 years, 3 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_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 406 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 chrome::NOTIFICATION_EXTENSION_INSTALLED, 417 chrome::NOTIFICATION_EXTENSION_INSTALLED,
418 chrome::NOTIFICATION_EXTENSION_UNINSTALLED, 418 chrome::NOTIFICATION_EXTENSION_UNINSTALLED,
419 chrome::NOTIFICATION_EXTENSION_LOADED, 419 chrome::NOTIFICATION_EXTENSION_LOADED,
420 chrome::NOTIFICATION_EXTENSION_UNLOADED 420 chrome::NOTIFICATION_EXTENSION_UNLOADED
421 }; 421 };
422 422
423 CHECK(registrar_.IsEmpty()); 423 CHECK(registrar_.IsEmpty());
424 for (size_t i = 0; i < arraysize(types); i++) { 424 for (size_t i = 0; i < arraysize(types); i++) {
425 registrar_.Add(this, 425 registrar_.Add(this,
426 types[i], 426 types[i],
427 NotificationService::AllSources()); 427 Source<Profile>(profile_));
428 } 428 }
429 } 429 }
430 430
431 void ExtensionManagementEventRouter::Observe( 431 void ExtensionManagementEventRouter::Observe(
432 int type, 432 int type,
433 const NotificationSource& source, 433 const NotificationSource& source,
434 const NotificationDetails& details) { 434 const NotificationDetails& details) {
435 const char* event_name = NULL; 435 const char* event_name = NULL;
436 Profile* profile = Source<Profile>(source).ptr(); 436 Profile* profile = Source<Profile>(source).ptr();
437 CHECK(profile); 437 CHECK(profile);
438 if (!profile_->IsSameProfile(profile)) { 438 CHECK(profile_->IsSameProfile(profile));
439 return;
440 }
441 439
442 switch (type) { 440 switch (type) {
443 case chrome::NOTIFICATION_EXTENSION_INSTALLED: 441 case chrome::NOTIFICATION_EXTENSION_INSTALLED:
444 event_name = events::kOnExtensionInstalled; 442 event_name = events::kOnExtensionInstalled;
445 break; 443 break;
446 case chrome::NOTIFICATION_EXTENSION_UNINSTALLED: 444 case chrome::NOTIFICATION_EXTENSION_UNINSTALLED:
447 event_name = events::kOnExtensionUninstalled; 445 event_name = events::kOnExtensionUninstalled;
448 break; 446 break;
449 case chrome::NOTIFICATION_EXTENSION_LOADED: 447 case chrome::NOTIFICATION_EXTENSION_LOADED:
450 event_name = events::kOnExtensionEnabled; 448 event_name = events::kOnExtensionEnabled;
(...skipping 23 matching lines...) Expand all
474 bool enabled = service->GetExtensionById(extension->id(), false) != NULL; 472 bool enabled = service->GetExtensionById(extension->id(), false) != NULL;
475 args.Append(CreateExtensionInfo(*extension, enabled)); 473 args.Append(CreateExtensionInfo(*extension, enabled));
476 } 474 }
477 475
478 std::string args_json; 476 std::string args_json;
479 base::JSONWriter::Write(&args, false /* pretty_print */, &args_json); 477 base::JSONWriter::Write(&args, false /* pretty_print */, &args_json);
480 478
481 profile->GetExtensionEventRouter()->DispatchEventToRenderers( 479 profile->GetExtensionEventRouter()->DispatchEventToRenderers(
482 event_name, args_json, NULL, GURL()); 480 event_name, args_json, NULL, GURL());
483 } 481 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698