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

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

Issue 11231033: Handle null Extension*s in AppRestoreService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rephrase Created 8 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/app_restore_service.h" 5 #include "chrome/browser/extensions/app_restore_service.h"
6 6
7 #include "chrome/browser/extensions/api/app_runtime/app_runtime_api.h" 7 #include "chrome/browser/extensions/api/app_runtime/app_runtime_api.h"
8 #include "chrome/browser/extensions/event_router.h" 8 #include "chrome/browser/extensions/event_router.h"
9 #include "chrome/browser/extensions/extension_host.h" 9 #include "chrome/browser/extensions/extension_host.h"
10 #include "chrome/browser/extensions/extension_service.h" 10 #include "chrome/browser/extensions/extension_service.h"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 } 50 }
51 } 51 }
52 } 52 }
53 53
54 void AppRestoreService::Observe(int type, 54 void AppRestoreService::Observe(int type,
55 const content::NotificationSource& source, 55 const content::NotificationSource& source,
56 const content::NotificationDetails& details) { 56 const content::NotificationDetails& details) {
57 switch (type) { 57 switch (type) {
58 case chrome::NOTIFICATION_EXTENSION_HOST_DID_STOP_LOADING: { 58 case chrome::NOTIFICATION_EXTENSION_HOST_DID_STOP_LOADING: {
59 ExtensionHost* host = content::Details<ExtensionHost>(details).ptr(); 59 ExtensionHost* host = content::Details<ExtensionHost>(details).ptr();
60 if (host->extension()->is_platform_app()) { 60 const Extension* extension = host->extension();
61 RecordAppStart(host->extension()->id()); 61 if (extension && extension->is_platform_app()) {
62 RecordAppStart(extension->id());
62 } 63 }
63 break; 64 break;
64 } 65 }
65 66
66 case chrome::NOTIFICATION_EXTENSION_HOST_DESTROYED: { 67 case chrome::NOTIFICATION_EXTENSION_HOST_DESTROYED: {
67 ExtensionHost* host = content::Details<ExtensionHost>(details).ptr(); 68 ExtensionHost* host = content::Details<ExtensionHost>(details).ptr();
68 if (host->extension()->is_platform_app()) { 69 if (host->extension()->is_platform_app()) {
benwells 2012/10/22 00:07:56 Is the NULL check needed here as well?
koz (OOO until 15th September) 2012/10/25 03:49:47 Yes, it is. Seeing as this patch has already lande
69 RecordAppStop(host->extension()->id()); 70 RecordAppStop(host->extension()->id());
70 } 71 }
71 break; 72 break;
72 } 73 }
73 74
74 case chrome::NOTIFICATION_APP_TERMINATING: { 75 case chrome::NOTIFICATION_APP_TERMINATING: {
75 // Stop listening to NOTIFICATION_EXTENSION_HOST_DESTROYED in particular 76 // Stop listening to NOTIFICATION_EXTENSION_HOST_DESTROYED in particular
76 // as all extension hosts will be destroyed as a result of shutdown. 77 // as all extension hosts will be destroyed as a result of shutdown.
77 registrar_.RemoveAll(); 78 registrar_.RemoveAll();
78 break; 79 break;
(...skipping 12 matching lines...) Expand all
91 ExtensionPrefs* extension_prefs = 92 ExtensionPrefs* extension_prefs =
92 ExtensionSystem::Get(profile_)->extension_service()->extension_prefs(); 93 ExtensionSystem::Get(profile_)->extension_service()->extension_prefs();
93 extension_prefs->SetExtensionRunning(extension_id, false); 94 extension_prefs->SetExtensionRunning(extension_id, false);
94 } 95 }
95 96
96 void AppRestoreService::RestoreApp(const Extension* extension) { 97 void AppRestoreService::RestoreApp(const Extension* extension) {
97 AppEventRouter::DispatchOnRestartedEvent(profile_, extension); 98 AppEventRouter::DispatchOnRestartedEvent(profile_, extension);
98 } 99 }
99 100
100 } // namespace extensions 101 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698