X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Fathena%2Fhome%2Fapp_list_view_delegate.cc;h=270aae6b326785431394f8e9515e2f0bb9457018;hb=1afa4dd80ef85af7c90efaea6959db1d92330844;hp=99b1041cf1057e1cc99dfeef467e80a5cfc67176;hpb=90762837333c13ccf56f2ad88e4481fc71e8d281;p=platform%2Fframework%2Fweb%2Fcrosswalk.git diff --git a/src/athena/home/app_list_view_delegate.cc b/src/athena/home/app_list_view_delegate.cc index 99b1041..270aae6 100644 --- a/src/athena/home/app_list_view_delegate.cc +++ b/src/athena/home/app_list_view_delegate.cc @@ -8,6 +8,7 @@ #include #include "athena/home/public/app_model_builder.h" +#include "athena/home/public/search_controller_factory.h" #include "athena/strings/grit/athena_strings.h" #include "base/basictypes.h" #include "base/bind.h" @@ -16,51 +17,29 @@ #include "third_party/skia/include/core/SkBitmap.h" #include "ui/app_list/app_list_model.h" #include "ui/app_list/search_box_model.h" +#include "ui/app_list/search_controller.h" #include "ui/app_list/search_provider.h" #include "ui/app_list/search_result.h" #include "ui/app_list/speech_ui_model.h" #include "ui/base/l10n/l10n_util.h" -#include "ui/base/resource/resource_bundle.h" -#include "ui/gfx/image/image_skia.h" -#include "ui/resources/grit/ui_resources.h" -#include "ui/views/controls/image_view.h" namespace athena { -AppListViewDelegate::AppListViewDelegate(AppModelBuilder* model_builder) +AppListViewDelegate::AppListViewDelegate( + AppModelBuilder* model_builder, + SearchControllerFactory* search_factory) : model_(new app_list::AppListModel), speech_ui_(new app_list::SpeechUIModel) { - model_builder->PopulateApps(model_.get()); + model_builder->RegisterAppListModel(model_.get()); model_->search_box()->SetHintText( l10n_util::GetStringUTF16(IDS_ATHENA_SEARCH_BOX_HINT)); + if (search_factory) { + search_controller_ = + search_factory->Create(model_->search_box(), model_->results()); + } } AppListViewDelegate::~AppListViewDelegate() { - for (size_t i = 0; i < search_providers_.size(); ++i) - search_providers_[i]->set_result_changed_callback(base::Closure()); -} - -void AppListViewDelegate::RegisterSearchProvider( - app_list::SearchProvider* search_provider) { - // Right now we allow only one provider. - // TODO(mukai): port app-list's mixer and remove this restriction. - DCHECK(search_providers_.empty()); - search_provider->set_result_changed_callback(base::Bind( - &AppListViewDelegate::SearchResultChanged, base::Unretained(this))); - search_providers_.push_back(search_provider); -} - -void AppListViewDelegate::SearchResultChanged() { - // TODO(mukai): port app-list's Mixer to reorder the results properly. - app_list::SearchProvider* search_provider = search_providers_[0]; - std::vector results; - search_provider->ReleaseResult(&results); - if (results.empty()) { - model_->results()->DeleteAll(); - } else { - for (size_t i = 0; i < results.size(); ++i) - model_->results()->Add(results[i]); - } } bool AppListViewDelegate::ForceNativeDesktop() const { @@ -86,26 +65,28 @@ void AppListViewDelegate::GetShortcutPathForApp( } void AppListViewDelegate::StartSearch() { - for (size_t i = 0; i < search_providers_.size(); ++i) - search_providers_[i]->Start(model_->search_box()->text()); + if (search_controller_) + search_controller_->Start(); } void AppListViewDelegate::StopSearch() { - for (size_t i = 0; i < search_providers_.size(); ++i) - search_providers_[i]->Stop(); + if (search_controller_) + search_controller_->Stop(); } void AppListViewDelegate::OpenSearchResult(app_list::SearchResult* result, bool auto_launch, int event_flags) { - result->Open(event_flags); + if (search_controller_) + search_controller_->OpenResult(result, event_flags); } void AppListViewDelegate::InvokeSearchResultAction( app_list::SearchResult* result, int action_index, int event_flags) { - // TODO(mukai): implement this. + if (search_controller_) + search_controller_->InvokeResultAction(result, action_index, event_flags); } base::TimeDelta AppListViewDelegate::GetAutoLaunchTimeout() { @@ -159,14 +140,7 @@ void AppListViewDelegate::ShowForProfileByPath( views::View* AppListViewDelegate::CreateStartPageWebView( const gfx::Size& size) { - // A static image of the logo. This needs to support dynamic Doodles - // eventually. - views::ImageView* logo_image = new views::ImageView(); - logo_image->SetImage(ui::ResourceBundle::GetSharedInstance(). - GetImageSkiaNamed(IDR_LOCAL_NTP_IMAGES_LOGO_PNG)); - logo_image->SetHorizontalAlignment(views::ImageView::CENTER); - logo_image->SetVerticalAlignment(views::ImageView::CENTER); - return logo_image; + return nullptr; } std::vector AppListViewDelegate::CreateCustomPageWebViews(