| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/ui/webui/hung_renderer_dialog.h" | 5 #include "chrome/browser/ui/webui/hung_renderer_dialog.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" |
| 11 #include "base/bind_helpers.h" |
| 10 #include "base/json/json_reader.h" | 12 #include "base/json/json_reader.h" |
| 11 #include "base/utf_string_conversions.h" | 13 #include "base/utf_string_conversions.h" |
| 12 #include "base/values.h" | 14 #include "base/values.h" |
| 13 #include "chrome/browser/ui/browser.h" | 15 #include "chrome/browser/ui/browser.h" |
| 14 #include "chrome/browser/ui/browser_list.h" | 16 #include "chrome/browser/ui/browser_list.h" |
| 15 #include "chrome/browser/ui/browser_dialogs.h" | 17 #include "chrome/browser/ui/browser_dialogs.h" |
| 16 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 18 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 17 #include "chrome/browser/ui/webui/html_dialog_ui.h" | 19 #include "chrome/browser/ui/webui/html_dialog_ui.h" |
| 18 #include "chrome/common/logging_chrome.h" | 20 #include "chrome/common/logging_chrome.h" |
| 19 #include "chrome/common/url_constants.h" | 21 #include "chrome/common/url_constants.h" |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 : contents_(contents) { | 170 : contents_(contents) { |
| 169 } | 171 } |
| 170 | 172 |
| 171 void HungRendererDialogHandler::CloseDialog() { | 173 void HungRendererDialogHandler::CloseDialog() { |
| 172 DCHECK(web_ui_); | 174 DCHECK(web_ui_); |
| 173 static_cast<HtmlDialogUI*>(web_ui_)->CloseDialog(NULL); | 175 static_cast<HtmlDialogUI*>(web_ui_)->CloseDialog(NULL); |
| 174 } | 176 } |
| 175 | 177 |
| 176 void HungRendererDialogHandler::RegisterMessages() { | 178 void HungRendererDialogHandler::RegisterMessages() { |
| 177 web_ui_->RegisterMessageCallback("requestTabContentsList", | 179 web_ui_->RegisterMessageCallback("requestTabContentsList", |
| 178 NewCallback(this, | 180 base::Bind(&HungRendererDialogHandler::RequestTabContentsList, |
| 179 &HungRendererDialogHandler::RequestTabContentsList)); | 181 base::Unretained(this))); |
| 180 } | 182 } |
| 181 | 183 |
| 182 void HungRendererDialogHandler::RequestTabContentsList( | 184 void HungRendererDialogHandler::RequestTabContentsList( |
| 183 const base::ListValue* args) { | 185 const base::ListValue* args) { |
| 184 ListValue tab_contents_list; | 186 ListValue tab_contents_list; |
| 185 for (TabContentsIterator it; !it.done(); ++it) { | 187 for (TabContentsIterator it; !it.done(); ++it) { |
| 186 if (it->tab_contents()->GetRenderProcessHost() == | 188 if (it->tab_contents()->GetRenderProcessHost() == |
| 187 contents_->GetRenderProcessHost()) { | 189 contents_->GetRenderProcessHost()) { |
| 188 string16 title = it->tab_contents()->GetTitle(); | 190 string16 title = it->tab_contents()->GetTitle(); |
| 189 if (title.empty()) | 191 if (title.empty()) |
| 190 title = TabContentsWrapper::GetDefaultTitle(); | 192 title = TabContentsWrapper::GetDefaultTitle(); |
| 191 // Add details for |url| and |title|. | 193 // Add details for |url| and |title|. |
| 192 DictionaryValue* dict = new DictionaryValue(); | 194 DictionaryValue* dict = new DictionaryValue(); |
| 193 dict->SetString("url", it->tab_contents()->GetURL().spec()); | 195 dict->SetString("url", it->tab_contents()->GetURL().spec()); |
| 194 dict->SetString("title", title); | 196 dict->SetString("title", title); |
| 195 tab_contents_list.Append(dict); | 197 tab_contents_list.Append(dict); |
| 196 } | 198 } |
| 197 } | 199 } |
| 198 // Send list of tab contents details to javascript. | 200 // Send list of tab contents details to javascript. |
| 199 web_ui_->CallJavascriptFunction("hungRendererDialog.setTabContentsList", | 201 web_ui_->CallJavascriptFunction("hungRendererDialog.setTabContentsList", |
| 200 tab_contents_list); | 202 tab_contents_list); |
| 201 } | 203 } |
| OLD | NEW |