OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/debugger/debugger_host_impl.h" | 5 #include "chrome/browser/debugger/debugger_host_impl.h" |
6 | 6 |
7 #include "base/json_reader.h" | 7 #include "base/json_reader.h" |
8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
9 #include "chrome/browser/debugger/debugger_io.h" | 9 #include "chrome/browser/debugger/debugger_io.h" |
10 #include "chrome/browser/debugger/debugger_wrapper.h" | 10 #include "chrome/browser/debugger/debugger_wrapper.h" |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 void DebuggerHostImpl::Start() { | 76 void DebuggerHostImpl::Start() { |
77 io_->Start(this); | 77 io_->Start(this); |
78 } | 78 } |
79 | 79 |
80 void DebuggerHostImpl::Debug(TabContents* tab) { | 80 void DebuggerHostImpl::Debug(TabContents* tab) { |
81 tab_reference_.reset(new TabContentsReference(tab)); | 81 tab_reference_.reset(new TabContentsReference(tab)); |
82 } | 82 } |
83 | 83 |
84 void DebuggerHostImpl::DebugMessage(const std::wstring& msg) { | 84 void DebuggerHostImpl::DebugMessage(const std::wstring& msg) { |
85 | 85 |
86 Value* msg_value = NULL; | 86 Value* msg_value = JSONReader::Read(WideToUTF8(msg), false); |
87 if (!JSONReader::Read(WideToUTF8(msg), &msg_value, false)) { | 87 if (!msg_value) { |
88 msg_value = Value::CreateStringValue(L"Message parse error!"); | 88 msg_value = Value::CreateStringValue(L"Message parse error!"); |
89 } | 89 } |
90 ListValue* argv = new ListValue; | 90 ListValue* argv = new ListValue; |
91 argv->Append(msg_value); | 91 argv->Append(msg_value); |
92 io_->CallFunctionInPage(L"response", argv); | 92 io_->CallFunctionInPage(L"response", argv); |
93 } | 93 } |
94 | 94 |
95 void DebuggerHostImpl::OnDebugAttach() { | 95 void DebuggerHostImpl::OnDebugAttach() { |
96 std::wstring title; | 96 std::wstring title; |
97 const TabContents* t = GetTabContentsBeingDebugged(); | 97 const TabContents* t = GetTabContentsBeingDebugged(); |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 } | 179 } |
180 } | 180 } |
181 | 181 |
182 TabContents* DebuggerHostImpl::GetTabContentsBeingDebugged() const { | 182 TabContents* DebuggerHostImpl::GetTabContentsBeingDebugged() const { |
183 if (tab_reference_ != NULL) { | 183 if (tab_reference_ != NULL) { |
184 return tab_reference_->GetTabContents(); | 184 return tab_reference_->GetTabContents(); |
185 } else { | 185 } else { |
186 return NULL; | 186 return NULL; |
187 } | 187 } |
188 } | 188 } |
OLD | NEW |