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