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

Side by Side Diff: content/browser/frame_host/render_frame_host_impl.cc

Issue 1549113002: Switch to standard integer types in content/browser/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 12 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
OLDNEW
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/containers/hash_tables.h" 8 #include "base/containers/hash_tables.h"
9 #include "base/lazy_instance.h" 9 #include "base/lazy_instance.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
11 #include "base/process/kill.h" 11 #include "base/process/kill.h"
12 #include "base/time/time.h" 12 #include "base/time/time.h"
13 #include "build/build_config.h"
13 #include "content/browser/accessibility/accessibility_mode_helper.h" 14 #include "content/browser/accessibility/accessibility_mode_helper.h"
14 #include "content/browser/accessibility/ax_tree_id_registry.h" 15 #include "content/browser/accessibility/ax_tree_id_registry.h"
15 #include "content/browser/accessibility/browser_accessibility_manager.h" 16 #include "content/browser/accessibility/browser_accessibility_manager.h"
16 #include "content/browser/accessibility/browser_accessibility_state_impl.h" 17 #include "content/browser/accessibility/browser_accessibility_state_impl.h"
17 #include "content/browser/child_process_security_policy_impl.h" 18 #include "content/browser/child_process_security_policy_impl.h"
18 #include "content/browser/child_process_security_policy_impl.h" 19 #include "content/browser/child_process_security_policy_impl.h"
19 #include "content/browser/devtools/render_frame_devtools_agent_host.h" 20 #include "content/browser/devtools/render_frame_devtools_agent_host.h"
20 #include "content/browser/download/mhtml_generation_manager.h" 21 #include "content/browser/download/mhtml_generation_manager.h"
21 #include "content/browser/frame_host/cross_process_frame_connector.h" 22 #include "content/browser/frame_host/cross_process_frame_connector.h"
22 #include "content/browser/frame_host/cross_site_transferring_request.h" 23 #include "content/browser/frame_host/cross_site_transferring_request.h"
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 int g_next_accessibility_reset_token = 1; 99 int g_next_accessibility_reset_token = 1;
99 100
100 // The next value to use for the javascript callback id. 101 // The next value to use for the javascript callback id.
101 int g_next_javascript_callback_id = 1; 102 int g_next_javascript_callback_id = 1;
102 103
103 // Whether to allow injecting javascript into any kind of frame (for Android 104 // Whether to allow injecting javascript into any kind of frame (for Android
104 // WebView). 105 // WebView).
105 bool g_allow_injecting_javascript = false; 106 bool g_allow_injecting_javascript = false;
106 107
107 // The (process id, routing id) pair that identifies one RenderFrame. 108 // The (process id, routing id) pair that identifies one RenderFrame.
108 typedef std::pair<int32, int32> RenderFrameHostID; 109 typedef std::pair<int32_t, int32_t> RenderFrameHostID;
109 typedef base::hash_map<RenderFrameHostID, RenderFrameHostImpl*> 110 typedef base::hash_map<RenderFrameHostID, RenderFrameHostImpl*>
110 RoutingIDFrameMap; 111 RoutingIDFrameMap;
111 base::LazyInstance<RoutingIDFrameMap> g_routing_id_frame_map = 112 base::LazyInstance<RoutingIDFrameMap> g_routing_id_frame_map =
112 LAZY_INSTANCE_INITIALIZER; 113 LAZY_INSTANCE_INITIALIZER;
113 114
114 // Translate a WebKit text direction into a base::i18n one. 115 // Translate a WebKit text direction into a base::i18n one.
115 base::i18n::TextDirection WebTextDirectionToChromeTextDirection( 116 base::i18n::TextDirection WebTextDirectionToChromeTextDirection(
116 blink::WebTextDirection dir) { 117 blink::WebTextDirection dir) {
117 switch (dir) { 118 switch (dir) {
118 case blink::WebTextDirectionLeftToRight: 119 case blink::WebTextDirectionLeftToRight:
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 AXTreeIDRegistry::GetInstance()->GetFrameID(ax_tree_id); 170 AXTreeIDRegistry::GetInstance()->GetFrameID(ax_tree_id);
170 return RenderFrameHostImpl::FromID(frame_id.first, frame_id.second); 171 return RenderFrameHostImpl::FromID(frame_id.first, frame_id.second);
171 } 172 }
172 173
173 RenderFrameHostImpl::RenderFrameHostImpl(SiteInstance* site_instance, 174 RenderFrameHostImpl::RenderFrameHostImpl(SiteInstance* site_instance,
174 RenderViewHostImpl* render_view_host, 175 RenderViewHostImpl* render_view_host,
175 RenderFrameHostDelegate* delegate, 176 RenderFrameHostDelegate* delegate,
176 RenderWidgetHostDelegate* rwh_delegate, 177 RenderWidgetHostDelegate* rwh_delegate,
177 FrameTree* frame_tree, 178 FrameTree* frame_tree,
178 FrameTreeNode* frame_tree_node, 179 FrameTreeNode* frame_tree_node,
179 int32 routing_id, 180 int32_t routing_id,
180 int32 widget_routing_id, 181 int32_t widget_routing_id,
181 int flags) 182 int flags)
182 : render_view_host_(render_view_host), 183 : render_view_host_(render_view_host),
183 delegate_(delegate), 184 delegate_(delegate),
184 site_instance_(static_cast<SiteInstanceImpl*>(site_instance)), 185 site_instance_(static_cast<SiteInstanceImpl*>(site_instance)),
185 process_(site_instance->GetProcess()), 186 process_(site_instance->GetProcess()),
186 cross_process_frame_connector_(NULL), 187 cross_process_frame_connector_(NULL),
187 render_frame_proxy_host_(NULL), 188 render_frame_proxy_host_(NULL),
188 frame_tree_(frame_tree), 189 frame_tree_(frame_tree),
189 frame_tree_node_(frame_tree_node), 190 frame_tree_node_(frame_tree_node),
190 render_widget_host_(nullptr), 191 render_widget_host_(nullptr),
(...skipping 570 matching lines...) Expand 10 before | Expand all | Expand 10 after
761 render_widget_host_->InitForFrame(); 762 render_widget_host_->InitForFrame();
762 } 763 }
763 764
764 void RenderFrameHostImpl::Init() { 765 void RenderFrameHostImpl::Init() {
765 // TODO(csharrison): Call GetProcess()->ResumeRequestsForFrame(routing_id_) 766 // TODO(csharrison): Call GetProcess()->ResumeRequestsForFrame(routing_id_)
766 // once ResourceDispatcherHostImpl is keyed on render frame routing ids 767 // once ResourceDispatcherHostImpl is keyed on render frame routing ids
767 // instead of render view routing ids. 768 // instead of render view routing ids.
768 } 769 }
769 770
770 void RenderFrameHostImpl::OnAddMessageToConsole( 771 void RenderFrameHostImpl::OnAddMessageToConsole(
771 int32 level, 772 int32_t level,
772 const base::string16& message, 773 const base::string16& message,
773 int32 line_no, 774 int32_t line_no,
774 const base::string16& source_id) { 775 const base::string16& source_id) {
775 if (delegate_->AddMessageToConsole(level, message, line_no, source_id)) 776 if (delegate_->AddMessageToConsole(level, message, line_no, source_id))
776 return; 777 return;
777 778
778 // Pass through log level only on WebUI pages to limit console spew. 779 // Pass through log level only on WebUI pages to limit console spew.
779 const bool is_web_ui = 780 const bool is_web_ui =
780 HasWebUIScheme(delegate_->GetMainFrameLastCommittedURL()); 781 HasWebUIScheme(delegate_->GetMainFrameLastCommittedURL());
781 const int32 resolved_level = is_web_ui ? level : ::logging::LOG_INFO; 782 const int32_t resolved_level = is_web_ui ? level : ::logging::LOG_INFO;
782 783
783 // LogMessages can be persisted so this shouldn't be logged in incognito mode. 784 // LogMessages can be persisted so this shouldn't be logged in incognito mode.
784 // This rule is not applied to WebUI pages, because source code of WebUI is a 785 // This rule is not applied to WebUI pages, because source code of WebUI is a
785 // part of Chrome source code, and we want to treat messages from WebUI the 786 // part of Chrome source code, and we want to treat messages from WebUI the
786 // same way as we treat log messages from native code. 787 // same way as we treat log messages from native code.
787 if (::logging::GetMinLogLevel() <= resolved_level && 788 if (::logging::GetMinLogLevel() <= resolved_level &&
788 (is_web_ui || 789 (is_web_ui ||
789 !GetSiteInstance()->GetBrowserContext()->IsOffTheRecord())) { 790 !GetSiteInstance()->GetBrowserContext()->IsOffTheRecord())) {
790 logging::LogMessage("CONSOLE", line_no, resolved_level).stream() 791 logging::LogMessage("CONSOLE", line_no, resolved_level).stream()
791 << "\"" << message << "\", source: " << source_id << " (" << line_no 792 << "\"" << message << "\", source: " << source_id << " (" << line_no
(...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after
1327 std::map<int, JavaScriptResultCallback>::iterator it = 1328 std::map<int, JavaScriptResultCallback>::iterator it =
1328 javascript_callbacks_.find(id); 1329 javascript_callbacks_.find(id);
1329 if (it != javascript_callbacks_.end()) { 1330 if (it != javascript_callbacks_.end()) {
1330 it->second.Run(result_value); 1331 it->second.Run(result_value);
1331 javascript_callbacks_.erase(it); 1332 javascript_callbacks_.erase(it);
1332 } else { 1333 } else {
1333 NOTREACHED() << "Received script response for unknown request"; 1334 NOTREACHED() << "Received script response for unknown request";
1334 } 1335 }
1335 } 1336 }
1336 1337
1337 void RenderFrameHostImpl::OnVisualStateResponse(uint64 id) { 1338 void RenderFrameHostImpl::OnVisualStateResponse(uint64_t id) {
1338 auto it = visual_state_callbacks_.find(id); 1339 auto it = visual_state_callbacks_.find(id);
1339 if (it != visual_state_callbacks_.end()) { 1340 if (it != visual_state_callbacks_.end()) {
1340 it->second.Run(true); 1341 it->second.Run(true);
1341 visual_state_callbacks_.erase(it); 1342 visual_state_callbacks_.erase(it);
1342 } else { 1343 } else {
1343 NOTREACHED() << "Received script response for unknown request"; 1344 NOTREACHED() << "Received script response for unknown request";
1344 } 1345 }
1345 } 1346 }
1346 1347
1347 void RenderFrameHostImpl::OnRunJavaScriptMessage( 1348 void RenderFrameHostImpl::OnRunJavaScriptMessage(
(...skipping 27 matching lines...) Expand all
1375 size_t start_offset, 1376 size_t start_offset,
1376 size_t end_offset) { 1377 size_t end_offset) {
1377 render_view_host_->OnTextSurroundingSelectionResponse( 1378 render_view_host_->OnTextSurroundingSelectionResponse(
1378 content, start_offset, end_offset); 1379 content, start_offset, end_offset);
1379 } 1380 }
1380 1381
1381 void RenderFrameHostImpl::OnDidAccessInitialDocument() { 1382 void RenderFrameHostImpl::OnDidAccessInitialDocument() {
1382 delegate_->DidAccessInitialDocument(); 1383 delegate_->DidAccessInitialDocument();
1383 } 1384 }
1384 1385
1385 void RenderFrameHostImpl::OnDidChangeOpener(int32 opener_routing_id) { 1386 void RenderFrameHostImpl::OnDidChangeOpener(int32_t opener_routing_id) {
1386 frame_tree_node_->render_manager()->DidChangeOpener(opener_routing_id, 1387 frame_tree_node_->render_manager()->DidChangeOpener(opener_routing_id,
1387 GetSiteInstance()); 1388 GetSiteInstance());
1388 } 1389 }
1389 1390
1390 void RenderFrameHostImpl::OnDidChangeName(const std::string& name) { 1391 void RenderFrameHostImpl::OnDidChangeName(const std::string& name) {
1391 std::string old_name = frame_tree_node()->frame_name(); 1392 std::string old_name = frame_tree_node()->frame_name();
1392 frame_tree_node()->SetFrameName(name); 1393 frame_tree_node()->SetFrameName(name);
1393 if (old_name.empty() && !name.empty()) 1394 if (old_name.empty() && !name.empty())
1394 frame_tree_node_->render_manager()->CreateProxiesForNewNamedFrame(); 1395 frame_tree_node_->render_manager()->CreateProxiesForNewNamedFrame();
1395 delegate_->DidChangeName(this, name); 1396 delegate_->DidChangeName(this, name);
1396 } 1397 }
1397 1398
1398 void RenderFrameHostImpl::OnEnforceStrictMixedContentChecking() { 1399 void RenderFrameHostImpl::OnEnforceStrictMixedContentChecking() {
1399 frame_tree_node()->SetEnforceStrictMixedContentChecking(true); 1400 frame_tree_node()->SetEnforceStrictMixedContentChecking(true);
1400 } 1401 }
1401 1402
1402 void RenderFrameHostImpl::OnDidAssignPageId(int32 page_id) { 1403 void RenderFrameHostImpl::OnDidAssignPageId(int32_t page_id) {
1403 // Update the RVH's current page ID so that future IPCs from the renderer 1404 // Update the RVH's current page ID so that future IPCs from the renderer
1404 // correspond to the new page. 1405 // correspond to the new page.
1405 render_view_host_->page_id_ = page_id; 1406 render_view_host_->page_id_ = page_id;
1406 } 1407 }
1407 1408
1408 FrameTreeNode* RenderFrameHostImpl::FindAndVerifyChild( 1409 FrameTreeNode* RenderFrameHostImpl::FindAndVerifyChild(
1409 int32 child_frame_routing_id, 1410 int32_t child_frame_routing_id,
1410 bad_message::BadMessageReason reason) { 1411 bad_message::BadMessageReason reason) {
1411 FrameTreeNode* child = frame_tree_node()->frame_tree()->FindByRoutingID( 1412 FrameTreeNode* child = frame_tree_node()->frame_tree()->FindByRoutingID(
1412 GetProcess()->GetID(), child_frame_routing_id); 1413 GetProcess()->GetID(), child_frame_routing_id);
1413 // A race can result in |child| to be nullptr. Avoid killing the renderer in 1414 // A race can result in |child| to be nullptr. Avoid killing the renderer in
1414 // that case. 1415 // that case.
1415 if (child && child->parent() != frame_tree_node()) { 1416 if (child && child->parent() != frame_tree_node()) {
1416 bad_message::ReceivedBadMessage(GetProcess(), reason); 1417 bad_message::ReceivedBadMessage(GetProcess(), reason);
1417 return nullptr; 1418 return nullptr;
1418 } 1419 }
1419 return child; 1420 return child;
1420 } 1421 }
1421 1422
1422 void RenderFrameHostImpl::OnDidChangeSandboxFlags( 1423 void RenderFrameHostImpl::OnDidChangeSandboxFlags(
1423 int32 frame_routing_id, 1424 int32_t frame_routing_id,
1424 blink::WebSandboxFlags flags) { 1425 blink::WebSandboxFlags flags) {
1425 // Ensure that a frame can only update sandbox flags for its immediate 1426 // Ensure that a frame can only update sandbox flags for its immediate
1426 // children. If this is not the case, the renderer is considered malicious 1427 // children. If this is not the case, the renderer is considered malicious
1427 // and is killed. 1428 // and is killed.
1428 FrameTreeNode* child = FindAndVerifyChild( 1429 FrameTreeNode* child = FindAndVerifyChild(
1429 frame_routing_id, bad_message::RFH_SANDBOX_FLAGS); 1430 frame_routing_id, bad_message::RFH_SANDBOX_FLAGS);
1430 if (!child) 1431 if (!child)
1431 return; 1432 return;
1432 1433
1433 child->set_sandbox_flags(flags); 1434 child->set_sandbox_flags(flags);
1434 1435
1435 // Notify the RenderFrame if it lives in a different process from its 1436 // Notify the RenderFrame if it lives in a different process from its
1436 // parent. The frame's proxies in other processes also need to learn about 1437 // parent. The frame's proxies in other processes also need to learn about
1437 // the updated sandbox flags, but these notifications are sent later in 1438 // the updated sandbox flags, but these notifications are sent later in
1438 // RenderFrameHostManager::CommitPendingSandboxFlags(), when the frame 1439 // RenderFrameHostManager::CommitPendingSandboxFlags(), when the frame
1439 // navigates and the new sandbox flags take effect. 1440 // navigates and the new sandbox flags take effect.
1440 RenderFrameHost* child_rfh = child->current_frame_host(); 1441 RenderFrameHost* child_rfh = child->current_frame_host();
1441 if (child_rfh->GetSiteInstance() != GetSiteInstance()) { 1442 if (child_rfh->GetSiteInstance() != GetSiteInstance()) {
1442 child_rfh->Send( 1443 child_rfh->Send(
1443 new FrameMsg_DidUpdateSandboxFlags(child_rfh->GetRoutingID(), flags)); 1444 new FrameMsg_DidUpdateSandboxFlags(child_rfh->GetRoutingID(), flags));
1444 } 1445 }
1445 } 1446 }
1446 1447
1447 void RenderFrameHostImpl::OnDidChangeFrameOwnerProperties( 1448 void RenderFrameHostImpl::OnDidChangeFrameOwnerProperties(
1448 int32 frame_routing_id, 1449 int32_t frame_routing_id,
1449 const blink::WebFrameOwnerProperties& frame_owner_properties) { 1450 const blink::WebFrameOwnerProperties& frame_owner_properties) {
1450 FrameTreeNode* child = FindAndVerifyChild( 1451 FrameTreeNode* child = FindAndVerifyChild(
1451 frame_routing_id, bad_message::RFH_OWNER_PROPERTY); 1452 frame_routing_id, bad_message::RFH_OWNER_PROPERTY);
1452 if (!child) 1453 if (!child)
1453 return; 1454 return;
1454 1455
1455 child->set_frame_owner_properties(frame_owner_properties); 1456 child->set_frame_owner_properties(frame_owner_properties);
1456 1457
1457 // Notify the RenderFrame if it lives in a different process from its parent. 1458 // Notify the RenderFrame if it lives in a different process from its parent.
1458 // These properties only affect the RenderFrame and live in its parent 1459 // These properties only affect the RenderFrame and live in its parent
(...skipping 818 matching lines...) Expand 10 before | Expand all | Expand 10 after
2277 if (accessibility_mode & AccessibilityModeFlagPlatform) { 2278 if (accessibility_mode & AccessibilityModeFlagPlatform) {
2278 BrowserAccessibilityManager* manager = 2279 BrowserAccessibilityManager* manager =
2279 GetOrCreateBrowserAccessibilityManager(); 2280 GetOrCreateBrowserAccessibilityManager();
2280 if (manager) 2281 if (manager)
2281 manager->ActivateFindInPageResult(request_id); 2282 manager->ActivateFindInPageResult(request_id);
2282 } 2283 }
2283 } 2284 }
2284 2285
2285 void RenderFrameHostImpl::InsertVisualStateCallback( 2286 void RenderFrameHostImpl::InsertVisualStateCallback(
2286 const VisualStateCallback& callback) { 2287 const VisualStateCallback& callback) {
2287 static uint64 next_id = 1; 2288 static uint64_t next_id = 1;
2288 uint64 key = next_id++; 2289 uint64_t key = next_id++;
2289 Send(new FrameMsg_VisualStateRequest(routing_id_, key)); 2290 Send(new FrameMsg_VisualStateRequest(routing_id_, key));
2290 visual_state_callbacks_.insert(std::make_pair(key, callback)); 2291 visual_state_callbacks_.insert(std::make_pair(key, callback));
2291 } 2292 }
2292 2293
2293 bool RenderFrameHostImpl::IsRenderFrameLive() { 2294 bool RenderFrameHostImpl::IsRenderFrameLive() {
2294 bool is_live = GetProcess()->HasConnection() && render_frame_created_; 2295 bool is_live = GetProcess()->HasConnection() && render_frame_created_;
2295 2296
2296 // Sanity check: the RenderView should always be live if the RenderFrame is. 2297 // Sanity check: the RenderView should always be live if the RenderFrame is.
2297 DCHECK(!is_live || render_view_host_->IsRenderViewLive()); 2298 DCHECK(!is_live || render_view_host_->IsRenderViewLive());
2298 2299
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
2484 void RenderFrameHostImpl::AXContentNodeDataToAXNodeData( 2485 void RenderFrameHostImpl::AXContentNodeDataToAXNodeData(
2485 const AXContentNodeData& src, 2486 const AXContentNodeData& src,
2486 ui::AXNodeData* dst) { 2487 ui::AXNodeData* dst) {
2487 // Copy the common fields. 2488 // Copy the common fields.
2488 *dst = src; 2489 *dst = src;
2489 2490
2490 // Map content-specific attributes based on routing IDs or browser plugin 2491 // Map content-specific attributes based on routing IDs or browser plugin
2491 // instance IDs to generic attributes with global AXTreeIDs. 2492 // instance IDs to generic attributes with global AXTreeIDs.
2492 for (auto iter : src.content_int_attributes) { 2493 for (auto iter : src.content_int_attributes) {
2493 AXContentIntAttribute attr = iter.first; 2494 AXContentIntAttribute attr = iter.first;
2494 int32 value = iter.second; 2495 int32_t value = iter.second;
2495 switch (attr) { 2496 switch (attr) {
2496 case AX_CONTENT_ATTR_CHILD_ROUTING_ID: 2497 case AX_CONTENT_ATTR_CHILD_ROUTING_ID:
2497 dst->int_attributes.push_back(std::make_pair( 2498 dst->int_attributes.push_back(std::make_pair(
2498 ui::AX_ATTR_CHILD_TREE_ID, RoutingIDToAXTreeID(value))); 2499 ui::AX_ATTR_CHILD_TREE_ID, RoutingIDToAXTreeID(value)));
2499 break; 2500 break;
2500 case AX_CONTENT_ATTR_CHILD_BROWSER_PLUGIN_INSTANCE_ID: 2501 case AX_CONTENT_ATTR_CHILD_BROWSER_PLUGIN_INSTANCE_ID:
2501 dst->int_attributes.push_back(std::make_pair( 2502 dst->int_attributes.push_back(std::make_pair(
2502 ui::AX_ATTR_CHILD_TREE_ID, 2503 ui::AX_ATTR_CHILD_TREE_ID,
2503 BrowserPluginInstanceIDToAXTreeID(value))); 2504 BrowserPluginInstanceIDToAXTreeID(value)));
2504 break; 2505 break;
(...skipping 11 matching lines...) Expand all
2516 *dst = src; 2517 *dst = src;
2517 2518
2518 if (src.routing_id != -1) 2519 if (src.routing_id != -1)
2519 dst->tree_id = RoutingIDToAXTreeID(src.routing_id); 2520 dst->tree_id = RoutingIDToAXTreeID(src.routing_id);
2520 2521
2521 if (src.parent_routing_id != -1) 2522 if (src.parent_routing_id != -1)
2522 dst->parent_tree_id = RoutingIDToAXTreeID(src.parent_routing_id); 2523 dst->parent_tree_id = RoutingIDToAXTreeID(src.parent_routing_id);
2523 } 2524 }
2524 2525
2525 } // namespace content 2526 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/frame_host/render_frame_host_impl.h ('k') | content/browser/frame_host/render_frame_host_impl_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698