Expose the ability to perform a search from CVC.
[chromium-blink-merge.git] / ash / shell / toplevel_window.cc
blobd6b83889fc591b3a82f4775107f31a62161b06bb
1 // Copyright (c) 2012 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 "ash/shell/toplevel_window.h"
7 #include "ash/display/display_controller.h"
8 #include "ash/screen_ash.h"
9 #include "ash/shell.h"
10 #include "ash/wm/property_util.h"
11 #include "base/strings/utf_string_conversions.h"
12 #include "ui/aura/root_window.h"
13 #include "ui/aura/window.h"
14 #include "ui/gfx/canvas.h"
15 #include "ui/views/widget/widget.h"
17 namespace ash {
18 namespace shell {
20 ToplevelWindow::CreateParams::CreateParams()
21 : can_resize(false),
22 can_maximize(false) {
25 // static
26 void ToplevelWindow::CreateToplevelWindow(const CreateParams& params) {
27 static int count = 0;
28 int x = count == 0 ? 150 : 750;
29 count = (count + 1) % 2;
31 gfx::Rect bounds(x, 150, 300, 300);
32 gfx::Display display =
33 ash::Shell::GetScreen()->GetDisplayMatching(bounds);
34 aura::RootWindow* root = ash::Shell::GetInstance()->display_controller()->
35 GetRootWindowForDisplayId(display.id());
36 views::Widget* widget = views::Widget::CreateWindowWithContextAndBounds(
37 new ToplevelWindow(params), root, bounds);
38 widget->GetNativeView()->SetName("Examples:ToplevelWindow");
39 widget->Show();
42 ToplevelWindow::ToplevelWindow(const CreateParams& params) : params_(params) {
45 ToplevelWindow::~ToplevelWindow() {
48 void ToplevelWindow::OnPaint(gfx::Canvas* canvas) {
49 canvas->FillRect(GetLocalBounds(), SK_ColorDKGRAY);
52 base::string16 ToplevelWindow::GetWindowTitle() const {
53 return ASCIIToUTF16("Examples: Toplevel Window");
56 views::View* ToplevelWindow::GetContentsView() {
57 return this;
60 bool ToplevelWindow::CanResize() const {
61 return params_.can_resize;
64 bool ToplevelWindow::CanMaximize() const {
65 return params_.can_maximize;
68 } // namespace shell
69 } // namespace ash