2016-07-20 09:30:06 +00:00
|
|
|
// Copyright (c) 2013 GitHub, Inc.
|
|
|
|
// Use of this source code is governed by the MIT license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
|
|
|
#include "atom/browser/osr_web_contents_view.h"
|
|
|
|
|
|
|
|
#include "atom/browser/osr_window.h"
|
|
|
|
#include <iostream>
|
|
|
|
|
|
|
|
namespace atom {
|
|
|
|
|
2016-07-27 12:36:22 +00:00
|
|
|
OffScreenWebContentsView::OffScreenWebContentsView() : web_contents_(nullptr) {
|
2016-07-22 11:55:58 +00:00
|
|
|
// std::cout << "OffScreenWebContentsView" << std::endl;
|
2016-07-20 09:30:06 +00:00
|
|
|
//std::this_thread::sleep_for(std::chrono::milliseconds(10000));
|
|
|
|
}
|
|
|
|
OffScreenWebContentsView::~OffScreenWebContentsView() {
|
2016-07-22 11:55:58 +00:00
|
|
|
// std::cout << "~OffScreenWebContentsView" << std::endl;
|
2016-07-20 09:30:06 +00:00
|
|
|
}
|
|
|
|
|
2016-07-27 12:36:22 +00:00
|
|
|
void OffScreenWebContentsView::SetWebContents(
|
|
|
|
content::WebContents* web_contents) {
|
|
|
|
web_contents_ = web_contents;
|
|
|
|
}
|
|
|
|
|
2016-07-20 09:30:06 +00:00
|
|
|
// Returns the native widget that contains the contents of the tab.
|
|
|
|
gfx::NativeView OffScreenWebContentsView::GetNativeView() const{
|
2016-07-22 11:55:58 +00:00
|
|
|
// std::cout << "GetNativeView" << std::endl;
|
2016-07-20 09:30:06 +00:00
|
|
|
return gfx::NativeView();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Returns the native widget with the main content of the tab (i.e. the main
|
|
|
|
// render view host, though there may be many popups in the tab as children of
|
|
|
|
// the container).
|
|
|
|
gfx::NativeView OffScreenWebContentsView::GetContentNativeView() const{
|
2016-07-22 11:55:58 +00:00
|
|
|
// std::cout << "GetContentNativeView" << std::endl;
|
2016-07-20 09:30:06 +00:00
|
|
|
return gfx::NativeView();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Returns the outermost native view. This will be used as the parent for
|
|
|
|
// dialog boxes.
|
|
|
|
gfx::NativeWindow OffScreenWebContentsView::GetTopLevelNativeWindow() const{
|
2016-07-22 11:55:58 +00:00
|
|
|
// std::cout << "GetTopLevelNativeWindow" << std::endl;
|
2016-07-20 09:30:06 +00:00
|
|
|
return gfx::NativeWindow();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Computes the rectangle for the native widget that contains the contents of
|
|
|
|
// the tab in the screen coordinate system.
|
|
|
|
void OffScreenWebContentsView::GetContainerBounds(gfx::Rect* out) const{
|
2016-07-22 11:55:58 +00:00
|
|
|
// std::cout << "GetContainerBounds" << std::endl;
|
2016-07-20 09:30:06 +00:00
|
|
|
*out = GetViewBounds();
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO(brettw) this is a hack. It's used in two places at the time of this
|
|
|
|
// writing: (1) when render view hosts switch, we need to size the replaced
|
|
|
|
// one to be correct, since it wouldn't have known about sizes that happened
|
|
|
|
// while it was hidden; (2) in constrained windows.
|
|
|
|
//
|
|
|
|
// (1) will be fixed once interstitials are cleaned up. (2) seems like it
|
|
|
|
// should be cleaned up or done some other way, since this works for normal
|
|
|
|
// WebContents without the special code.
|
|
|
|
void OffScreenWebContentsView::SizeContents(const gfx::Size& size){
|
2016-07-22 11:55:58 +00:00
|
|
|
// std::cout << "SizeContents" << std::endl;
|
2016-07-20 09:30:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Sets focus to the native widget for this tab.
|
|
|
|
void OffScreenWebContentsView::Focus(){
|
2016-07-22 11:55:58 +00:00
|
|
|
// std::cout << "OffScreenWebContentsView::Focus" << std::endl;
|
2016-07-20 09:30:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Sets focus to the appropriate element when the WebContents is shown the
|
|
|
|
// first time.
|
|
|
|
void OffScreenWebContentsView::SetInitialFocus(){
|
2016-07-22 11:55:58 +00:00
|
|
|
// std::cout << "SetInitialFocus" << std::endl;
|
2016-07-20 09:30:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Stores the currently focused view.
|
|
|
|
void OffScreenWebContentsView::StoreFocus(){
|
2016-07-22 11:55:58 +00:00
|
|
|
// std::cout << "StoreFocus" << std::endl;
|
2016-07-20 09:30:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Restores focus to the last focus view. If StoreFocus has not yet been
|
|
|
|
// invoked, SetInitialFocus is invoked.
|
|
|
|
void OffScreenWebContentsView::RestoreFocus(){
|
2016-07-22 11:55:58 +00:00
|
|
|
// std::cout << "RestoreFocus" << std::endl;
|
2016-07-20 09:30:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Returns the current drop data, if any.
|
|
|
|
content::DropData* OffScreenWebContentsView::GetDropData() const{
|
2016-07-22 11:55:58 +00:00
|
|
|
// std::cout << "GetDropData" << std::endl;
|
2016-07-20 09:30:06 +00:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Get the bounds of the View, relative to the parent.
|
|
|
|
gfx::Rect OffScreenWebContentsView::GetViewBounds() const{
|
2016-07-22 11:55:58 +00:00
|
|
|
// std::cout << "OffScreenWebContentsView::GetViewBounds" << std::endl;
|
2016-07-20 09:30:06 +00:00
|
|
|
return view_ ? view_->GetViewBounds() : gfx::Rect();
|
|
|
|
}
|
|
|
|
|
|
|
|
void OffScreenWebContentsView::CreateView(
|
|
|
|
const gfx::Size& initial_size, gfx::NativeView context){
|
2016-07-27 12:36:22 +00:00
|
|
|
std::cout << context << std::endl;
|
2016-07-22 11:55:58 +00:00
|
|
|
// std::cout << "CreateView" << std::endl;
|
|
|
|
// std::cout << initial_size.width() << "x" << initial_size.height() << std::endl;
|
2016-07-20 09:30:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Sets up the View that holds the rendered web page, receives messages for
|
|
|
|
// it and contains page plugins. The host view should be sized to the current
|
|
|
|
// size of the WebContents.
|
|
|
|
//
|
|
|
|
// |is_guest_view_hack| is temporary hack and will be removed once
|
|
|
|
// RenderWidgetHostViewGuest is not dependent on platform view.
|
|
|
|
// TODO(lazyboy): Remove |is_guest_view_hack| once http://crbug.com/330264 is
|
|
|
|
// fixed.
|
|
|
|
content::RenderWidgetHostViewBase*
|
|
|
|
OffScreenWebContentsView::CreateViewForWidget(
|
|
|
|
content::RenderWidgetHost* render_widget_host, bool is_guest_view_hack){
|
2016-07-22 11:55:58 +00:00
|
|
|
// std::cout << "CreateViewForWidget" << std::endl;
|
2016-07-27 12:36:22 +00:00
|
|
|
auto relay = NativeWindowRelay::FromWebContents(web_contents_);
|
|
|
|
view_ = new OffScreenWindow(render_widget_host, relay->window.get());
|
2016-07-20 09:30:06 +00:00
|
|
|
return view_;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Creates a new View that holds a popup and receives messages for it.
|
|
|
|
content::RenderWidgetHostViewBase*
|
|
|
|
OffScreenWebContentsView::CreateViewForPopupWidget(
|
|
|
|
content::RenderWidgetHost* render_widget_host){
|
2016-07-22 11:55:58 +00:00
|
|
|
// std::cout << "CreateViewForPopupWidget" << std::endl;
|
2016-07-27 12:36:22 +00:00
|
|
|
auto relay = NativeWindowRelay::FromWebContents(web_contents_);
|
|
|
|
view_ = new OffScreenWindow(render_widget_host, relay->window.get());
|
2016-07-20 09:30:06 +00:00
|
|
|
return view_;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Sets the page title for the native widgets corresponding to the view. This
|
|
|
|
// is not strictly necessary and isn't expected to be displayed anywhere, but
|
|
|
|
// can aid certain debugging tools such as Spy++ on Windows where you are
|
|
|
|
// trying to find a specific window.
|
|
|
|
void OffScreenWebContentsView::SetPageTitle(const base::string16& title){
|
2016-07-22 11:55:58 +00:00
|
|
|
// std::cout << "SetPageTitle" << std::endl;
|
|
|
|
// std::cout << title << std::endl;
|
2016-07-20 09:30:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Invoked when the WebContents is notified that the RenderView has been
|
|
|
|
// fully created.
|
|
|
|
void OffScreenWebContentsView::RenderViewCreated(content::RenderViewHost* host){
|
2016-07-22 11:55:58 +00:00
|
|
|
// std::cout << "RenderViewCreated" << std::endl;
|
2016-07-20 09:30:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Invoked when the WebContents is notified that the RenderView has been
|
|
|
|
// swapped in.
|
|
|
|
void OffScreenWebContentsView::RenderViewSwappedIn(content::RenderViewHost* host){
|
2016-07-22 11:55:58 +00:00
|
|
|
// std::cout << "RenderViewSwappedIn" << std::endl;
|
2016-07-20 09:30:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Invoked to enable/disable overscroll gesture navigation.
|
|
|
|
void OffScreenWebContentsView::SetOverscrollControllerEnabled(bool enabled){
|
2016-07-22 11:55:58 +00:00
|
|
|
// std::cout << "SetOverscrollControllerEnabled" << std::endl;
|
2016-07-20 09:30:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#if defined(OS_MACOSX)
|
|
|
|
void OffScreenWebContentsView::SetAllowOtherViews(bool allow) {
|
|
|
|
}
|
|
|
|
|
|
|
|
bool OffScreenWebContentsView::GetAllowOtherViews() const {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool OffScreenWebContentsView::IsEventTracking() const {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void OffScreenWebContentsView::CloseTabAfterEventTracking() {
|
|
|
|
}
|
|
|
|
#endif // defined(OS_MACOSX)
|
|
|
|
|
2016-07-25 13:55:00 +00:00
|
|
|
void OffScreenWebContentsView::StartDragging(
|
|
|
|
const content::DropData& drop_data,
|
|
|
|
blink::WebDragOperationsMask allowed_ops,
|
|
|
|
const gfx::ImageSkia& image,
|
|
|
|
const gfx::Vector2d& image_offset,
|
|
|
|
const content::DragEventSourceInfo& event_info) {
|
|
|
|
}
|
|
|
|
|
|
|
|
void OffScreenWebContentsView::UpdateDragCursor(
|
|
|
|
blink::WebDragOperation operation) {
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-07-20 09:30:06 +00:00
|
|
|
} // namespace atom
|