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

Side by Side Diff: content/browser/devtools/devtools_frontend_host_impl.cc

Issue 2620153002: Fix front-end host creation upon navigation (Closed)
Patch Set: Created 3 years, 11 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/devtools/devtools_frontend_host_impl.h" 5 #include "content/browser/devtools/devtools_frontend_host_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "content/browser/bad_message.h" 9 #include "content/browser/bad_message.h"
10 #include "content/browser/frame_host/frame_tree.h"
11 #include "content/browser/web_contents/web_contents_impl.h"
10 #include "content/common/devtools_messages.h" 12 #include "content/common/devtools_messages.h"
11 #include "content/public/browser/navigation_entry.h" 13 #include "content/public/browser/navigation_entry.h"
12 #include "content/public/browser/render_frame_host.h" 14 #include "content/public/browser/render_frame_host.h"
13 #include "content/public/browser/web_contents.h" 15 #include "content/public/browser/web_contents.h"
14 #include "content/public/common/content_client.h" 16 #include "content/public/common/content_client.h"
15 #include "grit/devtools_resources_map.h" 17 #include "grit/devtools_resources_map.h"
16 18
17 namespace content { 19 namespace content {
18 20
19 namespace { 21 namespace {
20 const char kCompatibilityScript[] = "devtools_compatibility.js"; 22 const char kCompatibilityScript[] = "devtools_compatibility.js";
21 const char kCompatibilityScriptSourceURL[] = 23 const char kCompatibilityScriptSourceURL[] =
22 "\n//# " 24 "\n//# "
23 "sourceURL=chrome-devtools://devtools/bundled/devtools_compatibility.js"; 25 "sourceURL=chrome-devtools://devtools/bundled/devtools_compatibility.js";
24 } 26 }
25 27
26 // static 28 // static
27 DevToolsFrontendHost* DevToolsFrontendHost::Create( 29 DevToolsFrontendHost* DevToolsFrontendHost::Create(
28 RenderFrameHost* frontend_main_frame, 30 WebContents* web_contents,
29 const HandleMessageCallback& handle_message_callback) { 31 const HandleMessageCallback& handle_message_callback) {
30 return new DevToolsFrontendHostImpl(frontend_main_frame, 32 RenderFrameHost* frame = web_contents->GetMainFrame();
33 FrameTree* tree = static_cast<WebContentsImpl*>(web_contents)->GetFrameTree();
34 RenderFrameHostManager* rfhm = tree->root()->render_manager();
35 RenderFrameHost* pending_frame = rfhm->pending_frame_host();
36 return new DevToolsFrontendHostImpl(pending_frame ? pending_frame : frame,
pfeldman 2017/01/10 22:31:51 This looks fragile and implementation implies navi
31 handle_message_callback); 37 handle_message_callback);
32 } 38 }
33 39
34 // static 40 // static
35 base::StringPiece DevToolsFrontendHost::GetFrontendResource( 41 base::StringPiece DevToolsFrontendHost::GetFrontendResource(
36 const std::string& path) { 42 const std::string& path) {
37 for (size_t i = 0; i < kDevtoolsResourcesSize; ++i) { 43 for (size_t i = 0; i < kDevtoolsResourcesSize; ++i) {
38 if (path == kDevtoolsResources[i].name) { 44 if (path == kDevtoolsResources[i].name) {
39 return GetContentClient()->GetDataResource( 45 return GetContentClient()->GetDataResource(
40 kDevtoolsResources[i].value, ui::SCALE_FACTOR_NONE); 46 kDevtoolsResources[i].value, ui::SCALE_FACTOR_NONE);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 IPC_END_MESSAGE_MAP() 83 IPC_END_MESSAGE_MAP()
78 return handled; 84 return handled;
79 } 85 }
80 86
81 void DevToolsFrontendHostImpl::OnDispatchOnEmbedder( 87 void DevToolsFrontendHostImpl::OnDispatchOnEmbedder(
82 const std::string& message) { 88 const std::string& message) {
83 handle_message_callback_.Run(message); 89 handle_message_callback_.Run(message);
84 } 90 }
85 91
86 } // namespace content 92 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698