| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/ui/app_list/search/app_search_provider.h" | 5 #include "chrome/browser/ui/app_list/search/app_search_provider.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "chrome/browser/chrome_notification_types.h" | 10 #include "chrome/browser/chrome_notification_types.h" |
| 11 #include "chrome/browser/extensions/extension_service.h" | 11 #include "chrome/browser/extensions/extension_service.h" |
| 12 #include "chrome/browser/extensions/extension_system_factory.h" | 12 #include "chrome/browser/extensions/extension_system_factory.h" |
| 13 #include "chrome/browser/extensions/extension_util.h" |
| 13 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
| 14 #include "chrome/browser/ui/app_list/search/app_result.h" | 15 #include "chrome/browser/ui/app_list/search/app_result.h" |
| 15 #include "chrome/browser/ui/app_list/search/tokenized_string.h" | 16 #include "chrome/browser/ui/app_list/search/tokenized_string.h" |
| 16 #include "chrome/browser/ui/app_list/search/tokenized_string_match.h" | 17 #include "chrome/browser/ui/app_list/search/tokenized_string_match.h" |
| 17 #include "content/public/browser/notification_details.h" | 18 #include "content/public/browser/notification_details.h" |
| 18 #include "content/public/browser/notification_source.h" | 19 #include "content/public/browser/notification_source.h" |
| 19 | 20 |
| 20 namespace app_list { | 21 namespace app_list { |
| 21 | 22 |
| 22 class AppSearchProvider::App { | 23 class AppSearchProvider::App { |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 void AppSearchProvider::AddApps(const ExtensionSet* extensions, | 76 void AppSearchProvider::AddApps(const ExtensionSet* extensions, |
| 76 ExtensionService* service) { | 77 ExtensionService* service) { |
| 77 for (ExtensionSet::const_iterator iter = extensions->begin(); | 78 for (ExtensionSet::const_iterator iter = extensions->begin(); |
| 78 iter != extensions->end(); ++iter) { | 79 iter != extensions->end(); ++iter) { |
| 79 const extensions::Extension* app = iter->get(); | 80 const extensions::Extension* app = iter->get(); |
| 80 | 81 |
| 81 if (!app->ShouldDisplayInAppLauncher()) | 82 if (!app->ShouldDisplayInAppLauncher()) |
| 82 continue; | 83 continue; |
| 83 | 84 |
| 84 if (profile_->IsOffTheRecord() && | 85 if (profile_->IsOffTheRecord() && |
| 85 !service->CanLoadInIncognito(app)) | 86 !extension_util::CanLoadInIncognito(app, service)) |
| 86 continue; | 87 continue; |
| 87 apps_.push_back(new App(app)); | 88 apps_.push_back(new App(app)); |
| 88 } | 89 } |
| 89 } | 90 } |
| 90 | 91 |
| 91 void AppSearchProvider::RefreshApps() { | 92 void AppSearchProvider::RefreshApps() { |
| 92 ExtensionService* extension_service = | 93 ExtensionService* extension_service = |
| 93 extensions::ExtensionSystemFactory::GetForProfile(profile_)-> | 94 extensions::ExtensionSystemFactory::GetForProfile(profile_)-> |
| 94 extension_service(); | 95 extension_service(); |
| 95 if (!extension_service) | 96 if (!extension_service) |
| 96 return; // During testing, there is no extension service. | 97 return; // During testing, there is no extension service. |
| 97 | 98 |
| 98 apps_.clear(); | 99 apps_.clear(); |
| 99 | 100 |
| 100 AddApps(extension_service->extensions(), extension_service); | 101 AddApps(extension_service->extensions(), extension_service); |
| 101 AddApps(extension_service->disabled_extensions(), extension_service); | 102 AddApps(extension_service->disabled_extensions(), extension_service); |
| 102 AddApps(extension_service->terminated_extensions(), extension_service); | 103 AddApps(extension_service->terminated_extensions(), extension_service); |
| 103 } | 104 } |
| 104 | 105 |
| 105 void AppSearchProvider::Observe(int type, | 106 void AppSearchProvider::Observe(int type, |
| 106 const content::NotificationSource& source, | 107 const content::NotificationSource& source, |
| 107 const content::NotificationDetails& detaila) { | 108 const content::NotificationDetails& detaila) { |
| 108 RefreshApps(); | 109 RefreshApps(); |
| 109 } | 110 } |
| 110 | 111 |
| 111 } // namespace app_list | 112 } // namespace app_list |
| OLD | NEW |