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

Side by Side Diff: chrome/browser/debugger/devtools_view.cc

Issue 50009: Allow different types of devtools client (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/debugger/devtools_view.h ('k') | chrome/browser/debugger/devtools_window.h » ('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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/browser/debugger/devtools_view.h" 5 #include "chrome/browser/debugger/devtools_view.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "chrome/browser/browser_list.h" 9 #include "chrome/browser/browser_list.h"
10 #include "chrome/browser/debugger/devtools_manager.h" 10 #include "chrome/browser/debugger/devtools_client_host.h"
11 #include "chrome/browser/profile.h" 11 #include "chrome/browser/profile.h"
12 #include "chrome/browser/tab_contents/web_contents.h" 12 #include "chrome/browser/tab_contents/web_contents.h"
13 #include "chrome/browser/views/tab_contents_container_view.h" 13 #include "chrome/browser/views/tab_contents_container_view.h"
14 #include "chrome/common/property_bag.h" 14 #include "chrome/common/property_bag.h"
15 #include "chrome/common/render_messages.h" 15 #include "chrome/common/render_messages.h"
16 #include "chrome/common/url_constants.h" 16 #include "chrome/common/url_constants.h"
17 17
18 DevToolsView::DevToolsView(DevToolsInstanceDescriptor* descriptor) 18 DevToolsView::DevToolsView() : web_contents_(NULL) {
19 : descriptor_(descriptor),
20 web_contents_(NULL) {
21 web_container_ = new TabContentsContainerView(); 19 web_container_ = new TabContentsContainerView();
22 AddChildView(web_container_); 20 AddChildView(web_container_);
23 } 21 }
24 22
25 DevToolsView::~DevToolsView() { 23 DevToolsView::~DevToolsView() {
26 } 24 }
27 25
28 std::string DevToolsView::GetClassName() const { 26 std::string DevToolsView::GetClassName() const {
29 return "DevToolsView"; 27 return "DevToolsView";
30 } 28 }
(...skipping 20 matching lines...) Expand all
51 // view hierarchy somewhere. 49 // view hierarchy somewhere.
52 Profile* profile = BrowserList::GetLastActive()->profile(); 50 Profile* profile = BrowserList::GetLastActive()->profile();
53 51
54 TabContents* tc = TabContents::CreateWithType(TAB_CONTENTS_WEB, profile, 52 TabContents* tc = TabContents::CreateWithType(TAB_CONTENTS_WEB, profile,
55 NULL); 53 NULL);
56 web_contents_ = tc->AsWebContents(); 54 web_contents_ = tc->AsWebContents();
57 web_contents_->SetupController(profile); 55 web_contents_->SetupController(profile);
58 web_contents_->set_delegate(this); 56 web_contents_->set_delegate(this);
59 web_container_->SetTabContents(web_contents_); 57 web_container_->SetTabContents(web_contents_);
60 web_contents_->render_view_host()->AllowDOMUIBindings(); 58 web_contents_->render_view_host()->AllowDOMUIBindings();
61 descriptor_->SetDevToolsHost(web_contents_->render_view_host());
62 59
63 // chrome-ui://devtools/devtools.html 60 // chrome-ui://devtools/devtools.html
64 GURL contents(std::string(chrome::kChromeUIDevToolsURL) + "devtools.html"); 61 GURL contents(std::string(chrome::kChromeUIDevToolsURL) + "devtools.html");
65 62
66 // this will call CreateRenderView to create renderer process 63 // this will call CreateRenderView to create renderer process
67 web_contents_->controller()->LoadURL(contents, GURL(), 64 web_contents_->controller()->LoadURL(contents, GURL(),
68 PageTransition::START_PAGE); 65 PageTransition::START_PAGE);
69 } 66 }
70 67
71 void DevToolsView::OnWindowClosing() { 68 void DevToolsView::OnWindowClosing() {
72 DCHECK(descriptor_) << "OnWindowClosing is called twice"; 69 DCHECK(web_contents_) << "OnWindowClosing is called twice";
73 if (descriptor_) { 70 if (web_contents_) {
74 descriptor_->Destroy(); 71 // Detach last (and only) tab.
75 descriptor_ = NULL; 72 web_container_->SetTabContents(NULL);
73
74 // Destroy the tab and navigation controller.
75 web_contents_->CloseContents();
76 web_contents_ = NULL;
76 } 77 }
77 web_container_->SetTabContents(NULL); // detach last (and only) tab 78 }
78 web_contents_->CloseContents(); // destroy the tab and navigation controller 79
80 void DevToolsView::SendMessageToClient(const IPC::Message& message) {
81 if (web_contents_) {
82 RenderViewHost* target_host = web_contents_->render_view_host();
83 IPC::Message* m = new IPC::Message(message);
84 m->set_routing_id(target_host->routing_id());
85 target_host->Send(m);
86 }
87 }
88
89 bool DevToolsView::HasRenderViewHost(const RenderViewHost& rvh) const {
90 if (web_contents_) {
91 return (&rvh == web_contents_->render_view_host());
92 }
93 return false;
79 } 94 }
80 95
81 void DevToolsView::OpenURLFromTab(TabContents* source, 96 void DevToolsView::OpenURLFromTab(TabContents* source,
82 const GURL& url, const GURL& referrer, 97 const GURL& url, const GURL& referrer,
83 WindowOpenDisposition disposition, 98 WindowOpenDisposition disposition,
84 PageTransition::Type transition) { 99 PageTransition::Type transition) {
85 NOTREACHED(); 100 NOTREACHED();
86 } 101 }
OLDNEW
« no previous file with comments | « chrome/browser/debugger/devtools_view.h ('k') | chrome/browser/debugger/devtools_window.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698