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 #include "content/browser/mojo/mojo_shell_context.h" | 5 #include "content/browser/mojo/mojo_shell_context.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <string> | 8 #include <string> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/json/json_reader.h" |
12 #include "base/lazy_instance.h" | 13 #include "base/lazy_instance.h" |
13 #include "base/macros.h" | 14 #include "base/macros.h" |
14 #include "base/memory/ptr_util.h" | 15 #include "base/memory/ptr_util.h" |
15 #include "base/single_thread_task_runner.h" | 16 #include "base/single_thread_task_runner.h" |
16 #include "content/browser/gpu/gpu_process_host.h" | 17 #include "content/browser/gpu/gpu_process_host.h" |
17 #include "content/common/mojo/constants.h" | 18 #include "content/browser/mojo/merge_dictionary.h" |
18 #include "content/common/mojo/mojo_shell_connection_impl.h" | 19 #include "content/common/mojo/mojo_shell_connection_impl.h" |
19 #include "content/grit/content_resources.h" | 20 #include "content/grit/content_resources.h" |
20 #include "content/public/browser/browser_thread.h" | 21 #include "content/public/browser/browser_thread.h" |
21 #include "content/public/browser/content_browser_client.h" | 22 #include "content/public/browser/content_browser_client.h" |
22 #include "content/public/browser/utility_process_host.h" | 23 #include "content/public/browser/utility_process_host.h" |
23 #include "content/public/browser/utility_process_host_client.h" | 24 #include "content/public/browser/utility_process_host_client.h" |
24 #include "content/public/common/content_client.h" | 25 #include "content/public/common/content_client.h" |
25 #include "content/public/common/mojo_shell_connection.h" | 26 #include "content/public/common/mojo_shell_connection.h" |
| 27 #include "content/public/common/service_names.h" |
26 #include "mojo/edk/embedder/embedder.h" | 28 #include "mojo/edk/embedder/embedder.h" |
27 #include "services/catalog/catalog.h" | 29 #include "services/catalog/catalog.h" |
28 #include "services/catalog/manifest_provider.h" | 30 #include "services/catalog/manifest_provider.h" |
29 #include "services/catalog/store.h" | 31 #include "services/catalog/store.h" |
30 #include "services/file/public/cpp/constants.h" | 32 #include "services/file/public/cpp/constants.h" |
31 #include "services/shell/connect_params.h" | 33 #include "services/shell/connect_params.h" |
32 #include "services/shell/native_runner.h" | 34 #include "services/shell/native_runner.h" |
33 #include "services/shell/public/cpp/connector.h" | 35 #include "services/shell/public/cpp/connector.h" |
34 #include "services/shell/public/cpp/service.h" | 36 #include "services/shell/public/cpp/service.h" |
35 #include "services/shell/public/interfaces/service.mojom.h" | 37 #include "services/shell/public/interfaces/service.mojom.h" |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 resource_id, ui::ScaleFactor::SCALE_FACTOR_NONE).as_string(); | 121 resource_id, ui::ScaleFactor::SCALE_FACTOR_NONE).as_string(); |
120 DCHECK(!contents.empty()); | 122 DCHECK(!contents.empty()); |
121 | 123 |
122 DCHECK(manifests_); | 124 DCHECK(manifests_); |
123 auto result = manifests_->insert(std::make_pair(name, contents)); | 125 auto result = manifests_->insert(std::make_pair(name, contents)); |
124 DCHECK(result.second) << "Duplicate manifest entry: " << name; | 126 DCHECK(result.second) << "Duplicate manifest entry: " << name; |
125 } | 127 } |
126 | 128 |
127 private: | 129 private: |
128 // catalog::ManifestProvider: | 130 // catalog::ManifestProvider: |
129 bool GetApplicationManifest(const base::StringPiece& name, | 131 std::unique_ptr<base::Value> GetManifest(const std::string& name) override { |
130 std::string* manifest_contents) override { | 132 auto manifest_it = manifests_->find(name); |
131 auto manifest_it = manifests_->find(name.as_string()); | 133 std::unique_ptr<base::Value> manifest_root; |
132 if (manifest_it != manifests_->end()) { | 134 if (manifest_it != manifests_->end()) |
133 *manifest_contents = manifest_it->second; | 135 manifest_root = base::JSONReader::Read(manifest_it->second); |
134 DCHECK(!manifest_contents->empty()); | 136 |
135 return true; | 137 base::DictionaryValue* manifest_dictionary = nullptr; |
| 138 if (manifest_root && !manifest_root->GetAsDictionary(&manifest_dictionary)) |
| 139 return nullptr; |
| 140 |
| 141 std::unique_ptr<base::Value> overlay_root = |
| 142 GetContentClient()->browser()->GetServiceManifestOverlay(name); |
| 143 if (overlay_root) { |
| 144 if (!manifest_root) { |
| 145 manifest_root = std::move(overlay_root); |
| 146 } else { |
| 147 base::DictionaryValue* overlay_dictionary = nullptr; |
| 148 if (overlay_root->GetAsDictionary(&overlay_dictionary)) |
| 149 MergeDictionary(manifest_dictionary, overlay_dictionary); |
| 150 } |
136 } | 151 } |
137 return false; | 152 return manifest_root; |
138 } | 153 } |
139 | 154 |
140 std::unique_ptr<ContentBrowserClient::MojoApplicationManifestMap> manifests_; | 155 std::unique_ptr<ContentBrowserClient::MojoApplicationManifestMap> manifests_; |
141 | 156 |
142 DISALLOW_COPY_AND_ASSIGN(BuiltinManifestProvider); | 157 DISALLOW_COPY_AND_ASSIGN(BuiltinManifestProvider); |
143 }; | 158 }; |
144 | 159 |
145 } // namespace | 160 } // namespace |
146 | 161 |
147 // State which lives on the IO thread and drives the ServiceManager. | 162 // State which lives on the IO thread and drives the ServiceManager. |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 in_process_context_->ShutDown(); | 311 in_process_context_->ShutDown(); |
297 } | 312 } |
298 | 313 |
299 // static | 314 // static |
300 shell::Connector* MojoShellContext::GetConnectorForIOThread() { | 315 shell::Connector* MojoShellContext::GetConnectorForIOThread() { |
301 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 316 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
302 return g_io_thread_connector.Get().get(); | 317 return g_io_thread_connector.Get().get(); |
303 } | 318 } |
304 | 319 |
305 } // namespace content | 320 } // namespace content |
OLD | NEW |