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

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

Issue 11275031: Add NULL check to AppRestoreService (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 const Extension* extension = host->extension(); 60 const Extension* extension = host->extension();
61 if (extension && extension->is_platform_app()) { 61 if (extension && extension->is_platform_app())
62 RecordAppStart(extension->id()); 62 RecordAppStart(extension->id());
63 }
64 break; 63 break;
65 } 64 }
66 65
67 case chrome::NOTIFICATION_EXTENSION_HOST_DESTROYED: { 66 case chrome::NOTIFICATION_EXTENSION_HOST_DESTROYED: {
68 ExtensionHost* host = content::Details<ExtensionHost>(details).ptr(); 67 ExtensionHost* host = content::Details<ExtensionHost>(details).ptr();
69 if (host->extension()->is_platform_app()) { 68 const Extension* extension = host->extension();
70 RecordAppStop(host->extension()->id()); 69 if (extension && extension->is_platform_app())
71 } 70 RecordAppStop(extension->id());
72 break; 71 break;
73 } 72 }
74 73
75 case chrome::NOTIFICATION_APP_TERMINATING: { 74 case chrome::NOTIFICATION_APP_TERMINATING: {
76 // Stop listening to NOTIFICATION_EXTENSION_HOST_DESTROYED in particular 75 // Stop listening to NOTIFICATION_EXTENSION_HOST_DESTROYED in particular
77 // as all extension hosts will be destroyed as a result of shutdown. 76 // as all extension hosts will be destroyed as a result of shutdown.
78 registrar_.RemoveAll(); 77 registrar_.RemoveAll();
79 break; 78 break;
80 } 79 }
81 } 80 }
(...skipping 10 matching lines...) Expand all
92 ExtensionPrefs* extension_prefs = 91 ExtensionPrefs* extension_prefs =
93 ExtensionSystem::Get(profile_)->extension_service()->extension_prefs(); 92 ExtensionSystem::Get(profile_)->extension_service()->extension_prefs();
94 extension_prefs->SetExtensionRunning(extension_id, false); 93 extension_prefs->SetExtensionRunning(extension_id, false);
95 } 94 }
96 95
97 void AppRestoreService::RestoreApp(const Extension* extension) { 96 void AppRestoreService::RestoreApp(const Extension* extension) {
98 AppEventRouter::DispatchOnRestartedEvent(profile_, extension); 97 AppEventRouter::DispatchOnRestartedEvent(profile_, extension);
99 } 98 }
100 99
101 } // namespace extensions 100 } // 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