Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2970)

Unified Diff: chrome/browser/ui/app_list/search/launcher_search/launcher_search_result.cc

Issue 1071093002: Implement setSearchResults. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Clear results after query is ended. Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/app_list/search/launcher_search/launcher_search_result.cc
diff --git a/chrome/browser/ui/app_list/search/launcher_search/launcher_search_result.cc b/chrome/browser/ui/app_list/search/launcher_search/launcher_search_result.cc
new file mode 100644
index 0000000000000000000000000000000000000000..51c413677c6bfcedffd768a327eec23f47308e0f
--- /dev/null
+++ b/chrome/browser/ui/app_list/search/launcher_search/launcher_search_result.cc
@@ -0,0 +1,62 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/app_list/search/launcher_search/launcher_search_result.h"
+
+#include "base/strings/utf_string_conversions.h"
+#include "chrome/browser/extensions/extension_util.h"
+#include "extensions/common/manifest_handlers/icons_handler.h"
+
+namespace app_list {
+
+LauncherSearchResult::LauncherSearchResult(
+ const std::string& id,
+ scoped_ptr<std::string> icon_url,
+ const int discrete_value_relevance,
+ Profile* profile,
+ const extensions::Extension* extension)
+ : discrete_value_relevance_(discrete_value_relevance),
+ profile_(profile),
+ extension_(extension) {
+ set_id(id);
Matt Giuca 2015/04/10 13:29:14 I think there will be a problem of ID conflicts be
yawano 2015/04/13 07:30:52 Done.
+ set_relevance(static_cast<double>(discrete_value_relevance) / 4.0);
Matt Giuca 2015/04/10 13:29:14 Above, I suggested creating kMaxSearchResultScore
yawano 2015/04/13 07:30:52 Done.
+ set_details(base::UTF8ToUTF16(extension->name()));
+
+ // TODO(yawano) Decode passed icon url and show it baddged with extension
Matt Giuca 2015/04/10 13:29:14 badged
yawano 2015/04/13 07:30:52 Done.
+ // icon.
+ icon_url_ = icon_url.Pass();
+
+ extension_icon_image_.reset(new extensions::IconImage(
+ profile, extension, extensions::IconsInfo::GetIcons(extension),
+ GetPreferredIconDimension(), extensions::util::GetDefaultExtensionIcon(),
+ this));
+ UpdateIcon();
+}
+
+LauncherSearchResult::~LauncherSearchResult() {
+}
+
+scoped_ptr<SearchResult> LauncherSearchResult::Duplicate() const {
+ std::string* icon_url =
+ icon_url_ == NULL ? nullptr : new std::string(icon_url_->c_str());
Matt Giuca 2015/04/10 13:29:14 s/NULL/nullptr No need for c_str; just new std::s
yawano 2015/04/13 07:30:52 Done. Changed not to use scoped_ptr here.
+
+ LauncherSearchResult* duplicated_result =
+ new LauncherSearchResult(id(), make_scoped_ptr(icon_url),
Matt Giuca 2015/04/10 13:29:14 I think this is too expensive (given that you use
yawano 2015/04/13 07:30:52 Since icon image loading is done as async, I think
Matt Giuca 2015/04/14 03:15:43 You mean actually share the extension::IconImage u
yawano 2015/04/14 05:41:59 Yes. I did it with the new patch set.
+ discrete_value_relevance_, profile_, extension_);
+ duplicated_result->set_title(title());
+ return make_scoped_ptr(duplicated_result);
+}
+
+void LauncherSearchResult::OnExtensionIconImageChanged(
+ extensions::IconImage* image) {
+ DCHECK_EQ(image, extension_icon_image_.get());
+ UpdateIcon();
+}
+
+void LauncherSearchResult::UpdateIcon() {
+ if (!extension_icon_image_->image_skia().isNull())
Matt Giuca 2015/04/10 13:29:14 Use AsImageSkia instead of image_skia(). Then if i
Matt Giuca 2015/04/13 07:25:14 As discussed, ignore this comment. (I just checked
+ SetIcon(extension_icon_image_->image_skia());
+}
+
+} // namespace app_list

Powered by Google App Engine
This is Rietveld 408576698