Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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/frame_host/render_frame_host_impl.h" | 5 #include "content/browser/frame_host/render_frame_host_impl.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/containers/hash_tables.h" | 9 #include "base/containers/hash_tables.h" |
| 10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 57 #include "content/public/browser/permission_type.h" | 57 #include "content/public/browser/permission_type.h" |
| 58 #include "content/public/browser/render_process_host.h" | 58 #include "content/public/browser/render_process_host.h" |
| 59 #include "content/public/browser/render_widget_host_view.h" | 59 #include "content/public/browser/render_widget_host_view.h" |
| 60 #include "content/public/browser/stream_handle.h" | 60 #include "content/public/browser/stream_handle.h" |
| 61 #include "content/public/browser/user_metrics.h" | 61 #include "content/public/browser/user_metrics.h" |
| 62 #include "content/public/common/content_constants.h" | 62 #include "content/public/common/content_constants.h" |
| 63 #include "content/public/common/content_switches.h" | 63 #include "content/public/common/content_switches.h" |
| 64 #include "content/public/common/url_constants.h" | 64 #include "content/public/common/url_constants.h" |
| 65 #include "content/public/common/url_utils.h" | 65 #include "content/public/common/url_utils.h" |
| 66 #include "ui/accessibility/ax_tree.h" | 66 #include "ui/accessibility/ax_tree.h" |
| 67 #include "ui/accessibility/ax_tree_update.h" | |
| 67 #include "url/gurl.h" | 68 #include "url/gurl.h" |
| 68 | 69 |
| 69 #if defined(OS_MACOSX) | 70 #if defined(OS_MACOSX) |
| 70 #include "content/browser/frame_host/popup_menu_helper_mac.h" | 71 #include "content/browser/frame_host/popup_menu_helper_mac.h" |
| 71 #endif | 72 #endif |
| 72 | 73 |
| 73 #if defined(ENABLE_MEDIA_MOJO_RENDERER) | 74 #if defined(ENABLE_MEDIA_MOJO_RENDERER) |
| 74 #include "media/mojo/interfaces/media_renderer.mojom.h" | 75 #include "media/mojo/interfaces/media_renderer.mojom.h" |
| 75 #include "media/mojo/services/mojo_renderer_service.h" | 76 #include "media/mojo/services/mojo_renderer_service.h" |
| 76 #endif | 77 #endif |
| (...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 374 IPC_MESSAGE_HANDLER(FrameHostMsg_BeginNavigation, | 375 IPC_MESSAGE_HANDLER(FrameHostMsg_BeginNavigation, |
| 375 OnBeginNavigation) | 376 OnBeginNavigation) |
| 376 IPC_MESSAGE_HANDLER(FrameHostMsg_DispatchLoad, OnDispatchLoad) | 377 IPC_MESSAGE_HANDLER(FrameHostMsg_DispatchLoad, OnDispatchLoad) |
| 377 IPC_MESSAGE_HANDLER(FrameHostMsg_TextSurroundingSelectionResponse, | 378 IPC_MESSAGE_HANDLER(FrameHostMsg_TextSurroundingSelectionResponse, |
| 378 OnTextSurroundingSelectionResponse) | 379 OnTextSurroundingSelectionResponse) |
| 379 IPC_MESSAGE_HANDLER(AccessibilityHostMsg_Events, OnAccessibilityEvents) | 380 IPC_MESSAGE_HANDLER(AccessibilityHostMsg_Events, OnAccessibilityEvents) |
| 380 IPC_MESSAGE_HANDLER(AccessibilityHostMsg_LocationChanges, | 381 IPC_MESSAGE_HANDLER(AccessibilityHostMsg_LocationChanges, |
| 381 OnAccessibilityLocationChanges) | 382 OnAccessibilityLocationChanges) |
| 382 IPC_MESSAGE_HANDLER(AccessibilityHostMsg_FindInPageResult, | 383 IPC_MESSAGE_HANDLER(AccessibilityHostMsg_FindInPageResult, |
| 383 OnAccessibilityFindInPageResult) | 384 OnAccessibilityFindInPageResult) |
| 385 IPC_MESSAGE_HANDLER(AccessibilityHostMsg_SnapshotResponse, | |
| 386 OnAccessibilitySnapshotResponse) | |
| 384 IPC_MESSAGE_HANDLER(FrameHostMsg_ToggleFullscreen, OnToggleFullscreen) | 387 IPC_MESSAGE_HANDLER(FrameHostMsg_ToggleFullscreen, OnToggleFullscreen) |
| 385 // The following message is synthetic and doesn't come from RenderFrame, but | 388 // The following message is synthetic and doesn't come from RenderFrame, but |
| 386 // from RenderProcessHost. | 389 // from RenderProcessHost. |
| 387 IPC_MESSAGE_HANDLER(FrameHostMsg_RenderProcessGone, OnRenderProcessGone) | 390 IPC_MESSAGE_HANDLER(FrameHostMsg_RenderProcessGone, OnRenderProcessGone) |
| 388 #if defined(OS_MACOSX) || defined(OS_ANDROID) | 391 #if defined(OS_MACOSX) || defined(OS_ANDROID) |
| 389 IPC_MESSAGE_HANDLER(FrameHostMsg_ShowPopup, OnShowPopup) | 392 IPC_MESSAGE_HANDLER(FrameHostMsg_ShowPopup, OnShowPopup) |
| 390 IPC_MESSAGE_HANDLER(FrameHostMsg_HidePopup, OnHidePopup) | 393 IPC_MESSAGE_HANDLER(FrameHostMsg_HidePopup, OnHidePopup) |
| 391 #endif | 394 #endif |
| 392 IPC_END_MESSAGE_MAP() | 395 IPC_END_MESSAGE_MAP() |
| 393 | 396 |
| (...skipping 991 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1385 BrowserAccessibilityManager* manager = | 1388 BrowserAccessibilityManager* manager = |
| 1386 GetOrCreateBrowserAccessibilityManager(); | 1389 GetOrCreateBrowserAccessibilityManager(); |
| 1387 if (manager) { | 1390 if (manager) { |
| 1388 manager->OnFindInPageResult( | 1391 manager->OnFindInPageResult( |
| 1389 params.request_id, params.match_index, params.start_id, | 1392 params.request_id, params.match_index, params.start_id, |
| 1390 params.start_offset, params.end_id, params.end_offset); | 1393 params.start_offset, params.end_id, params.end_offset); |
| 1391 } | 1394 } |
| 1392 } | 1395 } |
| 1393 } | 1396 } |
| 1394 | 1397 |
| 1398 void RenderFrameHostImpl::OnAccessibilitySnapshotResponse( | |
| 1399 int token, | |
|
Charlie Reis
2015/04/02 23:09:06
"token" seems like an ambiguous name here.
dmazzoni
2015/04/03 22:49:41
Happy to switch to "id" if you prefer, but deferri
Charlie Reis
2015/04/06 21:56:51
"id" isn't any less ambiguous, but at least it's c
dmazzoni
2015/04/09 18:39:01
Done.
| |
| 1400 const ui::AXTreeUpdate& snapshot) { | |
| 1401 std::map<int, AXTreeSnapshotCallback>::iterator it = | |
| 1402 ax_tree_snapshot_callbacks_.find(token); | |
| 1403 if (it != ax_tree_snapshot_callbacks_.end()) { | |
| 1404 it->second.Run(snapshot); | |
| 1405 ax_tree_snapshot_callbacks_.erase(it); | |
| 1406 } else { | |
| 1407 NOTREACHED() << "Received AX tree snapshot response for unknown request"; | |
| 1408 } | |
| 1409 } | |
| 1410 | |
| 1395 void RenderFrameHostImpl::OnToggleFullscreen(bool enter_fullscreen) { | 1411 void RenderFrameHostImpl::OnToggleFullscreen(bool enter_fullscreen) { |
| 1396 if (enter_fullscreen) | 1412 if (enter_fullscreen) |
| 1397 delegate_->EnterFullscreenMode(GetLastCommittedURL().GetOrigin()); | 1413 delegate_->EnterFullscreenMode(GetLastCommittedURL().GetOrigin()); |
| 1398 else | 1414 else |
| 1399 delegate_->ExitFullscreenMode(); | 1415 delegate_->ExitFullscreenMode(); |
| 1400 | 1416 |
| 1401 // The previous call might change the fullscreen state. We need to make sure | 1417 // The previous call might change the fullscreen state. We need to make sure |
| 1402 // the renderer is aware of that, which is done via the resize message. | 1418 // the renderer is aware of that, which is done via the resize message. |
| 1403 render_view_host_->WasResized(); | 1419 render_view_host_->WasResized(); |
| 1404 } | 1420 } |
| (...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1798 // As a sanity check, make sure the frame belongs to the same BrowserContext. | 1814 // As a sanity check, make sure the frame belongs to the same BrowserContext. |
| 1799 CHECK_EQ(GetSiteInstance()->GetBrowserContext(), | 1815 CHECK_EQ(GetSiteInstance()->GetBrowserContext(), |
| 1800 other_render_frame_host->GetSiteInstance()->GetBrowserContext()); | 1816 other_render_frame_host->GetSiteInstance()->GetBrowserContext()); |
| 1801 return GetSiteInstance() == other_render_frame_host->GetSiteInstance(); | 1817 return GetSiteInstance() == other_render_frame_host->GetSiteInstance(); |
| 1802 } | 1818 } |
| 1803 | 1819 |
| 1804 void RenderFrameHostImpl::SetAccessibilityMode(AccessibilityMode mode) { | 1820 void RenderFrameHostImpl::SetAccessibilityMode(AccessibilityMode mode) { |
| 1805 Send(new FrameMsg_SetAccessibilityMode(routing_id_, mode)); | 1821 Send(new FrameMsg_SetAccessibilityMode(routing_id_, mode)); |
| 1806 } | 1822 } |
| 1807 | 1823 |
| 1824 void RenderFrameHostImpl::RequestAXTreeSnapshot( | |
| 1825 AXTreeSnapshotCallback callback) { | |
| 1826 static int next_token = 1; | |
|
Charlie Reis
2015/04/02 23:09:06
This feels like an awkward pattern. We haven't re
dmazzoni
2015/04/03 22:49:41
FWIW, I copied this code nearly verbatim from Exec
Charlie Reis
2015/04/06 21:56:50
Oh, I'd never seen that. Ok, I'll defer, since th
| |
| 1827 int token = next_token++; | |
| 1828 Send(new AccessibilityMsg_SnapshotTree(routing_id_, token)); | |
| 1829 ax_tree_snapshot_callbacks_.insert(std::make_pair(token, callback)); | |
| 1830 } | |
| 1831 | |
| 1808 void RenderFrameHostImpl::SetAccessibilityCallbackForTesting( | 1832 void RenderFrameHostImpl::SetAccessibilityCallbackForTesting( |
| 1809 const base::Callback<void(ui::AXEvent, int)>& callback) { | 1833 const base::Callback<void(ui::AXEvent, int)>& callback) { |
| 1810 accessibility_testing_callback_ = callback; | 1834 accessibility_testing_callback_ = callback; |
| 1811 } | 1835 } |
| 1812 | 1836 |
| 1813 const ui::AXTree* RenderFrameHostImpl::GetAXTreeForTesting() { | 1837 const ui::AXTree* RenderFrameHostImpl::GetAXTreeForTesting() { |
| 1814 return ax_tree_for_testing_.get(); | 1838 return ax_tree_for_testing_.get(); |
| 1815 } | 1839 } |
| 1816 | 1840 |
| 1817 BrowserAccessibilityManager* | 1841 BrowserAccessibilityManager* |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1949 return; | 1973 return; |
| 1950 | 1974 |
| 1951 permission_manager->RegisterPermissionUsage( | 1975 permission_manager->RegisterPermissionUsage( |
| 1952 PermissionType::GEOLOCATION, | 1976 PermissionType::GEOLOCATION, |
| 1953 GetLastCommittedURL().GetOrigin(), | 1977 GetLastCommittedURL().GetOrigin(), |
| 1954 frame_tree_node()->frame_tree()->GetMainFrame() | 1978 frame_tree_node()->frame_tree()->GetMainFrame() |
| 1955 ->GetLastCommittedURL().GetOrigin()); | 1979 ->GetLastCommittedURL().GetOrigin()); |
| 1956 } | 1980 } |
| 1957 | 1981 |
| 1958 } // namespace content | 1982 } // namespace content |
| OLD | NEW |