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

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

Issue 924843002: Fix for possible crashes due to pointer value being null (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressing review comments Created 5 years, 10 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
« no previous file with comments | « no previous file | content/renderer/render_frame_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 target_data->SetInteger(kPidField, base::GetProcId(handle)); 59 target_data->SetInteger(kPidField, base::GetProcId(handle));
60 target_data->SetString(kFaviconUrlField, favicon_url.spec()); 60 target_data->SetString(kFaviconUrlField, favicon_url.spec());
61 target_data->SetInteger(kAccessibilityModeField, 61 target_data->SetInteger(kAccessibilityModeField,
62 accessibility_mode); 62 accessibility_mode);
63 return target_data; 63 return target_data;
64 } 64 }
65 65
66 base::DictionaryValue* BuildTargetDescriptor(RenderViewHost* rvh) { 66 base::DictionaryValue* BuildTargetDescriptor(RenderViewHost* rvh) {
67 WebContentsImpl* web_contents = static_cast<WebContentsImpl*>( 67 WebContentsImpl* web_contents = static_cast<WebContentsImpl*>(
68 WebContents::FromRenderViewHost(rvh)); 68 WebContents::FromRenderViewHost(rvh));
69 AccessibilityMode accessibility_mode = web_contents->GetAccessibilityMode(); 69 AccessibilityMode accessibility_mode = AccessibilityModeOff;
70 70
71 std::string title; 71 std::string title;
72 GURL url; 72 GURL url;
73 GURL favicon_url; 73 GURL favicon_url;
74 if (web_contents) { 74 if (web_contents) {
75 // TODO(nasko): Fix the following code to use a consistent set of data 75 // TODO(nasko): Fix the following code to use a consistent set of data
76 // across the URL, title, and favicon. 76 // across the URL, title, and favicon.
77 url = web_contents->GetURL(); 77 url = web_contents->GetURL();
78 title = base::UTF16ToUTF8(web_contents->GetTitle()); 78 title = base::UTF16ToUTF8(web_contents->GetTitle());
79 NavigationController& controller = web_contents->GetController(); 79 NavigationController& controller = web_contents->GetController();
80 NavigationEntry* entry = controller.GetVisibleEntry(); 80 NavigationEntry* entry = controller.GetVisibleEntry();
81 if (entry != NULL && entry->GetURL().is_valid()) 81 if (entry != NULL && entry->GetURL().is_valid())
82 favicon_url = entry->GetFavicon().url; 82 favicon_url = entry->GetFavicon().url;
83 accessibility_mode = web_contents->GetAccessibilityMode();
83 } 84 }
84 85
85 return BuildTargetDescriptor(url, 86 return BuildTargetDescriptor(url,
86 title, 87 title,
87 favicon_url, 88 favicon_url,
88 rvh->GetProcess()->GetID(), 89 rvh->GetProcess()->GetID(),
89 rvh->GetRoutingID(), 90 rvh->GetRoutingID(),
90 accessibility_mode); 91 accessibility_mode);
91 } 92 }
92 93
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 formatter->SetFilters(filters); 233 formatter->SetFilters(filters);
233 formatter->FormatAccessibilityTree(&accessibility_contents_utf16); 234 formatter->FormatAccessibilityTree(&accessibility_contents_utf16);
234 235
235 result->Set("tree", 236 result->Set("tree",
236 new base::StringValue( 237 new base::StringValue(
237 base::UTF16ToUTF8(accessibility_contents_utf16))); 238 base::UTF16ToUTF8(accessibility_contents_utf16)));
238 web_ui()->CallJavascriptFunction("accessibility.showTree", *(result.get())); 239 web_ui()->CallJavascriptFunction("accessibility.showTree", *(result.get()));
239 } 240 }
240 241
241 } // namespace content 242 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/renderer/render_frame_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698