summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--components/web_view/frame_connection.cc2
-rw-r--r--components/web_view/pending_web_view_load.cc4
-rw-r--r--components/web_view/web_view_impl.cc24
3 files changed, 21 insertions, 9 deletions
diff --git a/components/web_view/frame_connection.cc b/components/web_view/frame_connection.cc
index 55d4a1d..ec2fde7 100644
--- a/components/web_view/frame_connection.cc
+++ b/components/web_view/frame_connection.cc
@@ -16,6 +16,7 @@
#include "mojo/application/public/cpp/application_connection.h"
#include "mojo/application/public/cpp/application_impl.h"
#include "mojo/services/network/public/interfaces/cookie_store.mojom.h"
+#include "mojo/services/network/public/interfaces/network_service.mojom.h"
#include "mojo/services/network/public/interfaces/url_loader_factory.mojom.h"
#include "mojo/services/network/public/interfaces/web_socket_factory.mojom.h"
#include "mojo/services/tracing/public/interfaces/tracing.mojom.h"
@@ -78,6 +79,7 @@ void FrameConnection::Init(mojo::ApplicationImpl* app,
mojo::Array<mojo::String> network_service_interfaces;
network_service_interfaces.push_back(mojo::CookieStore::Name_);
+ network_service_interfaces.push_back(mojo::NetworkService::Name_);
network_service_interfaces.push_back(mojo::URLLoaderFactory::Name_);
network_service_interfaces.push_back(mojo::WebSocketFactory::Name_);
filter->filter.insert("mojo:network_service",
diff --git a/components/web_view/pending_web_view_load.cc b/components/web_view/pending_web_view_load.cc
index 81fc341..eca81e4 100644
--- a/components/web_view/pending_web_view_load.cc
+++ b/components/web_view/pending_web_view_load.cc
@@ -26,9 +26,9 @@ void PendingWebViewLoad::Init(mojo::URLRequestPtr request) {
void PendingWebViewLoad::OnGotContentHandlerID() {
is_content_handler_id_valid_ = true;
- if (web_view_->content_)
+ if (web_view_->root_)
web_view_->OnLoad();
- // The else case is handled by WebViewImpl when it gets the View (|content_|).
+ // The else case is handled by WebViewImpl when it gets the View (|root_|).
}
} // namespace web_view
diff --git a/components/web_view/web_view_impl.cc b/components/web_view/web_view_impl.cc
index 0326496..1c8654f 100644
--- a/components/web_view/web_view_impl.cc
+++ b/components/web_view/web_view_impl.cc
@@ -60,6 +60,21 @@ WebViewImpl::~WebViewImpl() {
}
void WebViewImpl::OnLoad() {
+ // Frames are uniqued based on the id of the associated View. By creating a
+ // new View each time through we ensure the renderers get a clean id, rather
+ // than one they may know about and try to incorrectly use.
+ if (content_) {
+ content_->Destroy();
+ DCHECK(!content_);
+ }
+
+ content_ = root_->connection()->CreateView();
+ content_->SetBounds(*mojo::Rect::From(
+ gfx::Rect(0, 0, root_->bounds().width, root_->bounds().height)));
+ root_->AddChild(content_);
+ content_->SetVisible(true);
+ content_->AddObserver(this);
+
scoped_ptr<PendingWebViewLoad> pending_load(pending_load_.Pass());
scoped_ptr<FrameConnection> frame_connection(
pending_load->frame_connection());
@@ -114,12 +129,6 @@ void WebViewImpl::OnEmbed(mus::View* root) {
DCHECK(root->connection()->IsEmbedRoot());
root->AddObserver(this);
root_ = root;
- content_ = root->connection()->CreateView();
- content_->SetBounds(*mojo::Rect::From(gfx::Rect(0, 0, root->bounds().width,
- root->bounds().height)));
- root->AddChild(content_);
- content_->SetVisible(true);
- content_->AddObserver(this);
if (pending_load_ && pending_load_->is_content_handler_id_valid())
OnLoad();
@@ -139,7 +148,8 @@ void WebViewImpl::OnViewBoundsChanged(mus::View* view,
mojo::Rect rect;
rect.width = new_bounds.width;
rect.height = new_bounds.height;
- content_->SetBounds(rect);
+ if (content_)
+ content_->SetBounds(rect);
}
}