OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 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 #ifndef UI_VIEWS_MUS_AURA_INIT_H_ | 5 #ifndef UI_VIEWS_MUS_AURA_INIT_H_ |
6 #define UI_VIEWS_MUS_AURA_INIT_H_ | 6 #define UI_VIEWS_MUS_AURA_INIT_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 AURA_MUS, | 44 AURA_MUS, |
45 | 45 |
46 // Indicates AuraInit should target using aura with mus, for a Window | 46 // Indicates AuraInit should target using aura with mus, for a Window |
47 // Manager client. | 47 // Manager client. |
48 AURA_MUS_WINDOW_MANAGER, | 48 AURA_MUS_WINDOW_MANAGER, |
49 | 49 |
50 // Indicates AuraInit should target using ui::Window. | 50 // Indicates AuraInit should target using ui::Window. |
51 UI | 51 UI |
52 }; | 52 }; |
53 | 53 |
| 54 ~AuraInit(); |
| 55 |
| 56 // Returns an AuraInit if initialization can be completed successfully, |
| 57 // otherwise a nullptr is returned. If initialization fails then Aura is in an |
| 58 // unusable state, and calling services should shutdown. |
54 // |resource_file| is the file to load strings and 1x icons from. | 59 // |resource_file| is the file to load strings and 1x icons from. |
55 // |resource_file_200| can be an empty string, otherwise it is the file to | 60 // |resource_file_200| can be an empty string, otherwise it is the file to |
56 // load 2x icons from. | 61 // load 2x icons from. |
57 AuraInit(service_manager::Connector* connector, | 62 static std::unique_ptr<AuraInit> Create( |
58 const service_manager::Identity& identity, | 63 service_manager::Connector* connector, |
59 const std::string& resource_file, | 64 const service_manager::Identity& identity, |
60 const std::string& resource_file_200 = std::string(), | 65 const std::string& resource_file, |
61 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner = nullptr, | 66 const std::string& resource_file_200 = std::string(), |
62 Mode mode = Mode::UI); | 67 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner = nullptr, |
63 ~AuraInit(); | 68 Mode mode = Mode::UI); |
64 | 69 |
65 // Only valid if Mode::AURA_MUS was passed to constructor. | 70 // Only valid if Mode::AURA_MUS was passed to constructor. |
66 MusClient* mus_client() { return mus_client_.get(); } | 71 MusClient* mus_client() { return mus_client_.get(); } |
67 | 72 |
| 73 private: |
| 74 AuraInit(); |
| 75 |
68 // Returns true if AuraInit was able to successfully complete initialization. | 76 // Returns true if AuraInit was able to successfully complete initialization. |
69 // If this returns false, then Aura is in an unusable state, and calling | 77 // If this returns false, then Aura is in an unusable state, and calling |
70 // services should shutdown. | 78 // services should shutdown. |
71 bool initialized() { return initialized_; } | 79 bool Init( |
| 80 service_manager::Connector* connector, |
| 81 const service_manager::Identity& identity, |
| 82 const std::string& resource_file, |
| 83 const std::string& resource_file_200 = std::string(), |
| 84 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner = nullptr, |
| 85 Mode mode = Mode::UI); |
72 | 86 |
73 private: | 87 bool InitializeResources(service_manager::Connector* connector, |
74 bool InitializeResources(service_manager::Connector* connector); | 88 const std::string& resource_file, |
| 89 const std::string& resource_file_200); |
75 | 90 |
76 #if defined(OS_LINUX) | 91 #if defined(OS_LINUX) |
77 sk_sp<font_service::FontLoader> font_loader_; | 92 sk_sp<font_service::FontLoader> font_loader_; |
78 #endif | 93 #endif |
79 | 94 |
80 const std::string resource_file_; | |
81 const std::string resource_file_200_; | |
82 | |
83 std::unique_ptr<aura::Env> env_; | 95 std::unique_ptr<aura::Env> env_; |
84 std::unique_ptr<MusClient> mus_client_; | 96 std::unique_ptr<MusClient> mus_client_; |
85 std::unique_ptr<ViewsDelegate> views_delegate_; | 97 std::unique_ptr<ViewsDelegate> views_delegate_; |
86 | 98 |
87 // Whether or not initialization succeeds. | |
88 bool initialized_ = false; | |
89 | |
90 DISALLOW_COPY_AND_ASSIGN(AuraInit); | 99 DISALLOW_COPY_AND_ASSIGN(AuraInit); |
91 }; | 100 }; |
92 | 101 |
93 } // namespace views | 102 } // namespace views |
94 | 103 |
95 #endif // UI_VIEWS_MUS_AURA_INIT_H_ | 104 #endif // UI_VIEWS_MUS_AURA_INIT_H_ |
OLD | NEW |