Xiaohui Chen | a8bced8 | 2015-02-27 10:35:26 -0800 | [diff] [blame^] | 1 | // Copyright 2015 The Chromium OS Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include "debugd/src/session_manager_proxy.h" |
| 6 | |
| 7 | #include <base/logging.h> |
| 8 | |
| 9 | namespace debugd { |
| 10 | |
| 11 | void SessionManagerProxy::LoginPromptVisible() { |
| 12 | // Try to enable Chrome remote debugging again on Login prompt. |
| 13 | // Theoretically it should already be enabled during debugd Init(). But |
| 14 | // There might be a timing issue if debugd started too fast. We try again |
| 15 | // here if the first attempt in Init() failed. |
| 16 | EnableChromeRemoteDebuggingInternal(); |
| 17 | } |
| 18 | |
| 19 | void SessionManagerProxy::EnableChromeRemoteDebugging() { |
| 20 | VLOG(1) << "Enable Chrome remote debugging: " |
| 21 | << should_enable_chrome_remote_debugging_ |
| 22 | << " " |
| 23 | << is_chrome_remote_debugging_enabled_; |
| 24 | should_enable_chrome_remote_debugging_ = true; |
| 25 | EnableChromeRemoteDebuggingInternal(); |
| 26 | } |
| 27 | |
| 28 | void SessionManagerProxy::EnableChromeRemoteDebuggingInternal() { |
| 29 | VLOG(1) << "Enable Chrome remote debugging internal: " |
| 30 | << should_enable_chrome_remote_debugging_ |
| 31 | << " " |
| 32 | << is_chrome_remote_debugging_enabled_; |
| 33 | if (!should_enable_chrome_remote_debugging_ || |
| 34 | is_chrome_remote_debugging_enabled_) { |
| 35 | return; |
| 36 | } |
| 37 | try { |
| 38 | EnableChromeTesting(true, // force restart Chrome |
| 39 | {"--remote-debugging-port=9222"}); |
| 40 | is_chrome_remote_debugging_enabled_ = true; |
| 41 | } catch (DBus::Error &err) { |
| 42 | LOG(ERROR) << "Failed to enable Chrome remote debugging: " << err; |
| 43 | } |
| 44 | } |
| 45 | |
| 46 | } // namespace debugd |