Home | History | Annotate | Download | only in search
      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
      3 // found in the LICENSE file.
      4 
      5 #include "chrome/browser/ui/app_list/search/search_webstore_result.h"
      6 
      7 #include "base/strings/string16.h"
      8 #include "base/strings/utf_string_conversions.h"
      9 #include "chrome/browser/ui/browser_navigator.h"
     10 #include "chrome/common/extensions/extension_constants.h"
     11 #include "grit/generated_resources.h"
     12 #include "grit/theme_resources.h"
     13 #include "ui/base/l10n/l10n_util.h"
     14 #include "ui/base/resource/resource_bundle.h"
     15 
     16 namespace app_list {
     17 
     18 SearchWebstoreResult::SearchWebstoreResult(Profile* profile,
     19                                            const std::string& query)
     20     : profile_(profile),
     21       query_(query),
     22       launch_url_(extension_urls::GetWebstoreSearchPageUrl(query)) {
     23   set_id(launch_url_.spec());
     24   set_relevance(0.0);
     25 
     26   set_title(UTF8ToUTF16(query));
     27 
     28   const base::string16 details =
     29       l10n_util::GetStringUTF16(IDS_EXTENSION_WEB_STORE_TITLE);
     30   Tags details_tags;
     31   details_tags.push_back(Tag(SearchResult::Tag::DIM, 0, details.length()));
     32 
     33   set_details(details);
     34   set_details_tags(details_tags);
     35 
     36   SetIcon(*ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(
     37       IDR_WEBSTORE_ICON));
     38 }
     39 
     40 SearchWebstoreResult::~SearchWebstoreResult() {}
     41 
     42 void SearchWebstoreResult::Open(int event_flags) {
     43   chrome::NavigateParams params(profile_,
     44                                 launch_url_,
     45                                 content::PAGE_TRANSITION_LINK);
     46   params.disposition = ui::DispositionFromEventFlags(event_flags);
     47   chrome::Navigate(&params);
     48 }
     49 
     50 void SearchWebstoreResult::InvokeAction(int action_index, int event_flags) {
     51 }
     52 
     53 scoped_ptr<ChromeSearchResult> SearchWebstoreResult::Duplicate() {
     54   return scoped_ptr<ChromeSearchResult>(
     55       new SearchWebstoreResult(profile_, query_)).Pass();
     56 }
     57 
     58 ChromeSearchResultType SearchWebstoreResult::GetType() {
     59   return WEBSTORE_SEARCH_RESULT;
     60 }
     61 
     62 }  // namespace app_list
     63