| 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/command_line.h" |
| 15 #include "base/compiler_specific.h" | 15 #include "base/compiler_specific.h" |
| 16 #include "base/files/file_path.h" | 16 #include "base/files/file_path.h" |
| 17 #include "base/logging.h" | 17 #include "base/logging.h" |
| 18 #include "base/strings/string_number_conversions.h" | 18 #include "base/strings/string_number_conversions.h" |
| 19 #include "base/strings/stringprintf.h" | 19 #include "base/strings/stringprintf.h" |
| 20 #include "base/strings/utf_string_conversions.h" | 20 #include "base/strings/utf_string_conversions.h" |
| 21 #include "chrome/browser/android/tab_android.h" | 21 #include "chrome/browser/android/tab_android.h" |
| 22 #include "chrome/browser/browser_process.h" | 22 #include "chrome/browser/browser_process.h" |
| 23 #include "chrome/browser/history/top_sites_factory.h" | 23 #include "chrome/browser/history/top_sites_factory.h" |
| 24 #include "chrome/browser/profiles/profile_manager.h" | 24 #include "chrome/browser/profiles/profile_manager.h" |
| 25 #include "chrome/browser/ui/android/tab_model/tab_model.h" | 25 #include "chrome/browser/ui/android/tab_model/tab_model.h" |
| 26 #include "chrome/browser/ui/android/tab_model/tab_model_list.h" | 26 #include "chrome/browser/ui/android/tab_model/tab_model_list.h" |
| 27 #include "chrome/common/chrome_content_client.h" | 27 #include "chrome/common/chrome_content_client.h" |
| 28 #include "chrome/common/chrome_version_info.h" | |
| 29 #include "components/devtools_http_handler/devtools_http_handler.h" | 28 #include "components/devtools_http_handler/devtools_http_handler.h" |
| 30 #include "components/devtools_http_handler/devtools_http_handler_delegate.h" | 29 #include "components/devtools_http_handler/devtools_http_handler_delegate.h" |
| 31 #include "components/history/core/browser/top_sites.h" | 30 #include "components/history/core/browser/top_sites.h" |
| 31 #include "components/version_info/version_info.h" |
| 32 #include "content/public/browser/android/devtools_auth.h" | 32 #include "content/public/browser/android/devtools_auth.h" |
| 33 #include "content/public/browser/browser_thread.h" | 33 #include "content/public/browser/browser_thread.h" |
| 34 #include "content/public/browser/devtools_agent_host.h" | 34 #include "content/public/browser/devtools_agent_host.h" |
| 35 #include "content/public/browser/favicon_status.h" | 35 #include "content/public/browser/favicon_status.h" |
| 36 #include "content/public/browser/navigation_entry.h" | 36 #include "content/public/browser/navigation_entry.h" |
| 37 #include "content/public/browser/render_view_host.h" | 37 #include "content/public/browser/render_view_host.h" |
| 38 #include "content/public/browser/web_contents.h" | 38 #include "content/public/browser/web_contents.h" |
| 39 #include "content/public/browser/web_contents_delegate.h" | 39 #include "content/public/browser/web_contents_delegate.h" |
| 40 #include "content/public/common/content_switches.h" | 40 #include "content/public/common/content_switches.h" |
| 41 #include "content/public/common/url_constants.h" | 41 #include "content/public/common/url_constants.h" |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 } | 198 } |
| 199 | 199 |
| 200 void DevToolsServer::Start(bool allow_debug_permission) { | 200 void DevToolsServer::Start(bool allow_debug_permission) { |
| 201 if (devtools_http_handler_) | 201 if (devtools_http_handler_) |
| 202 return; | 202 return; |
| 203 | 203 |
| 204 net::UnixDomainServerSocket::AuthCallback auth_callback = | 204 net::UnixDomainServerSocket::AuthCallback auth_callback = |
| 205 allow_debug_permission ? | 205 allow_debug_permission ? |
| 206 base::Bind(&AuthorizeSocketAccessWithDebugPermission) : | 206 base::Bind(&AuthorizeSocketAccessWithDebugPermission) : |
| 207 base::Bind(&content::CanUserConnectToDevTools); | 207 base::Bind(&content::CanUserConnectToDevTools); |
| 208 chrome::VersionInfo version_info; | |
| 209 | |
| 210 scoped_ptr<DevToolsHttpHandler::ServerSocketFactory> factory( | 208 scoped_ptr<DevToolsHttpHandler::ServerSocketFactory> factory( |
| 211 new UnixDomainServerSocketFactory(socket_name_, auth_callback)); | 209 new UnixDomainServerSocketFactory(socket_name_, auth_callback)); |
| 212 devtools_http_handler_.reset(new DevToolsHttpHandler( | 210 devtools_http_handler_.reset(new DevToolsHttpHandler( |
| 213 factory.Pass(), | 211 factory.Pass(), |
| 214 base::StringPrintf(kFrontEndURL, content::GetWebKitRevision().c_str()), | 212 base::StringPrintf(kFrontEndURL, content::GetWebKitRevision().c_str()), |
| 215 new DevToolsServerDelegate(), | 213 new DevToolsServerDelegate(), |
| 216 base::FilePath(), | 214 base::FilePath(), |
| 217 base::FilePath(), | 215 base::FilePath(), |
| 218 version_info.ProductNameAndVersionForUserAgent(), | 216 version_info::GetProductNameAndVersionForUserAgent(), |
| 219 ::GetUserAgent())); | 217 ::GetUserAgent())); |
| 220 } | 218 } |
| 221 | 219 |
| 222 void DevToolsServer::Stop() { | 220 void DevToolsServer::Stop() { |
| 223 devtools_http_handler_.reset(); | 221 devtools_http_handler_.reset(); |
| 224 } | 222 } |
| 225 | 223 |
| 226 bool DevToolsServer::IsStarted() const { | 224 bool DevToolsServer::IsStarted() const { |
| 227 return devtools_http_handler_; | 225 return devtools_http_handler_; |
| 228 } | 226 } |
| (...skipping 25 matching lines...) Expand all Loading... |
| 254 jlong server, | 252 jlong server, |
| 255 jboolean enabled, | 253 jboolean enabled, |
| 256 jboolean allow_debug_permission) { | 254 jboolean allow_debug_permission) { |
| 257 DevToolsServer* devtools_server = reinterpret_cast<DevToolsServer*>(server); | 255 DevToolsServer* devtools_server = reinterpret_cast<DevToolsServer*>(server); |
| 258 if (enabled) { | 256 if (enabled) { |
| 259 devtools_server->Start(allow_debug_permission); | 257 devtools_server->Start(allow_debug_permission); |
| 260 } else { | 258 } else { |
| 261 devtools_server->Stop(); | 259 devtools_server->Stop(); |
| 262 } | 260 } |
| 263 } | 261 } |
| OLD | NEW |