| 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/background/background_application_list_model.h" | 5 #include "chrome/browser/background/background_application_list_model.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 | 257 |
| 258 // static | 258 // static |
| 259 bool BackgroundApplicationListModel::IsBackgroundApp( | 259 bool BackgroundApplicationListModel::IsBackgroundApp( |
| 260 const Extension& extension, Profile* profile) { | 260 const Extension& extension, Profile* profile) { |
| 261 // An extension is a "background app" if it has the "background API" | 261 // An extension is a "background app" if it has the "background API" |
| 262 // permission, and meets one of the following criteria: | 262 // permission, and meets one of the following criteria: |
| 263 // 1) It is an extension (not a hosted app). | 263 // 1) It is an extension (not a hosted app). |
| 264 // 2) It is a hosted app, and has a background contents registered or in the | 264 // 2) It is a hosted app, and has a background contents registered or in the |
| 265 // manifest. | 265 // manifest. |
| 266 | 266 |
| 267 // Ephemeral apps are denied any background activity after their event page | |
| 268 // has been destroyed, thus they cannot be background apps. | |
| 269 if (extensions::util::IsEphemeralApp(extension.id(), profile)) | |
| 270 return false; | |
| 271 | |
| 272 // Not a background app if we don't have the background permission. | 267 // Not a background app if we don't have the background permission. |
| 273 if (!extension.permissions_data()->HasAPIPermission( | 268 if (!extension.permissions_data()->HasAPIPermission( |
| 274 APIPermission::kBackground)) { | 269 APIPermission::kBackground)) { |
| 275 return false; | 270 return false; |
| 276 } | 271 } |
| 277 | 272 |
| 278 // Extensions and packaged apps with background permission are always treated | 273 // Extensions and packaged apps with background permission are always treated |
| 279 // as background apps. | 274 // as background apps. |
| 280 if (!extension.is_hosted_app()) | 275 if (!extension.is_hosted_app()) |
| 281 return true; | 276 return true; |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 404 (*old_cursor)->name() == (*new_cursor)->name() && | 399 (*old_cursor)->name() == (*new_cursor)->name() && |
| 405 (*old_cursor)->id() == (*new_cursor)->id()) { | 400 (*old_cursor)->id() == (*new_cursor)->id()) { |
| 406 ++old_cursor; | 401 ++old_cursor; |
| 407 ++new_cursor; | 402 ++new_cursor; |
| 408 } | 403 } |
| 409 if (old_cursor != extensions_.end() || new_cursor != extensions.end()) { | 404 if (old_cursor != extensions_.end() || new_cursor != extensions.end()) { |
| 410 extensions_ = extensions; | 405 extensions_ = extensions; |
| 411 FOR_EACH_OBSERVER(Observer, observers_, OnApplicationListChanged(profile_)); | 406 FOR_EACH_OBSERVER(Observer, observers_, OnApplicationListChanged(profile_)); |
| 412 } | 407 } |
| 413 } | 408 } |
| OLD | NEW |