| OLD | NEW |
| 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/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-inl.h" | 10 #include "base/stl_util-inl.h" |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 } | 92 } |
| 93 | 93 |
| 94 std::string locale = g_browser_process->GetApplicationLocale(); | 94 std::string locale = g_browser_process->GetApplicationLocale(); |
| 95 icu::Locale loc(locale.c_str()); | 95 icu::Locale loc(locale.c_str()); |
| 96 UErrorCode error = U_ZERO_ERROR; | 96 UErrorCode error = U_ZERO_ERROR; |
| 97 scoped_ptr<icu::Collator> collator(icu::Collator::createInstance(loc, error)); | 97 scoped_ptr<icu::Collator> collator(icu::Collator::createInstance(loc, error)); |
| 98 sort(applications_result->begin(), applications_result->end(), | 98 sort(applications_result->begin(), applications_result->end(), |
| 99 ExtensionNameComparator(collator.get())); | 99 ExtensionNameComparator(collator.get())); |
| 100 } | 100 } |
| 101 | 101 |
| 102 bool HasBackgroundAppPermission( | |
| 103 const std::set<std::string>& api_permissions) { | |
| 104 return Extension::HasApiPermission( | |
| 105 api_permissions, Extension::kBackgroundPermission); | |
| 106 } | |
| 107 } // namespace | 102 } // namespace |
| 108 | 103 |
| 109 void | 104 void |
| 110 BackgroundApplicationListModel::Observer::OnApplicationDataChanged( | 105 BackgroundApplicationListModel::Observer::OnApplicationDataChanged( |
| 111 const Extension* extension, Profile* profile) { | 106 const Extension* extension, Profile* profile) { |
| 112 } | 107 } |
| 113 | 108 |
| 114 void | 109 void |
| 115 BackgroundApplicationListModel::Observer::OnApplicationListChanged( | 110 BackgroundApplicationListModel::Observer::OnApplicationListChanged( |
| 116 Profile* profile) { | 111 Profile* profile) { |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 if (id == cursor->get()->id()) | 238 if (id == cursor->get()->id()) |
| 244 return position; | 239 return position; |
| 245 } | 240 } |
| 246 NOTREACHED(); | 241 NOTREACHED(); |
| 247 return -1; | 242 return -1; |
| 248 } | 243 } |
| 249 | 244 |
| 250 // static | 245 // static |
| 251 bool BackgroundApplicationListModel::IsBackgroundApp( | 246 bool BackgroundApplicationListModel::IsBackgroundApp( |
| 252 const Extension& extension) { | 247 const Extension& extension) { |
| 253 return HasBackgroundAppPermission(extension.api_permissions()); | 248 return extension.HasAPIPermission(ExtensionAPIPermission::kBackground); |
| 254 } | 249 } |
| 255 | 250 |
| 256 void BackgroundApplicationListModel::Observe( | 251 void BackgroundApplicationListModel::Observe( |
| 257 NotificationType type, | 252 NotificationType type, |
| 258 const NotificationSource& source, | 253 const NotificationSource& source, |
| 259 const NotificationDetails& details) { | 254 const NotificationDetails& details) { |
| 260 if (type == NotificationType::EXTENSIONS_READY) { | 255 if (type == NotificationType::EXTENSIONS_READY) { |
| 261 Update(); | 256 Update(); |
| 262 return; | 257 return; |
| 263 } | 258 } |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 (*old_cursor)->name() == (*new_cursor)->name() && | 315 (*old_cursor)->name() == (*new_cursor)->name() && |
| 321 (*old_cursor)->id() == (*new_cursor)->id()) { | 316 (*old_cursor)->id() == (*new_cursor)->id()) { |
| 322 ++old_cursor; | 317 ++old_cursor; |
| 323 ++new_cursor; | 318 ++new_cursor; |
| 324 } | 319 } |
| 325 if (old_cursor != extensions_.end() || new_cursor != extensions.end()) { | 320 if (old_cursor != extensions_.end() || new_cursor != extensions.end()) { |
| 326 extensions_ = extensions; | 321 extensions_ = extensions; |
| 327 FOR_EACH_OBSERVER(Observer, observers_, OnApplicationListChanged(profile_)); | 322 FOR_EACH_OBSERVER(Observer, observers_, OnApplicationListChanged(profile_)); |
| 328 } | 323 } |
| 329 } | 324 } |
| OLD | NEW |