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

Side by Side Diff: shell/context.cc

Issue 816693006: Fix skydb to work for android (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 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 | « no previous file | sky/tools/debugger/prompt/prompt.cc » ('j') | sky/tools/debugger/prompt/prompt.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "shell/context.h" 5 #include "shell/context.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/files/file_path.h" 11 #include "base/files/file_path.h"
12 #include "base/lazy_instance.h" 12 #include "base/lazy_instance.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
15 #include "base/memory/scoped_vector.h" 15 #include "base/memory/scoped_vector.h"
16 #include "base/strings/string_split.h" 16 #include "base/strings/string_split.h"
17 #include "base/strings/string_util.h"
17 #include "build/build_config.h" 18 #include "build/build_config.h"
18 #include "mojo/application_manager/application_loader.h" 19 #include "mojo/application_manager/application_loader.h"
19 #include "mojo/application_manager/application_manager.h" 20 #include "mojo/application_manager/application_manager.h"
20 #include "mojo/common/tracing_impl.h" 21 #include "mojo/common/tracing_impl.h"
21 #include "mojo/edk/embedder/embedder.h" 22 #include "mojo/edk/embedder/embedder.h"
22 #include "mojo/edk/embedder/simple_platform_support.h" 23 #include "mojo/edk/embedder/simple_platform_support.h"
23 #include "mojo/public/cpp/application/application_connection.h" 24 #include "mojo/public/cpp/application/application_connection.h"
24 #include "mojo/public/cpp/application/application_delegate.h" 25 #include "mojo/public/cpp/application/application_delegate.h"
25 #include "mojo/public/cpp/application/application_impl.h" 26 #include "mojo/public/cpp/application/application_impl.h"
26 #include "services/tracing/tracing.mojom.h" 27 #include "services/tracing/tracing.mojom.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 loader->RegisterContentHandler("application/pdf", GURL("mojo:pdf_viewer")); 64 loader->RegisterContentHandler("application/pdf", GURL("mojo:pdf_viewer"));
64 loader->RegisterContentHandler("image/png", GURL("mojo:png_viewer")); 65 loader->RegisterContentHandler("image/png", GURL("mojo:png_viewer"));
65 loader->RegisterContentHandler("text/html", GURL("mojo:html_viewer")); 66 loader->RegisterContentHandler("text/html", GURL("mojo:html_viewer"));
66 67
67 // Command-line-specified content handlers. 68 // Command-line-specified content handlers.
68 std::string handlers_spec = 69 std::string handlers_spec =
69 command_line->GetSwitchValueASCII(switches::kContentHandlers); 70 command_line->GetSwitchValueASCII(switches::kContentHandlers);
70 if (handlers_spec.empty()) 71 if (handlers_spec.empty())
71 return; 72 return;
72 73
74 #if defined(OS_ANDROID)
75 // TODO(eseidel): On Android we pass command line arguments is via the
76 // 'parameters' key on the intent, which we specify during 'am shell start'
77 // via --esa, however that expects comma-separated values and says:
78 // am shell --help:
79 // [--esa <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]
80 // (to embed a comma into a string escape it using "\,")
81 // Whatever takes 'parameters' and constructs a CommandLine is failing to
82 // un-escape the commas, we need to move this fix to that file.
83 ReplaceSubstringsAfterOffset(&handlers_spec, 0, "\\,", ",");
abarth-chromium 2015/01/09 22:59:19 What about \\, ?
84 #endif
85
73 std::vector<std::string> parts; 86 std::vector<std::string> parts;
74 base::SplitString(handlers_spec, ',', &parts); 87 base::SplitString(handlers_spec, ',', &parts);
75 if (parts.size() % 2 != 0) { 88 if (parts.size() % 2 != 0) {
76 LOG(ERROR) << "Invalid value for switch " << switches::kContentHandlers 89 LOG(ERROR) << "Invalid value for switch " << switches::kContentHandlers
77 << ": must be a comma-separated list of mimetype/url pairs."; 90 << ": must be a comma-separated list of mimetype/url pairs."
91 << handlers_spec;
78 return; 92 return;
79 } 93 }
80 94
81 for (size_t i = 0; i < parts.size(); i += 2) { 95 for (size_t i = 0; i < parts.size(); i += 2) {
82 GURL url(parts[i + 1]); 96 GURL url(parts[i + 1]);
83 if (!url.is_valid()) { 97 if (!url.is_valid()) {
84 LOG(ERROR) << "Invalid value for switch " << switches::kContentHandlers 98 LOG(ERROR) << "Invalid value for switch " << switches::kContentHandlers
85 << ": '" << parts[i + 1] << "' is not a valid URL."; 99 << ": '" << parts[i + 1] << "' is not a valid URL.";
86 return; 100 return;
87 } 101 }
102 // TODO(eseidel): We should also validate that the mimetype is valid
103 // net/base/mime_util.h could do this, but we don't want to depend on net.
88 loader->RegisterContentHandler(parts[i], url); 104 loader->RegisterContentHandler(parts[i], url);
89 } 105 }
90 } 106 }
91 107
92 class EmptyServiceProvider : public InterfaceImpl<ServiceProvider> { 108 class EmptyServiceProvider : public InterfaceImpl<ServiceProvider> {
93 private: 109 private:
94 void ConnectToService(const mojo::String& service_name, 110 void ConnectToService(const mojo::String& service_name,
95 ScopedMessagePipeHandle client_handle) override {} 111 ScopedMessagePipeHandle client_handle) override {}
96 }; 112 };
97 113
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 ScopedMessagePipeHandle Context::ConnectToServiceByName( 223 ScopedMessagePipeHandle Context::ConnectToServiceByName(
208 const GURL& application_url, 224 const GURL& application_url,
209 const std::string& service_name) { 225 const std::string& service_name) {
210 app_urls_.insert(application_url); 226 app_urls_.insert(application_url);
211 return application_manager_.ConnectToServiceByName(application_url, 227 return application_manager_.ConnectToServiceByName(application_url,
212 service_name).Pass(); 228 service_name).Pass();
213 } 229 }
214 230
215 } // namespace shell 231 } // namespace shell
216 } // namespace mojo 232 } // namespace mojo
OLDNEW
« no previous file with comments | « no previous file | sky/tools/debugger/prompt/prompt.cc » ('j') | sky/tools/debugger/prompt/prompt.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698