OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/devtools/browser_list_tabcontents_provider.h" | 5 #include "chrome/browser/devtools/browser_list_tabcontents_provider.h" |
6 | 6 |
7 #include "base/path_service.h" | 7 #include "base/path_service.h" |
8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
9 #include "chrome/browser/devtools/devtools_target_impl.h" | 9 #include "chrome/browser/devtools/devtools_target_impl.h" |
10 #include "chrome/browser/history/top_sites.h" | 10 #include "chrome/browser/history/top_sites.h" |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 web_contents = | 112 web_contents = |
113 browser_list->get(0)->tab_strip_model()->GetActiveWebContents(); | 113 browser_list->get(0)->tab_strip_model()->GetActiveWebContents(); |
114 web_contents->GetController().LoadURL(url, | 114 web_contents->GetController().LoadURL(url, |
115 content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string()); | 115 content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string()); |
116 } else { | 116 } else { |
117 web_contents = chrome::AddSelectedTabWithURL( | 117 web_contents = chrome::AddSelectedTabWithURL( |
118 browser_list->get(0), | 118 browser_list->get(0), |
119 url, | 119 url, |
120 content::PAGE_TRANSITION_LINK); | 120 content::PAGE_TRANSITION_LINK); |
121 } | 121 } |
122 content::RenderViewHost* rvh = web_contents->GetRenderViewHost(); | |
123 if (!rvh) | |
124 return scoped_ptr<DevToolsTarget>(); | |
125 return scoped_ptr<DevToolsTarget>( | 122 return scoped_ptr<DevToolsTarget>( |
126 DevToolsTargetImpl::CreateForRenderViewHost(rvh, true)); | 123 DevToolsTargetImpl::CreateForWebContents(web_contents, true)); |
127 } | 124 } |
128 | 125 |
129 void BrowserListTabContentsProvider::EnumerateTargets(TargetCallback callback) { | 126 void BrowserListTabContentsProvider::EnumerateTargets(TargetCallback callback) { |
130 DevToolsTargetImpl::EnumerateAllTargets( | 127 DevToolsTargetImpl::EnumerateAllTargets( |
131 *reinterpret_cast<DevToolsTargetImpl::Callback*>(&callback)); | 128 *reinterpret_cast<DevToolsTargetImpl::Callback*>(&callback)); |
132 } | 129 } |
133 | 130 |
134 scoped_ptr<net::StreamListenSocket> | 131 scoped_ptr<net::StreamListenSocket> |
135 BrowserListTabContentsProvider::CreateSocketForTethering( | 132 BrowserListTabContentsProvider::CreateSocketForTethering( |
136 net::StreamListenSocket::Delegate* delegate, | 133 net::StreamListenSocket::Delegate* delegate, |
137 std::string* name) { | 134 std::string* name) { |
138 if (!g_tethering_enabled.Get()) | 135 if (!g_tethering_enabled.Get()) |
139 return scoped_ptr<net::StreamListenSocket>(); | 136 return scoped_ptr<net::StreamListenSocket>(); |
140 | 137 |
141 if (last_tethering_port_ == kMaxTetheringPort) | 138 if (last_tethering_port_ == kMaxTetheringPort) |
142 last_tethering_port_ = kMinTetheringPort; | 139 last_tethering_port_ = kMinTetheringPort; |
143 int port = ++last_tethering_port_; | 140 int port = ++last_tethering_port_; |
144 *name = base::IntToString(port); | 141 *name = base::IntToString(port); |
145 return net::TCPListenSocket::CreateAndListen("127.0.0.1", port, delegate) | 142 return net::TCPListenSocket::CreateAndListen("127.0.0.1", port, delegate) |
146 .PassAs<net::StreamListenSocket>(); | 143 .PassAs<net::StreamListenSocket>(); |
147 } | 144 } |
OLD | NEW |