OLD | NEW |
---|---|
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 Loading... | |
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 Loading... | |
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 |
OLD | NEW |