| 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_window.h" | 5 #include "chrome/browser/debugger/debugger_window.h" |
| 6 | 6 |
| 7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
| 9 #include "base/values.h" | 9 #include "base/values.h" |
| 10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
| 11 #include "chrome/browser/debugger/debugger_host_impl.h" | 11 #include "chrome/browser/debugger/debugger_host_impl.h" |
| 12 #include "chrome/browser/debugger/debugger_view.h" | 12 #include "chrome/browser/debugger/debugger_view.h" |
| 13 #include "chrome/browser/debugger/debugger_wrapper.h" | 13 #include "chrome/browser/debugger/debugger_wrapper.h" |
| 14 #include "chrome/browser/tab_contents/constrained_window.h" | 14 #include "chrome/browser/tab_contents/constrained_window.h" |
| 15 #include "chrome/browser/tab_contents/tab_contents.h" | 15 #include "chrome/browser/tab_contents/tab_contents.h" |
| 16 #include "grit/generated_resources.h" | 16 #include "grit/generated_resources.h" |
| 17 | 17 |
| 18 DebuggerWindow::DebuggerWindow() : window_(NULL), | 18 DebuggerWindow::DebuggerWindow() : window_(NULL), |
| 19 view_(NULL), | 19 view_(NULL), |
| 20 debugger_ready_(true), | 20 debugger_ready_(true), |
| 21 debugger_break_(false) { | 21 debugger_break_(false) { |
| 22 } | 22 } |
| 23 | 23 |
| 24 DebuggerWindow::~DebuggerWindow() { | 24 DebuggerWindow::~DebuggerWindow() { |
| 25 } | 25 } |
| 26 | 26 |
| 27 bool DebuggerWindow::DoesDebuggerExist() { | 27 DebuggerHost* DebuggerWindow::GetAnyExistingDebugger() { |
| 28 DebuggerWrapper* wrapper = g_browser_process->debugger_wrapper(); | 28 DebuggerWrapper* wrapper = g_browser_process->debugger_wrapper(); |
| 29 if (!wrapper) | 29 if (!wrapper) |
| 30 return false; | 30 return NULL; |
| 31 return wrapper->GetDebugger() != NULL; | 31 return wrapper->GetDebugger(); |
| 32 } | 32 } |
| 33 | 33 |
| 34 void DebuggerWindow::Show(TabContents* tab) { | 34 void DebuggerWindow::Show(TabContents* tab) { |
| 35 #ifndef CHROME_DEBUGGER_DISABLED | 35 #ifndef CHROME_DEBUGGER_DISABLED |
| 36 if (window_) { | 36 if (ShowWindow()) |
| 37 window_->Show(); | |
| 38 view_->OnShow(); | |
| 39 return; | 37 return; |
| 40 } | |
| 41 view_ = new DebuggerView(this); | 38 view_ = new DebuggerView(this); |
| 42 window_ = views::Window::CreateChromeWindow(NULL, gfx::Rect(), this); | 39 window_ = views::Window::CreateChromeWindow(NULL, gfx::Rect(), this); |
| 43 window_->Show(); | 40 window_->Show(); |
| 44 view_->OnShow(); | 41 view_->OnShow(); |
| 45 debugger_ready_ = true; | 42 debugger_ready_ = true; |
| 46 debugger_break_ = false; | 43 debugger_break_ = false; |
| 47 DebuggerHostImpl* debugger = new DebuggerHostImpl(this); | 44 DebuggerHostImpl* debugger = new DebuggerHostImpl(this); |
| 48 DebuggerWrapper* wrapper = g_browser_process->debugger_wrapper(); | 45 DebuggerWrapper* wrapper = g_browser_process->debugger_wrapper(); |
| 49 if (!wrapper) { | 46 if (!wrapper) { |
| 50 g_browser_process->InitDebuggerWrapper(0); | 47 g_browser_process->InitDebuggerWrapper(0); |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 ListValue* argv) { | 127 ListValue* argv) { |
| 131 if (view_) { | 128 if (view_) { |
| 132 DictionaryValue* body = new DictionaryValue; | 129 DictionaryValue* body = new DictionaryValue; |
| 133 body->Set(L"arguments", argv); | 130 body->Set(L"arguments", argv); |
| 134 view_->SendEventToPage(name, body); | 131 view_->SendEventToPage(name, body); |
| 135 } else { | 132 } else { |
| 136 delete argv; | 133 delete argv; |
| 137 } | 134 } |
| 138 } | 135 } |
| 139 | 136 |
| 137 bool DebuggerWindow::ShowWindow() { |
| 138 #ifndef CHROME_DEBUGGER_DISABLED |
| 139 if (window_) { |
| 140 window_->Show(); |
| 141 view_->OnShow(); |
| 142 return true; |
| 143 } |
| 144 #endif |
| 145 return false; |
| 146 } |
| 147 |
| 140 /////////////////////////////////////////////////////////////////// | 148 /////////////////////////////////////////////////////////////////// |
| 141 // views::WindowDelegate methods | 149 // views::WindowDelegate methods |
| 142 | 150 |
| 143 std::wstring DebuggerWindow::GetWindowTitle() const { | 151 std::wstring DebuggerWindow::GetWindowTitle() const { |
| 144 if (!debugger_ready_) { | 152 if (!debugger_ready_) { |
| 145 return l10n_util::GetString(IDS_DEBUGGER_TITLE_BUSY); | 153 return l10n_util::GetString(IDS_DEBUGGER_TITLE_BUSY); |
| 146 } else if (debugger_break_) { | 154 } else if (debugger_break_) { |
| 147 return l10n_util::GetString(IDS_DEBUGGER_TITLE_BREAK); | 155 return l10n_util::GetString(IDS_DEBUGGER_TITLE_BREAK); |
| 148 } else { | 156 } else { |
| 149 return l10n_util::GetString(IDS_DEBUGGER_TITLE_RUNNING); | 157 return l10n_util::GetString(IDS_DEBUGGER_TITLE_RUNNING); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 164 wrapper->SetDebugger(NULL); | 172 wrapper->SetDebugger(NULL); |
| 165 } | 173 } |
| 166 | 174 |
| 167 bool DebuggerWindow::CanResize() const { | 175 bool DebuggerWindow::CanResize() const { |
| 168 return true; | 176 return true; |
| 169 } | 177 } |
| 170 | 178 |
| 171 views::View* DebuggerWindow::GetContentsView() { | 179 views::View* DebuggerWindow::GetContentsView() { |
| 172 return view_; | 180 return view_; |
| 173 } | 181 } |
| OLD | NEW |