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/sha1.h" | 10 #include "base/sha1.h" |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 }; | 54 }; |
55 | 55 |
56 ExtensionNameComparator::ExtensionNameComparator(icu::Collator* collator) | 56 ExtensionNameComparator::ExtensionNameComparator(icu::Collator* collator) |
57 : collator_(collator) { | 57 : collator_(collator) { |
58 } | 58 } |
59 | 59 |
60 bool ExtensionNameComparator::operator()( | 60 bool ExtensionNameComparator::operator()( |
61 const scoped_refptr<const Extension>& x, | 61 const scoped_refptr<const Extension>& x, |
62 const scoped_refptr<const Extension>& y) { | 62 const scoped_refptr<const Extension>& y) { |
63 return l10n_util::StringComparator<base::string16>(collator_)( | 63 return l10n_util::StringComparator<base::string16>(collator_)( |
64 UTF8ToUTF16(x->name()), UTF8ToUTF16(y->name())); | 64 base::UTF8ToUTF16(x->name()), base::UTF8ToUTF16(y->name())); |
65 } | 65 } |
66 | 66 |
67 // Background application representation, private to the | 67 // Background application representation, private to the |
68 // BackgroundApplicationListModel class. | 68 // BackgroundApplicationListModel class. |
69 class BackgroundApplicationListModel::Application | 69 class BackgroundApplicationListModel::Application |
70 : public base::SupportsWeakPtr<Application> { | 70 : public base::SupportsWeakPtr<Application> { |
71 public: | 71 public: |
72 Application(BackgroundApplicationListModel* model, | 72 Application(BackgroundApplicationListModel* model, |
73 const Extension* an_extension); | 73 const Extension* an_extension); |
74 | 74 |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
310 // as background apps. | 310 // as background apps. |
311 if (!extension.is_hosted_app()) | 311 if (!extension.is_hosted_app()) |
312 return true; | 312 return true; |
313 | 313 |
314 // Hosted apps with manifest-provided background pages are background apps. | 314 // Hosted apps with manifest-provided background pages are background apps. |
315 if (extensions::BackgroundInfo::HasBackgroundPage(&extension)) | 315 if (extensions::BackgroundInfo::HasBackgroundPage(&extension)) |
316 return true; | 316 return true; |
317 | 317 |
318 BackgroundContentsService* service = | 318 BackgroundContentsService* service = |
319 BackgroundContentsServiceFactory::GetForProfile(profile); | 319 BackgroundContentsServiceFactory::GetForProfile(profile); |
320 base::string16 app_id = ASCIIToUTF16(extension.id()); | 320 base::string16 app_id = base::ASCIIToUTF16(extension.id()); |
321 // If we have an active or registered background contents for this app, then | 321 // If we have an active or registered background contents for this app, then |
322 // it's a background app. This covers the cases where the app has created its | 322 // it's a background app. This covers the cases where the app has created its |
323 // background contents, but it hasn't navigated yet, or the background | 323 // background contents, but it hasn't navigated yet, or the background |
324 // contents crashed and hasn't yet been restarted - in both cases we still | 324 // contents crashed and hasn't yet been restarted - in both cases we still |
325 // want to treat the app as a background app. | 325 // want to treat the app as a background app. |
326 if (service->GetAppBackgroundContents(app_id) || | 326 if (service->GetAppBackgroundContents(app_id) || |
327 service->HasRegisteredBackgroundContents(app_id)) { | 327 service->HasRegisteredBackgroundContents(app_id)) { |
328 return true; | 328 return true; |
329 } | 329 } |
330 | 330 |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
434 (*old_cursor)->name() == (*new_cursor)->name() && | 434 (*old_cursor)->name() == (*new_cursor)->name() && |
435 (*old_cursor)->id() == (*new_cursor)->id()) { | 435 (*old_cursor)->id() == (*new_cursor)->id()) { |
436 ++old_cursor; | 436 ++old_cursor; |
437 ++new_cursor; | 437 ++new_cursor; |
438 } | 438 } |
439 if (old_cursor != extensions_.end() || new_cursor != extensions.end()) { | 439 if (old_cursor != extensions_.end() || new_cursor != extensions.end()) { |
440 extensions_ = extensions; | 440 extensions_ = extensions; |
441 FOR_EACH_OBSERVER(Observer, observers_, OnApplicationListChanged(profile_)); | 441 FOR_EACH_OBSERVER(Observer, observers_, OnApplicationListChanged(profile_)); |
442 } | 442 } |
443 } | 443 } |
OLD | NEW |