This source file includes following definitions.
- can_close_app_list_
- ShowAndReacquireFocus
- ShowForProfile
- GetWindow
- CreateViewForProfile
- DismissAppList
- CloseAppList
- IsAppListVisible
- WarmupForProfile
- HasView
#include "base/bind.h"
#include "base/message_loop/message_loop.h"
#include "chrome/browser/ui/app_list/app_list_shower.h"
AppListShower::AppListShower(scoped_ptr<AppListFactory> factory,
scoped_ptr<KeepAliveService> keep_alive,
AppListService* service)
: factory_(factory.Pass()),
keep_alive_service_(keep_alive.Pass()),
service_(service),
profile_(NULL),
can_close_app_list_(true) {
}
AppListShower::~AppListShower() {
}
void AppListShower::ShowAndReacquireFocus(Profile* requested_profile) {
ShowForProfile(requested_profile);
app_list_->ReactivateOnNextFocusLoss();
}
void AppListShower::ShowForProfile(Profile* requested_profile) {
if (IsAppListVisible() && (requested_profile == profile_)) {
app_list_->Show();
return;
}
if (!app_list_) {
CreateViewForProfile(requested_profile);
} else if (requested_profile != profile_) {
profile_ = requested_profile;
app_list_->SetProfile(requested_profile);
}
keep_alive_service_->EnsureKeepAlive();
if (!IsAppListVisible())
app_list_->MoveNearCursor();
app_list_->Show();
}
gfx::NativeWindow AppListShower::GetWindow() {
if (!IsAppListVisible())
return NULL;
return app_list_->GetWindow();
}
void AppListShower::CreateViewForProfile(Profile* requested_profile) {
profile_ = requested_profile;
app_list_.reset(factory_->CreateAppList(
profile_,
service_,
base::Bind(&AppListShower::DismissAppList, base::Unretained(this))));
}
void AppListShower::DismissAppList() {
if (app_list_ && can_close_app_list_) {
app_list_->Hide();
keep_alive_service_->FreeKeepAlive();
}
}
void AppListShower::CloseAppList() {
app_list_.reset();
profile_ = NULL;
can_close_app_list_ = true;
if (base::MessageLoop::current()) {
base::MessageLoop::current()->PostTask(FROM_HERE,
base::Bind(&KeepAliveService::FreeKeepAlive,
base::Unretained(keep_alive_service_.get())));
return;
}
keep_alive_service_->FreeKeepAlive();
}
bool AppListShower::IsAppListVisible() const {
return app_list_ && app_list_->IsVisible();
}
void AppListShower::WarmupForProfile(Profile* profile) {
DCHECK(!profile_);
CreateViewForProfile(profile);
app_list_->Prerender();
}
bool AppListShower::HasView() const {
return !!app_list_;
}