Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(797)

Side by Side Diff: content/browser/accessibility/accessibility_ui.cc

Issue 16431010: Refactor RenderProcessHost to use IPC::Listener instead of RenderWidgetHost (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix cleanup crashes. Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 "content/browser/accessibility/accessibility_ui.h" 5 #include "content/browser/accessibility/accessibility_ui.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/json/json_writer.h" 9 #include "base/json/json_writer.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 favicon_url, 87 favicon_url,
88 rvh->GetProcess()->GetID(), 88 rvh->GetProcess()->GetID(),
89 rvh->GetRoutingID(), 89 rvh->GetRoutingID(),
90 accessibility_mode); 90 accessibility_mode);
91 } 91 }
92 92
93 void SendTargetsData( 93 void SendTargetsData(
94 const WebUIDataSource::GotDataCallback& callback) { 94 const WebUIDataSource::GotDataCallback& callback) {
95 scoped_ptr<ListValue> rvh_list(new ListValue()); 95 scoped_ptr<ListValue> rvh_list(new ListValue());
96 96
97 for (RenderProcessHost::iterator it(RenderProcessHost::AllHostsIterator()); 97 scoped_ptr<RenderWidgetHost::List> hosts =
98 !it.IsAtEnd(); it.Advance()) { 98 RenderWidgetHost::GetRenderWidgetHosts();
99 RenderProcessHost* render_process_host = it.GetCurrentValue(); 99 for (RenderWidgetHost::List::const_iterator it = hosts->begin();
100 DCHECK(render_process_host); 100 it != hosts->end();
101 101 ++it) {
102 const RenderWidgetHost* widget = *it;
102 // Ignore processes that don't have a connection, such as crashed tabs. 103 // Ignore processes that don't have a connection, such as crashed tabs.
103 if (!render_process_host->HasConnection()) 104 if (!widget->GetProcess()->HasConnection())
104 continue; 105 continue;
105 106
106 RenderProcessHost::RenderWidgetHostsIterator rwh_it( 107 if (!widget->IsRenderView())
107 render_process_host->GetRenderWidgetHostsIterator());
108 for (; !rwh_it.IsAtEnd(); rwh_it.Advance()) {
109 const RenderWidgetHost* rwh = rwh_it.GetCurrentValue();
110 DCHECK(rwh);
111 if (!rwh || !rwh->IsRenderView())
112 continue; 108 continue;
113 109
114 RenderViewHost* rvh = 110 RenderViewHost* rvh =
115 RenderViewHost::From(const_cast<RenderWidgetHost*>(rwh)); 111 RenderViewHost::From(const_cast<RenderWidgetHost*>(widget));
116 112
117 rvh_list->Append(BuildTargetDescriptor(rvh)); 113 rvh_list->Append(BuildTargetDescriptor(rvh));
118 }
119 } 114 }
120 115
121 scoped_ptr<DictionaryValue> data(new DictionaryValue()); 116 scoped_ptr<DictionaryValue> data(new DictionaryValue());
122 data->Set("list", rvh_list.release()); 117 data->Set("list", rvh_list.release());
123 scoped_ptr<FundamentalValue> a11y_mode(new FundamentalValue( 118 scoped_ptr<FundamentalValue> a11y_mode(new FundamentalValue(
124 BrowserAccessibilityStateImpl::GetInstance()->accessibility_mode())); 119 BrowserAccessibilityStateImpl::GetInstance()->accessibility_mode()));
125 data->Set("global_a11y_mode", a11y_mode.release()); 120 data->Set("global_a11y_mode", a11y_mode.release());
126 121
127 std::string json_string; 122 std::string json_string;
128 base::JSONWriter::Write(data.get(), &json_string); 123 base::JSONWriter::Write(data.get(), &json_string);
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 AccessibilityTreeFormatter::Filter::ALLOW)); 252 AccessibilityTreeFormatter::Filter::ALLOW));
258 formatter->SetFilters(filters); 253 formatter->SetFilters(filters);
259 formatter->FormatAccessibilityTree(&accessibility_contents_utf16); 254 formatter->FormatAccessibilityTree(&accessibility_contents_utf16);
260 255
261 result->Set("tree", 256 result->Set("tree",
262 new StringValue(UTF16ToUTF8(accessibility_contents_utf16))); 257 new StringValue(UTF16ToUTF8(accessibility_contents_utf16)));
263 web_ui()->CallJavascriptFunction("accessibility.showTree", *(result.get())); 258 web_ui()->CallJavascriptFunction("accessibility.showTree", *(result.get()));
264 } 259 }
265 260
266 } // namespace content 261 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698