| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/android/dev_tools_server.h" | 5 #include "chrome/browser/android/dev_tools_server.h" |
| 6 | 6 |
| 7 #include <pwd.h> | 7 #include <pwd.h> |
| 8 #include <cstring> | 8 #include <cstring> |
| 9 | 9 |
| 10 #include "base/android/jni_string.h" | 10 #include "base/android/jni_string.h" |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/bind.h" | 12 #include "base/bind.h" |
| 13 #include "base/callback.h" | 13 #include "base/callback.h" |
| 14 #include "base/command_line.h" |
| 14 #include "base/compiler_specific.h" | 15 #include "base/compiler_specific.h" |
| 15 #include "base/logging.h" | 16 #include "base/logging.h" |
| 16 #include "base/stringprintf.h" | 17 #include "base/stringprintf.h" |
| 17 #include "chrome/browser/history/top_sites.h" | 18 #include "chrome/browser/history/top_sites.h" |
| 18 #include "chrome/browser/profiles/profile_manager.h" | 19 #include "chrome/browser/profiles/profile_manager.h" |
| 19 #include "chrome/common/chrome_version_info.h" | 20 #include "chrome/common/chrome_version_info.h" |
| 20 #include "content/public/browser/android/devtools_auth.h" | 21 #include "content/public/browser/android/devtools_auth.h" |
| 21 #include "content/public/browser/browser_thread.h" | 22 #include "content/public/browser/browser_thread.h" |
| 22 #include "content/public/browser/devtools_http_handler.h" | 23 #include "content/public/browser/devtools_http_handler.h" |
| 23 #include "content/public/browser/devtools_http_handler_delegate.h" | 24 #include "content/public/browser/devtools_http_handler_delegate.h" |
| 25 #include "content/public/common/content_switches.h" |
| 24 #include "grit/devtools_discovery_page_resources.h" | 26 #include "grit/devtools_discovery_page_resources.h" |
| 25 #include "jni/DevToolsServer_jni.h" | 27 #include "jni/DevToolsServer_jni.h" |
| 26 #include "net/socket/unix_domain_socket_posix.h" | 28 #include "net/socket/unix_domain_socket_posix.h" |
| 27 #include "net/url_request/url_request_context_getter.h" | 29 #include "net/url_request/url_request_context_getter.h" |
| 28 #include "ui/base/resource/resource_bundle.h" | 30 #include "ui/base/resource/resource_bundle.h" |
| 29 | 31 |
| 30 namespace { | 32 namespace { |
| 31 | 33 |
| 32 const char kFrontEndURL[] = | 34 const char kFrontEndURL[] = |
| 33 "http://chrome-devtools-frontend.appspot.com/static/%s/devtools.html"; | 35 "http://chrome-devtools-frontend.appspot.com/static/%s/devtools.html"; |
| 34 const char kSocketName[] = "chrome_devtools_remote"; | 36 const char kDefaultSocketName[] = "chrome_devtools_remote"; |
| 35 const char kTetheringSocketName[] = "chrome_devtools_tethering_%d"; | 37 const char kTetheringSocketName[] = "chrome_devtools_tethering_%d"; |
| 36 | 38 |
| 37 // Delegate implementation for the devtools http handler on android. A new | 39 // Delegate implementation for the devtools http handler on android. A new |
| 38 // instance of this gets created each time devtools is enabled. | 40 // instance of this gets created each time devtools is enabled. |
| 39 class DevToolsServerDelegate : public content::DevToolsHttpHandlerDelegate { | 41 class DevToolsServerDelegate : public content::DevToolsHttpHandlerDelegate { |
| 40 public: | 42 public: |
| 41 explicit DevToolsServerDelegate(bool use_bundled_frontend_resources) | 43 explicit DevToolsServerDelegate(bool use_bundled_frontend_resources) |
| 42 : use_bundled_frontend_resources_(use_bundled_frontend_resources), | 44 : use_bundled_frontend_resources_(use_bundled_frontend_resources), |
| 43 last_tethering_socket_(0) { | 45 last_tethering_socket_(0) { |
| 44 } | 46 } |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 bool use_bundled_frontend_resources_; | 111 bool use_bundled_frontend_resources_; |
| 110 int last_tethering_socket_; | 112 int last_tethering_socket_; |
| 111 | 113 |
| 112 DISALLOW_COPY_AND_ASSIGN(DevToolsServerDelegate); | 114 DISALLOW_COPY_AND_ASSIGN(DevToolsServerDelegate); |
| 113 }; | 115 }; |
| 114 | 116 |
| 115 } // namespace | 117 } // namespace |
| 116 | 118 |
| 117 DevToolsServer::DevToolsServer() | 119 DevToolsServer::DevToolsServer() |
| 118 : use_bundled_frontend_resources_(false), | 120 : use_bundled_frontend_resources_(false), |
| 119 socket_name_(kSocketName), | 121 socket_name_(kDefaultSocketName), |
| 120 protocol_handler_(NULL) { | 122 protocol_handler_(NULL) { |
| 123 // Override the default socket name if one is specified on the command line. |
| 124 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 125 if (command_line.HasSwitch(switches::kRemoteDebuggingSocketName)) { |
| 126 socket_name_ = command_line.GetSwitchValueASCII( |
| 127 switches::kRemoteDebuggingSocketName); |
| 128 } |
| 121 } | 129 } |
| 122 | 130 |
| 123 DevToolsServer::DevToolsServer(bool use_bundled_frontend_resources, | 131 DevToolsServer::DevToolsServer(bool use_bundled_frontend_resources, |
| 124 const std::string& socket_name) | 132 const std::string& socket_name) |
| 125 : use_bundled_frontend_resources_(use_bundled_frontend_resources), | 133 : use_bundled_frontend_resources_(use_bundled_frontend_resources), |
| 126 socket_name_(socket_name), | 134 socket_name_(socket_name), |
| 127 protocol_handler_(NULL) { | 135 protocol_handler_(NULL) { |
| 128 } | 136 } |
| 129 | 137 |
| 130 DevToolsServer::~DevToolsServer() { | 138 DevToolsServer::~DevToolsServer() { |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 jobject obj, | 196 jobject obj, |
| 189 jint server, | 197 jint server, |
| 190 jboolean enabled) { | 198 jboolean enabled) { |
| 191 DevToolsServer* devtools_server = reinterpret_cast<DevToolsServer*>(server); | 199 DevToolsServer* devtools_server = reinterpret_cast<DevToolsServer*>(server); |
| 192 if (enabled) { | 200 if (enabled) { |
| 193 devtools_server->Start(); | 201 devtools_server->Start(); |
| 194 } else { | 202 } else { |
| 195 devtools_server->Stop(); | 203 devtools_server->Stop(); |
| 196 } | 204 } |
| 197 } | 205 } |
| OLD | NEW |