Supervised user whitelists: Cleanup
[chromium-blink-merge.git] / ui / app_list / views / app_list_background.cc
blobc22d89f47504d99fddc7850a623cc8b723aaeb77
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 "ui/app_list/views/app_list_background.h"
7 #include "base/command_line.h"
8 #include "third_party/skia/include/core/SkPaint.h"
9 #include "third_party/skia/include/core/SkPath.h"
10 #include "ui/app_list/app_list_constants.h"
11 #include "ui/app_list/app_list_switches.h"
12 #include "ui/app_list/views/contents_view.h"
13 #include "ui/app_list/views/search_box_view.h"
14 #include "ui/gfx/canvas.h"
15 #include "ui/gfx/geometry/rect.h"
16 #include "ui/gfx/skia_util.h"
17 #include "ui/views/view.h"
19 namespace app_list {
21 AppListBackground::AppListBackground(int corner_radius)
22 : corner_radius_(corner_radius) {
25 AppListBackground::~AppListBackground() {
28 void AppListBackground::Paint(gfx::Canvas* canvas,
29 views::View* view) const {
30 gfx::Rect bounds = view->GetContentsBounds();
32 if (corner_radius_ > 0) {
33 canvas->Save();
34 SkPath path;
35 // Contents corner radius is 1px smaller than border corner radius.
36 SkScalar radius = SkIntToScalar(corner_radius_ - 1);
37 path.addRoundRect(gfx::RectToSkRect(bounds), radius, radius);
38 canvas->ClipPath(path, false);
41 SkPaint paint;
42 paint.setStyle(SkPaint::kFill_Style);
44 int contents_top = bounds.y();
45 gfx::Rect contents_rect(bounds.x(),
46 contents_top,
47 bounds.width(),
48 bounds.bottom() - contents_top);
50 paint.setColor(kContentsBackgroundColor);
51 canvas->DrawRect(contents_rect, paint);
53 if (corner_radius_ > 0)
54 canvas->Restore();
57 } // namespace app_list