| Index: chrome/browser/ui/app_list/app_list_service_views_mac.mm
|
| diff --git a/chrome/browser/ui/app_list/app_list_service_views_mac.mm b/chrome/browser/ui/app_list/app_list_service_views_mac.mm
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..3c152ec6c2573534347860cee4dc9fea8540bfa8
|
| --- /dev/null
|
| +++ b/chrome/browser/ui/app_list/app_list_service_views_mac.mm
|
| @@ -0,0 +1,100 @@
|
| +// Copyright 2015 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "chrome/browser/ui/app_list/app_list_service_views_mac.h"
|
| +
|
| +#include "base/memory/singleton.h"
|
| +#include "base/thread_task_runner_handle.h"
|
| +#include "chrome/browser/ui/app_list/app_list_controller_delegate_views.h"
|
| +#include "ui/app_list/views/app_list_view.h"
|
| +
|
| +void AppListServiceViewsBridge::DismissAppList() {
|
| + // Override dismiss so that the app list can be hidden with an animation.
|
| + // Currently this will close the widget when complete, rather than hide it.
|
| + owner_->DismissAppList();
|
| +}
|
| +
|
| +void AppListServiceViewsBridge::OnViewCreated() {
|
| + shower().app_list()->AddObserver(this);
|
| +}
|
| +
|
| +void AppListServiceViewsBridge::OnViewBeingDestroyed() {
|
| + shower().app_list()->RemoveObserver(this);
|
| + AppListServiceViews::OnViewBeingDestroyed();
|
| +}
|
| +
|
| +void AppListServiceViewsBridge::OnViewDismissed() {
|
| +}
|
| +
|
| +void AppListServiceViewsBridge::MoveNearCursor(app_list::AppListView* view) {
|
| + owner_->ShowWindowNearDock();
|
| +}
|
| +
|
| +void AppListServiceViewsBridge::OnActivationChanged(views::Widget* widget,
|
| + bool active) {
|
| + if (active)
|
| + return;
|
| +
|
| + if (app_list::switches::ShouldNotDismissOnBlur())
|
| + return;
|
| +
|
| + // Dismiss the app list asynchronously. This must be done asynchronously
|
| + // or our caller will crash, as it expects the app list to remain alive.
|
| + base::ThreadTaskRunnerHandle::Get()->PostTask(
|
| + FROM_HERE,
|
| + base::Bind(&AppListServiceViewsBridge::DismissAppList,
|
| + base::Unretained(this)));
|
| +}
|
| +
|
| +AppListServiceViewsBridge::AppListServiceViewsBridge(
|
| + AppListServiceViewsMac* owner)
|
| + : AppListServiceViews(scoped_ptr<AppListControllerDelegate>(
|
| + new AppListControllerDelegateViews(this))),
|
| + owner_(owner) {
|
| +}
|
| +
|
| +AppListServiceViewsMac::~AppListServiceViewsMac() {
|
| +}
|
| +
|
| +// static
|
| +AppListServiceViewsMac* AppListServiceViewsMac::GetInstance() {
|
| + return Singleton<AppListServiceViewsMac,
|
| + LeakySingletonTraits<AppListServiceViewsMac>>::get();
|
| +}
|
| +
|
| +void AppListServiceViewsMac::ShowForProfile(Profile* requested_profile) {
|
| + bridge_.ShowForProfile(requested_profile);
|
| +}
|
| +
|
| +Profile* AppListServiceViewsMac::GetCurrentAppListProfile() {
|
| + return bridge_.GetCurrentAppListProfile();
|
| +}
|
| +
|
| +AppListControllerDelegate* AppListServiceViewsMac::GetControllerDelegate() {
|
| + return bridge_.GetControllerDelegate();
|
| +}
|
| +
|
| +void AppListServiceViewsMac::CreateForProfile(Profile* requested_profile) {
|
| + bridge_.CreateForProfile(requested_profile);
|
| +}
|
| +
|
| +void AppListServiceViewsMac::DestroyAppList() {
|
| + bridge_.DestroyAppList();
|
| +}
|
| +
|
| +NSWindow* AppListServiceViewsMac::GetNativeWindow() const {
|
| + app_list::AppListView* app_list_view = bridge_.shower().app_list();
|
| + return app_list_view
|
| + ? app_list_view->GetWidget()->GetNativeWindow()
|
| + : nullptr;
|
| +}
|
| +
|
| +bool AppListServiceViewsMac::ReadyToShow() {
|
| + // Views app list can only be shown once created.
|
| + return GetNativeWindow();
|
| +}
|
| +
|
| +AppListServiceViewsMac::AppListServiceViewsMac()
|
| + : bridge_(this) {
|
| +}
|
|
|