OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/macros.h" | 5 #include "base/macros.h" |
6 #include "components/filesystem/public/cpp/prefs/pref_service_factory.h" | 6 #include "components/filesystem/public/cpp/prefs/pref_service_factory.h" |
7 #include "components/mus/public/cpp/property_type_converters.h" | 7 #include "components/mus/public/cpp/property_type_converters.h" |
8 #include "components/prefs/pref_registry_simple.h" | 8 #include "components/prefs/pref_registry_simple.h" |
9 #include "mash/wm/public/interfaces/container.mojom.h" | 9 #include "mash/wm/public/interfaces/container.mojom.h" |
10 #include "mojo/public/c/system/main.h" | 10 #include "mojo/public/c/system/main.h" |
11 #include "mojo/services/tracing/public/cpp/tracing_impl.h" | 11 #include "mojo/services/tracing/public/cpp/tracing_impl.h" |
12 #include "mojo/shell/public/cpp/application_connection.h" | 12 #include "mojo/shell/public/cpp/application_connection.h" |
13 #include "mojo/shell/public/cpp/application_delegate.h" | 13 #include "mojo/shell/public/cpp/application_delegate.h" |
14 #include "mojo/shell/public/cpp/application_impl.h" | |
15 #include "mojo/shell/public/cpp/application_runner.h" | 14 #include "mojo/shell/public/cpp/application_runner.h" |
| 15 #include "mojo/shell/public/cpp/shell.h" |
16 #include "ui/gfx/canvas.h" | 16 #include "ui/gfx/canvas.h" |
17 #include "ui/views/mus/aura_init.h" | 17 #include "ui/views/mus/aura_init.h" |
18 #include "ui/views/mus/native_widget_mus.h" | 18 #include "ui/views/mus/native_widget_mus.h" |
19 #include "ui/views/mus/window_manager_connection.h" | 19 #include "ui/views/mus/window_manager_connection.h" |
20 #include "ui/views/widget/widget_delegate.h" | 20 #include "ui/views/widget/widget_delegate.h" |
21 | 21 |
22 namespace mash { | 22 namespace mash { |
23 namespace wallpaper { | 23 namespace wallpaper { |
24 namespace { | 24 namespace { |
25 | 25 |
(...skipping 17 matching lines...) Expand all Loading... |
43 public: | 43 public: |
44 WallpaperApplicationDelegate() {} | 44 WallpaperApplicationDelegate() {} |
45 ~WallpaperApplicationDelegate() override {} | 45 ~WallpaperApplicationDelegate() override {} |
46 | 46 |
47 void OnLoaded(bool whatever) { | 47 void OnLoaded(bool whatever) { |
48 // TODO(erg): Now do something with this result. | 48 // TODO(erg): Now do something with this result. |
49 } | 49 } |
50 | 50 |
51 private: | 51 private: |
52 // mojo::ApplicationDelegate: | 52 // mojo::ApplicationDelegate: |
53 void Initialize(mojo::ApplicationImpl* app) override { | 53 void Initialize(mojo::Shell* shell, const std::string& url, |
54 tracing_.Initialize(app); | 54 uint32_t id) override { |
| 55 tracing_.Initialize(shell, url); |
55 | 56 |
56 aura_init_.reset(new views::AuraInit(app, "views_mus_resources.pak")); | 57 aura_init_.reset(new views::AuraInit(shell, "views_mus_resources.pak")); |
57 views::WindowManagerConnection::Create(app); | 58 views::WindowManagerConnection::Create(shell); |
58 | 59 |
59 scoped_refptr<PrefRegistrySimple> registry = new PrefRegistrySimple; | 60 scoped_refptr<PrefRegistrySimple> registry = new PrefRegistrySimple; |
60 registry->RegisterStringPref("filename", "", 0); | 61 registry->RegisterStringPref("filename", "", 0); |
61 pref_service_ = filesystem::CreatePrefService(app, registry.get()); | 62 pref_service_ = filesystem::CreatePrefService(shell, registry.get()); |
62 pref_service_->AddPrefInitObserver(base::Bind( | 63 pref_service_->AddPrefInitObserver(base::Bind( |
63 &WallpaperApplicationDelegate::OnLoaded, base::Unretained(this))); | 64 &WallpaperApplicationDelegate::OnLoaded, base::Unretained(this))); |
64 | 65 |
65 views::Widget* widget = new views::Widget; | 66 views::Widget* widget = new views::Widget; |
66 views::Widget::InitParams params( | 67 views::Widget::InitParams params( |
67 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); | 68 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); |
68 params.delegate = new Wallpaper; | 69 params.delegate = new Wallpaper; |
69 | 70 |
70 std::map<std::string, std::vector<uint8_t>> properties; | 71 std::map<std::string, std::vector<uint8_t>> properties; |
71 properties[mash::wm::mojom::kWindowContainer_Property] = | 72 properties[mash::wm::mojom::kWindowContainer_Property] = |
72 mojo::TypeConverter<const std::vector<uint8_t>, int32_t>::Convert( | 73 mojo::TypeConverter<const std::vector<uint8_t>, int32_t>::Convert( |
73 static_cast<int32_t>(mash::wm::mojom::Container::USER_BACKGROUND)); | 74 static_cast<int32_t>(mash::wm::mojom::Container::USER_BACKGROUND)); |
74 mus::Window* window = | 75 mus::Window* window = |
75 views::WindowManagerConnection::Get()->NewWindow(properties); | 76 views::WindowManagerConnection::Get()->NewWindow(properties); |
76 params.native_widget = new views::NativeWidgetMus( | 77 params.native_widget = new views::NativeWidgetMus( |
77 widget, app->shell(), window, mus::mojom::SurfaceType::DEFAULT); | 78 widget, shell, window, mus::mojom::SurfaceType::DEFAULT); |
78 widget->Init(params); | 79 widget->Init(params); |
79 widget->Show(); | 80 widget->Show(); |
80 } | 81 } |
81 | 82 |
82 mojo::TracingImpl tracing_; | 83 mojo::TracingImpl tracing_; |
83 scoped_ptr<views::AuraInit> aura_init_; | 84 scoped_ptr<views::AuraInit> aura_init_; |
84 scoped_ptr<PrefService> pref_service_; | 85 scoped_ptr<PrefService> pref_service_; |
85 | 86 |
86 DISALLOW_COPY_AND_ASSIGN(WallpaperApplicationDelegate); | 87 DISALLOW_COPY_AND_ASSIGN(WallpaperApplicationDelegate); |
87 }; | 88 }; |
88 | 89 |
89 } // namespace | 90 } // namespace |
90 } // namespace wallpaper | 91 } // namespace wallpaper |
91 } // namespace mash | 92 } // namespace mash |
92 | 93 |
93 MojoResult MojoMain(MojoHandle shell_handle) { | 94 MojoResult MojoMain(MojoHandle shell_handle) { |
94 mojo::ApplicationRunner runner( | 95 mojo::ApplicationRunner runner( |
95 new mash::wallpaper::WallpaperApplicationDelegate); | 96 new mash::wallpaper::WallpaperApplicationDelegate); |
96 return runner.Run(shell_handle); | 97 return runner.Run(shell_handle); |
97 } | 98 } |
OLD | NEW |