summaryrefslogtreecommitdiff
path: root/chromium/services/content
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2018-12-10 16:19:40 +0100
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2018-12-10 16:01:50 +0000
commit51f6c2793adab2d864b3d2b360000ef8db1d3e92 (patch)
tree835b3b4446b012c75e80177cef9fbe6972cc7dbe /chromium/services/content
parent6036726eb981b6c4b42047513b9d3f4ac865daac (diff)
downloadqtwebengine-chromium-51f6c2793adab2d864b3d2b360000ef8db1d3e92.tar.gz
BASELINE: Update Chromium to 71.0.3578.93
Change-Id: I6a32086c33670e1b033f8b10e6bf1fd4da1d105d Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'chromium/services/content')
-rw-r--r--chromium/services/content/BUILD.gn2
-rw-r--r--chromium/services/content/DEPS2
-rw-r--r--chromium/services/content/navigable_contents_delegate.h3
-rw-r--r--chromium/services/content/navigable_contents_impl.cc26
-rw-r--r--chromium/services/content/navigable_contents_impl.h10
-rw-r--r--chromium/services/content/public/cpp/BUILD.gn10
-rw-r--r--chromium/services/content/public/cpp/DEPS3
-rw-r--r--chromium/services/content/public/cpp/navigable_contents.cc43
-rw-r--r--chromium/services/content/public/cpp/navigable_contents.h22
-rw-r--r--chromium/services/content/public/cpp/navigable_contents_observer.h30
-rw-r--r--chromium/services/content/public/cpp/navigable_contents_view.cc128
-rw-r--r--chromium/services/content/public/cpp/navigable_contents_view.h57
-rw-r--r--chromium/services/content/public/mojom/BUILD.gn2
-rw-r--r--chromium/services/content/public/mojom/navigable_contents.mojom25
-rw-r--r--chromium/services/content/public/mojom/navigable_contents_factory.mojom7
-rw-r--r--chromium/services/content/service_delegate.h4
-rw-r--r--chromium/services/content/service_unittest.cc11
17 files changed, 319 insertions, 66 deletions
diff --git a/chromium/services/content/BUILD.gn b/chromium/services/content/BUILD.gn
index a9b95dee876..f972bd4f278 100644
--- a/chromium/services/content/BUILD.gn
+++ b/chromium/services/content/BUILD.gn
@@ -26,6 +26,8 @@ source_set("impl") {
"service.cc",
]
+ configs += [ "//build/config/compiler:wexit_time_destructors" ]
+
public_deps = [
"//base",
"//services/content/public/cpp:buildflags",
diff --git a/chromium/services/content/DEPS b/chromium/services/content/DEPS
index 7c7f37f94c6..f3ff2940ecd 100644
--- a/chromium/services/content/DEPS
+++ b/chromium/services/content/DEPS
@@ -1,4 +1,6 @@
include_rules = [
+ "+services/network/public",
+
"+ui/aura",
"+ui/base",
"+ui/gfx",
diff --git a/chromium/services/content/navigable_contents_delegate.h b/chromium/services/content/navigable_contents_delegate.h
index 9e8208b1b59..55ed240f791 100644
--- a/chromium/services/content/navigable_contents_delegate.h
+++ b/chromium/services/content/navigable_contents_delegate.h
@@ -5,6 +5,7 @@
#ifndef SERVICES_CONTENT_NAVIGABLE_CONTENTS_DELEGATE_H_
#define SERVICES_CONTENT_NAVIGABLE_CONTENTS_DELEGATE_H_
+#include "services/content/public/mojom/navigable_contents.mojom.h"
#include "ui/gfx/native_widget_types.h"
class GURL;
@@ -31,7 +32,7 @@ class NavigableContentsDelegate {
virtual gfx::NativeView GetNativeView() = 0;
// Navigates the content object to a new URL.
- virtual void Navigate(const GURL& url) = 0;
+ virtual void Navigate(const GURL& url, mojom::NavigateParamsPtr params) = 0;
};
} // namespace content
diff --git a/chromium/services/content/navigable_contents_impl.cc b/chromium/services/content/navigable_contents_impl.cc
index e518888c827..da1f99ce4c0 100644
--- a/chromium/services/content/navigable_contents_impl.cc
+++ b/chromium/services/content/navigable_contents_impl.cc
@@ -35,7 +35,8 @@ NavigableContentsImpl::NavigableContentsImpl(
binding_(this, std::move(request)),
client_(std::move(client)),
delegate_(
- service_->delegate()->CreateNavigableContentsDelegate(client_.get())),
+ service_->delegate()->CreateNavigableContentsDelegate(*params,
+ client_.get())),
native_content_view_(delegate_->GetNativeView()) {
binding_.set_connection_error_handler(base::BindRepeating(
&Service::RemoveNavigableContents, base::Unretained(service_), this));
@@ -43,12 +44,13 @@ NavigableContentsImpl::NavigableContentsImpl(
NavigableContentsImpl::~NavigableContentsImpl() = default;
-void NavigableContentsImpl::Navigate(const GURL& url) {
+void NavigableContentsImpl::Navigate(const GURL& url,
+ mojom::NavigateParamsPtr params) {
// Ignore non-HTTP/HTTPS requests for now.
if (!url.SchemeIsHTTPOrHTTPS())
return;
- delegate_->Navigate(url);
+ delegate_->Navigate(url, std::move(params));
}
void NavigableContentsImpl::CreateView(bool in_service_process,
@@ -85,10 +87,10 @@ void NavigableContentsImpl::CreateView(bool in_service_process,
void NavigableContentsImpl::OnEmbedTokenReceived(
CreateViewCallback callback,
const base::UnguessableToken& token) {
-#if defined(TOOLKIT_VIEWS)
- if (native_content_view_)
- native_content_view_->Show();
-#endif // defined(TOOLKIT_VIEWS)
+#if defined(TOOLKIT_VIEWS) && defined(USE_AURA)
+ DCHECK(native_content_view_);
+ native_content_view_->Show();
+#endif // defined(TOOLKIT_VIEWS) && defined(USE_AURA)
std::move(callback).Run(token);
}
#endif // BUILDFLAG(ENABLE_REMOTE_NAVIGABLE_CONTENTS_VIEW)
@@ -96,13 +98,9 @@ void NavigableContentsImpl::OnEmbedTokenReceived(
void NavigableContentsImpl::EmbedInProcessClientView(
NavigableContentsView* view) {
DCHECK(native_content_view_);
-#if defined(TOOLKIT_VIEWS)
- DCHECK(!local_view_host_);
- local_view_host_ = std::make_unique<views::NativeViewHost>();
- local_view_host_->set_owned_by_client();
- view->view()->AddChildView(local_view_host_.get());
- view->view()->Layout();
- local_view_host_->Attach(native_content_view_);
+#if defined(TOOLKIT_VIEWS) && defined(USE_AURA)
+ view->native_view()->AddChild(native_content_view_);
+ native_content_view_->Show();
#else
// TODO(https://crbug.com/855092): Support embedding of other native client
// views without Views + Aura.
diff --git a/chromium/services/content/navigable_contents_impl.h b/chromium/services/content/navigable_contents_impl.h
index 54d0a6b37de..160257a049b 100644
--- a/chromium/services/content/navigable_contents_impl.h
+++ b/chromium/services/content/navigable_contents_impl.h
@@ -15,7 +15,6 @@
#include "ui/gfx/native_widget_types.h"
namespace views {
-class NativeViewHost;
class RemoteViewProvider;
}
@@ -38,7 +37,7 @@ class NavigableContentsImpl : public mojom::NavigableContents {
private:
// mojom::NavigableContents:
- void Navigate(const GURL& url) override;
+ void Navigate(const GURL& url, mojom::NavigateParamsPtr params) override;
void CreateView(bool in_service_process,
CreateViewCallback callback) override;
@@ -62,13 +61,6 @@ class NavigableContentsImpl : public mojom::NavigableContents {
std::unique_ptr<views::RemoteViewProvider> remote_view_provider_;
#endif
-#if defined(TOOLKIT_VIEWS)
- // Used to support local view embedding in cases where remote embedding is
- // not supported and the client controlling this NavigableContents is running
- // within the same process as the Content Service.
- std::unique_ptr<views::NativeViewHost> local_view_host_;
-#endif
-
base::WeakPtrFactory<NavigableContentsImpl> weak_ptr_factory_{this};
DISALLOW_COPY_AND_ASSIGN(NavigableContentsImpl);
diff --git a/chromium/services/content/public/cpp/BUILD.gn b/chromium/services/content/public/cpp/BUILD.gn
index 171af0cbef9..66cd4a1d50e 100644
--- a/chromium/services/content/public/cpp/BUILD.gn
+++ b/chromium/services/content/public/cpp/BUILD.gn
@@ -14,6 +14,7 @@ component("cpp") {
public = [
"navigable_contents.h",
+ "navigable_contents_observer.h",
"navigable_contents_view.h",
]
@@ -22,12 +23,17 @@ component("cpp") {
"navigable_contents_view.cc",
]
+ configs += [ "//build/config/compiler:wexit_time_destructors" ]
+
defines = [ "IS_CONTENT_SERVICE_CPP_IMPL" ]
public_deps = [
":buildflags",
"//base",
+ "//net",
"//services/content/public/mojom",
+ "//ui/gfx:native_widget_types",
+ "//ui/gfx/geometry",
"//url",
]
@@ -45,4 +51,8 @@ component("cpp") {
]
}
}
+
+ if (use_aura) {
+ deps += [ "//ui/aura" ]
+ }
}
diff --git a/chromium/services/content/public/cpp/DEPS b/chromium/services/content/public/cpp/DEPS
index 51a5fb7e88f..8640a7517e0 100644
--- a/chromium/services/content/public/cpp/DEPS
+++ b/chromium/services/content/public/cpp/DEPS
@@ -1,5 +1,8 @@
include_rules = [
+ "+net/http/http_response_headers.h",
+
"+services/ws/public",
+
"+ui/aura",
"+ui/views",
]
diff --git a/chromium/services/content/public/cpp/navigable_contents.cc b/chromium/services/content/public/cpp/navigable_contents.cc
index 3f1c8dd1ced..cfce9ca9c89 100644
--- a/chromium/services/content/public/cpp/navigable_contents.cc
+++ b/chromium/services/content/public/cpp/navigable_contents.cc
@@ -10,15 +10,27 @@
namespace content {
NavigableContents::NavigableContents(mojom::NavigableContentsFactory* factory)
+ : NavigableContents(factory, mojom::NavigableContentsParams::New()) {}
+
+NavigableContents::NavigableContents(mojom::NavigableContentsFactory* factory,
+ mojom::NavigableContentsParamsPtr params)
: client_binding_(this) {
mojom::NavigableContentsClientPtr client;
client_binding_.Bind(mojo::MakeRequest(&client));
- factory->CreateContents(mojom::NavigableContentsParams::New(),
- mojo::MakeRequest(&contents_), std::move(client));
+ factory->CreateContents(std::move(params), mojo::MakeRequest(&contents_),
+ std::move(client));
}
NavigableContents::~NavigableContents() = default;
+void NavigableContents::AddObserver(NavigableContentsObserver* observer) {
+ observers_.AddObserver(observer);
+}
+
+void NavigableContents::RemoveObserver(NavigableContentsObserver* observer) {
+ observers_.RemoveObserver(observer);
+}
+
NavigableContentsView* NavigableContents::GetView() {
if (!view_) {
view_ = base::WrapUnique(new NavigableContentsView);
@@ -31,12 +43,33 @@ NavigableContentsView* NavigableContents::GetView() {
}
void NavigableContents::Navigate(const GURL& url) {
- contents_->Navigate(url);
+ NavigateWithParams(url, mojom::NavigateParams::New());
+}
+
+void NavigableContents::NavigateWithParams(const GURL& url,
+ mojom::NavigateParamsPtr params) {
+ contents_->Navigate(url, std::move(params));
+}
+
+void NavigableContents::DidFinishNavigation(
+ const GURL& url,
+ bool is_main_frame,
+ bool is_error_page,
+ const scoped_refptr<net::HttpResponseHeaders>& response_headers) {
+ for (auto& observer : observers_) {
+ observer.DidFinishNavigation(url, is_main_frame, is_error_page,
+ response_headers.get());
+ }
}
void NavigableContents::DidStopLoading() {
- if (did_stop_loading_callback_)
- did_stop_loading_callback_.Run();
+ for (auto& observer : observers_)
+ observer.DidStopLoading();
+}
+
+void NavigableContents::DidAutoResizeView(const gfx::Size& new_size) {
+ for (auto& observer : observers_)
+ observer.DidAutoResizeView(new_size);
}
void NavigableContents::OnEmbedTokenReceived(
diff --git a/chromium/services/content/public/cpp/navigable_contents.h b/chromium/services/content/public/cpp/navigable_contents.h
index d9b5d6e68b8..7078b2d3a86 100644
--- a/chromium/services/content/public/cpp/navigable_contents.h
+++ b/chromium/services/content/public/cpp/navigable_contents.h
@@ -10,7 +10,9 @@
#include "base/callback.h"
#include "base/component_export.h"
#include "base/macros.h"
+#include "base/observer_list.h"
#include "mojo/public/cpp/bindings/binding.h"
+#include "services/content/public/cpp/navigable_contents_observer.h"
#include "services/content/public/mojom/navigable_contents.mojom.h"
#include "services/content/public/mojom/navigable_contents_factory.mojom.h"
@@ -28,8 +30,14 @@ class COMPONENT_EXPORT(CONTENT_SERVICE_CPP) NavigableContents
public:
// Constructs a new NavigableContents using |factory|.
explicit NavigableContents(mojom::NavigableContentsFactory* factory);
+ NavigableContents(mojom::NavigableContentsFactory* factory,
+ mojom::NavigableContentsParamsPtr params);
~NavigableContents() override;
+ // These methods NavigableContentsObservers registered on this object.
+ void AddObserver(NavigableContentsObserver* observer);
+ void RemoveObserver(NavigableContentsObserver* observer);
+
// Returns a NavigableContentsView which renders this NavigableContents's
// currently navigated contents. This widget can be parented and displayed
// anywhere within the application's own window tree.
@@ -42,15 +50,17 @@ class COMPONENT_EXPORT(CONTENT_SERVICE_CPP) NavigableContents
// Begins an attempt to asynchronously navigate this NavigableContents to
// |url|.
void Navigate(const GURL& url);
-
- void set_did_stop_loading_callback_for_testing(
- base::RepeatingClosure callback) {
- did_stop_loading_callback_ = std::move(callback);
- }
+ void NavigateWithParams(const GURL& url, mojom::NavigateParamsPtr params);
private:
// mojom::NavigableContentsClient:
+ void DidFinishNavigation(
+ const GURL& url,
+ bool is_main_frame,
+ bool is_error_page,
+ const scoped_refptr<net::HttpResponseHeaders>& response_headers) override;
void DidStopLoading() override;
+ void DidAutoResizeView(const gfx::Size& new_size) override;
void OnEmbedTokenReceived(const base::UnguessableToken& token);
@@ -58,7 +68,7 @@ class COMPONENT_EXPORT(CONTENT_SERVICE_CPP) NavigableContents
mojo::Binding<mojom::NavigableContentsClient> client_binding_;
std::unique_ptr<NavigableContentsView> view_;
- base::RepeatingClosure did_stop_loading_callback_;
+ base::ReentrantObserverList<NavigableContentsObserver> observers_;
DISALLOW_COPY_AND_ASSIGN(NavigableContents);
};
diff --git a/chromium/services/content/public/cpp/navigable_contents_observer.h b/chromium/services/content/public/cpp/navigable_contents_observer.h
new file mode 100644
index 00000000000..c863de441b6
--- /dev/null
+++ b/chromium/services/content/public/cpp/navigable_contents_observer.h
@@ -0,0 +1,30 @@
+// Copyright 2018 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef SERVICES_CONTENT_PUBLIC_CPP_NAVIGABLE_CONTENTS_OBSERVER_H_
+#define SERVICES_CONTENT_PUBLIC_CPP_NAVIGABLE_CONTENTS_OBSERVER_H_
+
+#include "base/component_export.h"
+#include "base/observer_list_types.h"
+#include "net/http/http_response_headers.h"
+#include "ui/gfx/geometry/size.h"
+#include "url/gurl.h"
+
+namespace content {
+
+class COMPONENT_EXPORT(CONTENT_SERVICE_CPP) NavigableContentsObserver
+ : public base::CheckedObserver {
+ public:
+ virtual void DidFinishNavigation(
+ const GURL& url,
+ bool is_main_frame,
+ bool is_error_page,
+ const net::HttpResponseHeaders* response_headers) {}
+ virtual void DidStopLoading() {}
+ virtual void DidAutoResizeView(const gfx::Size& new_size) {}
+};
+
+} // namespace content
+
+#endif // SERVICES_CONTENT_PUBLIC_CPP_NAVIGABLE_CONTENTS_OBSERVER_H_
diff --git a/chromium/services/content/public/cpp/navigable_contents_view.cc b/chromium/services/content/public/cpp/navigable_contents_view.cc
index fd5c1f6d651..44596695d09 100644
--- a/chromium/services/content/public/cpp/navigable_contents_view.cc
+++ b/chromium/services/content/public/cpp/navigable_contents_view.cc
@@ -19,10 +19,16 @@
#if BUILDFLAG(ENABLE_REMOTE_NAVIGABLE_CONTENTS_VIEW)
#include "services/ws/public/mojom/window_tree_constants.mojom.h" // nogncheck
#include "ui/base/ui_base_features.h" // nogncheck
+#include "ui/views/controls/native/native_view_host.h" // nogncheck
#include "ui/views/mus/remote_view/remote_view_host.h" // nogncheck
#endif // BUILDFLAG(ENABLE_REMOTE_NAVIGABLE_CONTENTS_VIEW)
#endif // defined(TOOLKIT_VIEWS)
+#if defined(USE_AURA)
+#include "ui/aura/layout_manager.h" // nogncheck
+#include "ui/aura/window.h" // nogncheck
+#endif
+
namespace content {
namespace {
@@ -41,6 +47,71 @@ base::AtomicFlag& GetInServiceProcessFlag() {
return *in_service_process;
}
+#if BUILDFLAG(ENABLE_REMOTE_NAVIGABLE_CONTENTS_VIEW)
+
+std::unique_ptr<NavigableContentsView::RemoteViewManager>&
+GetRemoteViewManager() {
+ static base::NoDestructor<
+ std::unique_ptr<NavigableContentsView::RemoteViewManager>>
+ manager;
+ return *manager;
+}
+
+#endif // BUILDFLAG(ENABLE_REMOTE_NAVIGABLE_CONTENTS_VIEW)
+
+#if defined(TOOLKIT_VIEWS) && defined(USE_AURA)
+
+// Keeps child windows sized to the same bounds as the owning window.
+class LocalWindowLayoutManager : public aura::LayoutManager {
+ public:
+ explicit LocalWindowLayoutManager(aura::Window* owner) : owner_(owner) {}
+ ~LocalWindowLayoutManager() override = default;
+
+ // aura::LayoutManger:
+ void OnWindowResized() override { ResizeChildren(); }
+ void OnWindowAddedToLayout(aura::Window* child) override { ResizeChildren(); }
+ void OnWillRemoveWindowFromLayout(aura::Window* child) override {}
+ void OnWindowRemovedFromLayout(aura::Window* child) override {}
+ void OnChildWindowVisibilityChanged(aura::Window* child,
+ bool visible) override {}
+ void SetChildBounds(aura::Window* child,
+ const gfx::Rect& requested_bounds) override {}
+
+ private:
+ void ResizeChildren() {
+ for (auto* child : owner_->children())
+ SetChildBoundsDirect(child, owner_->bounds());
+ }
+
+ aura::Window* const owner_;
+
+ DISALLOW_COPY_AND_ASSIGN(LocalWindowLayoutManager);
+};
+
+// Owns an Aura window which parents another Aura window in the same process,
+// corresponding to a web contents view hosted in the process.
+class LocalViewHost : public views::NativeViewHost {
+ public:
+ explicit LocalViewHost(aura::Window* window) : window_(window) {
+ window_->SetLayoutManager(new LocalWindowLayoutManager(window_));
+ }
+
+ ~LocalViewHost() override = default;
+
+ // views::View:
+ void AddedToWidget() override {
+ if (!native_view())
+ Attach(window_);
+ }
+
+ private:
+ aura::Window* const window_;
+
+ DISALLOW_COPY_AND_ASSIGN(LocalViewHost);
+};
+
+#endif // defined(TOOLKIT_VIEWS) && defined(USE_AURA)
+
} // namespace
NavigableContentsView::~NavigableContentsView() = default;
@@ -56,29 +127,57 @@ bool NavigableContentsView::IsClientRunningInServiceProcess() {
}
NavigableContentsView::NavigableContentsView() {
-#if defined(TOOLKIT_VIEWS)
- view_ = std::make_unique<views::View>();
- view_->set_owned_by_client();
- view_->SetLayoutManager(std::make_unique<views::FillLayout>());
+#if defined(TOOLKIT_VIEWS) && defined(USE_AURA)
#if BUILDFLAG(ENABLE_REMOTE_NAVIGABLE_CONTENTS_VIEW)
if (!IsClientRunningInServiceProcess()) {
- DCHECK(!remote_view_host_);
- remote_view_host_ = new views::RemoteViewHost;
- view_->AddChildView(remote_view_host_);
+ RemoteViewManager* manager = GetRemoteViewManager().get();
+ if (manager)
+ view_ = manager->CreateRemoteViewHost();
+ else
+ view_ = std::make_unique<views::RemoteViewHost>();
+ view_->set_owned_by_client();
+ return;
}
#endif // BUILDFLAG(ENABLE_REMOTE_NAVIGABLE_CONTENTS_VIEW)
-#endif // defined(TOOLKIT_VIEWS)
+
+ window_ = std::make_unique<aura::Window>(nullptr);
+ window_->set_owned_by_parent(false);
+ window_->SetName("NavigableContentsViewWindow");
+ window_->SetType(aura::client::WINDOW_TYPE_CONTROL);
+ window_->Init(ui::LAYER_NOT_DRAWN);
+ window_->Show();
+
+ view_ = std::make_unique<LocalViewHost>(window_.get());
+ view_->set_owned_by_client();
+#endif // defined(TOOLKIT_VIEWS) && defined(USE_AURA)
}
+#if BUILDFLAG(ENABLE_REMOTE_NAVIGABLE_CONTENTS_VIEW)
+
+// static
+void NavigableContentsView::SetRemoteViewManager(
+ std::unique_ptr<RemoteViewManager> manager) {
+ GetRemoteViewManager() = std::move(manager);
+}
+
+#endif // BUILDFLAG(ENABLE_REMOTE_NAVIGABLE_CONTENTS_VIEW)
+
void NavigableContentsView::EmbedUsingToken(
const base::UnguessableToken& token) {
#if defined(TOOLKIT_VIEWS)
#if BUILDFLAG(ENABLE_REMOTE_NAVIGABLE_CONTENTS_VIEW)
- if (remote_view_host_) {
- const uint32_t kEmbedFlags =
- ws::mojom::kEmbedFlagEmbedderInterceptsEvents |
- ws::mojom::kEmbedFlagEmbedderControlsVisibility;
- remote_view_host_->EmbedUsingToken(token, kEmbedFlags, base::DoNothing());
+ if (!IsClientRunningInServiceProcess()) {
+ RemoteViewManager* manager = GetRemoteViewManager().get();
+ if (manager) {
+ manager->EmbedUsingToken(view_.get(), token);
+ } else {
+ constexpr uint32_t kEmbedFlags =
+ ws::mojom::kEmbedFlagEmbedderInterceptsEvents |
+ ws::mojom::kEmbedFlagEmbedderControlsVisibility;
+ static_cast<views::RemoteViewHost*>(view_.get())
+ ->EmbedUsingToken(token, kEmbedFlags, base::DoNothing());
+ }
+
return;
}
#endif // BUILDFLAG(ENABLE_REMOTE_NAVIGABLE_CONTENTS_VIEW)
@@ -94,6 +193,9 @@ void NavigableContentsView::EmbedUsingToken(
return;
}
+ // Invoke a callback provided by the Content Service's host environment. This
+ // should parent a web content view to our own |view()|, as well as set
+ // |native_view_| to the corresponding web contents' own NativeView.
auto callback = std::move(it->second);
embeddings.erase(it);
std::move(callback).Run(this);
diff --git a/chromium/services/content/public/cpp/navigable_contents_view.h b/chromium/services/content/public/cpp/navigable_contents_view.h
index fd1d7573990..4b1dab9777a 100644
--- a/chromium/services/content/public/cpp/navigable_contents_view.h
+++ b/chromium/services/content/public/cpp/navigable_contents_view.h
@@ -7,13 +7,23 @@
#include <memory>
+#include "base/callback.h"
#include "base/component_export.h"
#include "base/unguessable_token.h"
#include "services/content/public/cpp/buildflags.h"
+#include "ui/gfx/native_widget_types.h"
+
+#if defined(TOOLKIT_VIEWS) && defined(USE_AURA)
+#include "ui/views/controls/native/native_view_host.h" // nogncheck
+#endif
+
+namespace aura {
+class Window;
+}
namespace views {
-class RemoteViewHost;
class View;
+class NativeViewHost;
} // namespace views
namespace content {
@@ -26,9 +36,32 @@ class NavigableContentsImpl;
// either Views, UIKit, AppKit, or the Android Framework.
//
// TODO(https://crbug.com/855092): Actually support UI frameworks other than
-// Views UI.
+// Views UI on Aura.
class COMPONENT_EXPORT(CONTENT_SERVICE_CPP) NavigableContentsView {
public:
+#if BUILDFLAG(ENABLE_REMOTE_NAVIGABLE_CONTENTS_VIEW)
+ // May be used if the Content Service client is running within a process whose
+ // UI environment requires a different remote View implementation from
+ // the default one. For example, on Chrome OS when Ash and the Window Service
+ // are running in the same process, the default implementation
+ // (views::RemoteViewHost) will not work.
+ class RemoteViewManager {
+ public:
+ virtual ~RemoteViewManager() {}
+
+ // Creates a new NativeViewHost suitable for remote embedding.
+ virtual std::unique_ptr<views::NativeViewHost> CreateRemoteViewHost() = 0;
+
+ // Initiates an embedding of a remote client -- identified by |token| --
+ // within |view_host|. Note that |view_host| is always an object returned by
+ // |CreateRemoteViewHost()| on the same RemoteViewManager.
+ virtual void EmbedUsingToken(views::NativeViewHost* view_host,
+ const base::UnguessableToken& token) = 0;
+ };
+
+ static void SetRemoteViewManager(std::unique_ptr<RemoteViewManager> manager);
+#endif
+
~NavigableContentsView();
// Used to set/query whether the calling process is the same process in which
@@ -39,9 +72,11 @@ class COMPONENT_EXPORT(CONTENT_SERVICE_CPP) NavigableContentsView {
static void SetClientRunningInServiceProcess();
static bool IsClientRunningInServiceProcess();
-#if defined(TOOLKIT_VIEWS)
+#if defined(TOOLKIT_VIEWS) && defined(USE_AURA)
views::View* view() const { return view_.get(); }
-#endif
+
+ gfx::NativeView native_view() const { return view_->native_view(); }
+#endif // defined(TOOLKIT_VIEWS) && defined(USE_AURA)
private:
friend class NavigableContents;
@@ -59,15 +94,11 @@ class COMPONENT_EXPORT(CONTENT_SERVICE_CPP) NavigableContentsView {
const base::UnguessableToken& token,
base::OnceCallback<void(NavigableContentsView*)> callback);
-#if defined(TOOLKIT_VIEWS)
- // This NavigableContents's View. Only initialized if |GetView()| is called,
- // and only on platforms which support Views UI.
- std::unique_ptr<views::View> view_;
-
-#if BUILDFLAG(ENABLE_REMOTE_NAVIGABLE_CONTENTS_VIEW)
- views::RemoteViewHost* remote_view_host_ = nullptr;
-#endif
-#endif // BUILDFLAG(TOOLKIT_VIEWS)
+#if defined(TOOLKIT_VIEWS) && defined(USE_AURA)
+ // This NavigableContents's Window and corresponding View.
+ std::unique_ptr<aura::Window> window_;
+ std::unique_ptr<views::NativeViewHost> view_;
+#endif // defined(TOOLKIT_VIEWS) && defined(USE_AURA)
DISALLOW_COPY_AND_ASSIGN(NavigableContentsView);
};
diff --git a/chromium/services/content/public/mojom/BUILD.gn b/chromium/services/content/public/mojom/BUILD.gn
index 830829538cb..58b7e0dabd6 100644
--- a/chromium/services/content/public/mojom/BUILD.gn
+++ b/chromium/services/content/public/mojom/BUILD.gn
@@ -19,6 +19,8 @@ mojom_component("mojom") {
public_deps = [
"//mojo/public/mojom/base",
+ "//services/network/public/mojom:websocket_mojom",
+ "//ui/gfx/geometry/mojo",
"//url/mojom:url_mojom_gurl",
]
diff --git a/chromium/services/content/public/mojom/navigable_contents.mojom b/chromium/services/content/public/mojom/navigable_contents.mojom
index 620280eec57..2797df25f11 100644
--- a/chromium/services/content/public/mojom/navigable_contents.mojom
+++ b/chromium/services/content/public/mojom/navigable_contents.mojom
@@ -5,15 +5,25 @@
module content.mojom;
import "mojo/public/mojom/base/unguessable_token.mojom";
+import "services/network/public/mojom/network_param.mojom";
+import "ui/gfx/geometry/mojo/geometry.mojom";
import "url/mojom/url.mojom";
+// Parameters used to configure the behavior of |NavigableContents.Navigate|.
+struct NavigateParams {
+ // Indicates that upon successful navigation, the session history should be
+ // cleared, resulting in the navigated page being the first and only entry in
+ // the session's history.
+ bool should_clear_session_history = false;
+};
+
// The primary interface an application uses to drive a top-level, navigable
// content object. Typically this would correspond to e.g. a browser tab, but
// it is not strictly necessary that the contents have any graphical presence
// within the client application.
interface NavigableContents {
// Initiates a navigation to |url|.
- Navigate(url.mojom.Url url);
+ Navigate(url.mojom.Url url, NavigateParams params);
// Creates a visual representation of the navigated contents, which is
// maintained by the Content Service. Responds with a |embed_token| which can
@@ -34,7 +44,20 @@ interface NavigableContents {
// A client interface used by the Content Service to push contents-scoped events
// back to the application.
interface NavigableContentsClient {
+ // Notifies the client that a navigation has finished.
+ DidFinishNavigation(url.mojom.Url url,
+ bool is_main_frame,
+ bool is_error_page,
+ network.mojom.HttpResponseHeaders? response_headers);
+
// Notifies the client that the NavigableContents has stopped loading
// resources pertaining to a prior navigation request.
DidStopLoading();
+
+ // Indicates that the navigated contents changed in such a way as to elicit
+ // automatic resizing of the containing view. Only fired if
+ // |NavigableContentsParams.enable_view_auto_resize| was set to |true| when
+ // creating the corresponding NavigableContents. The client may use this as a
+ // signal to, e.g., resize a UI element containing the content view.
+ DidAutoResizeView(gfx.mojom.Size new_size);
};
diff --git a/chromium/services/content/public/mojom/navigable_contents_factory.mojom b/chromium/services/content/public/mojom/navigable_contents_factory.mojom
index b79c633d040..acb42101eea 100644
--- a/chromium/services/content/public/mojom/navigable_contents_factory.mojom
+++ b/chromium/services/content/public/mojom/navigable_contents_factory.mojom
@@ -7,7 +7,12 @@ module content.mojom;
import "services/content/public/mojom/navigable_contents.mojom";
// Parameters used to configure a newly created NavigableContents.
-struct NavigableContentsParams {};
+struct NavigableContentsParams {
+ // Enables auto-resizing of any view created for this NavigableContents. If
+ // |true|, the corresponding NavigableContentsClient will receive
+ // |DidAutoResizeView()| notifications whenever such resizing happens.
+ bool enable_view_auto_resize = false;
+};
// NavigableContentsFactory is the primary interface through which a new
// NavigableContents interface is bound to a new concrete navigable contents
diff --git a/chromium/services/content/service_delegate.h b/chromium/services/content/service_delegate.h
index 650a2e1b6be..9749bf27218 100644
--- a/chromium/services/content/service_delegate.h
+++ b/chromium/services/content/service_delegate.h
@@ -6,6 +6,7 @@
#define SERVICES_CONTENT_SERVICE_DELEGATE_H_
#include "services/content/public/mojom/navigable_contents.mojom.h"
+#include "services/content/public/mojom/navigable_contents_factory.mojom.h"
namespace content {
@@ -33,7 +34,8 @@ class ServiceDelegate {
// |client| is a NavigableContentsClient interface the implementation can use
// to communicate with the client of this contents.
virtual std::unique_ptr<NavigableContentsDelegate>
- CreateNavigableContentsDelegate(mojom::NavigableContentsClient* client) = 0;
+ CreateNavigableContentsDelegate(const mojom::NavigableContentsParams& params,
+ mojom::NavigableContentsClient* client) = 0;
};
}; // namespace content
diff --git a/chromium/services/content/service_unittest.cc b/chromium/services/content/service_unittest.cc
index d0e08dac12e..a97e3608cde 100644
--- a/chromium/services/content/service_unittest.cc
+++ b/chromium/services/content/service_unittest.cc
@@ -30,7 +30,13 @@ class TestNavigableContentsClient : public mojom::NavigableContentsClient {
private:
// mojom::NavigableContentsClient:
+ void DidFinishNavigation(const GURL& url,
+ bool is_main_frame,
+ bool is_error_page,
+ const scoped_refptr<net::HttpResponseHeaders>&
+ response_headers) override {}
void DidStopLoading() override {}
+ void DidAutoResizeView(const gfx::Size& new_size) override {}
DISALLOW_COPY_AND_ASSIGN(TestNavigableContentsClient);
};
@@ -47,7 +53,7 @@ class TestNavigableContentsDelegate : public NavigableContentsDelegate {
}
// NavigableContentsDelegate:
- void Navigate(const GURL& url) override {
+ void Navigate(const GURL& url, mojom::NavigateParamsPtr params) override {
last_navigated_url_ = url;
if (navigation_callback_)
navigation_callback_.Run();
@@ -76,6 +82,7 @@ class TestServiceDelegate : public ServiceDelegate {
void WillDestroyServiceInstance(Service* service) override {}
std::unique_ptr<NavigableContentsDelegate> CreateNavigableContentsDelegate(
+ const mojom::NavigableContentsParams& params,
mojom::NavigableContentsClient* client) override {
auto delegate = std::make_unique<TestNavigableContentsDelegate>();
if (navigable_contents_delegate_created_callback_)
@@ -148,7 +155,7 @@ TEST_F(ContentServiceTest, NavigableContentsCreation) {
navigation_loop.QuitClosure());
const GURL kTestUrl("https://example.com/");
- contents->Navigate(kTestUrl);
+ contents->Navigate(kTestUrl, mojom::NavigateParams::New());
navigation_loop.Run();
EXPECT_EQ(kTestUrl, navigable_contents_delegate->last_navigated_url());