Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(212)

Side by Side Diff: mash/system_ui/system_ui.cc

Issue 1576683002: Add rudimentary mash shelf functionality. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Sync and rebase. Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 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 #include "mash/system_ui/system_ui.h"
6
7 #include <stdint.h>
8
9 #include "base/macros.h"
10 #include "components/mus/public/cpp/property_type_converters.h"
11 #include "mash/wm/public/interfaces/container.mojom.h"
12 #include "mojo/shell/public/cpp/application_connection.h"
13 #include "mojo/shell/public/cpp/application_impl.h"
14 #include "ui/gfx/canvas.h"
15 #include "ui/views/mus/aura_init.h"
16 #include "ui/views/mus/native_widget_mus.h"
17 #include "ui/views/mus/window_manager_connection.h"
18 #include "ui/views/widget/widget_delegate.h"
19
20 namespace mash {
21 namespace system_ui {
22 namespace {
23
24 class Shelf : public views::WidgetDelegateView {
25 public:
26 static void Create(mojo::Shell* shell) {
27 views::Widget* widget = new views::Widget;
28 views::Widget::InitParams params(
29 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS);
30 params.delegate = new Shelf;
31
32 std::map<std::string, std::vector<uint8_t>> properties;
33 properties[mash::wm::mojom::kWindowContainer_Property] =
34 mojo::TypeConverter<const std::vector<uint8_t>, int32_t>::Convert(
35 mash::wm::mojom::CONTAINER_USER_SHELF);
36 mus::Window* window =
37 views::WindowManagerConnection::Get()->NewWindow(properties);
38 params.native_widget = new views::NativeWidgetMus(
39 widget, shell, window, mus::mojom::SURFACE_TYPE_DEFAULT);
40 widget->Init(params);
41 widget->Show();
42 }
43
44 private:
45 Shelf() {}
46 ~Shelf() override {}
47
48 // Overridden from views::View:
49 void OnPaint(gfx::Canvas* canvas) override {
50 canvas->FillRect(GetLocalBounds(), SK_ColorYELLOW);
51 }
52 gfx::Size GetPreferredSize() const override { return gfx::Size(1, 48); }
53
54 // Overridden from views::WidgetDelegate:
55 views::View* GetContentsView() override { return this; }
56
57 DISALLOW_COPY_AND_ASSIGN(Shelf);
58 };
59
60 } // namespace
61
62 SystemUI::SystemUI() {}
63
64 SystemUI::~SystemUI() {
65 }
66
67 void SystemUI::Initialize(mojo::ApplicationImpl* app) {
68 tracing_.Initialize(app);
69
70 aura_init_.reset(new views::AuraInit(app, "views_mus_resources.pak"));
71 views::WindowManagerConnection::Create(app);
72
73 Shelf::Create(app->shell());
74 }
75
76 bool SystemUI::ConfigureIncomingConnection(
77 mojo::ApplicationConnection* connection) {
78 return true;
79 }
80
81 } // namespace system_ui
82 } // namespace mash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698