| Index: chrome/browser/ui/app_list/search_builder.cc
|
| diff --git a/chrome/browser/ui/app_list/search_builder.cc b/chrome/browser/ui/app_list/search_builder.cc
|
| index 399cc64c97d31410b601d82e51e918538de4cd15..8f772d4c2f9099aab8d7c5572bd5f635d3d6c759 100644
|
| --- a/chrome/browser/ui/app_list/search_builder.cc
|
| +++ b/chrome/browser/ui/app_list/search_builder.cc
|
| @@ -5,6 +5,7 @@
|
| #include "chrome/browser/ui/app_list/search_builder.h"
|
|
|
| #include <string>
|
| +#include <vector>
|
|
|
| #include "base/command_line.h"
|
| #include "chrome/browser/autocomplete/autocomplete_controller.h"
|
| @@ -20,6 +21,7 @@
|
| #include "chrome/browser/ui/browser.h"
|
| #include "chrome/browser/ui/browser_navigator.h"
|
| #include "chrome/browser/ui/browser_tabstrip.h"
|
| +#include "chrome/common/chrome_switches.h"
|
| #include "chrome/common/extensions/extension.h"
|
| #include "chrome/common/extensions/extension_constants.h"
|
| #include "chrome/common/extensions/extension_icon_set.h"
|
| @@ -33,6 +35,14 @@
|
| #include "ui/app_list/search_result.h"
|
| #include "ui/base/l10n/l10n_util.h"
|
| #include "ui/base/resource/resource_bundle.h"
|
| +#include "ui/gfx/codec/png_codec.h"
|
| +
|
| +#if defined(OS_CHROMEOS)
|
| +#include "base/memory/ref_counted.h"
|
| +#include "chrome/browser/chromeos/contacts/contact.pb.h"
|
| +#include "chrome/browser/chromeos/contacts/contact_manager.h"
|
| +#include "chrome/browser/image_decoder.h"
|
| +#endif
|
|
|
| namespace {
|
|
|
| @@ -93,6 +103,9 @@ const extensions::Extension* GetExtensionByURL(Profile* profile,
|
| // SearchBuildResult is an app list SearchResult built from an
|
| // AutocompleteMatch.
|
| class SearchBuilderResult : public app_list::SearchResult,
|
| +#if defined(OS_CHROMEOS)
|
| + public ImageDecoder::Delegate,
|
| +#endif
|
| public ImageLoadingTracker::Observer {
|
| public:
|
| SearchBuilderResult(Profile* profile,
|
| @@ -101,6 +114,17 @@ class SearchBuilderResult : public app_list::SearchResult,
|
| match_(match) {
|
| UpdateIcon();
|
| UpdateTitleAndDetails();
|
| +#if defined(OS_CHROMEOS)
|
| + if (match_.type == AutocompleteMatch::CONTACT)
|
| + AddContactActionIcons();
|
| +#endif
|
| + }
|
| +
|
| + virtual ~SearchBuilderResult() {
|
| +#if defined(OS_CHROMEOS)
|
| + if (contact_photo_decoder_.get())
|
| + contact_photo_decoder_->set_delegate(NULL);
|
| +#endif
|
| }
|
|
|
| const AutocompleteMatch& match() const {
|
| @@ -118,6 +142,29 @@ class SearchBuilderResult : public app_list::SearchResult,
|
| }
|
| }
|
|
|
| +#if defined(OS_CHROMEOS)
|
| + if (match_.type == AutocompleteMatch::CONTACT) {
|
| + AutocompleteMatch::AdditionalInfo::const_iterator it =
|
| + match_.additional_info.find("contact_id");
|
| + DCHECK(it != match_.additional_info.end());
|
| + const contacts::Contact* contact =
|
| + contacts::ContactManager::GetInstance()->GetContactById(
|
| + profile_, it->second);
|
| + if (contact && contact->has_raw_untrusted_photo()) {
|
| + contact_photo_decoder_ =
|
| + new ImageDecoder(
|
| + this,
|
| + contact->raw_untrusted_photo(),
|
| + ImageDecoder::DEFAULT_CODEC);
|
| + contact_photo_decoder_->Start();
|
| + return;
|
| + } else {
|
| + SetIcon(*ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(
|
| + IDR_CONTACT_DEFAULT_PHOTO));
|
| + }
|
| + }
|
| +#endif
|
| +
|
| int resource_id = match_.starred ?
|
| IDR_OMNIBOX_STAR : AutocompleteMatch::TypeToIcon(match_.type);
|
| SetIcon(*ui::ResourceBundle::GetSharedInstance().GetBitmapNamed(
|
| @@ -152,6 +199,52 @@ class SearchBuilderResult : public app_list::SearchResult,
|
| set_details_tags(details_tags);
|
| }
|
|
|
| +#if defined(OS_CHROMEOS)
|
| + // Add icons for contact-related actions.
|
| + void AddContactActionIcons() {
|
| + ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
|
| + std::vector<app_list::SearchResult::ActionIconSet> icons;
|
| + icons.push_back(
|
| + app_list::SearchResult::ActionIconSet(
|
| + *bundle.GetImageSkiaNamed(IDR_CONTACT_ACTION_CHAT),
|
| + *bundle.GetImageSkiaNamed(IDR_CONTACT_ACTION_CHAT_H),
|
| + *bundle.GetImageSkiaNamed(IDR_CONTACT_ACTION_CHAT),
|
| + l10n_util::GetStringUTF16(IDS_APP_LIST_CONTACT_CHAT_TOOLTIP)));
|
| + icons.push_back(
|
| + app_list::SearchResult::ActionIconSet(
|
| + *bundle.GetImageSkiaNamed(IDR_CONTACT_ACTION_VIDEO),
|
| + *bundle.GetImageSkiaNamed(IDR_CONTACT_ACTION_VIDEO_H),
|
| + *bundle.GetImageSkiaNamed(IDR_CONTACT_ACTION_VIDEO),
|
| + l10n_util::GetStringUTF16(IDS_APP_LIST_CONTACT_VIDEO_TOOLTIP)));
|
| + icons.push_back(
|
| + app_list::SearchResult::ActionIconSet(
|
| + *bundle.GetImageSkiaNamed(IDR_CONTACT_ACTION_PHONE),
|
| + *bundle.GetImageSkiaNamed(IDR_CONTACT_ACTION_PHONE_H),
|
| + *bundle.GetImageSkiaNamed(IDR_CONTACT_ACTION_PHONE),
|
| + l10n_util::GetStringUTF16(IDS_APP_LIST_CONTACT_PHONE_TOOLTIP)));
|
| + icons.push_back(
|
| + app_list::SearchResult::ActionIconSet(
|
| + *bundle.GetImageSkiaNamed(IDR_CONTACT_ACTION_EMAIL),
|
| + *bundle.GetImageSkiaNamed(IDR_CONTACT_ACTION_EMAIL_H),
|
| + *bundle.GetImageSkiaNamed(IDR_CONTACT_ACTION_EMAIL),
|
| + l10n_util::GetStringUTF16(IDS_APP_LIST_CONTACT_EMAIL_TOOLTIP)));
|
| + SetActionIcons(icons);
|
| + }
|
| +
|
| + // Overridden from ImageDecoder::Delegate:
|
| + virtual void OnImageDecoded(const ImageDecoder* decoder,
|
| + const SkBitmap& decoded_image) OVERRIDE {
|
| + DCHECK_EQ(decoder, contact_photo_decoder_);
|
| + SetIcon(decoded_image);
|
| + }
|
| +
|
| + virtual void OnDecodeImageFailed(const ImageDecoder* decoder) OVERRIDE {
|
| + DCHECK_EQ(decoder, contact_photo_decoder_);
|
| + SetIcon(*ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(
|
| + IDR_CONTACT_DEFAULT_PHOTO));
|
| + }
|
| +#endif
|
| +
|
| // Overridden from ImageLoadingTracker::Observer:
|
| virtual void OnImageLoaded(const gfx::Image& image,
|
| const std::string& extension_id,
|
| @@ -169,6 +262,10 @@ class SearchBuilderResult : public app_list::SearchResult,
|
| AutocompleteMatch match_;
|
| scoped_ptr<ImageLoadingTracker> tracker_;
|
|
|
| +#if defined(OS_CHROMEOS)
|
| + scoped_refptr<ImageDecoder> contact_photo_decoder_;
|
| +#endif
|
| +
|
| DISALLOW_COPY_AND_ASSIGN(SearchBuilderResult);
|
| };
|
|
|
|
|