mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Update to Chromium revision ad468e8b (#292352).
- Building Chromium using SVN is no longer supported. - Remove CefDOMEvent and CefDOMEventListener (issue #933). - Remove CefRenderHandler::OnScrollOffsetChanged (http://crbug.com/404656). - Remove UR_FLAG_REPORT_LOAD_TIMING (https://codereview.chromium.org/451623002/). git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@1816 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
@ -28,24 +28,61 @@
|
||||
#include "content/public/common/content_switches.h"
|
||||
#include "content/public/common/url_constants.h"
|
||||
#include "grit/cef_resources.h"
|
||||
#include "net/socket/tcp_listen_socket.h"
|
||||
#include "net/socket/tcp_server_socket.h"
|
||||
#include "ui/base/layout.h"
|
||||
#include "ui/base/resource/resource_bundle.h"
|
||||
|
||||
namespace {
|
||||
|
||||
const char kTargetTypePage[] = "page";
|
||||
const char kTargetTypeServiceWorker[] = "service_worker";
|
||||
const char kTargetTypeOther[] = "other";
|
||||
|
||||
class TCPServerSocketFactory
|
||||
: public content::DevToolsHttpHandler::ServerSocketFactory {
|
||||
public:
|
||||
TCPServerSocketFactory(const std::string& address, int port, int backlog)
|
||||
: content::DevToolsHttpHandler::ServerSocketFactory(
|
||||
address, port, backlog) {}
|
||||
|
||||
private:
|
||||
// content::DevToolsHttpHandler::ServerSocketFactory.
|
||||
virtual scoped_ptr<net::ServerSocket> Create() const OVERRIDE {
|
||||
return scoped_ptr<net::ServerSocket>(
|
||||
new net::TCPServerSocket(NULL, net::NetLog::Source()));
|
||||
}
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(TCPServerSocketFactory);
|
||||
};
|
||||
|
||||
scoped_ptr<content::DevToolsHttpHandler::ServerSocketFactory>
|
||||
CreateSocketFactory(int port) {
|
||||
return scoped_ptr<content::DevToolsHttpHandler::ServerSocketFactory>(
|
||||
new TCPServerSocketFactory("127.0.0.1", port, 1));
|
||||
}
|
||||
|
||||
class Target : public content::DevToolsTarget {
|
||||
public:
|
||||
explicit Target(content::WebContents* web_contents);
|
||||
explicit Target(scoped_refptr<content::DevToolsAgentHost> agent_host);
|
||||
|
||||
virtual std::string GetId() const OVERRIDE { return id_; }
|
||||
virtual std::string GetId() const OVERRIDE { return agent_host_->GetId(); }
|
||||
virtual std::string GetParentId() const OVERRIDE { return std::string(); }
|
||||
virtual std::string GetType() const OVERRIDE { return kTargetTypePage; }
|
||||
virtual std::string GetTitle() const OVERRIDE { return title_; }
|
||||
virtual std::string GetType() const OVERRIDE {
|
||||
switch (agent_host_->GetType()) {
|
||||
case content::DevToolsAgentHost::TYPE_WEB_CONTENTS:
|
||||
return kTargetTypePage;
|
||||
case content::DevToolsAgentHost::TYPE_SERVICE_WORKER:
|
||||
return kTargetTypeServiceWorker;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return kTargetTypeOther;
|
||||
}
|
||||
virtual std::string GetTitle() const OVERRIDE {
|
||||
return agent_host_->GetTitle();
|
||||
}
|
||||
virtual std::string GetDescription() const OVERRIDE { return std::string(); }
|
||||
virtual GURL GetURL() const OVERRIDE { return url_; }
|
||||
virtual GURL GetURL() const OVERRIDE { return agent_host_->GetURL(); }
|
||||
virtual GURL GetFaviconURL() const OVERRIDE { return favicon_url_; }
|
||||
virtual base::TimeTicks GetLastActivityTime() const OVERRIDE {
|
||||
return last_activity_time_;
|
||||
@ -62,45 +99,27 @@ class Target : public content::DevToolsTarget {
|
||||
|
||||
private:
|
||||
scoped_refptr<content::DevToolsAgentHost> agent_host_;
|
||||
std::string id_;
|
||||
std::string title_;
|
||||
GURL url_;
|
||||
GURL favicon_url_;
|
||||
base::TimeTicks last_activity_time_;
|
||||
};
|
||||
|
||||
Target::Target(content::WebContents* web_contents) {
|
||||
agent_host_ =
|
||||
content::DevToolsAgentHost::GetOrCreateFor(
|
||||
web_contents->GetRenderViewHost());
|
||||
id_ = agent_host_->GetId();
|
||||
title_ = base::UTF16ToUTF8(web_contents->GetTitle());
|
||||
url_ = web_contents->GetURL();
|
||||
content::NavigationController& controller = web_contents->GetController();
|
||||
content::NavigationEntry* entry = controller.GetActiveEntry();
|
||||
if (entry != NULL && entry->GetURL().is_valid())
|
||||
favicon_url_ = entry->GetFavicon().url;
|
||||
last_activity_time_ = web_contents->GetLastActiveTime();
|
||||
Target::Target(scoped_refptr<content::DevToolsAgentHost> agent_host)
|
||||
: agent_host_(agent_host) {
|
||||
if (content::WebContents* web_contents = agent_host_->GetWebContents()) {
|
||||
content::NavigationController& controller = web_contents->GetController();
|
||||
content::NavigationEntry* entry = controller.GetActiveEntry();
|
||||
if (entry != NULL && entry->GetURL().is_valid())
|
||||
favicon_url_ = entry->GetFavicon().url;
|
||||
last_activity_time_ = web_contents->GetLastActiveTime();
|
||||
}
|
||||
}
|
||||
|
||||
bool Target::Activate() const {
|
||||
content::RenderViewHost* rvh = agent_host_->GetRenderViewHost();
|
||||
if (!rvh)
|
||||
return false;
|
||||
content::WebContents* web_contents =
|
||||
content::WebContents::FromRenderViewHost(rvh);
|
||||
if (!web_contents)
|
||||
return false;
|
||||
web_contents->GetDelegate()->ActivateContents(web_contents);
|
||||
return true;
|
||||
return agent_host_->Activate();
|
||||
}
|
||||
|
||||
bool Target::Close() const {
|
||||
content::RenderViewHost* rvh = agent_host_->GetRenderViewHost();
|
||||
if (!rvh)
|
||||
return false;
|
||||
rvh->ClosePage();
|
||||
return true;
|
||||
return agent_host_->Close();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
@ -109,8 +128,8 @@ bool Target::Close() const {
|
||||
|
||||
CefDevToolsDelegate::CefDevToolsDelegate(int port) {
|
||||
devtools_http_handler_ = content::DevToolsHttpHandler::Start(
|
||||
new net::TCPListenSocketFactory("127.0.0.1", port),
|
||||
"",
|
||||
CreateSocketFactory(port),
|
||||
std::string(),
|
||||
this,
|
||||
base::FilePath());
|
||||
}
|
||||
@ -147,14 +166,11 @@ scoped_ptr<content::DevToolsTarget> CefDevToolsDelegate::CreateNewTarget(
|
||||
|
||||
void CefDevToolsDelegate::EnumerateTargets(TargetCallback callback) {
|
||||
TargetList targets;
|
||||
std::vector<content::RenderViewHost*> rvh_list =
|
||||
content::DevToolsAgentHost::GetValidRenderViewHosts();
|
||||
for (std::vector<content::RenderViewHost*>::iterator it = rvh_list.begin();
|
||||
it != rvh_list.end(); ++it) {
|
||||
content::WebContents* web_contents =
|
||||
content::WebContents::FromRenderViewHost(*it);
|
||||
if (web_contents)
|
||||
targets.push_back(new Target(web_contents));
|
||||
content::DevToolsAgentHost::List agents =
|
||||
content::DevToolsAgentHost::GetOrCreateAll();
|
||||
for (content::DevToolsAgentHost::List::iterator it = agents.begin();
|
||||
it != agents.end(); ++it) {
|
||||
targets.push_back(new Target(*it));
|
||||
}
|
||||
callback.Run(targets);
|
||||
}
|
||||
|
Reference in New Issue
Block a user