app_list_win.h revision f2477e01787aa58f445919b809d89e252beef54f
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#ifndef CHROME_BROWSER_UI_VIEWS_APP_LIST_WIN_APP_LIST_WIN_H_
6#define CHROME_BROWSER_UI_VIEWS_APP_LIST_WIN_APP_LIST_WIN_H_
7
8#include "base/callback_forward.h"
9#include "chrome/browser/ui/app_list/app_list.h"
10#include "chrome/browser/ui/views/app_list/win/activation_tracker_win.h"
11#include "ui/app_list/views/app_list_view.h"
12
13namespace gfx {
14class Display;
15class Point;
16class Size;
17}  // namespace gfx
18
19// Responsible for positioning, hiding and showing an AppListView on Windows.
20// This includes watching window activation/deactivation messages to determine
21// if the user has clicked away from it.
22class AppListWin : public AppList {
23 public:
24  AppListWin(app_list::AppListView* view,
25             const base::Closure& on_should_dismiss);
26  virtual ~AppListWin();
27
28  // Finds the position for a window to anchor it to the taskbar. This chooses
29  // the most appropriate position for the window based on whether the taskbar
30  // exists, the position of the taskbar, and the mouse cursor. Returns the
31  // intended coordinates for the center of the window. If |taskbar_rect| is
32  // empty, assumes there is no taskbar on the given display.
33  static gfx::Point FindAnchorPoint(const gfx::Size view_size,
34                                    const gfx::Display& display,
35                                    const gfx::Point& cursor,
36                                    const gfx::Rect& taskbar_rect);
37
38  // AppList overrides.
39  virtual void Show() OVERRIDE;
40  virtual void Hide() OVERRIDE;
41  virtual void MoveNearCursor() OVERRIDE;
42  virtual bool IsVisible() OVERRIDE;
43  virtual void Prerender() OVERRIDE;
44  virtual void ReactivateOnNextFocusLoss() OVERRIDE;
45  virtual gfx::NativeWindow GetWindow() OVERRIDE;
46  virtual void SetProfile(Profile* profile) OVERRIDE;
47
48 private:
49  // Weak pointer. The view manages its own lifetime.
50  app_list::AppListView* view_;
51  ActivationTrackerWin activation_tracker_;
52  bool window_icon_updated_;
53
54  DISALLOW_COPY_AND_ASSIGN(AppListWin);
55};
56
57#endif  // CHROME_BROWSER_UI_VIEWS_APP_LIST_WIN_APP_LIST_WIN_H_
58