Merge pull request #112 from atom/devtools-load-network-resources
Fix networking requests not loading in devtools
This commit is contained in:
commit
44ba4e87aa
18 changed files with 547 additions and 380 deletions
|
@ -33,11 +33,11 @@ class BrowserContext::ResourceContext : public content::ResourceContext {
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual net::HostResolver* GetHostResolver() override {
|
net::HostResolver* GetHostResolver() override {
|
||||||
return getter_->host_resolver();
|
return getter_->host_resolver();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual net::URLRequestContext* GetRequestContext() override {
|
net::URLRequestContext* GetRequestContext() override {
|
||||||
return getter_->GetURLRequestContext();
|
return getter_->GetURLRequestContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,9 +40,9 @@ class BrowserContext : public content::BrowserContext,
|
||||||
virtual void RegisterPrefs(PrefRegistrySimple* pref_registry) {}
|
virtual void RegisterPrefs(PrefRegistrySimple* pref_registry) {}
|
||||||
|
|
||||||
// URLRequestContextGetter::Delegate:
|
// URLRequestContextGetter::Delegate:
|
||||||
virtual net::NetworkDelegate* CreateNetworkDelegate() override;
|
net::NetworkDelegate* CreateNetworkDelegate() override;
|
||||||
|
|
||||||
virtual base::FilePath GetPath() const override;
|
base::FilePath GetPath() const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class ResourceContext;
|
class ResourceContext;
|
||||||
|
|
|
@ -39,12 +39,12 @@ class BrowserMainParts : public content::BrowserMainParts {
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// content::BrowserMainParts:
|
// content::BrowserMainParts:
|
||||||
virtual void PreEarlyInitialization() override;
|
void PreEarlyInitialization() override;
|
||||||
virtual void ToolkitInitialized() override;
|
void ToolkitInitialized() override;
|
||||||
virtual void PreMainMessageLoopStart() override;
|
void PreMainMessageLoopStart() override;
|
||||||
virtual void PreMainMessageLoopRun() override;
|
void PreMainMessageLoopRun() override;
|
||||||
virtual void PostMainMessageLoopRun() override;
|
void PostMainMessageLoopRun() override;
|
||||||
virtual int PreCreateThreads() override;
|
int PreCreateThreads() override;
|
||||||
|
|
||||||
// Subclasses should override this to provide their own BrowserContxt
|
// Subclasses should override this to provide their own BrowserContxt
|
||||||
// implementation. The caller takes ownership of the returned object.
|
// implementation. The caller takes ownership of the returned object.
|
||||||
|
|
|
@ -11,21 +11,23 @@ namespace brightray {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
bool GetValue(const base::ListValue& list, int pos, std::string& value) {
|
using DispatchCallback = DevToolsEmbedderMessageDispatcher::DispatchCallback;
|
||||||
return list.GetString(pos, &value);
|
|
||||||
|
bool GetValue(const base::Value* value, std::string* result) {
|
||||||
|
return value->GetAsString(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GetValue(const base::ListValue& list, int pos, int& value) {
|
bool GetValue(const base::Value* value, int* result) {
|
||||||
return list.GetInteger(pos, &value);
|
return value->GetAsInteger(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GetValue(const base::ListValue& list, int pos, bool& value) {
|
bool GetValue(const base::Value* value, bool* result) {
|
||||||
return list.GetBoolean(pos, &value);
|
return value->GetAsBoolean(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GetValue(const base::ListValue& list, int pos, gfx::Rect& rect) {
|
bool GetValue(const base::Value* value, gfx::Rect* rect) {
|
||||||
const base::DictionaryValue* dict;
|
const base::DictionaryValue* dict;
|
||||||
if (!list.GetDictionary(pos, &dict))
|
if (!value->GetAsDictionary(&dict))
|
||||||
return false;
|
return false;
|
||||||
int x = 0;
|
int x = 0;
|
||||||
int y = 0;
|
int y = 0;
|
||||||
|
@ -36,217 +38,164 @@ bool GetValue(const base::ListValue& list, int pos, gfx::Rect& rect) {
|
||||||
!dict->GetInteger("width", &width) ||
|
!dict->GetInteger("width", &width) ||
|
||||||
!dict->GetInteger("height", &height))
|
!dict->GetInteger("height", &height))
|
||||||
return false;
|
return false;
|
||||||
rect.SetRect(x, y, width, height);
|
rect->SetRect(x, y, width, height);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct StorageTraits {
|
struct StorageTraits {
|
||||||
typedef T StorageType;
|
using StorageType = T;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct StorageTraits<const T&> {
|
struct StorageTraits<const T&> {
|
||||||
typedef T StorageType;
|
using StorageType = T;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class A>
|
template <typename... Ts>
|
||||||
class Argument {
|
struct ParamTuple {
|
||||||
public:
|
bool Parse(const base::ListValue& list,
|
||||||
typedef typename StorageTraits<A>::StorageType ValueType;
|
const base::ListValue::const_iterator& it) {
|
||||||
|
return it == list.end();
|
||||||
Argument(const base::ListValue& list, int pos) {
|
|
||||||
valid_ = GetValue(list, pos, value_);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ValueType value() const { return value_; }
|
template <typename H, typename... As>
|
||||||
bool valid() const { return valid_; }
|
void Apply(const H& handler, As... args) {
|
||||||
|
handler.Run(args...);
|
||||||
private:
|
}
|
||||||
ValueType value_;
|
|
||||||
bool valid_;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
bool ParseAndHandle0(const base::Callback<void(void)>& handler,
|
template <typename T, typename... Ts>
|
||||||
|
struct ParamTuple<T, Ts...> {
|
||||||
|
bool Parse(const base::ListValue& list,
|
||||||
|
const base::ListValue::const_iterator& it) {
|
||||||
|
return it != list.end() && GetValue(*it, &head) && tail.Parse(list, it + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename H, typename... As>
|
||||||
|
void Apply(const H& handler, As... args) {
|
||||||
|
tail.template Apply<H, As..., T>(handler, args..., head);
|
||||||
|
}
|
||||||
|
|
||||||
|
typename StorageTraits<T>::StorageType head;
|
||||||
|
ParamTuple<Ts...> tail;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename... As>
|
||||||
|
bool ParseAndHandle(const base::Callback<void(As...)>& handler,
|
||||||
|
const DispatchCallback& callback,
|
||||||
const base::ListValue& list) {
|
const base::ListValue& list) {
|
||||||
handler.Run();
|
ParamTuple<As...> tuple;
|
||||||
|
if (!tuple.Parse(list, list.begin()))
|
||||||
|
return false;
|
||||||
|
tuple.Apply(handler);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class A1>
|
template<typename... As>
|
||||||
bool ParseAndHandle1(const base::Callback<void(A1)>& handler,
|
bool ParseAndHandleWithCallback(
|
||||||
|
const base::Callback<void(const DispatchCallback&, As...)>& handler,
|
||||||
|
const DispatchCallback& callback,
|
||||||
const base::ListValue& list) {
|
const base::ListValue& list) {
|
||||||
if (list.GetSize() != 1)
|
ParamTuple<As...> tuple;
|
||||||
|
if (!tuple.Parse(list, list.begin()))
|
||||||
return false;
|
return false;
|
||||||
Argument<A1> arg1(list, 0);
|
tuple.Apply(handler, callback);
|
||||||
if (!arg1.valid())
|
|
||||||
return false;
|
|
||||||
handler.Run(arg1.value());
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class A1, class A2>
|
|
||||||
bool ParseAndHandle2(const base::Callback<void(A1, A2)>& handler,
|
|
||||||
const base::ListValue& list) {
|
|
||||||
if (list.GetSize() != 2)
|
|
||||||
return false;
|
|
||||||
Argument<A1> arg1(list, 0);
|
|
||||||
if (!arg1.valid())
|
|
||||||
return false;
|
|
||||||
Argument<A2> arg2(list, 1);
|
|
||||||
if (!arg2.valid())
|
|
||||||
return false;
|
|
||||||
handler.Run(arg1.value(), arg2.value());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class A1, class A2, class A3>
|
|
||||||
bool ParseAndHandle3(const base::Callback<void(A1, A2, A3)>& handler,
|
|
||||||
const base::ListValue& list) {
|
|
||||||
if (list.GetSize() != 3)
|
|
||||||
return false;
|
|
||||||
Argument<A1> arg1(list, 0);
|
|
||||||
if (!arg1.valid())
|
|
||||||
return false;
|
|
||||||
Argument<A2> arg2(list, 1);
|
|
||||||
if (!arg2.valid())
|
|
||||||
return false;
|
|
||||||
Argument<A3> arg3(list, 2);
|
|
||||||
if (!arg3.valid())
|
|
||||||
return false;
|
|
||||||
handler.Run(arg1.value(), arg2.value(), arg3.value());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class A1, class A2, class A3, class A4>
|
|
||||||
bool ParseAndHandle3(const base::Callback<void(A1, A2, A3, A4)>& handler,
|
|
||||||
const base::ListValue& list) {
|
|
||||||
if (list.GetSize() != 3)
|
|
||||||
return false;
|
|
||||||
Argument<A1> arg1(list, 0);
|
|
||||||
if (!arg1.valid())
|
|
||||||
return false;
|
|
||||||
Argument<A2> arg2(list, 1);
|
|
||||||
if (!arg2.valid())
|
|
||||||
return false;
|
|
||||||
Argument<A3> arg3(list, 2);
|
|
||||||
if (!arg3.valid())
|
|
||||||
return false;
|
|
||||||
Argument<A4> arg4(list, 3);
|
|
||||||
if (!arg4.valid())
|
|
||||||
return false;
|
|
||||||
handler.Run(arg1.value(), arg2.value(), arg3.value(), arg4.value());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
typedef base::Callback<bool (const base::ListValue&)> ListValueParser;
|
|
||||||
|
|
||||||
ListValueParser BindToListParser(const base::Callback<void()>& handler) {
|
|
||||||
return base::Bind(&ParseAndHandle0, handler);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class A1>
|
|
||||||
ListValueParser BindToListParser(const base::Callback<void(A1)>& handler) {
|
|
||||||
return base::Bind(&ParseAndHandle1<A1>, handler);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class A1, class A2>
|
|
||||||
ListValueParser BindToListParser(const base::Callback<void(A1, A2)>& handler) {
|
|
||||||
return base::Bind(&ParseAndHandle2<A1, A2>, handler);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class A1, class A2, class A3>
|
|
||||||
ListValueParser BindToListParser(
|
|
||||||
const base::Callback<void(A1, A2, A3)>& handler) {
|
|
||||||
return base::Bind(&ParseAndHandle3<A1, A2, A3>, handler);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class A1, class A2, class A3, class A4>
|
|
||||||
ListValueParser BindToListParser(
|
|
||||||
const base::Callback<void(A1, A2, A3, A4)>& handler) {
|
|
||||||
return base::Bind(&ParseAndHandle3<A1, A2, A3, A4>, handler);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
DevToolsEmbedderMessageDispatcher::DevToolsEmbedderMessageDispatcher(
|
/**
|
||||||
Delegate* delegate) {
|
* Dispatcher for messages sent from the frontend running in an
|
||||||
RegisterHandler("bringToFront",
|
* isolated renderer (chrome-devtools:// or chrome://inspect) to the embedder
|
||||||
BindToListParser(base::Bind(&Delegate::ActivateWindow,
|
* in the browser.
|
||||||
base::Unretained(delegate))));
|
*
|
||||||
RegisterHandler("closeWindow",
|
* The messages are sent via InspectorFrontendHost.sendMessageToEmbedder or
|
||||||
BindToListParser(base::Bind(&Delegate::CloseWindow,
|
* chrome.send method accordingly.
|
||||||
base::Unretained(delegate))));
|
*/
|
||||||
RegisterHandler("setInspectedPageBounds",
|
class DispatcherImpl : public DevToolsEmbedderMessageDispatcher {
|
||||||
BindToListParser(base::Bind(&Delegate::SetInspectedPageBounds,
|
public:
|
||||||
base::Unretained(delegate))));
|
~DispatcherImpl() override {}
|
||||||
RegisterHandler("inspectElementCompleted",
|
|
||||||
BindToListParser(base::Bind(&Delegate::InspectElementCompleted,
|
|
||||||
base::Unretained(delegate))));
|
|
||||||
RegisterHandler("moveWindowBy",
|
|
||||||
BindToListParser(base::Bind(&Delegate::MoveWindow,
|
|
||||||
base::Unretained(delegate))));
|
|
||||||
RegisterHandler("setIsDocked",
|
|
||||||
BindToListParser(base::Bind(&Delegate::SetIsDocked,
|
|
||||||
base::Unretained(delegate))));
|
|
||||||
RegisterHandler("openInNewTab",
|
|
||||||
BindToListParser(base::Bind(&Delegate::OpenInNewTab,
|
|
||||||
base::Unretained(delegate))));
|
|
||||||
RegisterHandler("save",
|
|
||||||
BindToListParser(base::Bind(&Delegate::SaveToFile,
|
|
||||||
base::Unretained(delegate))));
|
|
||||||
RegisterHandler("append",
|
|
||||||
BindToListParser(base::Bind(&Delegate::AppendToFile,
|
|
||||||
base::Unretained(delegate))));
|
|
||||||
RegisterHandler("requestFileSystems",
|
|
||||||
BindToListParser(base::Bind(&Delegate::RequestFileSystems,
|
|
||||||
base::Unretained(delegate))));
|
|
||||||
RegisterHandler("addFileSystem",
|
|
||||||
BindToListParser(base::Bind(&Delegate::AddFileSystem,
|
|
||||||
base::Unretained(delegate))));
|
|
||||||
RegisterHandler("removeFileSystem",
|
|
||||||
BindToListParser(base::Bind(&Delegate::RemoveFileSystem,
|
|
||||||
base::Unretained(delegate))));
|
|
||||||
RegisterHandler("upgradeDraggedFileSystemPermissions",
|
|
||||||
BindToListParser(base::Bind(&Delegate::UpgradeDraggedFileSystemPermissions,
|
|
||||||
base::Unretained(delegate))));
|
|
||||||
RegisterHandler("indexPath",
|
|
||||||
BindToListParser(base::Bind(&Delegate::IndexPath,
|
|
||||||
base::Unretained(delegate))));
|
|
||||||
RegisterHandler("stopIndexing",
|
|
||||||
BindToListParser(base::Bind(&Delegate::StopIndexing,
|
|
||||||
base::Unretained(delegate))));
|
|
||||||
RegisterHandler("searchInPath",
|
|
||||||
BindToListParser(base::Bind(&Delegate::SearchInPath,
|
|
||||||
base::Unretained(delegate))));
|
|
||||||
RegisterHandler("zoomIn",
|
|
||||||
BindToListParser(base::Bind(&Delegate::ZoomIn,
|
|
||||||
base::Unretained(delegate))));
|
|
||||||
RegisterHandler("zoomOut",
|
|
||||||
BindToListParser(base::Bind(&Delegate::ZoomOut,
|
|
||||||
base::Unretained(delegate))));
|
|
||||||
RegisterHandler("resetZoom",
|
|
||||||
BindToListParser(base::Bind(&Delegate::ResetZoom,
|
|
||||||
base::Unretained(delegate))));
|
|
||||||
}
|
|
||||||
|
|
||||||
DevToolsEmbedderMessageDispatcher::~DevToolsEmbedderMessageDispatcher() {}
|
bool Dispatch(const DispatchCallback& callback,
|
||||||
|
const std::string& method,
|
||||||
std::string DevToolsEmbedderMessageDispatcher::Dispatch(
|
const base::ListValue* params) override {
|
||||||
const std::string& method, base::ListValue* params) {
|
|
||||||
HandlerMap::iterator it = handlers_.find(method);
|
HandlerMap::iterator it = handlers_.find(method);
|
||||||
if (it == handlers_.end())
|
return it != handlers_.end() && it->second.Run(callback, *params);
|
||||||
return "Unsupported frontend host method: " + method;
|
|
||||||
|
|
||||||
if (!it->second.Run(*params))
|
|
||||||
return "Invalid frontend host message parameters: " + method;
|
|
||||||
return "";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DevToolsEmbedderMessageDispatcher::RegisterHandler(
|
template<typename... As>
|
||||||
const std::string& method, const Handler& handler) {
|
void RegisterHandler(const std::string& method,
|
||||||
handlers_[method] = handler;
|
void (Delegate::*handler)(As...),
|
||||||
|
Delegate* delegate) {
|
||||||
|
handlers_[method] = base::Bind(&ParseAndHandle<As...>,
|
||||||
|
base::Bind(handler,
|
||||||
|
base::Unretained(delegate)));
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename... As>
|
||||||
|
void RegisterHandlerWithCallback(
|
||||||
|
const std::string& method,
|
||||||
|
void (Delegate::*handler)(const DispatchCallback&, As...),
|
||||||
|
Delegate* delegate) {
|
||||||
|
handlers_[method] = base::Bind(&ParseAndHandleWithCallback<As...>,
|
||||||
|
base::Bind(handler,
|
||||||
|
base::Unretained(delegate)));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
using Handler = base::Callback<bool(const DispatchCallback&,
|
||||||
|
const base::ListValue&)>;
|
||||||
|
using HandlerMap = std::map<std::string, Handler>;
|
||||||
|
HandlerMap handlers_;
|
||||||
|
};
|
||||||
|
|
||||||
|
// static
|
||||||
|
DevToolsEmbedderMessageDispatcher*
|
||||||
|
DevToolsEmbedderMessageDispatcher::CreateForDevToolsFrontend(
|
||||||
|
Delegate* delegate) {
|
||||||
|
DispatcherImpl* d = new DispatcherImpl();
|
||||||
|
|
||||||
|
d->RegisterHandler("bringToFront", &Delegate::ActivateWindow, delegate);
|
||||||
|
d->RegisterHandler("closeWindow", &Delegate::CloseWindow, delegate);
|
||||||
|
d->RegisterHandler("loadCompleted", &Delegate::LoadCompleted, delegate);
|
||||||
|
d->RegisterHandler("setInspectedPageBounds",
|
||||||
|
&Delegate::SetInspectedPageBounds, delegate);
|
||||||
|
d->RegisterHandler("inspectElementCompleted",
|
||||||
|
&Delegate::InspectElementCompleted, delegate);
|
||||||
|
d->RegisterHandler("inspectedURLChanged",
|
||||||
|
&Delegate::InspectedURLChanged, delegate);
|
||||||
|
d->RegisterHandlerWithCallback("setIsDocked",
|
||||||
|
&Delegate::SetIsDocked, delegate);
|
||||||
|
d->RegisterHandler("openInNewTab", &Delegate::OpenInNewTab, delegate);
|
||||||
|
d->RegisterHandler("save", &Delegate::SaveToFile, delegate);
|
||||||
|
d->RegisterHandler("append", &Delegate::AppendToFile, delegate);
|
||||||
|
d->RegisterHandler("requestFileSystems",
|
||||||
|
&Delegate::RequestFileSystems, delegate);
|
||||||
|
d->RegisterHandler("addFileSystem", &Delegate::AddFileSystem, delegate);
|
||||||
|
d->RegisterHandler("removeFileSystem", &Delegate::RemoveFileSystem, delegate);
|
||||||
|
d->RegisterHandler("upgradeDraggedFileSystemPermissions",
|
||||||
|
&Delegate::UpgradeDraggedFileSystemPermissions, delegate);
|
||||||
|
d->RegisterHandler("indexPath", &Delegate::IndexPath, delegate);
|
||||||
|
d->RegisterHandlerWithCallback("loadNetworkResource",
|
||||||
|
&Delegate::LoadNetworkResource, delegate);
|
||||||
|
d->RegisterHandler("stopIndexing", &Delegate::StopIndexing, delegate);
|
||||||
|
d->RegisterHandler("searchInPath", &Delegate::SearchInPath, delegate);
|
||||||
|
d->RegisterHandler("setWhitelistedShortcuts",
|
||||||
|
&Delegate::SetWhitelistedShortcuts, delegate);
|
||||||
|
d->RegisterHandler("zoomIn", &Delegate::ZoomIn, delegate);
|
||||||
|
d->RegisterHandler("zoomOut", &Delegate::ZoomOut, delegate);
|
||||||
|
d->RegisterHandler("resetZoom", &Delegate::ResetZoom, delegate);
|
||||||
|
d->RegisterHandler("setDevicesUpdatesEnabled",
|
||||||
|
&Delegate::SetDevicesUpdatesEnabled, delegate);
|
||||||
|
d->RegisterHandler("sendMessageToBrowser",
|
||||||
|
&Delegate::SendMessageToBrowser, delegate);
|
||||||
|
d->RegisterHandler("recordActionUMA", &Delegate::RecordActionUMA, delegate);
|
||||||
|
d->RegisterHandlerWithCallback("sendJsonRequest",
|
||||||
|
&Delegate::SendJsonRequest, delegate);
|
||||||
|
return d;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace brightray
|
} // namespace brightray
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
|
|
||||||
namespace base {
|
namespace base {
|
||||||
class ListValue;
|
class ListValue;
|
||||||
|
class Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace brightray {
|
namespace brightray {
|
||||||
|
@ -29,14 +30,18 @@ class DevToolsEmbedderMessageDispatcher {
|
||||||
public:
|
public:
|
||||||
class Delegate {
|
class Delegate {
|
||||||
public:
|
public:
|
||||||
|
using DispatchCallback = base::Callback<void(const base::Value*)>;
|
||||||
|
|
||||||
virtual ~Delegate() {}
|
virtual ~Delegate() {}
|
||||||
|
|
||||||
virtual void ActivateWindow() = 0;
|
virtual void ActivateWindow() = 0;
|
||||||
virtual void CloseWindow() = 0;
|
virtual void CloseWindow() = 0;
|
||||||
|
virtual void LoadCompleted() = 0;
|
||||||
virtual void SetInspectedPageBounds(const gfx::Rect& rect) = 0;
|
virtual void SetInspectedPageBounds(const gfx::Rect& rect) = 0;
|
||||||
virtual void InspectElementCompleted() = 0;
|
virtual void InspectElementCompleted() = 0;
|
||||||
virtual void MoveWindow(int x, int y) = 0;
|
virtual void InspectedURLChanged(const std::string& url) = 0;
|
||||||
virtual void SetIsDocked(bool docked) = 0;
|
virtual void SetIsDocked(const DispatchCallback& callback,
|
||||||
|
bool is_docked) = 0;
|
||||||
virtual void OpenInNewTab(const std::string& url) = 0;
|
virtual void OpenInNewTab(const std::string& url) = 0;
|
||||||
virtual void SaveToFile(const std::string& url,
|
virtual void SaveToFile(const std::string& url,
|
||||||
const std::string& content,
|
const std::string& content,
|
||||||
|
@ -48,29 +53,37 @@ class DevToolsEmbedderMessageDispatcher {
|
||||||
virtual void RemoveFileSystem(const std::string& file_system_path) = 0;
|
virtual void RemoveFileSystem(const std::string& file_system_path) = 0;
|
||||||
virtual void UpgradeDraggedFileSystemPermissions(
|
virtual void UpgradeDraggedFileSystemPermissions(
|
||||||
const std::string& file_system_url) = 0;
|
const std::string& file_system_url) = 0;
|
||||||
virtual void IndexPath(int request_id,
|
virtual void IndexPath(int index_request_id,
|
||||||
const std::string& file_system_path) = 0;
|
const std::string& file_system_path) = 0;
|
||||||
virtual void StopIndexing(int request_id) = 0;
|
virtual void StopIndexing(int index_request_id) = 0;
|
||||||
virtual void SearchInPath(int request_id,
|
virtual void LoadNetworkResource(const DispatchCallback& callback,
|
||||||
|
const std::string& url,
|
||||||
|
const std::string& headers,
|
||||||
|
int stream_id) = 0;
|
||||||
|
virtual void SearchInPath(int search_request_id,
|
||||||
const std::string& file_system_path,
|
const std::string& file_system_path,
|
||||||
const std::string& query) = 0;
|
const std::string& query) = 0;
|
||||||
|
virtual void SetWhitelistedShortcuts(const std::string& message) = 0;
|
||||||
virtual void ZoomIn() = 0;
|
virtual void ZoomIn() = 0;
|
||||||
virtual void ZoomOut() = 0;
|
virtual void ZoomOut() = 0;
|
||||||
virtual void ResetZoom() = 0;
|
virtual void ResetZoom() = 0;
|
||||||
|
virtual void SetDevicesUpdatesEnabled(bool enabled) = 0;
|
||||||
|
virtual void SendMessageToBrowser(const std::string& message) = 0;
|
||||||
|
virtual void RecordActionUMA(const std::string& name, int action) = 0;
|
||||||
|
virtual void SendJsonRequest(const DispatchCallback& callback,
|
||||||
|
const std::string& browser_id,
|
||||||
|
const std::string& url) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
explicit DevToolsEmbedderMessageDispatcher(Delegate* delegate);
|
using DispatchCallback = Delegate::DispatchCallback;
|
||||||
|
|
||||||
~DevToolsEmbedderMessageDispatcher();
|
virtual ~DevToolsEmbedderMessageDispatcher() {}
|
||||||
|
virtual bool Dispatch(const DispatchCallback& callback,
|
||||||
|
const std::string& method,
|
||||||
|
const base::ListValue* params) = 0;
|
||||||
|
|
||||||
std::string Dispatch(const std::string& method, base::ListValue* params);
|
static DevToolsEmbedderMessageDispatcher* CreateForDevToolsFrontend(
|
||||||
|
Delegate* delegate);
|
||||||
private:
|
|
||||||
typedef base::Callback<bool (const base::ListValue&)> Handler;
|
|
||||||
void RegisterHandler(const std::string& method, const Handler& handler);
|
|
||||||
|
|
||||||
typedef std::map<std::string, Handler> HandlerMap;
|
|
||||||
HandlerMap handlers_;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace brightray
|
} // namespace brightray
|
||||||
|
|
|
@ -52,15 +52,14 @@ std::string GetMimeTypeForPath(const std::string& path) {
|
||||||
|
|
||||||
class BundledDataSource : public content::URLDataSource {
|
class BundledDataSource : public content::URLDataSource {
|
||||||
public:
|
public:
|
||||||
explicit BundledDataSource() {
|
BundledDataSource() {}
|
||||||
}
|
|
||||||
|
|
||||||
// content::URLDataSource implementation.
|
// content::URLDataSource implementation.
|
||||||
virtual std::string GetSource() const override {
|
std::string GetSource() const override {
|
||||||
return kChromeUIDevToolsBundledHost;
|
return kChromeUIDevToolsBundledHost;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void StartDataRequest(const std::string& path,
|
void StartDataRequest(const std::string& path,
|
||||||
int render_process_id,
|
int render_process_id,
|
||||||
int render_view_id,
|
int render_view_id,
|
||||||
const GotDataCallback& callback) override {
|
const GotDataCallback& callback) override {
|
||||||
|
@ -79,19 +78,19 @@ class BundledDataSource : public content::URLDataSource {
|
||||||
callback.Run(bytes.get());
|
callback.Run(bytes.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual std::string GetMimeType(const std::string& path) const override {
|
std::string GetMimeType(const std::string& path) const override {
|
||||||
return GetMimeTypeForPath(path);
|
return GetMimeTypeForPath(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool ShouldAddContentSecurityPolicy() const override {
|
bool ShouldAddContentSecurityPolicy() const override {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool ShouldDenyXFrameOptions() const override {
|
bool ShouldDenyXFrameOptions() const override {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool ShouldServeMimeTypeAsContentTypeHeader() const override {
|
bool ShouldServeMimeTypeAsContentTypeHeader() const override {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,10 @@
|
||||||
|
|
||||||
#include "content/public/browser/web_contents.h"
|
#include "content/public/browser/web_contents.h"
|
||||||
|
|
||||||
|
namespace base {
|
||||||
|
class Value;
|
||||||
|
}
|
||||||
|
|
||||||
namespace content {
|
namespace content {
|
||||||
class DevToolsAgentHost;
|
class DevToolsAgentHost;
|
||||||
}
|
}
|
||||||
|
@ -14,8 +18,7 @@ class InspectableWebContentsView;
|
||||||
|
|
||||||
class InspectableWebContents {
|
class InspectableWebContents {
|
||||||
public:
|
public:
|
||||||
static InspectableWebContents* Create(
|
static InspectableWebContents* Create(const content::WebContents::CreateParams&);
|
||||||
const content::WebContents::CreateParams&);
|
|
||||||
|
|
||||||
// The returned InspectableWebContents takes ownership of the passed-in
|
// The returned InspectableWebContents takes ownership of the passed-in
|
||||||
// WebContents.
|
// WebContents.
|
||||||
|
@ -26,16 +29,20 @@ class InspectableWebContents {
|
||||||
virtual InspectableWebContentsView* GetView() const = 0;
|
virtual InspectableWebContentsView* GetView() const = 0;
|
||||||
virtual content::WebContents* GetWebContents() const = 0;
|
virtual content::WebContents* GetWebContents() const = 0;
|
||||||
|
|
||||||
virtual void SetCanDock(bool can_dock) = 0;
|
|
||||||
virtual void ShowDevTools() = 0;
|
|
||||||
// Close the DevTools completely instead of just hide it.
|
|
||||||
virtual void CloseDevTools() = 0;
|
|
||||||
virtual bool IsDevToolsViewShowing() = 0;
|
|
||||||
virtual void AttachTo(const scoped_refptr<content::DevToolsAgentHost>&) = 0;
|
|
||||||
|
|
||||||
// The delegate manages its own life.
|
// The delegate manages its own life.
|
||||||
virtual void SetDelegate(InspectableWebContentsDelegate* delegate) = 0;
|
virtual void SetDelegate(InspectableWebContentsDelegate* delegate) = 0;
|
||||||
virtual InspectableWebContentsDelegate* GetDelegate() const = 0;
|
virtual InspectableWebContentsDelegate* GetDelegate() const = 0;
|
||||||
|
|
||||||
|
virtual void SetCanDock(bool can_dock) = 0;
|
||||||
|
virtual void ShowDevTools() = 0;
|
||||||
|
virtual void CloseDevTools() = 0;
|
||||||
|
virtual bool IsDevToolsViewShowing() = 0;
|
||||||
|
virtual void AttachTo(const scoped_refptr<content::DevToolsAgentHost>&) = 0;
|
||||||
|
virtual void Detach() = 0;
|
||||||
|
virtual void CallClientFunction(const std::string& function_name,
|
||||||
|
const base::Value* arg1,
|
||||||
|
const base::Value* arg2,
|
||||||
|
const base::Value* arg3) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace brightray
|
} // namespace brightray
|
||||||
|
|
|
@ -12,15 +12,21 @@
|
||||||
#include "browser/inspectable_web_contents_view.h"
|
#include "browser/inspectable_web_contents_view.h"
|
||||||
|
|
||||||
#include "base/json/json_reader.h"
|
#include "base/json/json_reader.h"
|
||||||
|
#include "base/json/json_writer.h"
|
||||||
|
#include "base/metrics/histogram.h"
|
||||||
#include "base/prefs/pref_registry_simple.h"
|
#include "base/prefs/pref_registry_simple.h"
|
||||||
#include "base/prefs/pref_service.h"
|
#include "base/prefs/pref_service.h"
|
||||||
#include "base/strings/stringprintf.h"
|
#include "base/strings/stringprintf.h"
|
||||||
#include "base/strings/utf_string_conversions.h"
|
#include "base/strings/utf_string_conversions.h"
|
||||||
#include "base/values.h"
|
#include "base/values.h"
|
||||||
|
#include "content/public/browser/browser_thread.h"
|
||||||
#include "content/public/browser/devtools_http_handler.h"
|
#include "content/public/browser/devtools_http_handler.h"
|
||||||
#include "content/public/browser/host_zoom_map.h"
|
#include "content/public/browser/host_zoom_map.h"
|
||||||
#include "content/public/browser/render_frame_host.h"
|
#include "content/public/browser/render_frame_host.h"
|
||||||
#include "content/public/browser/render_view_host.h"
|
#include "content/public/browser/render_view_host.h"
|
||||||
|
#include "net/http/http_response_headers.h"
|
||||||
|
#include "net/url_request/url_fetcher.h"
|
||||||
|
#include "net/url_request/url_fetcher_response_writer.h"
|
||||||
|
|
||||||
namespace brightray {
|
namespace brightray {
|
||||||
|
|
||||||
|
@ -41,6 +47,13 @@ const char kFrontendHostId[] = "id";
|
||||||
const char kFrontendHostMethod[] = "method";
|
const char kFrontendHostMethod[] = "method";
|
||||||
const char kFrontendHostParams[] = "params";
|
const char kFrontendHostParams[] = "params";
|
||||||
|
|
||||||
|
const char kDevToolsActionTakenHistogram[] = "DevTools.ActionTaken";
|
||||||
|
const int kDevToolsActionTakenBoundary = 100;
|
||||||
|
const char kDevToolsPanelShownHistogram[] = "DevTools.PanelShown";
|
||||||
|
const int kDevToolsPanelShownBoundary = 20;
|
||||||
|
|
||||||
|
const size_t kMaxMessageChunkSize = IPC::Channel::kMaximumMessageSize / 4;
|
||||||
|
|
||||||
void RectToDictionary(const gfx::Rect& bounds, base::DictionaryValue* dict) {
|
void RectToDictionary(const gfx::Rect& bounds, base::DictionaryValue* dict) {
|
||||||
dict->SetInteger("x", bounds.x());
|
dict->SetInteger("x", bounds.x());
|
||||||
dict->SetInteger("y", bounds.y());
|
dict->SetInteger("y", bounds.y());
|
||||||
|
@ -57,34 +70,6 @@ void DictionaryToRect(const base::DictionaryValue& dict, gfx::Rect* bounds) {
|
||||||
*bounds = gfx::Rect(x, y, width, height);
|
*bounds = gfx::Rect(x, y, width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ParseMessage(const std::string& message,
|
|
||||||
std::string* method,
|
|
||||||
base::ListValue* params,
|
|
||||||
int* id) {
|
|
||||||
scoped_ptr<base::Value> parsed_message(base::JSONReader::Read(message));
|
|
||||||
if (!parsed_message)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
base::DictionaryValue* dict = NULL;
|
|
||||||
if (!parsed_message->GetAsDictionary(&dict))
|
|
||||||
return false;
|
|
||||||
if (!dict->GetString(kFrontendHostMethod, method))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
// "params" is optional.
|
|
||||||
if (dict->HasKey(kFrontendHostParams)) {
|
|
||||||
base::ListValue* internal_params;
|
|
||||||
if (dict->GetList(kFrontendHostParams, &internal_params))
|
|
||||||
params->Swap(internal_params);
|
|
||||||
else
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
*id = 0;
|
|
||||||
dict->GetInteger(kFrontendHostId, id);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
double GetZoomLevelForWebContents(content::WebContents* web_contents) {
|
double GetZoomLevelForWebContents(content::WebContents* web_contents) {
|
||||||
return content::HostZoomMap::GetZoomLevel(web_contents);
|
return content::HostZoomMap::GetZoomLevel(web_contents);
|
||||||
}
|
}
|
||||||
|
@ -107,6 +92,59 @@ double GetNextZoomLevel(double level, bool out) {
|
||||||
return level;
|
return level;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ResponseWriter -------------------------------------------------------------
|
||||||
|
|
||||||
|
class ResponseWriter : public net::URLFetcherResponseWriter {
|
||||||
|
public:
|
||||||
|
ResponseWriter(base::WeakPtr<InspectableWebContentsImpl> bindings, int stream_id);
|
||||||
|
~ResponseWriter() override;
|
||||||
|
|
||||||
|
// URLFetcherResponseWriter overrides:
|
||||||
|
int Initialize(const net::CompletionCallback& callback) override;
|
||||||
|
int Write(net::IOBuffer* buffer,
|
||||||
|
int num_bytes,
|
||||||
|
const net::CompletionCallback& callback) override;
|
||||||
|
int Finish(const net::CompletionCallback& callback) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
base::WeakPtr<InspectableWebContentsImpl> bindings_;
|
||||||
|
int stream_id_;
|
||||||
|
|
||||||
|
DISALLOW_COPY_AND_ASSIGN(ResponseWriter);
|
||||||
|
};
|
||||||
|
|
||||||
|
ResponseWriter::ResponseWriter(base::WeakPtr<InspectableWebContentsImpl> bindings,
|
||||||
|
int stream_id)
|
||||||
|
: bindings_(bindings),
|
||||||
|
stream_id_(stream_id) {
|
||||||
|
}
|
||||||
|
|
||||||
|
ResponseWriter::~ResponseWriter() {
|
||||||
|
}
|
||||||
|
|
||||||
|
int ResponseWriter::Initialize(const net::CompletionCallback& callback) {
|
||||||
|
return net::OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ResponseWriter::Write(net::IOBuffer* buffer,
|
||||||
|
int num_bytes,
|
||||||
|
const net::CompletionCallback& callback) {
|
||||||
|
base::FundamentalValue* id = new base::FundamentalValue(stream_id_);
|
||||||
|
base::StringValue* chunk =
|
||||||
|
new base::StringValue(std::string(buffer->data(), num_bytes));
|
||||||
|
|
||||||
|
content::BrowserThread::PostTask(
|
||||||
|
content::BrowserThread::UI, FROM_HERE,
|
||||||
|
base::Bind(&InspectableWebContentsImpl::CallClientFunction,
|
||||||
|
bindings_, "DevToolsAPI.streamWrite",
|
||||||
|
base::Owned(id), base::Owned(chunk), nullptr));
|
||||||
|
return num_bytes;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ResponseWriter::Finish(const net::CompletionCallback& callback) {
|
||||||
|
return net::OK;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
// Implemented separately on each platform.
|
// Implemented separately on each platform.
|
||||||
|
@ -122,8 +160,10 @@ void InspectableWebContentsImpl::RegisterPrefs(PrefRegistrySimple* registry) {
|
||||||
InspectableWebContentsImpl::InspectableWebContentsImpl(
|
InspectableWebContentsImpl::InspectableWebContentsImpl(
|
||||||
content::WebContents* web_contents)
|
content::WebContents* web_contents)
|
||||||
: web_contents_(web_contents),
|
: web_contents_(web_contents),
|
||||||
|
frontend_loaded_(false),
|
||||||
can_dock_(true),
|
can_dock_(true),
|
||||||
delegate_(nullptr) {
|
delegate_(nullptr),
|
||||||
|
weak_factory_(this) {
|
||||||
auto context = static_cast<BrowserContext*>(web_contents_->GetBrowserContext());
|
auto context = static_cast<BrowserContext*>(web_contents_->GetBrowserContext());
|
||||||
auto bounds_dict = context->prefs()->GetDictionary(kDevToolsBoundsPref);
|
auto bounds_dict = context->prefs()->GetDictionary(kDevToolsBoundsPref);
|
||||||
if (bounds_dict)
|
if (bounds_dict)
|
||||||
|
@ -143,6 +183,14 @@ content::WebContents* InspectableWebContentsImpl::GetWebContents() const {
|
||||||
return web_contents_.get();
|
return web_contents_.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void InspectableWebContentsImpl::SetDelegate(InspectableWebContentsDelegate* delegate) {
|
||||||
|
delegate_ = delegate;
|
||||||
|
}
|
||||||
|
|
||||||
|
InspectableWebContentsDelegate* InspectableWebContentsImpl::GetDelegate() const {
|
||||||
|
return delegate_;
|
||||||
|
}
|
||||||
|
|
||||||
void InspectableWebContentsImpl::SetCanDock(bool can_dock) {
|
void InspectableWebContentsImpl::SetCanDock(bool can_dock) {
|
||||||
can_dock_ = can_dock;
|
can_dock_ = can_dock;
|
||||||
}
|
}
|
||||||
|
@ -152,7 +200,7 @@ void InspectableWebContentsImpl::ShowDevTools() {
|
||||||
// SetIsDocked is called *BEFORE* ShowDevTools.
|
// SetIsDocked is called *BEFORE* ShowDevTools.
|
||||||
if (!devtools_web_contents_) {
|
if (!devtools_web_contents_) {
|
||||||
embedder_message_dispatcher_.reset(
|
embedder_message_dispatcher_.reset(
|
||||||
new DevToolsEmbedderMessageDispatcher(this));
|
DevToolsEmbedderMessageDispatcher::CreateForDevToolsFrontend(this));
|
||||||
|
|
||||||
content::WebContents::CreateParams create_params(web_contents_->GetBrowserContext());
|
content::WebContents::CreateParams create_params(web_contents_->GetBrowserContext());
|
||||||
devtools_web_contents_.reset(content::WebContents::Create(create_params));
|
devtools_web_contents_.reset(content::WebContents::Create(create_params));
|
||||||
|
@ -200,6 +248,29 @@ void InspectableWebContentsImpl::Detach() {
|
||||||
agent_host_ = nullptr;
|
agent_host_ = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void InspectableWebContentsImpl::CallClientFunction(const std::string& function_name,
|
||||||
|
const base::Value* arg1,
|
||||||
|
const base::Value* arg2,
|
||||||
|
const base::Value* arg3) {
|
||||||
|
std::string javascript = function_name + "(";
|
||||||
|
if (arg1) {
|
||||||
|
std::string json;
|
||||||
|
base::JSONWriter::Write(arg1, &json);
|
||||||
|
javascript.append(json);
|
||||||
|
if (arg2) {
|
||||||
|
base::JSONWriter::Write(arg2, &json);
|
||||||
|
javascript.append(", ").append(json);
|
||||||
|
if (arg3) {
|
||||||
|
base::JSONWriter::Write(arg3, &json);
|
||||||
|
javascript.append(", ").append(json);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
javascript.append(");");
|
||||||
|
devtools_web_contents_->GetMainFrame()->ExecuteJavaScript(
|
||||||
|
base::UTF8ToUTF16(javascript));
|
||||||
|
}
|
||||||
|
|
||||||
gfx::Rect InspectableWebContentsImpl::GetDevToolsBounds() const {
|
gfx::Rect InspectableWebContentsImpl::GetDevToolsBounds() const {
|
||||||
return devtools_bounds_;
|
return devtools_bounds_;
|
||||||
}
|
}
|
||||||
|
@ -219,6 +290,15 @@ void InspectableWebContentsImpl::CloseWindow() {
|
||||||
devtools_web_contents()->DispatchBeforeUnload(false);
|
devtools_web_contents()->DispatchBeforeUnload(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void InspectableWebContentsImpl::LoadCompleted() {
|
||||||
|
frontend_loaded_ = true;
|
||||||
|
view_->ShowDevTools();
|
||||||
|
|
||||||
|
// If the devtools can dock, "SetIsDocked" will be called by devtools itself.
|
||||||
|
if (!can_dock_)
|
||||||
|
SetIsDocked(DispatchCallback(), false);
|
||||||
|
}
|
||||||
|
|
||||||
void InspectableWebContentsImpl::SetInspectedPageBounds(const gfx::Rect& rect) {
|
void InspectableWebContentsImpl::SetInspectedPageBounds(const gfx::Rect& rect) {
|
||||||
DevToolsContentsResizingStrategy strategy(rect);
|
DevToolsContentsResizingStrategy strategy(rect);
|
||||||
if (contents_resizing_strategy_.Equals(strategy))
|
if (contents_resizing_strategy_.Equals(strategy))
|
||||||
|
@ -231,11 +311,39 @@ void InspectableWebContentsImpl::SetInspectedPageBounds(const gfx::Rect& rect) {
|
||||||
void InspectableWebContentsImpl::InspectElementCompleted() {
|
void InspectableWebContentsImpl::InspectElementCompleted() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void InspectableWebContentsImpl::MoveWindow(int x, int y) {
|
void InspectableWebContentsImpl::InspectedURLChanged(const std::string& url) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void InspectableWebContentsImpl::SetIsDocked(bool docked) {
|
void InspectableWebContentsImpl::LoadNetworkResource(
|
||||||
|
const DispatchCallback& callback,
|
||||||
|
const std::string& url,
|
||||||
|
const std::string& headers,
|
||||||
|
int stream_id) {
|
||||||
|
GURL gurl(url);
|
||||||
|
if (!gurl.is_valid()) {
|
||||||
|
base::DictionaryValue response;
|
||||||
|
response.SetInteger("statusCode", 404);
|
||||||
|
callback.Run(&response);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto browser_context = static_cast<BrowserContext*>(devtools_web_contents_->GetBrowserContext());
|
||||||
|
|
||||||
|
net::URLFetcher* fetcher =
|
||||||
|
net::URLFetcher::Create(gurl, net::URLFetcher::GET, this);
|
||||||
|
pending_requests_[fetcher] = callback;
|
||||||
|
fetcher->SetRequestContext(browser_context->url_request_context_getter());
|
||||||
|
fetcher->SetExtraRequestHeaders(headers);
|
||||||
|
fetcher->SaveResponseWithWriter(scoped_ptr<net::URLFetcherResponseWriter>(
|
||||||
|
new ResponseWriter(weak_factory_.GetWeakPtr(), stream_id)));
|
||||||
|
fetcher->Start();
|
||||||
|
}
|
||||||
|
|
||||||
|
void InspectableWebContentsImpl::SetIsDocked(const DispatchCallback& callback,
|
||||||
|
bool docked) {
|
||||||
view_->SetIsDocked(docked);
|
view_->SetIsDocked(docked);
|
||||||
|
if (!callback.is_null())
|
||||||
|
callback.Run(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void InspectableWebContentsImpl::OpenInNewTab(const std::string& url) {
|
void InspectableWebContentsImpl::OpenInNewTab(const std::string& url) {
|
||||||
|
@ -253,12 +361,6 @@ void InspectableWebContentsImpl::AppendToFile(
|
||||||
delegate_->DevToolsAppendToFile(url, content);
|
delegate_->DevToolsAppendToFile(url, content);
|
||||||
}
|
}
|
||||||
|
|
||||||
void InspectableWebContentsImpl::WebContentsFocused(
|
|
||||||
content::WebContents* contents) {
|
|
||||||
if (delegate_)
|
|
||||||
delegate_->DevToolsFocused();
|
|
||||||
}
|
|
||||||
|
|
||||||
void InspectableWebContentsImpl::RequestFileSystems() {
|
void InspectableWebContentsImpl::RequestFileSystems() {
|
||||||
devtools_web_contents()->GetMainFrame()->ExecuteJavaScript(
|
devtools_web_contents()->GetMainFrame()->ExecuteJavaScript(
|
||||||
base::ASCIIToUTF16("DevToolsAPI.fileSystemsLoaded([])"));
|
base::ASCIIToUTF16("DevToolsAPI.fileSystemsLoaded([])"));
|
||||||
|
@ -292,6 +394,9 @@ void InspectableWebContentsImpl::SearchInPath(
|
||||||
const std::string& query) {
|
const std::string& query) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void InspectableWebContentsImpl::SetWhitelistedShortcuts(const std::string& message) {
|
||||||
|
}
|
||||||
|
|
||||||
void InspectableWebContentsImpl::ZoomIn() {
|
void InspectableWebContentsImpl::ZoomIn() {
|
||||||
double level = GetZoomLevelForWebContents(devtools_web_contents());
|
double level = GetZoomLevelForWebContents(devtools_web_contents());
|
||||||
SetZoomLevelForWebContents(devtools_web_contents(), GetNextZoomLevel(level, false));
|
SetZoomLevelForWebContents(devtools_web_contents(), GetNextZoomLevel(level, false));
|
||||||
|
@ -306,33 +411,76 @@ void InspectableWebContentsImpl::ResetZoom() {
|
||||||
SetZoomLevelForWebContents(devtools_web_contents(), 0.);
|
SetZoomLevelForWebContents(devtools_web_contents(), 0.);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void InspectableWebContentsImpl::SetDevicesUpdatesEnabled(bool enabled) {
|
||||||
|
}
|
||||||
|
|
||||||
|
void InspectableWebContentsImpl::SendMessageToBrowser(const std::string& message) {
|
||||||
|
if (agent_host_.get())
|
||||||
|
agent_host_->DispatchProtocolMessage(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
void InspectableWebContentsImpl::RecordActionUMA(const std::string& name, int action) {
|
||||||
|
if (name == kDevToolsActionTakenHistogram)
|
||||||
|
UMA_HISTOGRAM_ENUMERATION(name, action, kDevToolsActionTakenBoundary);
|
||||||
|
else if (name == kDevToolsPanelShownHistogram)
|
||||||
|
UMA_HISTOGRAM_ENUMERATION(name, action, kDevToolsPanelShownBoundary);
|
||||||
|
}
|
||||||
|
|
||||||
|
void InspectableWebContentsImpl::SendJsonRequest(const DispatchCallback& callback,
|
||||||
|
const std::string& browser_id,
|
||||||
|
const std::string& url) {
|
||||||
|
callback.Run(nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
void InspectableWebContentsImpl::HandleMessageFromDevToolsFrontend(const std::string& message) {
|
void InspectableWebContentsImpl::HandleMessageFromDevToolsFrontend(const std::string& message) {
|
||||||
std::string method;
|
std::string method;
|
||||||
base::ListValue params;
|
base::ListValue empty_params;
|
||||||
int id;
|
base::ListValue* params = &empty_params;
|
||||||
if (!ParseMessage(message, &method, ¶ms, &id)) {
|
|
||||||
|
base::DictionaryValue* dict = nullptr;
|
||||||
|
scoped_ptr<base::Value> parsed_message(base::JSONReader::Read(message));
|
||||||
|
if (!parsed_message ||
|
||||||
|
!parsed_message->GetAsDictionary(&dict) ||
|
||||||
|
!dict->GetString(kFrontendHostMethod, &method) ||
|
||||||
|
(dict->HasKey(kFrontendHostParams) &&
|
||||||
|
!dict->GetList(kFrontendHostParams, ¶ms))) {
|
||||||
LOG(ERROR) << "Invalid message was sent to embedder: " << message;
|
LOG(ERROR) << "Invalid message was sent to embedder: " << message;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
int id = 0;
|
||||||
std::string error = embedder_message_dispatcher_->Dispatch(method, ¶ms);
|
dict->GetInteger(kFrontendHostId, &id);
|
||||||
if (id) {
|
embedder_message_dispatcher_->Dispatch(
|
||||||
std::string ack = base::StringPrintf(
|
base::Bind(&InspectableWebContentsImpl::SendMessageAck,
|
||||||
"DevToolsAPI.embedderMessageAck(%d, \"%s\");", id, error.c_str());
|
weak_factory_.GetWeakPtr(),
|
||||||
devtools_web_contents()->GetMainFrame()->ExecuteJavaScript(base::UTF8ToUTF16(ack));
|
id),
|
||||||
}
|
method,
|
||||||
|
params);
|
||||||
}
|
}
|
||||||
|
|
||||||
void InspectableWebContentsImpl::HandleMessageFromDevToolsFrontendToBackend(
|
void InspectableWebContentsImpl::HandleMessageFromDevToolsFrontendToBackend(
|
||||||
const std::string& message) {
|
const std::string& message) {
|
||||||
|
if (agent_host_.get())
|
||||||
agent_host_->DispatchProtocolMessage(message);
|
agent_host_->DispatchProtocolMessage(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
void InspectableWebContentsImpl::DispatchProtocolMessage(
|
void InspectableWebContentsImpl::DispatchProtocolMessage(
|
||||||
content::DevToolsAgentHost* agent_host, const std::string& message) {
|
content::DevToolsAgentHost* agent_host, const std::string& message) {
|
||||||
std::string code = "DevToolsAPI.dispatchMessage(" + message + ");";
|
if (!frontend_loaded_)
|
||||||
base::string16 javascript = base::UTF8ToUTF16(code);
|
return;
|
||||||
web_contents()->GetMainFrame()->ExecuteJavaScript(javascript);
|
|
||||||
|
if (message.length() < kMaxMessageChunkSize) {
|
||||||
|
base::string16 javascript = base::UTF8ToUTF16(
|
||||||
|
"DevToolsAPI.dispatchMessage(" + message + ");");
|
||||||
|
devtools_web_contents_->GetMainFrame()->ExecuteJavaScript(javascript);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
base::FundamentalValue total_size(static_cast<int>(message.length()));
|
||||||
|
for (size_t pos = 0; pos < message.length(); pos += kMaxMessageChunkSize) {
|
||||||
|
base::StringValue message_value(message.substr(pos, kMaxMessageChunkSize));
|
||||||
|
CallClientFunction("DevToolsAPI.dispatchMessageChunk",
|
||||||
|
&message_value, pos ? nullptr : &total_size, nullptr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void InspectableWebContentsImpl::AgentHostClosed(
|
void InspectableWebContentsImpl::AgentHostClosed(
|
||||||
|
@ -347,22 +495,15 @@ void InspectableWebContentsImpl::AboutToNavigateRenderFrame(
|
||||||
frontend_host_.reset(content::DevToolsFrontendHost::Create(new_host, this));
|
frontend_host_.reset(content::DevToolsFrontendHost::Create(new_host, this));
|
||||||
}
|
}
|
||||||
|
|
||||||
void InspectableWebContentsImpl::DidFinishLoad(content::RenderFrameHost* render_frame_host,
|
|
||||||
const GURL& validated_url) {
|
|
||||||
if (render_frame_host->GetParent())
|
|
||||||
return;
|
|
||||||
|
|
||||||
view_->ShowDevTools();
|
|
||||||
|
|
||||||
// If the devtools can dock, "SetIsDocked" will be called by devtools itself.
|
|
||||||
if (!can_dock_)
|
|
||||||
SetIsDocked(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
void InspectableWebContentsImpl::WebContentsDestroyed() {
|
void InspectableWebContentsImpl::WebContentsDestroyed() {
|
||||||
agent_host_->DetachClient();
|
frontend_loaded_ = false;
|
||||||
Observe(nullptr);
|
Observe(nullptr);
|
||||||
|
Detach();
|
||||||
agent_host_ = nullptr;
|
agent_host_ = nullptr;
|
||||||
|
embedder_message_dispatcher_ = nullptr;
|
||||||
|
|
||||||
|
for (const auto& pair : pending_requests_)
|
||||||
|
delete pair.first;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool InspectableWebContentsImpl::AddMessageToConsole(
|
bool InspectableWebContentsImpl::AddMessageToConsole(
|
||||||
|
@ -400,4 +541,39 @@ void InspectableWebContentsImpl::CloseContents(content::WebContents* source) {
|
||||||
CloseDevTools();
|
CloseDevTools();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void InspectableWebContentsImpl::WebContentsFocused(
|
||||||
|
content::WebContents* contents) {
|
||||||
|
if (delegate_)
|
||||||
|
delegate_->DevToolsFocused();
|
||||||
|
}
|
||||||
|
|
||||||
|
void InspectableWebContentsImpl::OnURLFetchComplete(const net::URLFetcher* source) {
|
||||||
|
DCHECK(source);
|
||||||
|
PendingRequestsMap::iterator it = pending_requests_.find(source);
|
||||||
|
DCHECK(it != pending_requests_.end());
|
||||||
|
|
||||||
|
base::DictionaryValue response;
|
||||||
|
base::DictionaryValue* headers = new base::DictionaryValue();
|
||||||
|
net::HttpResponseHeaders* rh = source->GetResponseHeaders();
|
||||||
|
response.SetInteger("statusCode", rh ? rh->response_code() : 200);
|
||||||
|
response.Set("headers", headers);
|
||||||
|
|
||||||
|
void* iterator = nullptr;
|
||||||
|
std::string name;
|
||||||
|
std::string value;
|
||||||
|
while (rh && rh->EnumerateHeaderLines(&iterator, &name, &value))
|
||||||
|
headers->SetString(name, value);
|
||||||
|
|
||||||
|
it->second.Run(&response);
|
||||||
|
pending_requests_.erase(it);
|
||||||
|
delete source;
|
||||||
|
}
|
||||||
|
|
||||||
|
void InspectableWebContentsImpl::SendMessageAck(int request_id,
|
||||||
|
const base::Value* arg) {
|
||||||
|
base::FundamentalValue id_value(request_id);
|
||||||
|
CallClientFunction("DevToolsAPI.embedderMessageAck",
|
||||||
|
&id_value, arg, nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace brightray
|
} // namespace brightray
|
||||||
|
|
|
@ -11,10 +11,12 @@
|
||||||
#include "browser/devtools_contents_resizing_strategy.h"
|
#include "browser/devtools_contents_resizing_strategy.h"
|
||||||
#include "browser/devtools_embedder_message_dispatcher.h"
|
#include "browser/devtools_embedder_message_dispatcher.h"
|
||||||
|
|
||||||
|
#include "base/memory/weak_ptr.h"
|
||||||
#include "content/public/browser/devtools_agent_host.h"
|
#include "content/public/browser/devtools_agent_host.h"
|
||||||
#include "content/public/browser/devtools_frontend_host.h"
|
#include "content/public/browser/devtools_frontend_host.h"
|
||||||
#include "content/public/browser/web_contents_delegate.h"
|
#include "content/public/browser/web_contents_delegate.h"
|
||||||
#include "content/public/browser/web_contents_observer.h"
|
#include "content/public/browser/web_contents_observer.h"
|
||||||
|
#include "net/url_request/url_fetcher_delegate.h"
|
||||||
#include "ui/gfx/geometry/rect.h"
|
#include "ui/gfx/geometry/rect.h"
|
||||||
|
|
||||||
class PrefRegistrySimple;
|
class PrefRegistrySimple;
|
||||||
|
@ -34,7 +36,8 @@ class InspectableWebContentsImpl :
|
||||||
public content::DevToolsAgentHostClient,
|
public content::DevToolsAgentHostClient,
|
||||||
public content::WebContentsObserver,
|
public content::WebContentsObserver,
|
||||||
public content::WebContentsDelegate,
|
public content::WebContentsDelegate,
|
||||||
public DevToolsEmbedderMessageDispatcher::Delegate {
|
public DevToolsEmbedderMessageDispatcher::Delegate,
|
||||||
|
public net::URLFetcherDelegate {
|
||||||
public:
|
public:
|
||||||
static void RegisterPrefs(PrefRegistrySimple* pref_registry);
|
static void RegisterPrefs(PrefRegistrySimple* pref_registry);
|
||||||
|
|
||||||
|
@ -44,25 +47,23 @@ class InspectableWebContentsImpl :
|
||||||
InspectableWebContentsView* GetView() const override;
|
InspectableWebContentsView* GetView() const override;
|
||||||
content::WebContents* GetWebContents() const override;
|
content::WebContents* GetWebContents() const override;
|
||||||
|
|
||||||
|
void SetDelegate(InspectableWebContentsDelegate* delegate) override;
|
||||||
|
InspectableWebContentsDelegate* GetDelegate() const override;
|
||||||
void SetCanDock(bool can_dock) override;
|
void SetCanDock(bool can_dock) override;
|
||||||
void ShowDevTools() override;
|
void ShowDevTools() override;
|
||||||
void CloseDevTools() override;
|
void CloseDevTools() override;
|
||||||
bool IsDevToolsViewShowing() override;
|
bool IsDevToolsViewShowing() override;
|
||||||
void AttachTo(const scoped_refptr<content::DevToolsAgentHost>&) override;
|
void AttachTo(const scoped_refptr<content::DevToolsAgentHost>&) override;
|
||||||
|
void Detach() override;
|
||||||
void Detach();
|
void CallClientFunction(const std::string& function_name,
|
||||||
|
const base::Value* arg1,
|
||||||
|
const base::Value* arg2,
|
||||||
|
const base::Value* arg3) override;
|
||||||
|
|
||||||
// Return the last position and size of devtools window.
|
// Return the last position and size of devtools window.
|
||||||
gfx::Rect GetDevToolsBounds() const;
|
gfx::Rect GetDevToolsBounds() const;
|
||||||
void SaveDevToolsBounds(const gfx::Rect& bounds);
|
void SaveDevToolsBounds(const gfx::Rect& bounds);
|
||||||
|
|
||||||
virtual void SetDelegate(InspectableWebContentsDelegate* delegate) {
|
|
||||||
delegate_ = delegate;
|
|
||||||
}
|
|
||||||
virtual InspectableWebContentsDelegate* GetDelegate() const {
|
|
||||||
return delegate_;
|
|
||||||
}
|
|
||||||
|
|
||||||
content::WebContents* devtools_web_contents() {
|
content::WebContents* devtools_web_contents() {
|
||||||
return devtools_web_contents_.get();
|
return devtools_web_contents_.get();
|
||||||
}
|
}
|
||||||
|
@ -71,10 +72,15 @@ class InspectableWebContentsImpl :
|
||||||
// DevToolsEmbedderMessageDispacher::Delegate
|
// DevToolsEmbedderMessageDispacher::Delegate
|
||||||
void ActivateWindow() override;
|
void ActivateWindow() override;
|
||||||
void CloseWindow() override;
|
void CloseWindow() override;
|
||||||
|
void LoadCompleted() override;
|
||||||
void SetInspectedPageBounds(const gfx::Rect& rect) override;
|
void SetInspectedPageBounds(const gfx::Rect& rect) override;
|
||||||
void InspectElementCompleted() override;
|
void InspectElementCompleted() override;
|
||||||
void MoveWindow(int x, int y) override;
|
void InspectedURLChanged(const std::string& url) override;
|
||||||
void SetIsDocked(bool docked) override;
|
void LoadNetworkResource(const DispatchCallback& callback,
|
||||||
|
const std::string& url,
|
||||||
|
const std::string& headers,
|
||||||
|
int stream_id) override;
|
||||||
|
void SetIsDocked(const DispatchCallback& callback, bool is_docked) override;
|
||||||
void OpenInNewTab(const std::string& url) override;
|
void OpenInNewTab(const std::string& url) override;
|
||||||
void SaveToFile(const std::string& url,
|
void SaveToFile(const std::string& url,
|
||||||
const std::string& content,
|
const std::string& content,
|
||||||
|
@ -86,15 +92,22 @@ class InspectableWebContentsImpl :
|
||||||
void RemoveFileSystem(const std::string& file_system_path) override;
|
void RemoveFileSystem(const std::string& file_system_path) override;
|
||||||
void UpgradeDraggedFileSystemPermissions(
|
void UpgradeDraggedFileSystemPermissions(
|
||||||
const std::string& file_system_url) override;
|
const std::string& file_system_url) override;
|
||||||
void IndexPath(int request_id,
|
void IndexPath(int index_request_id,
|
||||||
const std::string& file_system_path) override;
|
const std::string& file_system_path) override;
|
||||||
void StopIndexing(int request_id) override;
|
void StopIndexing(int index_request_id) override;
|
||||||
void SearchInPath(int request_id,
|
void SearchInPath(int search_request_id,
|
||||||
const std::string& file_system_path,
|
const std::string& file_system_path,
|
||||||
const std::string& query) override;
|
const std::string& query) override;
|
||||||
|
void SetWhitelistedShortcuts(const std::string& message) override;
|
||||||
void ZoomIn() override;
|
void ZoomIn() override;
|
||||||
void ZoomOut() override;
|
void ZoomOut() override;
|
||||||
void ResetZoom() override;
|
void ResetZoom() override;
|
||||||
|
void SetDevicesUpdatesEnabled(bool enabled) override;
|
||||||
|
void SendMessageToBrowser(const std::string& message) override;
|
||||||
|
void RecordActionUMA(const std::string& name, int action) override;
|
||||||
|
void SendJsonRequest(const DispatchCallback& callback,
|
||||||
|
const std::string& browser_id,
|
||||||
|
const std::string& url) override;
|
||||||
|
|
||||||
// content::DevToolsFrontendHostDelegate:
|
// content::DevToolsFrontendHostDelegate:
|
||||||
void HandleMessageFromDevToolsFrontend(const std::string& message) override;
|
void HandleMessageFromDevToolsFrontend(const std::string& message) override;
|
||||||
|
@ -109,11 +122,9 @@ class InspectableWebContentsImpl :
|
||||||
// content::WebContentsObserver:
|
// content::WebContentsObserver:
|
||||||
void AboutToNavigateRenderFrame(content::RenderFrameHost* old_host,
|
void AboutToNavigateRenderFrame(content::RenderFrameHost* old_host,
|
||||||
content::RenderFrameHost* new_host) override;
|
content::RenderFrameHost* new_host) override;
|
||||||
void DidFinishLoad(content::RenderFrameHost* render_frame_host,
|
|
||||||
const GURL& validated_url) override;
|
|
||||||
void WebContentsDestroyed() override;
|
void WebContentsDestroyed() override;
|
||||||
|
|
||||||
// content::WebContentsDelegate
|
// content::WebContentsDelegate:
|
||||||
bool AddMessageToConsole(content::WebContents* source,
|
bool AddMessageToConsole(content::WebContents* source,
|
||||||
int32 level,
|
int32 level,
|
||||||
const base::string16& message,
|
const base::string16& message,
|
||||||
|
@ -133,19 +144,30 @@ class InspectableWebContentsImpl :
|
||||||
void CloseContents(content::WebContents* source) override;
|
void CloseContents(content::WebContents* source) override;
|
||||||
void WebContentsFocused(content::WebContents* contents) override;
|
void WebContentsFocused(content::WebContents* contents) override;
|
||||||
|
|
||||||
|
// net::URLFetcherDelegate:
|
||||||
|
void OnURLFetchComplete(const net::URLFetcher* source) override;
|
||||||
|
|
||||||
|
void SendMessageAck(int request_id,
|
||||||
|
const base::Value* arg1);
|
||||||
|
|
||||||
scoped_ptr<content::WebContents> web_contents_;
|
scoped_ptr<content::WebContents> web_contents_;
|
||||||
scoped_ptr<content::WebContents> devtools_web_contents_;
|
scoped_ptr<content::WebContents> devtools_web_contents_;
|
||||||
scoped_ptr<InspectableWebContentsView> view_;
|
scoped_ptr<InspectableWebContentsView> view_;
|
||||||
|
|
||||||
|
bool frontend_loaded_;
|
||||||
scoped_refptr<content::DevToolsAgentHost> agent_host_;
|
scoped_refptr<content::DevToolsAgentHost> agent_host_;
|
||||||
scoped_ptr<content::DevToolsFrontendHost> frontend_host_;
|
scoped_ptr<content::DevToolsFrontendHost> frontend_host_;
|
||||||
|
scoped_ptr<DevToolsEmbedderMessageDispatcher> embedder_message_dispatcher_;
|
||||||
|
|
||||||
DevToolsContentsResizingStrategy contents_resizing_strategy_;
|
DevToolsContentsResizingStrategy contents_resizing_strategy_;
|
||||||
gfx::Rect devtools_bounds_;
|
gfx::Rect devtools_bounds_;
|
||||||
bool can_dock_;
|
bool can_dock_;
|
||||||
|
|
||||||
scoped_ptr<DevToolsEmbedderMessageDispatcher> embedder_message_dispatcher_;
|
InspectableWebContentsDelegate* delegate_; // weak references.
|
||||||
|
|
||||||
InspectableWebContentsDelegate* delegate_;
|
using PendingRequestsMap = std::map<const net::URLFetcher*, DispatchCallback>;
|
||||||
|
PendingRequestsMap pending_requests_;
|
||||||
|
base::WeakPtrFactory<InspectableWebContentsImpl> weak_factory_;
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(InspectableWebContentsImpl);
|
DISALLOW_COPY_AND_ASSIGN(InspectableWebContentsImpl);
|
||||||
};
|
};
|
||||||
|
|
|
@ -17,12 +17,12 @@ class InspectableWebContentsViewMac : public InspectableWebContentsView {
|
||||||
InspectableWebContentsImpl* inspectable_web_contents_impl);
|
InspectableWebContentsImpl* inspectable_web_contents_impl);
|
||||||
virtual ~InspectableWebContentsViewMac();
|
virtual ~InspectableWebContentsViewMac();
|
||||||
|
|
||||||
virtual gfx::NativeView GetNativeView() const override;
|
gfx::NativeView GetNativeView() const override;
|
||||||
virtual void ShowDevTools() override;
|
void ShowDevTools() override;
|
||||||
virtual void CloseDevTools() override;
|
void CloseDevTools() override;
|
||||||
virtual bool IsDevToolsViewShowing() override;
|
bool IsDevToolsViewShowing() override;
|
||||||
virtual void SetIsDocked(bool docked) override;
|
void SetIsDocked(bool docked) override;
|
||||||
virtual void SetContentsResizingStrategy(
|
void SetContentsResizingStrategy(
|
||||||
const DevToolsContentsResizingStrategy& strategy) override;
|
const DevToolsContentsResizingStrategy& strategy) override;
|
||||||
|
|
||||||
InspectableWebContentsImpl* inspectable_web_contents() {
|
InspectableWebContentsImpl* inspectable_web_contents() {
|
||||||
|
|
|
@ -107,7 +107,8 @@ void NotificationPresenterLinux::ShowNotification(
|
||||||
// Zen Nature" is difficult, we will test for the presence of the indicate
|
// Zen Nature" is difficult, we will test for the presence of the indicate
|
||||||
// dbus service
|
// dbus service
|
||||||
if (!UnityIsRunning()) {
|
if (!UnityIsRunning()) {
|
||||||
notify_notification_add_action(notification, "default", "View", OnNotificationViewThunk, this, nullptr);
|
notify_notification_add_action(
|
||||||
|
notification, "default", "View", OnNotificationViewThunk, this, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
GdkPixbuf* pixbuf = libgtk2ui::GdkPixbufFromSkBitmap(icon);
|
GdkPixbuf* pixbuf = libgtk2ui::GdkPixbufFromSkBitmap(icon);
|
||||||
|
|
|
@ -51,16 +51,16 @@ class MediaCaptureDevicesDispatcher : public content::MediaObserver {
|
||||||
void DisableDeviceEnumerationForTesting();
|
void DisableDeviceEnumerationForTesting();
|
||||||
|
|
||||||
// Overridden from content::MediaObserver:
|
// Overridden from content::MediaObserver:
|
||||||
virtual void OnAudioCaptureDevicesChanged() override;
|
void OnAudioCaptureDevicesChanged() override;
|
||||||
virtual void OnVideoCaptureDevicesChanged() override;
|
void OnVideoCaptureDevicesChanged() override;
|
||||||
virtual void OnMediaRequestStateChanged(
|
void OnMediaRequestStateChanged(
|
||||||
int render_process_id,
|
int render_process_id,
|
||||||
int render_view_id,
|
int render_view_id,
|
||||||
int page_request_id,
|
int page_request_id,
|
||||||
const GURL& security_origin,
|
const GURL& security_origin,
|
||||||
content::MediaStreamType stream_type,
|
content::MediaStreamType stream_type,
|
||||||
content::MediaRequestState state) override;
|
content::MediaRequestState state) override;
|
||||||
virtual void OnCreatingAudioStream(int render_process_id,
|
void OnCreatingAudioStream(int render_process_id,
|
||||||
int render_view_id) override;
|
int render_view_id) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -52,8 +52,8 @@ class URLRequestContextGetter : public net::URLRequestContextGetter {
|
||||||
virtual ~URLRequestContextGetter();
|
virtual ~URLRequestContextGetter();
|
||||||
|
|
||||||
// net::URLRequestContextGetter:
|
// net::URLRequestContextGetter:
|
||||||
virtual net::URLRequestContext* GetURLRequestContext() override;
|
net::URLRequestContext* GetURLRequestContext() override;
|
||||||
virtual scoped_refptr<base::SingleThreadTaskRunner> GetNetworkTaskRunner() const override;
|
scoped_refptr<base::SingleThreadTaskRunner> GetNetworkTaskRunner() const override;
|
||||||
|
|
||||||
net::HostResolver* host_resolver();
|
net::HostResolver* host_resolver();
|
||||||
|
|
||||||
|
|
|
@ -24,13 +24,13 @@ class InspectableWebContentsViewViews : public InspectableWebContentsView,
|
||||||
~InspectableWebContentsViewViews();
|
~InspectableWebContentsViewViews();
|
||||||
|
|
||||||
// InspectableWebContentsView:
|
// InspectableWebContentsView:
|
||||||
virtual views::View* GetView() override;
|
views::View* GetView() override;
|
||||||
virtual views::View* GetWebView() override;
|
views::View* GetWebView() override;
|
||||||
virtual void ShowDevTools() override;
|
void ShowDevTools() override;
|
||||||
virtual void CloseDevTools() override;
|
void CloseDevTools() override;
|
||||||
virtual bool IsDevToolsViewShowing() override;
|
bool IsDevToolsViewShowing() override;
|
||||||
virtual void SetIsDocked(bool docked) override;
|
void SetIsDocked(bool docked) override;
|
||||||
virtual void SetContentsResizingStrategy(
|
void SetContentsResizingStrategy(
|
||||||
const DevToolsContentsResizingStrategy& strategy) override;
|
const DevToolsContentsResizingStrategy& strategy) override;
|
||||||
|
|
||||||
InspectableWebContentsImpl* inspectable_web_contents() {
|
InspectableWebContentsImpl* inspectable_web_contents() {
|
||||||
|
@ -39,7 +39,7 @@ class InspectableWebContentsViewViews : public InspectableWebContentsView,
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// views::View:
|
// views::View:
|
||||||
virtual void Layout() override;
|
void Layout() override;
|
||||||
|
|
||||||
// Owns us.
|
// Owns us.
|
||||||
InspectableWebContentsImpl* inspectable_web_contents_;
|
InspectableWebContentsImpl* inspectable_web_contents_;
|
||||||
|
|
|
@ -17,42 +17,42 @@ class ViewsDelegate : public views::ViewsDelegate {
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// views::ViewsDelegate:
|
// views::ViewsDelegate:
|
||||||
virtual void SaveWindowPlacement(const views::Widget* window,
|
void SaveWindowPlacement(const views::Widget* window,
|
||||||
const std::string& window_name,
|
const std::string& window_name,
|
||||||
const gfx::Rect& bounds,
|
const gfx::Rect& bounds,
|
||||||
ui::WindowShowState show_state) override;
|
ui::WindowShowState show_state) override;
|
||||||
virtual bool GetSavedWindowPlacement(
|
bool GetSavedWindowPlacement(
|
||||||
const views::Widget* widget,
|
const views::Widget* widget,
|
||||||
const std::string& window_name,
|
const std::string& window_name,
|
||||||
gfx::Rect* bounds,
|
gfx::Rect* bounds,
|
||||||
ui::WindowShowState* show_state) const override;
|
ui::WindowShowState* show_state) const override;
|
||||||
virtual void NotifyAccessibilityEvent(
|
void NotifyAccessibilityEvent(
|
||||||
views::View* view, ui::AXEvent event_type) override;
|
views::View* view, ui::AXEvent event_type) override;
|
||||||
virtual void NotifyMenuItemFocused(const base::string16& menu_name,
|
void NotifyMenuItemFocused(const base::string16& menu_name,
|
||||||
const base::string16& menu_item_name,
|
const base::string16& menu_item_name,
|
||||||
int item_index,
|
int item_index,
|
||||||
int item_count,
|
int item_count,
|
||||||
bool has_submenu) override;
|
bool has_submenu) override;
|
||||||
|
|
||||||
#if defined(OS_WIN)
|
#if defined(OS_WIN)
|
||||||
virtual HICON GetDefaultWindowIcon() const override;
|
HICON GetDefaultWindowIcon() const override;
|
||||||
virtual HICON GetSmallWindowIcon() const override;
|
HICON GetSmallWindowIcon() const override;
|
||||||
virtual bool IsWindowInMetro(gfx::NativeWindow window) const override;
|
bool IsWindowInMetro(gfx::NativeWindow window) const override;
|
||||||
#elif defined(OS_LINUX) && !defined(OS_CHROMEOS)
|
#elif defined(OS_LINUX) && !defined(OS_CHROMEOS)
|
||||||
virtual gfx::ImageSkia* GetDefaultWindowIcon() const override;
|
gfx::ImageSkia* GetDefaultWindowIcon() const override;
|
||||||
#endif
|
#endif
|
||||||
virtual views::NonClientFrameView* CreateDefaultNonClientFrameView(
|
views::NonClientFrameView* CreateDefaultNonClientFrameView(
|
||||||
views::Widget* widget) override;
|
views::Widget* widget) override;
|
||||||
virtual void AddRef() override;
|
void AddRef() override;
|
||||||
virtual void ReleaseRef() override;
|
void ReleaseRef() override;
|
||||||
virtual content::WebContents* CreateWebContents(
|
content::WebContents* CreateWebContents(
|
||||||
content::BrowserContext* browser_context,
|
content::BrowserContext* browser_context,
|
||||||
content::SiteInstance* site_instance) override;
|
content::SiteInstance* site_instance) override;
|
||||||
virtual void OnBeforeWidgetInit(
|
void OnBeforeWidgetInit(
|
||||||
views::Widget::InitParams* params,
|
views::Widget::InitParams* params,
|
||||||
views::internal::NativeWidgetDelegate* delegate) override;
|
views::internal::NativeWidgetDelegate* delegate) override;
|
||||||
virtual base::TimeDelta GetDefaultTextfieldObscuredRevealDuration() override;
|
base::TimeDelta GetDefaultTextfieldObscuredRevealDuration() override;
|
||||||
virtual bool WindowManagerProvidesTitleBar(bool maximized) override;
|
bool WindowManagerProvidesTitleBar(bool maximized) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DISALLOW_COPY_AND_ASSIGN(ViewsDelegate);
|
DISALLOW_COPY_AND_ASSIGN(ViewsDelegate);
|
||||||
|
|
|
@ -18,13 +18,13 @@ class WebUIControllerFactory : public content::WebUIControllerFactory {
|
||||||
explicit WebUIControllerFactory(BrowserContext* browser_context);
|
explicit WebUIControllerFactory(BrowserContext* browser_context);
|
||||||
virtual ~WebUIControllerFactory();
|
virtual ~WebUIControllerFactory();
|
||||||
|
|
||||||
virtual content::WebUI::TypeID GetWebUIType(
|
content::WebUI::TypeID GetWebUIType(
|
||||||
content::BrowserContext* browser_context, const GURL& url) const override;
|
content::BrowserContext* browser_context, const GURL& url) const override;
|
||||||
virtual bool UseWebUIForURL(content::BrowserContext* browser_context,
|
bool UseWebUIForURL(content::BrowserContext* browser_context,
|
||||||
const GURL& url) const override;
|
const GURL& url) const override;
|
||||||
virtual bool UseWebUIBindingsForURL(content::BrowserContext* browser_context,
|
bool UseWebUIBindingsForURL(content::BrowserContext* browser_context,
|
||||||
const GURL& url) const override;
|
const GURL& url) const override;
|
||||||
virtual content::WebUIController* CreateWebUIControllerForURL(
|
content::WebUIController* CreateWebUIControllerForURL(
|
||||||
content::WebUI* web_ui,
|
content::WebUI* web_ui,
|
||||||
const GURL& url) const override;
|
const GURL& url) const override;
|
||||||
|
|
||||||
|
|
|
@ -49,11 +49,11 @@ class MainDelegate : public content::ContentMainDelegate {
|
||||||
virtual void OverrideFrameworkBundlePath();
|
virtual void OverrideFrameworkBundlePath();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
virtual bool BasicStartupComplete(int* exit_code) override;
|
bool BasicStartupComplete(int* exit_code) override;
|
||||||
virtual void PreSandboxStartup() override;
|
void PreSandboxStartup() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual content::ContentBrowserClient* CreateContentBrowserClient() override;
|
content::ContentBrowserClient* CreateContentBrowserClient() override;
|
||||||
|
|
||||||
void InitializeResourceBundle();
|
void InitializeResourceBundle();
|
||||||
|
|
||||||
|
|
2
brightray/vendor/google-styleguide
vendored
2
brightray/vendor/google-styleguide
vendored
|
@ -1 +1 @@
|
||||||
Subproject commit 8025f5495c04f1cf9e0d65a0aaa97b58c304faf7
|
Subproject commit ba88c8a53f1b563c43fc063cc048e5efdc238c18
|
Loading…
Reference in a new issue