OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/renderer/render_view.h" | 5 #include "chrome/renderer/render_view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 776 matching lines...) Loading... |
787 IPC_MESSAGE_HANDLER(ViewMsg_ExecuteCode, | 787 IPC_MESSAGE_HANDLER(ViewMsg_ExecuteCode, |
788 OnExecuteCode) | 788 OnExecuteCode) |
789 IPC_MESSAGE_HANDLER(ViewMsg_CustomContextMenuAction, | 789 IPC_MESSAGE_HANDLER(ViewMsg_CustomContextMenuAction, |
790 OnCustomContextMenuAction) | 790 OnCustomContextMenuAction) |
791 IPC_MESSAGE_HANDLER(ViewMsg_TranslatePage, OnTranslatePage) | 791 IPC_MESSAGE_HANDLER(ViewMsg_TranslatePage, OnTranslatePage) |
792 IPC_MESSAGE_HANDLER(ViewMsg_RevertTranslation, OnRevertTranslation) | 792 IPC_MESSAGE_HANDLER(ViewMsg_RevertTranslation, OnRevertTranslation) |
793 IPC_MESSAGE_HANDLER(ViewMsg_GetAccessibilityTree, OnGetAccessibilityTree) | 793 IPC_MESSAGE_HANDLER(ViewMsg_GetAccessibilityTree, OnGetAccessibilityTree) |
794 IPC_MESSAGE_HANDLER(ViewMsg_SetAccessibilityFocus, OnSetAccessibilityFocus) | 794 IPC_MESSAGE_HANDLER(ViewMsg_SetAccessibilityFocus, OnSetAccessibilityFocus) |
795 IPC_MESSAGE_HANDLER(ViewMsg_AccessibilityDoDefaultAction, | 795 IPC_MESSAGE_HANDLER(ViewMsg_AccessibilityDoDefaultAction, |
796 OnAccessibilityDoDefaultAction) | 796 OnAccessibilityDoDefaultAction) |
| 797 IPC_MESSAGE_HANDLER(ViewMsg_AccessibilityObjectChildrenChange_ACK, |
| 798 OnAccessibilityObjectChildrenChangeAck) |
797 IPC_MESSAGE_HANDLER(ViewMsg_OpenFileSystemRequest_Complete, | 799 IPC_MESSAGE_HANDLER(ViewMsg_OpenFileSystemRequest_Complete, |
798 OnOpenFileSystemRequestComplete) | 800 OnOpenFileSystemRequestComplete) |
799 | 801 |
800 // Have the super handle all other messages. | 802 // Have the super handle all other messages. |
801 IPC_MESSAGE_UNHANDLED(RenderWidget::OnMessageReceived(message)) | 803 IPC_MESSAGE_UNHANDLED(RenderWidget::OnMessageReceived(message)) |
802 IPC_END_MESSAGE_MAP() | 804 IPC_END_MESSAGE_MAP() |
803 } | 805 } |
804 | 806 |
805 void RenderView::OnCaptureThumbnail() { | 807 void RenderView::OnCaptureThumbnail() { |
806 WebFrame* main_frame = webview()->mainFrame(); | 808 WebFrame* main_frame = webview()->mainFrame(); |
(...skipping 638 matching lines...) Loading... |
1445 std::max(last_page_id_sent_to_browser_, page_id_); | 1447 std::max(last_page_id_sent_to_browser_, page_id_); |
1446 | 1448 |
1447 // If we end up reusing this WebRequest (for example, due to a #ref click), | 1449 // If we end up reusing this WebRequest (for example, due to a #ref click), |
1448 // we don't want the transition type to persist. Just clear it. | 1450 // we don't want the transition type to persist. Just clear it. |
1449 navigation_state->set_transition_type(PageTransition::LINK); | 1451 navigation_state->set_transition_type(PageTransition::LINK); |
1450 | 1452 |
1451 if (accessibility_.get()) { | 1453 if (accessibility_.get()) { |
1452 accessibility_->clear(); | 1454 accessibility_->clear(); |
1453 accessibility_.reset(); | 1455 accessibility_.reset(); |
1454 } | 1456 } |
| 1457 accessibility_changes_.clear(); |
1455 } | 1458 } |
1456 | 1459 |
1457 // Tell the embedding application that the title of the active page has changed | 1460 // Tell the embedding application that the title of the active page has changed |
1458 void RenderView::UpdateTitle(WebFrame* frame, const string16& title) { | 1461 void RenderView::UpdateTitle(WebFrame* frame, const string16& title) { |
1459 // Ignore all but top level navigations... | 1462 // Ignore all but top level navigations... |
1460 if (!frame->parent()) { | 1463 if (!frame->parent()) { |
1461 Send(new ViewHostMsg_UpdateTitle( | 1464 Send(new ViewHostMsg_UpdateTitle( |
1462 routing_id_, | 1465 routing_id_, |
1463 page_id_, | 1466 page_id_, |
1464 UTF16ToWideHack(title.length() > chrome::kMaxTitleChars ? | 1467 UTF16ToWideHack(title.length() > chrome::kMaxTitleChars ? |
(...skipping 2794 matching lines...) Loading... |
4259 | 4262 |
4260 void RenderView::OnUpdateBrowserWindowId(int window_id) { | 4263 void RenderView::OnUpdateBrowserWindowId(int window_id) { |
4261 browser_window_id_ = window_id; | 4264 browser_window_id_ = window_id; |
4262 } | 4265 } |
4263 | 4266 |
4264 void RenderView::OnGetAccessibilityTree() { | 4267 void RenderView::OnGetAccessibilityTree() { |
4265 if (accessibility_.get()) | 4268 if (accessibility_.get()) |
4266 accessibility_->clear(); | 4269 accessibility_->clear(); |
4267 accessibility_.reset(WebAccessibilityCache::create()); | 4270 accessibility_.reset(WebAccessibilityCache::create()); |
4268 accessibility_->initialize(webview()); | 4271 accessibility_->initialize(webview()); |
| 4272 accessibility_changes_.clear(); |
4269 | 4273 |
4270 WebAccessibilityObject src_tree = webview()->accessibilityObject(); | 4274 WebAccessibilityObject src_tree = webview()->accessibilityObject(); |
4271 webkit_glue::WebAccessibility dst_tree(src_tree, accessibility_.get()); | 4275 webkit_glue::WebAccessibility dst_tree(src_tree, accessibility_.get()); |
4272 Send(new ViewHostMsg_AccessibilityTree(routing_id_, dst_tree)); | 4276 Send(new ViewHostMsg_AccessibilityTree(routing_id_, dst_tree)); |
4273 } | 4277 } |
4274 | 4278 |
4275 void RenderView::OnSetAccessibilityFocus(int acc_obj_id) { | 4279 void RenderView::OnSetAccessibilityFocus(int acc_obj_id) { |
4276 if (!accessibility_.get()) | 4280 if (!accessibility_.get()) |
4277 return; | 4281 return; |
4278 if (accessibility_->isValidId(acc_obj_id)) { | 4282 if (accessibility_->isValidId(acc_obj_id)) { |
4279 // TODO(dmazzoni) fix the cache so that id=1000 is not a magic number. | 4283 // TODO(dmazzoni) fix the cache so that id=1000 is not a magic number. |
4280 // By convention, calling SetFocus on the root of the tree (id = 1000) | 4284 // By convention, calling SetFocus on the root of the tree (id = 1000) |
4281 // should clear the current focus. Otherwise set the focus to the new | 4285 // should clear the current focus. Otherwise set the focus to the new |
4282 // node. | 4286 // node. |
4283 if (acc_obj_id == 1000) | 4287 if (acc_obj_id == 1000) |
4284 webview()->clearFocusedNode(); | 4288 webview()->clearFocusedNode(); |
4285 else | 4289 else |
4286 accessibility_->getObjectById(acc_obj_id).setFocused(true); | 4290 accessibility_->getObjectById(acc_obj_id).setFocused(true); |
4287 } | 4291 } |
4288 } | 4292 } |
4289 | 4293 |
4290 void RenderView::OnAccessibilityDoDefaultAction(int acc_obj_id) { | 4294 void RenderView::OnAccessibilityDoDefaultAction(int acc_obj_id) { |
4291 if (!accessibility_.get()) | 4295 if (!accessibility_.get()) |
4292 return; | 4296 return; |
4293 if (accessibility_->isValidId(acc_obj_id)) { | 4297 if (accessibility_->isValidId(acc_obj_id)) { |
4294 accessibility_->getObjectById(acc_obj_id).performDefaultAction(); | 4298 accessibility_->getObjectById(acc_obj_id).performDefaultAction(); |
4295 } | 4299 } |
4296 } | 4300 } |
4297 | 4301 |
| 4302 void RenderView::OnAccessibilityObjectChildrenChangeAck() { |
| 4303 if (!accessibility_.get()) |
| 4304 return; |
| 4305 |
| 4306 if (!accessibility_changes_.empty()) { |
| 4307 Send(new ViewHostMsg_AccessibilityObjectChildrenChange( |
| 4308 routing_id_, |
| 4309 accessibility_changes_)); |
| 4310 } |
| 4311 |
| 4312 accessibility_changes_.clear(); |
| 4313 } |
| 4314 |
4298 void RenderView::OnGetAllSavableResourceLinksForCurrentPage( | 4315 void RenderView::OnGetAllSavableResourceLinksForCurrentPage( |
4299 const GURL& page_url) { | 4316 const GURL& page_url) { |
4300 // Prepare list to storage all savable resource links. | 4317 // Prepare list to storage all savable resource links. |
4301 std::vector<GURL> resources_list; | 4318 std::vector<GURL> resources_list; |
4302 std::vector<GURL> referrers_list; | 4319 std::vector<GURL> referrers_list; |
4303 std::vector<GURL> frames_list; | 4320 std::vector<GURL> frames_list; |
4304 webkit_glue::SavableResourcesResult result(&resources_list, | 4321 webkit_glue::SavableResourcesResult result(&resources_list, |
4305 &referrers_list, | 4322 &referrers_list, |
4306 &frames_list); | 4323 &frames_list); |
4307 | 4324 |
(...skipping 938 matching lines...) Loading... |
5246 if (acc_obj_id >= 0) | 5263 if (acc_obj_id >= 0) |
5247 Send(new ViewHostMsg_AccessibilityObjectStateChange(routing_id_, | 5264 Send(new ViewHostMsg_AccessibilityObjectStateChange(routing_id_, |
5248 acc_obj_id)); | 5265 acc_obj_id)); |
5249 | 5266 |
5250 #else // defined(OS_WIN) | 5267 #else // defined(OS_WIN) |
5251 // TODO(port): accessibility not yet implemented | 5268 // TODO(port): accessibility not yet implemented |
5252 NOTIMPLEMENTED(); | 5269 NOTIMPLEMENTED(); |
5253 #endif | 5270 #endif |
5254 } | 5271 } |
5255 | 5272 |
| 5273 void RenderView::didChangeAccessibilityObjectChildren( |
| 5274 const WebKit::WebAccessibilityObject& acc_obj) { |
| 5275 if (!accessibility_.get()) |
| 5276 return; |
| 5277 |
| 5278 if (accessibility_changes_.empty()) { |
| 5279 Send(new ViewHostMsg_AccessibilityObjectChildrenChange( |
| 5280 routing_id_, |
| 5281 std::vector<webkit_glue::WebAccessibility>())); |
| 5282 } |
| 5283 |
| 5284 accessibility_changes_.push_back( |
| 5285 webkit_glue::WebAccessibility(acc_obj, accessibility_.get())); |
| 5286 } |
| 5287 |
5256 void RenderView::Print(WebFrame* frame, bool script_initiated) { | 5288 void RenderView::Print(WebFrame* frame, bool script_initiated) { |
5257 DCHECK(frame); | 5289 DCHECK(frame); |
5258 if (print_helper_.get() == NULL) { | 5290 if (print_helper_.get() == NULL) { |
5259 print_helper_.reset(new PrintWebViewHelper(this)); | 5291 print_helper_.reset(new PrintWebViewHelper(this)); |
5260 } | 5292 } |
5261 print_helper_->Print(frame, script_initiated); | 5293 print_helper_->Print(frame, script_initiated); |
5262 } | 5294 } |
5263 | 5295 |
5264 void RenderView::OnSetEditCommandsForNextKeyEvent( | 5296 void RenderView::OnSetEditCommandsForNextKeyEvent( |
5265 const EditCommands& edit_commands) { | 5297 const EditCommands& edit_commands) { |
(...skipping 273 matching lines...) Loading... |
5539 PendingOpenFileSystem* request = pending_file_system_requests_.Lookup( | 5571 PendingOpenFileSystem* request = pending_file_system_requests_.Lookup( |
5540 request_id); | 5572 request_id); |
5541 DCHECK(request); | 5573 DCHECK(request); |
5542 if (accepted) | 5574 if (accepted) |
5543 request->callbacks->didOpenFileSystem(name, root_path); | 5575 request->callbacks->didOpenFileSystem(name, root_path); |
5544 else | 5576 else |
5545 request->callbacks->didFail(WebKit::WebFileErrorSecurity); | 5577 request->callbacks->didFail(WebKit::WebFileErrorSecurity); |
5546 request->callbacks = NULL; | 5578 request->callbacks = NULL; |
5547 pending_file_system_requests_.Remove(request_id); | 5579 pending_file_system_requests_.Remove(request_id); |
5548 } | 5580 } |
OLD | NEW |