Add code to register <webview> tag
This commit is contained in:
parent
e7c7e086b1
commit
380de24f2e
10 changed files with 649 additions and 1 deletions
|
@ -7,6 +7,7 @@
|
|||
#include "atom/browser/atom_browser_main_parts.h"
|
||||
#include "atom/browser/net/atom_url_request_job_factory.h"
|
||||
#include "atom/browser/net/asar/asar_protocol_handler.h"
|
||||
#include "atom/browser/web_view/web_view_manager.h"
|
||||
#include "base/threading/sequenced_worker_pool.h"
|
||||
#include "base/threading/worker_pool.h"
|
||||
#include "chrome/browser/browser_process.h"
|
||||
|
@ -68,6 +69,12 @@ net::URLRequestJobFactory* AtomBrowserContext::CreateURLRequestJobFactory(
|
|||
return top_job_factory.release();
|
||||
}
|
||||
|
||||
content::BrowserPluginGuestManager* AtomBrowserContext::GetGuestManager() {
|
||||
if (!guest_manager_)
|
||||
guest_manager_.reset(new WebViewManager(this));
|
||||
return guest_manager_.get();
|
||||
}
|
||||
|
||||
// static
|
||||
AtomBrowserContext* AtomBrowserContext::Get() {
|
||||
return static_cast<AtomBrowserContext*>(
|
||||
|
|
|
@ -12,6 +12,7 @@ class BrowserProcess;
|
|||
namespace atom {
|
||||
|
||||
class AtomURLRequestJobFactory;
|
||||
class WebViewManager;
|
||||
|
||||
class AtomBrowserContext : public brightray::BrowserContext {
|
||||
public:
|
||||
|
@ -27,11 +28,15 @@ class AtomBrowserContext : public brightray::BrowserContext {
|
|||
// brightray::URLRequestContextGetter::Delegate:
|
||||
virtual net::URLRequestJobFactory* CreateURLRequestJobFactory(
|
||||
content::ProtocolHandlerMap* handlers,
|
||||
content::URLRequestInterceptorScopedVector* interceptors) OVERRIDE;
|
||||
content::URLRequestInterceptorScopedVector* interceptors) override;
|
||||
|
||||
// content::BrowserContext:
|
||||
virtual content::BrowserPluginGuestManager* GetGuestManager() override;
|
||||
|
||||
private:
|
||||
// A fake BrowserProcess object that used to feed the source code from chrome.
|
||||
scoped_ptr<BrowserProcess> fake_browser_process_;
|
||||
scoped_ptr<WebViewManager> guest_manager_;
|
||||
|
||||
AtomURLRequestJobFactory* job_factory_; // Weak reference.
|
||||
|
||||
|
|
|
@ -56,6 +56,8 @@
|
|||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<browser-plugin type="application/browser-plugin"></browser-plugin>
|
||||
|
||||
<script>
|
||||
var execPath = require('remote').process.execPath;
|
||||
var command = execPath + ' path-to-your-app';
|
||||
|
|
11
atom/browser/web_view/web_view_guest.cc
Normal file
11
atom/browser/web_view/web_view_guest.cc
Normal file
|
@ -0,0 +1,11 @@
|
|||
// Copyright (c) 2014 GitHub, Inc. All rights reserved.
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "atom/browser/web_view/web_view_guest.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
|
||||
|
||||
} // namespace atom
|
19
atom/browser/web_view/web_view_guest.h
Normal file
19
atom/browser/web_view/web_view_guest.h
Normal file
|
@ -0,0 +1,19 @@
|
|||
// Copyright (c) 2014 GitHub, Inc. All rights reserved.
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef ATOM_BROWSER_WEB_VIEW_WEB_VIEW_GUEST_H_
|
||||
#define ATOM_BROWSER_WEB_VIEW_WEB_VIEW_GUEST_H_
|
||||
|
||||
namespace atom {
|
||||
|
||||
// A WebViewGuest provides the browser-side implementation of the <webview> API
|
||||
// and manages the dispatch of <webview> extension events. WebViewGuest is
|
||||
// created on attachment. That is, when a guest WebContents is associated with
|
||||
// a particular embedder WebContents. This happens on either initial navigation
|
||||
// or through the use of the New Window API, when a new window is attached to
|
||||
// a particular <webview>.
|
||||
|
||||
} // namespace atom
|
||||
|
||||
#endif // ATOM_BROWSER_WEB_VIEW_WEB_VIEW_GUEST_H_
|
31
atom/browser/web_view/web_view_manager.cc
Normal file
31
atom/browser/web_view/web_view_manager.cc
Normal file
|
@ -0,0 +1,31 @@
|
|||
// Copyright (c) 2014 GitHub, Inc. All rights reserved.
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "atom/browser/web_view/web_view_manager.h"
|
||||
|
||||
#include "base/logging.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
WebViewManager::WebViewManager(content::BrowserContext* context) {
|
||||
}
|
||||
|
||||
WebViewManager::~WebViewManager() {
|
||||
}
|
||||
|
||||
void WebViewManager::MaybeGetGuestByInstanceIDOrKill(
|
||||
int guest_instance_id,
|
||||
int embedder_render_process_id,
|
||||
const GuestByInstanceIDCallback& callback) {
|
||||
LOG(ERROR) << "MaybeGetGuestByInstanceIDOrKill";
|
||||
callback.Run(nullptr);
|
||||
}
|
||||
|
||||
bool WebViewManager::ForEachGuest(content::WebContents* embedder_web_contents,
|
||||
const GuestCallback& callback) {
|
||||
LOG(ERROR) << "ForEachGuest";
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace atom
|
35
atom/browser/web_view/web_view_manager.h
Normal file
35
atom/browser/web_view/web_view_manager.h
Normal file
|
@ -0,0 +1,35 @@
|
|||
// Copyright (c) 2014 GitHub, Inc. All rights reserved.
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef ATOM_BROWSER_WEB_VIEW_WEB_VIEW_MANAGER_H_
|
||||
#define ATOM_BROWSER_WEB_VIEW_WEB_VIEW_MANAGER_H_
|
||||
|
||||
#include "content/public/browser/browser_plugin_guest_manager.h"
|
||||
|
||||
namespace content {
|
||||
class BrowserContext;
|
||||
}
|
||||
|
||||
namespace atom {
|
||||
|
||||
class WebViewManager : public content::BrowserPluginGuestManager {
|
||||
public:
|
||||
explicit WebViewManager(content::BrowserContext* context);
|
||||
virtual ~WebViewManager();
|
||||
|
||||
// content::BrowserPluginGuestManager:
|
||||
virtual void MaybeGetGuestByInstanceIDOrKill(
|
||||
int guest_instance_id,
|
||||
int embedder_render_process_id,
|
||||
const GuestByInstanceIDCallback& callback) override;
|
||||
virtual bool ForEachGuest(content::WebContents* embedder_web_contents,
|
||||
const GuestCallback& callback) override;
|
||||
|
||||
private:
|
||||
DISALLOW_COPY_AND_ASSIGN(WebViewManager);
|
||||
};
|
||||
|
||||
} // namespace atom
|
||||
|
||||
#endif // ATOM_BROWSER_WEB_VIEW_WEB_VIEW_MANAGER_H_
|
Loading…
Add table
Add a link
Reference in a new issue