| 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 "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
| 9 #include "base/json_writer.h" | 9 #include "base/json_writer.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 Profile* profile = BrowserList::GetLastActive()->profile(); | 94 Profile* profile = BrowserList::GetLastActive()->profile(); |
| 95 TabContents* tc = TabContents::CreateWithType(TAB_CONTENTS_DEBUGGER, | 95 TabContents* tc = TabContents::CreateWithType(TAB_CONTENTS_DEBUGGER, |
| 96 ::GetDesktopWindow(), profile, NULL); | 96 ::GetDesktopWindow(), profile, NULL); |
| 97 web_contents_ = tc->AsWebContents(); | 97 web_contents_ = tc->AsWebContents(); |
| 98 web_contents_->SetupController(profile); | 98 web_contents_->SetupController(profile); |
| 99 web_contents_->set_delegate(this); | 99 web_contents_->set_delegate(this); |
| 100 web_container_->SetTabContents(web_contents_); | 100 web_container_->SetTabContents(web_contents_); |
| 101 web_contents_->render_view_host()->AllowDOMUIBindings(); | 101 web_contents_->render_view_host()->AllowDOMUIBindings(); |
| 102 | 102 |
| 103 GURL contents("chrome-resource://debugger/"); | 103 GURL contents("chrome-resource://debugger/"); |
| 104 web_contents_->controller()->LoadURL(contents, PageTransition::START_PAGE); | 104 web_contents_->controller()->LoadURL(contents, GURL(), |
| 105 PageTransition::START_PAGE); |
| 105 } | 106 } |
| 106 | 107 |
| 107 void DebuggerView::OnShow() { | 108 void DebuggerView::OnShow() { |
| 108 web_contents_->Focus(); | 109 web_contents_->Focus(); |
| 109 if (output_ready_) | 110 if (output_ready_) |
| 110 ExecuteJavascript("focusOnCommandLine()"); | 111 ExecuteJavascript("focusOnCommandLine()"); |
| 111 } | 112 } |
| 112 | 113 |
| 113 void DebuggerView::OnClose() { | 114 void DebuggerView::OnClose() { |
| 114 web_container_->SetTabContents(NULL); | 115 web_container_->SetTabContents(NULL); |
| 115 web_contents_->CloseContents(); | 116 web_contents_->CloseContents(); |
| 116 } | 117 } |
| 117 | 118 |
| 118 void DebuggerView::SetDebuggerBreak(bool is_broken) { | 119 void DebuggerView::SetDebuggerBreak(bool is_broken) { |
| 119 const std::string js = | 120 const std::string js = |
| 120 StringPrintf("setDebuggerBreak(%s)", is_broken ? "true" : "false"); | 121 StringPrintf("setDebuggerBreak(%s)", is_broken ? "true" : "false"); |
| 121 ExecuteJavascript(js); | 122 ExecuteJavascript(js); |
| 122 } | 123 } |
| 123 | 124 |
| 124 void DebuggerView::OpenURLFromTab(TabContents* source, | 125 void DebuggerView::OpenURLFromTab(TabContents* source, |
| 125 const GURL& url, | 126 const GURL& url, |
| 127 const GURL& referrer, |
| 126 WindowOpenDisposition disposition, | 128 WindowOpenDisposition disposition, |
| 127 PageTransition::Type transition) { | 129 PageTransition::Type transition) { |
| 128 BrowserList::GetLastActive()->OpenURL(url, disposition, transition); | 130 BrowserList::GetLastActive()->OpenURL(url, referrer, disposition, |
| 131 transition); |
| 129 } | 132 } |
| 130 | 133 |
| 131 void DebuggerView::ExecuteJavascript(const std::string& js) { | 134 void DebuggerView::ExecuteJavascript(const std::string& js) { |
| 132 const std::string url = StringPrintf("javascript:void(%s)", js.c_str()); | 135 const std::string url = StringPrintf("javascript:void(%s)", js.c_str()); |
| 133 web_contents_->render_view_host()->ExecuteJavascriptInWebFrame(L"", | 136 web_contents_->render_view_host()->ExecuteJavascriptInWebFrame(L"", |
| 134 UTF8ToWide(url)); | 137 UTF8ToWide(url)); |
| 135 } | 138 } |
| 136 | 139 |
| 137 void DebuggerView::LoadingStateChanged(TabContents* source) { | 140 void DebuggerView::LoadingStateChanged(TabContents* source) { |
| 138 if (!source->is_loading()) | 141 if (!source->is_loading()) |
| 139 SetOutputViewReady(); | 142 SetOutputViewReady(); |
| 140 } | 143 } |
| 141 | 144 |
| OLD | NEW |