Move Webstore URL concepts to //extensions and out
[chromium-blink-merge.git] / chrome / browser / ui / app_list / app_list_service_views.cc
blob88fa4b8f0c1b6ba03341805fa82828f5fa6a62d8
1 // Copyright 2014 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.
5 #include "chrome/browser/ui/app_list/app_list_service_views.h"
7 #include "chrome/browser/ui/app_list/app_list_controller_delegate.h"
8 #include "chrome/browser/ui/app_list/scoped_keep_alive.h"
9 #include "ui/app_list/views/app_list_view.h"
11 AppListServiceViews::AppListServiceViews(
12 scoped_ptr<AppListControllerDelegate> controller_delegate)
13 : shower_(this),
14 can_dismiss_(true),
15 controller_delegate_(controller_delegate.Pass()) {
18 AppListServiceViews::~AppListServiceViews() {}
20 void AppListServiceViews::OnViewBeingDestroyed() {
21 can_dismiss_ = true;
22 shower_.HandleViewBeingDestroyed();
25 void AppListServiceViews::Init(Profile* initial_profile) {
26 PerformStartupChecks(initial_profile);
29 void AppListServiceViews::CreateForProfile(Profile* requested_profile) {
30 shower_.CreateViewForProfile(requested_profile);
33 void AppListServiceViews::ShowForProfile(Profile* requested_profile) {
34 DCHECK(requested_profile);
36 ScopedKeepAlive keep_alive;
38 InvalidatePendingProfileLoads();
39 SetProfilePath(requested_profile->GetPath());
40 shower_.ShowForProfile(requested_profile);
41 RecordAppListLaunch();
44 void AppListServiceViews::DismissAppList() {
45 if (!can_dismiss_)
46 return;
48 shower_.DismissAppList();
51 bool AppListServiceViews::IsAppListVisible() const {
52 return shower_.IsAppListVisible();
55 gfx::NativeWindow AppListServiceViews::GetAppListWindow() {
56 return shower_.GetWindow();
59 Profile* AppListServiceViews::GetCurrentAppListProfile() {
60 return shower_.profile();
63 AppListControllerDelegate* AppListServiceViews::GetControllerDelegate() {
64 return controller_delegate_.get();
67 void AppListServiceViews::DestroyAppList() {
68 if (!shower_.HasView())
69 return;
71 // Use CloseNow(). This can't be asynchronous because the profile will be
72 // deleted once this function returns.
73 shower_.app_list()->GetWidget()->CloseNow();
74 DCHECK(!shower_.HasView());
77 AppListControllerDelegate*
78 AppListServiceViews::GetControllerDelegateForCreate() {
79 return controller_delegate_.get();