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

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

Issue 1624683002: mash: Add a simple, temporary preferences store. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: sky comments 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
« no previous file with comments | « mash/wallpaper/DEPS ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "base/prefs/pref_registry_simple.h"
7 #include "components/filesystem/public/cpp/prefs/pref_service_factory.h"
6 #include "components/mus/public/cpp/property_type_converters.h" 8 #include "components/mus/public/cpp/property_type_converters.h"
7 #include "mash/wm/public/interfaces/container.mojom.h" 9 #include "mash/wm/public/interfaces/container.mojom.h"
8 #include "mojo/public/c/system/main.h" 10 #include "mojo/public/c/system/main.h"
9 #include "mojo/services/tracing/public/cpp/tracing_impl.h" 11 #include "mojo/services/tracing/public/cpp/tracing_impl.h"
10 #include "mojo/shell/public/cpp/application_connection.h" 12 #include "mojo/shell/public/cpp/application_connection.h"
11 #include "mojo/shell/public/cpp/application_delegate.h" 13 #include "mojo/shell/public/cpp/application_delegate.h"
12 #include "mojo/shell/public/cpp/application_impl.h" 14 #include "mojo/shell/public/cpp/application_impl.h"
13 #include "mojo/shell/public/cpp/application_runner.h" 15 #include "mojo/shell/public/cpp/application_runner.h"
14 #include "ui/gfx/canvas.h" 16 #include "ui/gfx/canvas.h"
15 #include "ui/views/mus/aura_init.h" 17 #include "ui/views/mus/aura_init.h"
(...skipping 19 matching lines...) Expand all
35 views::View* GetContentsView() override { return this; } 37 views::View* GetContentsView() override { return this; }
36 38
37 DISALLOW_COPY_AND_ASSIGN(Wallpaper); 39 DISALLOW_COPY_AND_ASSIGN(Wallpaper);
38 }; 40 };
39 41
40 class WallpaperApplicationDelegate : public mojo::ApplicationDelegate { 42 class WallpaperApplicationDelegate : public mojo::ApplicationDelegate {
41 public: 43 public:
42 WallpaperApplicationDelegate() {} 44 WallpaperApplicationDelegate() {}
43 ~WallpaperApplicationDelegate() override {} 45 ~WallpaperApplicationDelegate() override {}
44 46
47 void OnLoaded(bool whatever) {
48 // TODO(erg): Now do something with this result.
49 }
50
45 private: 51 private:
46 // mojo::ApplicationDelegate: 52 // mojo::ApplicationDelegate:
47 void Initialize(mojo::ApplicationImpl* app) override { 53 void Initialize(mojo::ApplicationImpl* app) override {
48 tracing_.Initialize(app); 54 tracing_.Initialize(app);
49 55
50 aura_init_.reset(new views::AuraInit(app, "views_mus_resources.pak")); 56 aura_init_.reset(new views::AuraInit(app, "views_mus_resources.pak"));
51 views::WindowManagerConnection::Create(app); 57 views::WindowManagerConnection::Create(app);
52 58
59 scoped_refptr<PrefRegistrySimple> registry = new PrefRegistrySimple;
60 registry->RegisterStringPref("filename", "", 0);
61 pref_service_ = filesystem::CreatePrefService(app, registry.get());
62 pref_service_->AddPrefInitObserver(base::Bind(
63 &WallpaperApplicationDelegate::OnLoaded, base::Unretained(this)));
64
53 views::Widget* widget = new views::Widget; 65 views::Widget* widget = new views::Widget;
54 views::Widget::InitParams params( 66 views::Widget::InitParams params(
55 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); 67 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS);
56 params.delegate = new Wallpaper; 68 params.delegate = new Wallpaper;
57 69
58 std::map<std::string, std::vector<uint8_t>> properties; 70 std::map<std::string, std::vector<uint8_t>> properties;
59 properties[mash::wm::mojom::kWindowContainer_Property] = 71 properties[mash::wm::mojom::kWindowContainer_Property] =
60 mojo::TypeConverter<const std::vector<uint8_t>, int32_t>::Convert( 72 mojo::TypeConverter<const std::vector<uint8_t>, int32_t>::Convert(
61 static_cast<int32_t>(mash::wm::mojom::Container::USER_BACKGROUND)); 73 static_cast<int32_t>(mash::wm::mojom::Container::USER_BACKGROUND));
62 mus::Window* window = 74 mus::Window* window =
63 views::WindowManagerConnection::Get()->NewWindow(properties); 75 views::WindowManagerConnection::Get()->NewWindow(properties);
64 params.native_widget = new views::NativeWidgetMus( 76 params.native_widget = new views::NativeWidgetMus(
65 widget, app->shell(), window, mus::mojom::SurfaceType::DEFAULT); 77 widget, app->shell(), window, mus::mojom::SurfaceType::DEFAULT);
66 widget->Init(params); 78 widget->Init(params);
67 widget->Show(); 79 widget->Show();
68 } 80 }
69 81
70 mojo::TracingImpl tracing_; 82 mojo::TracingImpl tracing_;
71 scoped_ptr<views::AuraInit> aura_init_; 83 scoped_ptr<views::AuraInit> aura_init_;
84 scoped_ptr<PrefService> pref_service_;
72 85
73 DISALLOW_COPY_AND_ASSIGN(WallpaperApplicationDelegate); 86 DISALLOW_COPY_AND_ASSIGN(WallpaperApplicationDelegate);
74 }; 87 };
75 88
76 } // namespace 89 } // namespace
77 } // namespace wallpaper 90 } // namespace wallpaper
78 } // namespace mash 91 } // namespace mash
79 92
80 MojoResult MojoMain(MojoHandle shell_handle) { 93 MojoResult MojoMain(MojoHandle shell_handle) {
81 mojo::ApplicationRunner runner( 94 mojo::ApplicationRunner runner(
82 new mash::wallpaper::WallpaperApplicationDelegate); 95 new mash::wallpaper::WallpaperApplicationDelegate);
83 return runner.Run(shell_handle); 96 return runner.Run(shell_handle);
84 } 97 }
OLDNEW
« no previous file with comments | « mash/wallpaper/DEPS ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698