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

Side by Side Diff: components/mus/example/mock_sysui/mock_sysui.cc

Issue 1469733004: Moves components/mus/examples into mash (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: git add Created 5 years, 1 month 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 "components/mus/example/mock_sysui/mock_sysui.h"
6
7 #include "components/mus/public/cpp/property_type_converters.h"
8 #include "mash/wm/public/interfaces/container.mojom.h"
9 #include "mojo/application/public/cpp/application_connection.h"
10 #include "mojo/application/public/cpp/application_impl.h"
11 #include "ui/gfx/canvas.h"
12 #include "ui/views/mus/aura_init.h"
13 #include "ui/views/mus/native_widget_mus.h"
14 #include "ui/views/mus/window_manager_connection.h"
15 #include "ui/views/widget/widget_delegate.h"
16
17 namespace {
18
19 class DesktopBackground : public views::WidgetDelegateView {
20 public:
21 static void Create(mojo::Shell* shell) {
22 views::Widget* widget = new views::Widget;
23 views::Widget::InitParams params(
24 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS);
25 params.delegate = new DesktopBackground;
26
27 std::map<std::string, std::vector<uint8_t>> properties;
28 properties[mash::wm::mojom::kWindowContainer_Property] =
29 mojo::TypeConverter<const std::vector<uint8_t>, int32_t>::Convert(
30 mash::wm::mojom::CONTAINER_USER_BACKGROUND);
31 mus::Window* window =
32 views::WindowManagerConnection::Get()->NewWindow(properties);
33 params.native_widget = new views::NativeWidgetMus(
34 widget, shell, window, mus::mojom::SURFACE_TYPE_DEFAULT);
35 widget->Init(params);
36 widget->Show();
37 }
38
39 private:
40 DesktopBackground() {}
41 ~DesktopBackground() override {}
42
43 // Overridden from views::View:
44 void OnPaint(gfx::Canvas* canvas) override {
45 canvas->FillRect(GetLocalBounds(), SK_ColorRED);
46 }
47
48 // Overridden from views::WidgetDelegate:
49 views::View* GetContentsView() override { return this; }
50
51 DISALLOW_COPY_AND_ASSIGN(DesktopBackground);
52 };
53
54 class Shelf : public views::WidgetDelegateView {
55 public:
56 static void Create(mojo::Shell* shell) {
57 views::Widget* widget = new views::Widget;
58 views::Widget::InitParams params(
59 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS);
60 params.delegate = new Shelf;
61
62 std::map<std::string, std::vector<uint8_t>> properties;
63 properties[mash::wm::mojom::kWindowContainer_Property] =
64 mojo::TypeConverter<const std::vector<uint8_t>, int32_t>::Convert(
65 mash::wm::mojom::CONTAINER_USER_SHELF);
66 mus::Window* window =
67 views::WindowManagerConnection::Get()->NewWindow(properties);
68 params.native_widget = new views::NativeWidgetMus(
69 widget, shell, window, mus::mojom::SURFACE_TYPE_DEFAULT);
70 widget->Init(params);
71 widget->Show();
72 }
73
74 private:
75 Shelf() {}
76 ~Shelf() override {}
77
78 // Overridden from views::View:
79 void OnPaint(gfx::Canvas* canvas) override {
80 canvas->FillRect(GetLocalBounds(), SK_ColorYELLOW);
81 }
82 gfx::Size GetPreferredSize() const override { return gfx::Size(1, 48); }
83
84 // Overridden from views::WidgetDelegate:
85 views::View* GetContentsView() override { return this; }
86
87 DISALLOW_COPY_AND_ASSIGN(Shelf);
88 };
89
90 } // namespace
91
92 MockSysUI::MockSysUI() {}
93
94 MockSysUI::~MockSysUI() {
95 }
96
97 void MockSysUI::Initialize(mojo::ApplicationImpl* app) {
98 tracing_.Initialize(app);
99
100 aura_init_.reset(new views::AuraInit(app, "views_mus_resources.pak"));
101 views::WindowManagerConnection::Create(app);
102
103 DesktopBackground::Create(app->shell());
104 Shelf::Create(app->shell());
105 }
106
107 bool MockSysUI::ConfigureIncomingConnection(
108 mojo::ApplicationConnection* connection) {
109 return false;
110 }
OLDNEW
« no previous file with comments | « components/mus/example/mock_sysui/mock_sysui.h ('k') | components/mus/example/views_examples/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698