blob: aae04e6c86270932834de9e201bb8daeec25130e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
|
// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/debugger/debugger_window.h"
#include "base/string_util.h"
#include "base/values.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/debugger/debugger_host_impl.h"
#include "chrome/browser/debugger/debugger_view.h"
#include "chrome/browser/debugger/debugger_wrapper.h"
#include "chrome/browser/tab_contents/constrained_window.h"
#include "chrome/browser/tab_contents/tab_contents.h"
#include "chrome/common/l10n_util.h"
#include "grit/generated_resources.h"
DebuggerWindow::DebuggerWindow() : window_(NULL),
view_(NULL),
debugger_ready_(true),
debugger_break_(false) {
}
DebuggerWindow::~DebuggerWindow() {
}
bool DebuggerWindow::DoesDebuggerExist() {
DebuggerWrapper* wrapper = g_browser_process->debugger_wrapper();
if (!wrapper)
return false;
return wrapper->GetDebugger() != NULL;
}
void DebuggerWindow::Show(TabContents* tab) {
#ifndef CHROME_DEBUGGER_DISABLED
if (window_) {
window_->Show();
view_->OnShow();
return;
}
view_ = new DebuggerView();
window_ = views::Window::CreateChromeWindow(NULL, gfx::Rect(), this);
window_->Show();
view_->OnShow();
debugger_ready_ = true;
debugger_break_ = false;
DebuggerHostImpl* debugger = new DebuggerHostImpl(this);
DebuggerWrapper* wrapper = g_browser_process->debugger_wrapper();
if (!wrapper) {
g_browser_process->InitDebuggerWrapper(0);
wrapper = g_browser_process->debugger_wrapper();
}
wrapper->SetDebugger(debugger);
debugger->Start();
// TODO(erikkay): this method name should really change, or maybe even
// go away / merge into start. It's a legacy from the telnet code.
debugger->DidConnect();
debugger->Debug(tab);
#endif
}
///////////////////////////////////////////////////////////////////
// DebuggerInputOutput overrides
void DebuggerWindow::Output(const std::wstring &out) {
#ifndef CHROME_DEBUGGER_DISABLED
if (view_)
view_->Output(out);
#endif
}
void DebuggerWindow::OutputLine(const std::wstring &out) {
#ifndef CHROME_DEBUGGER_DISABLED
if (view_)
view_->Output(out);
#endif
}
void DebuggerWindow::OutputPrompt(const std::wstring& prompt) {
}
void DebuggerWindow::Output(const std::string &out) {
#ifndef CHROME_DEBUGGER_DISABLED
if (view_)
view_->Output(out);
#endif
}
void DebuggerWindow::OutputLine(const std::string &out) {
#ifndef CHROME_DEBUGGER_DISABLED
if (view_)
view_->Output(out);
#endif
}
void DebuggerWindow::OutputPrompt(const std::string& prompt) {
}
void DebuggerWindow::Start(DebuggerHost* debugger) {
#ifndef CHROME_DEBUGGER_DISABLED
DebuggerInputOutput::Start(debugger);
#endif
}
void DebuggerWindow::SetDebuggerReady(bool ready) {
#ifndef CHROME_DEBUGGER_DISABLED
if (debugger_ready_ != ready) {
debugger_ready_ = ready;
if (window_)
window_->UpdateWindowTitle();
}
#endif
}
void DebuggerWindow::SetDebuggerBreak(bool brk) {
#ifndef CHROME_DEBUGGER_DISABLED
if (debugger_break_ != brk) {
debugger_break_ = brk;
if (window_) {
window_->UpdateWindowTitle();
if (brk)
window_->Activate();
}
}
#endif
}
void DebuggerWindow::CallFunctionInPage(const std::wstring& name,
ListValue* argv) {
if (view_) {
DictionaryValue* body = new DictionaryValue;
body->Set(L"arguments", argv);
view_->SendEventToPage(name, body);
} else {
delete argv;
}
}
///////////////////////////////////////////////////////////////////
// views::WindowDelegate methods
std::wstring DebuggerWindow::GetWindowTitle() const {
if (!debugger_ready_) {
return l10n_util::GetString(IDS_DEBUGGER_TITLE_BUSY);
} else if (debugger_break_) {
return l10n_util::GetString(IDS_DEBUGGER_TITLE_BREAK);
} else {
return l10n_util::GetString(IDS_DEBUGGER_TITLE_RUNNING);
}
}
void DebuggerWindow::WindowClosing() {
#ifndef CHROME_DEBUGGER_DISABLED
view_->OnClose();
#endif
window_ = NULL;
view_ = NULL;
#ifndef CHROME_DEBUGGER_DISABLED
debugger_->DidDisconnect();
#endif
debugger_ = NULL;
DebuggerWrapper* wrapper = g_browser_process->debugger_wrapper();
wrapper->SetDebugger(NULL);
}
bool DebuggerWindow::CanResize() const {
return true;
}
views::View* DebuggerWindow::GetContentsView() {
return view_;
}
|