| 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_result.h" | 5 #include "chrome/browser/ui/app_list/search/app_result.h" |
| 6 | 6 |
| 7 #include "base/time/time.h" | 7 #include "base/time/time.h" |
| 8 #include "chrome/browser/extensions/extension_service.h" | 8 #include "chrome/browser/extensions/extension_service.h" |
| 9 #include "chrome/browser/extensions/extension_util.h" | 9 #include "chrome/browser/extensions/extension_util.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 #include "ui/app_list/app_list_switches.h" | 25 #include "ui/app_list/app_list_switches.h" |
| 26 #include "ui/app_list/search/tokenized_string.h" | 26 #include "ui/app_list/search/tokenized_string.h" |
| 27 #include "ui/app_list/search/tokenized_string_match.h" | 27 #include "ui/app_list/search/tokenized_string_match.h" |
| 28 #include "ui/gfx/color_utils.h" | 28 #include "ui/gfx/color_utils.h" |
| 29 #include "ui/gfx/image/image_skia_operations.h" | 29 #include "ui/gfx/image/image_skia_operations.h" |
| 30 | 30 |
| 31 namespace app_list { | 31 namespace app_list { |
| 32 | 32 |
| 33 AppResult::AppResult(Profile* profile, | 33 AppResult::AppResult(Profile* profile, |
| 34 const std::string& app_id, | 34 const std::string& app_id, |
| 35 AppListControllerDelegate* controller) | 35 AppListControllerDelegate* controller, |
| 36 bool is_recommendation) |
| 36 : profile_(profile), | 37 : profile_(profile), |
| 37 app_id_(app_id), | 38 app_id_(app_id), |
| 38 controller_(controller), | 39 controller_(controller), |
| 39 extension_registry_(NULL) { | 40 extension_registry_(NULL) { |
| 40 set_id(extensions::Extension::GetBaseURLFromExtensionId(app_id_).spec()); | 41 set_id(extensions::Extension::GetBaseURLFromExtensionId(app_id_).spec()); |
| 41 if (app_list::switches::IsExperimentalAppListEnabled()) | 42 if (app_list::switches::IsExperimentalAppListEnabled()) |
| 42 set_display_type(DISPLAY_TILE); | 43 set_display_type(is_recommendation ? DISPLAY_RECOMMENDATION : DISPLAY_TILE); |
| 43 | 44 |
| 44 const extensions::Extension* extension = | 45 const extensions::Extension* extension = |
| 45 extensions::ExtensionSystem::Get(profile_)->extension_service() | 46 extensions::ExtensionSystem::Get(profile_)->extension_service() |
| 46 ->GetInstalledExtension(app_id_); | 47 ->GetInstalledExtension(app_id_); |
| 47 DCHECK(extension); | 48 DCHECK(extension); |
| 48 | 49 |
| 49 is_platform_app_ = extension->is_platform_app(); | 50 is_platform_app_ = extension->is_platform_app(); |
| 50 | 51 |
| 51 icon_.reset( | 52 icon_.reset( |
| 52 new extensions::IconImage(profile_, | 53 new extensions::IconImage(profile_, |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 base::UserMetricsAction("AppList_ClickOnAppFromSearch")); | 117 base::UserMetricsAction("AppList_ClickOnAppFromSearch")); |
| 117 | 118 |
| 118 controller_->ActivateApp( | 119 controller_->ActivateApp( |
| 119 profile_, | 120 profile_, |
| 120 extension, | 121 extension, |
| 121 AppListControllerDelegate::LAUNCH_FROM_APP_LIST_SEARCH, | 122 AppListControllerDelegate::LAUNCH_FROM_APP_LIST_SEARCH, |
| 122 event_flags); | 123 event_flags); |
| 123 } | 124 } |
| 124 | 125 |
| 125 scoped_ptr<SearchResult> AppResult::Duplicate() { | 126 scoped_ptr<SearchResult> AppResult::Duplicate() { |
| 126 scoped_ptr<SearchResult> copy(new AppResult(profile_, app_id_, controller_)); | 127 scoped_ptr<SearchResult> copy( |
| 128 new AppResult(profile_, app_id_, controller_, |
| 129 display_type() == DISPLAY_RECOMMENDATION)); |
| 127 copy->set_title(title()); | 130 copy->set_title(title()); |
| 128 copy->set_title_tags(title_tags()); | 131 copy->set_title_tags(title_tags()); |
| 129 | 132 |
| 130 return copy.Pass(); | 133 return copy.Pass(); |
| 131 } | 134 } |
| 132 | 135 |
| 133 ui::MenuModel* AppResult::GetContextMenuModel() { | 136 ui::MenuModel* AppResult::GetContextMenuModel() { |
| 134 if (!context_menu_) { | 137 if (!context_menu_) { |
| 135 context_menu_.reset(new AppContextMenu( | 138 context_menu_.reset(new AppContextMenu( |
| 136 this, profile_, app_id_, controller_)); | 139 this, profile_, app_id_, controller_)); |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 const extensions::Extension* extension) { | 209 const extensions::Extension* extension) { |
| 207 UpdateIcon(); | 210 UpdateIcon(); |
| 208 } | 211 } |
| 209 | 212 |
| 210 void AppResult::OnShutdown(extensions::ExtensionRegistry* registry) { | 213 void AppResult::OnShutdown(extensions::ExtensionRegistry* registry) { |
| 211 DCHECK_EQ(extension_registry_, registry); | 214 DCHECK_EQ(extension_registry_, registry); |
| 212 StopObservingExtensionRegistry(); | 215 StopObservingExtensionRegistry(); |
| 213 } | 216 } |
| 214 | 217 |
| 215 } // namespace app_list | 218 } // namespace app_list |
| OLD | NEW |