diff options
author | sky <sky@chromium.org> | 2015-08-20 11:54:59 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-08-20 18:55:34 +0000 |
commit | 0a7d81c3b6206e709b63da9cb81742f19ee1c706 (patch) | |
tree | 0e156c5c8b67a927fc26fe7806b1766164cd9c86 /components/html_viewer | |
parent | b5f69ad76f082ed98964dd3079f6a0eafb7b3010 (diff) | |
download | chromium_src-0a7d81c3b6206e709b63da9cb81742f19ee1c706.zip chromium_src-0a7d81c3b6206e709b63da9cb81742f19ee1c706.tar.gz chromium_src-0a7d81c3b6206e709b63da9cb81742f19ee1c706.tar.bz2 |
Nukes non-OOPIF path
BUG=none
TEST=none
R=ben@chromium.org
Review URL: https://codereview.chromium.org/1283163005
Cr-Commit-Position: refs/heads/master@{#344551}
Diffstat (limited to 'components/html_viewer')
-rw-r--r-- | components/html_viewer/BUILD.gn | 3 | ||||
-rw-r--r-- | components/html_viewer/ax_provider_apptest.cc | 41 | ||||
-rw-r--r-- | components/html_viewer/html_document.cc | 499 | ||||
-rw-r--r-- | components/html_viewer/html_document.h | 204 | ||||
-rw-r--r-- | components/html_viewer/html_document_application_delegate.cc | 42 | ||||
-rw-r--r-- | components/html_viewer/html_document_application_delegate.h | 6 | ||||
-rw-r--r-- | components/html_viewer/html_frame.cc | 1 | ||||
-rw-r--r-- | components/html_viewer/html_frame_apptest.cc | 27 | ||||
-rw-r--r-- | components/html_viewer/html_viewer_switches.cc | 2 | ||||
-rw-r--r-- | components/html_viewer/html_viewer_switches.h | 3 |
10 files changed, 21 insertions, 807 deletions
diff --git a/components/html_viewer/BUILD.gn b/components/html_viewer/BUILD.gn index 62332d4..28dadba 100644 --- a/components/html_viewer/BUILD.gn +++ b/components/html_viewer/BUILD.gn @@ -80,8 +80,6 @@ source_set("lib") { "geolocation_client_impl.h", "global_state.cc", "global_state.h", - "html_document.cc", - "html_document.h", "html_document_application_delegate.cc", "html_document_application_delegate.h", "html_document_oopif.cc", @@ -154,7 +152,6 @@ source_set("lib") { "//components/view_manager/public/interfaces", "//components/webcrypto", "//gin", - "//mandoline/services/navigation/public/interfaces", "//mandoline/tab/public/interfaces", "//media", "//media/blink", diff --git a/components/html_viewer/ax_provider_apptest.cc b/components/html_viewer/ax_provider_apptest.cc index 11b4cf2..4bf8120 100644 --- a/components/html_viewer/ax_provider_apptest.cc +++ b/components/html_viewer/ax_provider_apptest.cc @@ -30,15 +30,6 @@ bool AxTreeContainsText(const Array<AxNodePtr>& tree, const String& text) { return false; } -// Switch to disable out of process iframes. -const char kDisableOOPIF[] = "disable--oopifs"; - -bool EnableOOPIFs() { - if (base::CommandLine::ForCurrentProcess()->HasSwitch(kDisableOOPIF)) - return false; - return true; -} - class TestFrameTreeServer : public mandoline::FrameTreeServer { public: TestFrameTreeServer() {} @@ -93,23 +84,21 @@ TEST_F(AXProviderTest, HelloWorld) { View* embed_view = window_manager()->CreateView(); embed_view->Embed(view_manager_client.Pass()); - if (EnableOOPIFs()) { - TestFrameTreeServer frame_tree_server; - mandoline::FrameTreeServerPtr frame_tree_server_ptr; - mojo::Binding<mandoline::FrameTreeServer> frame_tree_server_binding( - &frame_tree_server); - frame_tree_server_binding.Bind(GetProxy(&frame_tree_server_ptr).Pass()); - - mojo::Array<mandoline::FrameDataPtr> array(1u); - array[0] = mandoline::FrameData::New().Pass(); - array[0]->frame_id = embed_view->id(); - array[0]->parent_id = 0u; - - mandoline::FrameTreeClientPtr frame_tree_client; - connection->ConnectToService(&frame_tree_client); - frame_tree_client->OnConnect(frame_tree_server_ptr.Pass(), 1u, - array.Pass()); - } + TestFrameTreeServer frame_tree_server; + mandoline::FrameTreeServerPtr frame_tree_server_ptr; + mojo::Binding<mandoline::FrameTreeServer> frame_tree_server_binding( + &frame_tree_server); + frame_tree_server_binding.Bind(GetProxy(&frame_tree_server_ptr).Pass()); + + mojo::Array<mandoline::FrameDataPtr> array(1u); + array[0] = mandoline::FrameData::New().Pass(); + array[0]->frame_id = embed_view->id(); + array[0]->parent_id = 0u; + + mandoline::FrameTreeClientPtr frame_tree_client; + connection->ConnectToService(&frame_tree_client); + frame_tree_client->OnConnect(frame_tree_server_ptr.Pass(), 1u, + array.Pass()); // Connect to the AxProvider of the HTML document and get the AxTree. AxProviderPtr ax_provider; diff --git a/components/html_viewer/html_document.cc b/components/html_viewer/html_document.cc deleted file mode 100644 index ab68283..0000000 --- a/components/html_viewer/html_document.cc +++ /dev/null @@ -1,499 +0,0 @@ -// Copyright 2014 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. - -#include "components/html_viewer/html_document.h" - -#include "base/bind.h" -#include "base/command_line.h" -#include "base/location.h" -#include "base/memory/scoped_ptr.h" -#include "base/single_thread_task_runner.h" -#include "base/stl_util.h" -#include "base/strings/string_util.h" -#include "base/thread_task_runner_handle.h" -#include "components/devtools_service/public/cpp/switches.h" -#include "components/html_viewer/blink_input_events_type_converters.h" -#include "components/html_viewer/blink_url_request_type_converters.h" -#include "components/html_viewer/devtools_agent_impl.h" -#include "components/html_viewer/geolocation_client_impl.h" -#include "components/html_viewer/global_state.h" -#include "components/html_viewer/media_factory.h" -#include "components/html_viewer/stats_collection_controller.h" -#include "components/html_viewer/web_layer_tree_view_impl.h" -#include "components/html_viewer/web_storage_namespace_impl.h" -#include "components/html_viewer/web_url_loader_impl.h" -#include "components/view_manager/public/cpp/view.h" -#include "components/view_manager/public/cpp/view_manager.h" -#include "components/view_manager/public/cpp/view_property.h" -#include "components/view_manager/public/interfaces/surfaces.mojom.h" -#include "mojo/application/public/cpp/application_impl.h" -#include "mojo/application/public/cpp/connect.h" -#include "mojo/application/public/interfaces/shell.mojom.h" -#include "mojo/converters/geometry/geometry_type_converters.h" -#include "skia/ext/refptr.h" -#include "third_party/WebKit/public/platform/Platform.h" -#include "third_party/WebKit/public/platform/WebHTTPHeaderVisitor.h" -#include "third_party/WebKit/public/platform/WebSize.h" -#include "third_party/WebKit/public/web/WebConsoleMessage.h" -#include "third_party/WebKit/public/web/WebDocument.h" -#include "third_party/WebKit/public/web/WebElement.h" -#include "third_party/WebKit/public/web/WebInputEvent.h" -#include "third_party/WebKit/public/web/WebLocalFrame.h" -#include "third_party/WebKit/public/web/WebRemoteFrame.h" -#include "third_party/WebKit/public/web/WebRemoteFrameClient.h" -#include "third_party/WebKit/public/web/WebScriptSource.h" -#include "third_party/WebKit/public/web/WebSettings.h" -#include "third_party/WebKit/public/web/WebView.h" -#include "third_party/mojo/src/mojo/public/cpp/system/data_pipe.h" -#include "third_party/skia/include/core/SkCanvas.h" -#include "third_party/skia/include/core/SkColor.h" -#include "third_party/skia/include/core/SkDevice.h" -#include "ui/gfx/geometry/dip_util.h" -#include "ui/gfx/geometry/size.h" - -using blink::WebString; -using mojo::AxProvider; -using mojo::Rect; -using mojo::ServiceProviderPtr; -using mojo::URLResponsePtr; -using mojo::View; -using mojo::ViewManager; -using mojo::WeakBindToRequest; - -namespace html_viewer { -namespace { - -bool EnableRemoteDebugging() { - return base::CommandLine::ForCurrentProcess()->HasSwitch( - devtools_service::kRemoteDebuggingPort); -} - -// WebRemoteFrameClient implementation used for OOPIFs. -// TODO(sky): this needs to talk to browser by way of an interface. -class RemoteFrameClientImpl : public blink::WebRemoteFrameClient { - public: - explicit RemoteFrameClientImpl(mojo::View* view) : view_(view) {} - ~RemoteFrameClientImpl() {} - - // WebRemoteFrameClient methods: - virtual void postMessageEvent(blink::WebLocalFrame* source_frame, - blink::WebRemoteFrame* target_frame, - blink::WebSecurityOrigin target_origin, - blink::WebDOMMessageEvent event) {} - virtual void initializeChildFrame(const blink::WebRect& frame_rect, - float scale_factor) { - mojo::Rect rect; - rect.x = frame_rect.x; - rect.y = frame_rect.y; - rect.width = frame_rect.width; - rect.height = frame_rect.height; - view_->SetBounds(rect); - } - virtual void navigate(const blink::WebURLRequest& request, - bool should_replace_current_entry) {} - virtual void reload(bool ignore_cache, bool is_client_redirect) {} - - virtual void forwardInputEvent(const blink::WebInputEvent* event) {} - - private: - mojo::View* const view_; - - DISALLOW_COPY_AND_ASSIGN(RemoteFrameClientImpl); -}; - -void ConfigureSettings(blink::WebSettings* settings) { - settings->setCookieEnabled(true); - settings->setDefaultFixedFontSize(13); - settings->setDefaultFontSize(16); - settings->setLoadsImagesAutomatically(true); - settings->setJavaScriptEnabled(true); -} - -mojo::Target WebNavigationPolicyToNavigationTarget( - blink::WebNavigationPolicy policy) { - switch (policy) { - case blink::WebNavigationPolicyCurrentTab: - return mojo::TARGET_SOURCE_NODE; - case blink::WebNavigationPolicyNewBackgroundTab: - case blink::WebNavigationPolicyNewForegroundTab: - case blink::WebNavigationPolicyNewWindow: - case blink::WebNavigationPolicyNewPopup: - return mojo::TARGET_NEW_NODE; - default: - return mojo::TARGET_DEFAULT; - } -} - -bool CanNavigateLocally(blink::WebFrame* frame, - const blink::WebURLRequest& request) { - // For now, we just load child frames locally. - if (frame->parent()) - return true; - - // If we have extraData() it means we already have the url response - // (presumably because we are being called via Navigate()). In that case we - // can go ahead and navigate locally. - if (request.extraData()) - return true; - - // Otherwise we don't know if we're the right app to handle this request. Ask - // host to do the navigation for us. - return false; -} - -} // namespace - -HTMLDocument::CreateParams::CreateParams( - mojo::ApplicationImpl* html_document_app, - mojo::ApplicationConnection* connection, - mojo::URLResponsePtr response, - GlobalState* global_state, - const DeleteCallback& delete_callback) - : html_document_app(html_document_app), - connection(connection), - response(response.Pass()), - global_state(global_state), - delete_callback(delete_callback) { -} - -HTMLDocument::CreateParams::~CreateParams() { -} - -HTMLDocument::HTMLDocument(HTMLDocument::CreateParams* params) - : app_refcount_(params->html_document_app->app_lifetime_helper() - ->CreateAppRefCount()), - html_document_app_(params->html_document_app), - response_(params->response.Pass()), - navigator_host_(params->connection->GetServiceProvider()), - web_view_(nullptr), - root_(nullptr), - view_manager_client_factory_(params->html_document_app->shell(), this), - global_state_(params->global_state), - delete_callback_(params->delete_callback) { - params->connection->AddService( - static_cast<InterfaceFactory<mojo::AxProvider>*>(this)); - params->connection->AddService(&view_manager_client_factory_); - - if (global_state_->did_init()) - Load(response_.Pass()); -} - -void HTMLDocument::Destroy() { - // See comment in header for a description of lifetime. - if (root_) { - // Deleting the ViewManager calls back to OnViewManagerDestroyed() and - // triggers deletion. - delete root_->view_manager(); - } else { - delete this; - } -} - -HTMLDocument::~HTMLDocument() { - delete_callback_.Run(this); - - STLDeleteElements(&ax_providers_); - STLDeleteElements(&ax_provider_requests_); - - if (web_view_) - web_view_->close(); - if (root_) - root_->RemoveObserver(this); -} - -void HTMLDocument::OnEmbed(View* root) { - DCHECK(!global_state_->is_headless()); - root_ = root; - root_->AddObserver(this); - UpdateFocus(); - - InitGlobalStateAndLoadIfNecessary(); -} - -void HTMLDocument::OnViewManagerDestroyed(ViewManager* view_manager) { - delete this; -} - -void HTMLDocument::Create(mojo::ApplicationConnection* connection, - mojo::InterfaceRequest<AxProvider> request) { - if (!did_finish_load_) { - // Cache AxProvider interface requests until the document finishes loading. - auto cached_request = new mojo::InterfaceRequest<AxProvider>(); - *cached_request = request.Pass(); - ax_provider_requests_.insert(cached_request); - } else { - ax_providers_.insert( - new AxProviderImpl(web_view_, request.Pass())); - } -} - -void HTMLDocument::Load(URLResponsePtr response) { - DCHECK(!web_view_); - web_view_ = blink::WebView::create(this); - touch_handler_.reset(new TouchHandler(web_view_)); - web_layer_tree_view_impl_->set_widget(web_view_); - ConfigureSettings(web_view_->settings()); - - blink::WebLocalFrame* main_frame = - blink::WebLocalFrame::create(blink::WebTreeScopeType::Document, this); - web_view_->setMainFrame(main_frame); - - // TODO(yzshen): http://crbug.com/498986 Creating DevToolsAgentImpl instances - // causes html_viewer_apptests flakiness currently. Before we fix that we - // cannot enable remote debugging (which is required by Telemetry tests) on - // the bots. - if (EnableRemoteDebugging()) { - devtools_agent_.reset( - new DevToolsAgentImpl(main_frame, html_document_app_->shell())); - } - - startup_performance_data_collector_ = - StatsCollectionController::Install(main_frame, html_document_app_); - - GURL url(response->url); - - WebURLRequestExtraData* extra_data = new WebURLRequestExtraData; - extra_data->synthetic_response = response.Pass(); - - blink::WebURLRequest web_request; - web_request.initialize(); - web_request.setURL(url); - web_request.setExtraData(extra_data); - - web_view_->mainFrame()->loadRequest(web_request); - UpdateFocus(); -} - -void HTMLDocument::UpdateWebviewSizeFromViewSize() { - web_view_->setDeviceScaleFactor(global_state_->device_pixel_ratio()); - const gfx::Size size_in_pixels(root_->bounds().width, root_->bounds().height); - const gfx::Size size_in_dips = gfx::ConvertSizeToDIP( - root_->viewport_metrics().device_pixel_ratio, size_in_pixels); - web_view_->resize( - blink::WebSize(size_in_dips.width(), size_in_dips.height())); - web_layer_tree_view_impl_->setViewportSize(size_in_pixels); -} - -void HTMLDocument::InitGlobalStateAndLoadIfNecessary() { - DCHECK(root_); - if (root_->viewport_metrics().device_pixel_ratio == 0.f) - return; - - if (!web_view_) { - global_state_->InitIfNecessary( - root_->viewport_metrics().size_in_pixels.To<gfx::Size>(), - root_->viewport_metrics().device_pixel_ratio); - Load(response_.Pass()); - } - - UpdateWebviewSizeFromViewSize(); - web_layer_tree_view_impl_->set_view(root_); -} - -blink::WebStorageNamespace* HTMLDocument::createSessionStorageNamespace() { - return new WebStorageNamespaceImpl(); -} - -void HTMLDocument::initializeLayerTreeView() { - if (global_state_->is_headless()) { - web_layer_tree_view_impl_.reset( - new WebLayerTreeViewImpl(global_state_->compositor_thread(), nullptr, - nullptr, nullptr, nullptr)); - return; - } - - mojo::URLRequestPtr request(mojo::URLRequest::New()); - request->url = mojo::String::From("mojo:view_manager"); - mojo::SurfacePtr surface; - html_document_app_->ConnectToService(request.Pass(), &surface); - - // TODO(jamesr): Should be mojo:gpu_service - mojo::URLRequestPtr request2(mojo::URLRequest::New()); - request2->url = mojo::String::From("mojo:view_manager"); - mojo::GpuPtr gpu_service; - html_document_app_->ConnectToService(request2.Pass(), &gpu_service); - web_layer_tree_view_impl_.reset(new WebLayerTreeViewImpl( - global_state_->compositor_thread(), - global_state_->gpu_memory_buffer_manager(), - global_state_->raster_thread_helper()->task_graph_runner(), - surface.Pass(), gpu_service.Pass())); -} - -blink::WebLayerTreeView* HTMLDocument::layerTreeView() { - return web_layer_tree_view_impl_.get(); -} - -blink::WebMediaPlayer* HTMLDocument::createMediaPlayer( - blink::WebLocalFrame* frame, - const blink::WebURL& url, - blink::WebMediaPlayerClient* client, - blink::WebMediaPlayerEncryptedMediaClient* encrypted_client, - blink::WebContentDecryptionModule* initial_cdm) { - return global_state_->media_factory()->CreateMediaPlayer( - frame, url, client, encrypted_client, initial_cdm, - html_document_app_->shell()); -} - -blink::WebFrame* HTMLDocument::createChildFrame( - blink::WebLocalFrame* parent, - blink::WebTreeScopeType scope, - const blink::WebString& frameName, - blink::WebSandboxFlags sandboxFlags) { - blink::WebLocalFrame* child_frame = blink::WebLocalFrame::create(scope, this); - parent->appendChild(child_frame); - return child_frame; -} - -void HTMLDocument::frameDetached(blink::WebFrame* frame, DetachType type) { - DCHECK(type == DetachType::Remove); - if (frame->parent()) - frame->parent()->removeChild(frame); - - if (devtools_agent_ && frame == devtools_agent_->frame()) - devtools_agent_.reset(); - - // |frame| is invalid after here. - frame->close(); -} - -blink::WebCookieJar* HTMLDocument::cookieJar(blink::WebLocalFrame* frame) { - // TODO(darin): Blink does not fallback to the Platform provided WebCookieJar. - // Either it should, as it once did, or we should find another solution here. - return blink::Platform::current()->cookieJar(); -} - -blink::WebNavigationPolicy HTMLDocument::decidePolicyForNavigation( - const NavigationPolicyInfo& info) { - // TODO(yzshen): Force the current instance to handle all mainframe - // navigations locally, if remote debugging is enabled. Otherwise, we will - // lose DevTools agent state established in this HTMLDocument. - // This can be removed once crbug.com/517266 is fixed. - if (devtools_agent_ && devtools_agent_->frame() == info.frame) - return info.defaultPolicy; - - std::string frame_name = info.frame ? info.frame->assignedName().utf8() : ""; - - if (CanNavigateLocally(info.frame, info.urlRequest)) - return info.defaultPolicy; - - if (navigator_host_.get()) { - mojo::URLRequestPtr url_request = mojo::URLRequest::From(info.urlRequest); - navigator_host_->RequestNavigate( - WebNavigationPolicyToNavigationTarget(info.defaultPolicy), - url_request.Pass()); - } - - return blink::WebNavigationPolicyIgnore; -} - -blink::WebGeolocationClient* HTMLDocument::geolocationClient() { - if (!geolocation_client_impl_) - geolocation_client_impl_.reset(new GeolocationClientImpl); - return geolocation_client_impl_.get(); -} - -void HTMLDocument::didAddMessageToConsole( - const blink::WebConsoleMessage& message, - const blink::WebString& source_name, - unsigned source_line, - const blink::WebString& stack_trace) { - VLOG(1) << "[" << source_name.utf8() << "(" << source_line << ")] " - << message.text.utf8(); -} - -void HTMLDocument::didHandleOnloadEvents(blink::WebLocalFrame* frame) { - static bool recorded = false; - if (!recorded && startup_performance_data_collector_) { - startup_performance_data_collector_->SetFirstWebContentsMainFrameLoadTime( - base::Time::Now().ToInternalValue()); - recorded = true; - } -} - -void HTMLDocument::didFinishLoad(blink::WebLocalFrame* frame) { - // TODO(msw): Notify AxProvider clients of updates on child frame loads. - did_finish_load_ = true; - // Bind any pending AxProviderImpl interface requests. - for (auto it : ax_provider_requests_) - ax_providers_.insert(new AxProviderImpl(web_view_, it->Pass())); - STLDeleteElements(&ax_provider_requests_); -} - -void HTMLDocument::didNavigateWithinPage( - blink::WebLocalFrame* frame, - const blink::WebHistoryItem& history_item, - blink::WebHistoryCommitType commit_type) { - if (navigator_host_.get()) - navigator_host_->DidNavigateLocally(history_item.urlString().utf8()); -} - -void HTMLDocument::didFirstVisuallyNonEmptyLayout(blink::WebLocalFrame* frame) { - static bool recorded = false; - if (!recorded && startup_performance_data_collector_) { - startup_performance_data_collector_->SetFirstVisuallyNonEmptyLayoutTime( - base::Time::Now().ToInternalValue()); - recorded = true; - } -} - -blink::WebEncryptedMediaClient* HTMLDocument::encryptedMediaClient() { - return global_state_->media_factory()->GetEncryptedMediaClient(); -} - -void HTMLDocument::OnViewBoundsChanged(View* view, - const Rect& old_bounds, - const Rect& new_bounds) { - DCHECK_EQ(view, root_); - UpdateWebviewSizeFromViewSize(); -} - -void HTMLDocument::OnViewViewportMetricsChanged( - mojo::View* view, - const mojo::ViewportMetrics& old_metrics, - const mojo::ViewportMetrics& new_metrics) { - InitGlobalStateAndLoadIfNecessary(); -} - -void HTMLDocument::OnViewDestroyed(View* view) { - DCHECK_EQ(view, root_); - root_ = nullptr; -} - -void HTMLDocument::OnViewInputEvent(View* view, const mojo::EventPtr& event) { - if (event->pointer_data) { - // Blink expects coordintes to be in DIPs. - event->pointer_data->x /= global_state_->device_pixel_ratio(); - event->pointer_data->y /= global_state_->device_pixel_ratio(); - event->pointer_data->screen_x /= global_state_->device_pixel_ratio(); - event->pointer_data->screen_y /= global_state_->device_pixel_ratio(); - } - - if ((event->action == mojo::EVENT_TYPE_POINTER_DOWN || - event->action == mojo::EVENT_TYPE_POINTER_UP || - event->action == mojo::EVENT_TYPE_POINTER_CANCEL || - event->action == mojo::EVENT_TYPE_POINTER_MOVE) && - event->pointer_data->kind == mojo::POINTER_KIND_TOUCH) { - touch_handler_->OnTouchEvent(*event); - return; - } - scoped_ptr<blink::WebInputEvent> web_event = - event.To<scoped_ptr<blink::WebInputEvent>>(); - if (web_event) - web_view_->handleInputEvent(*web_event); -} - -void HTMLDocument::OnViewFocusChanged(mojo::View* gained_focus, - mojo::View* lost_focus) { - UpdateFocus(); -} - -void HTMLDocument::UpdateFocus() { - if (!web_view_) - return; - bool is_focused = root_ && root_->HasFocus(); - web_view_->setFocus(is_focused); - web_view_->setIsActive(is_focused); -} - -} // namespace html_viewer diff --git a/components/html_viewer/html_document.h b/components/html_viewer/html_document.h deleted file mode 100644 index eb20f46..0000000 --- a/components/html_viewer/html_document.h +++ /dev/null @@ -1,204 +0,0 @@ -// Copyright 2014 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 COMPONENTS_HTML_VIEWER_HTML_DOCUMENT_H_ -#define COMPONENTS_HTML_VIEWER_HTML_DOCUMENT_H_ - -#include <set> - -#include "base/callback.h" -#include "base/macros.h" -#include "components/html_viewer/ax_provider_impl.h" -#include "components/html_viewer/touch_handler.h" -#include "components/view_manager/public/cpp/view_manager_client_factory.h" -#include "components/view_manager/public/cpp/view_manager_delegate.h" -#include "components/view_manager/public/cpp/view_observer.h" -#include "mandoline/services/navigation/public/interfaces/navigation.mojom.h" -#include "mojo/application/public/cpp/app_lifetime_helper.h" -#include "mojo/application/public/cpp/interface_factory.h" -#include "mojo/application/public/cpp/lazy_interface_ptr.h" -#include "mojo/application/public/cpp/service_provider_impl.h" -#include "mojo/application/public/interfaces/application.mojom.h" -#include "mojo/application/public/interfaces/content_handler.mojom.h" -#include "mojo/services/network/public/interfaces/url_loader.mojom.h" -#include "mojo/services/tracing/public/interfaces/tracing.mojom.h" -#include "third_party/WebKit/public/web/WebFrameClient.h" -#include "third_party/WebKit/public/web/WebSandboxFlags.h" -#include "third_party/WebKit/public/web/WebViewClient.h" - -namespace base { -class SingleThreadTaskRunner; -} - -namespace mojo { -class ViewManager; -class View; -} - -namespace html_viewer { - -class AxProviderImpl; -class DevToolsAgentImpl; -class GeolocationClientImpl; -class GlobalState; -class WebLayerTreeViewImpl; - -// A view for a single HTML document. -// -// HTMLDocument is deleted in one of two ways: -// . When the View the HTMLDocument is embedded in is destroyed. -// . Explicitly by way of Destroy(). -class HTMLDocument : public blink::WebViewClient, - public blink::WebFrameClient, - public mojo::ViewManagerDelegate, - public mojo::ViewObserver, - public mojo::InterfaceFactory<mojo::AxProvider> { - public: - using DeleteCallback = base::Callback<void(HTMLDocument*)>; - - struct CreateParams { - CreateParams(mojo::ApplicationImpl* html_document_app, - mojo::ApplicationConnection* connection, - mojo::URLResponsePtr response, - GlobalState* global_state, - const DeleteCallback& delete_callback); - ~CreateParams(); - - mojo::ApplicationImpl* html_document_app; - mojo::ApplicationConnection* connection; - mojo::URLResponsePtr response; - GlobalState* global_state; - DeleteCallback delete_callback; - }; - - // Load a new HTMLDocument with |response|. - // |html_document_app| is the application this app was created in, and - // |connection| the specific connection triggering this new instance. - // |setup| is used to obtain init type state (such as resources). - explicit HTMLDocument(CreateParams* params); - - // Deletes this object. - void Destroy(); - - blink::WebView* web_view() const { return web_view_; } - - protected: - ~HTMLDocument() override; - - // WebViewClient methods: - virtual blink::WebStorageNamespace* createSessionStorageNamespace(); - - // WebWidgetClient methods: - void initializeLayerTreeView() override; - blink::WebLayerTreeView* layerTreeView() override; - - // WebFrameClient methods: - virtual blink::WebMediaPlayer* createMediaPlayer( - blink::WebLocalFrame* frame, - const blink::WebURL& url, - blink::WebMediaPlayerClient* client, - blink::WebMediaPlayerEncryptedMediaClient* encrypted_client, - blink::WebContentDecryptionModule* initial_cdm); - virtual blink::WebFrame* createChildFrame( - blink::WebLocalFrame* parent, - blink::WebTreeScopeType scope, - const blink::WebString& frameName, - blink::WebSandboxFlags sandboxFlags); - virtual void frameDetached(blink::WebFrame* frame, DetachType type); - virtual blink::WebCookieJar* cookieJar(blink::WebLocalFrame* frame); - virtual blink::WebNavigationPolicy decidePolicyForNavigation( - const NavigationPolicyInfo& info); - virtual blink::WebGeolocationClient* geolocationClient(); - - virtual void didAddMessageToConsole(const blink::WebConsoleMessage& message, - const blink::WebString& source_name, - unsigned source_line, - const blink::WebString& stack_trace); - virtual void didHandleOnloadEvents(blink::WebLocalFrame* frame); - virtual void didFinishLoad(blink::WebLocalFrame* frame); - virtual void didNavigateWithinPage(blink::WebLocalFrame* frame, - const blink::WebHistoryItem& history_item, - blink::WebHistoryCommitType commit_type); - virtual void didFirstVisuallyNonEmptyLayout(blink::WebLocalFrame* frame); - virtual blink::WebEncryptedMediaClient* encryptedMediaClient(); - - private: - // Data associated with a child iframe. - struct ChildFrameData { - mojo::View* view; - blink::WebTreeScopeType scope; - }; - - // Updates the size and scale factor of the webview and related classes from - // |root_|. - void UpdateWebviewSizeFromViewSize(); - - void InitGlobalStateAndLoadIfNecessary(); - - // ViewManagerDelegate methods: - void OnEmbed(mojo::View* root) override; - void OnViewManagerDestroyed(mojo::ViewManager* view_manager) override; - - // ViewObserver methods: - void OnViewBoundsChanged(mojo::View* view, - const mojo::Rect& old_bounds, - const mojo::Rect& new_bounds) override; - void OnViewViewportMetricsChanged( - mojo::View* view, - const mojo::ViewportMetrics& old_metrics, - const mojo::ViewportMetrics& new_metrics) override; - void OnViewDestroyed(mojo::View* view) override; - void OnViewInputEvent(mojo::View* view, const mojo::EventPtr& event) override; - void OnViewFocusChanged(mojo::View* gained_focus, - mojo::View* lost_focus) override; - - // mojo::InterfaceFactory<mojo::AxProvider> - void Create(mojo::ApplicationConnection* connection, - mojo::InterfaceRequest<mojo::AxProvider> request) override; - - void Load(mojo::URLResponsePtr response); - - // Converts a WebLocalFrame to a WebRemoteFrame. Used once we know the - // url of a frame to trigger the navigation. - void ConvertLocalFrameToRemoteFrame(blink::WebLocalFrame* frame); - - // Updates the focus state of |web_view_| based on the focus state of |root_|. - void UpdateFocus(); - - scoped_ptr<mojo::AppRefCount> app_refcount_; - mojo::ApplicationImpl* html_document_app_; - mojo::URLResponsePtr response_; - mojo::LazyInterfacePtr<mojo::NavigatorHost> navigator_host_; - blink::WebView* web_view_; - mojo::View* root_; - mojo::ViewManagerClientFactory view_manager_client_factory_; - scoped_ptr<WebLayerTreeViewImpl> web_layer_tree_view_impl_; - scoped_refptr<base::SingleThreadTaskRunner> compositor_thread_; - scoped_ptr<GeolocationClientImpl> geolocation_client_impl_; - - // HTMLDocument owns these pointers; binding requests after document load. - std::set<mojo::InterfaceRequest<mojo::AxProvider>*> ax_provider_requests_; - std::set<AxProviderImpl*> ax_providers_; - - // A flag set on didFinishLoad. - bool did_finish_load_ = false; - - GlobalState* global_state_; - - scoped_ptr<TouchHandler> touch_handler_; - - scoped_ptr<DevToolsAgentImpl> devtools_agent_; - - DeleteCallback delete_callback_; - - // This object is only valid in the context of performance tests. - tracing::StartupPerformanceDataCollectorPtr - startup_performance_data_collector_; - - DISALLOW_COPY_AND_ASSIGN(HTMLDocument); -}; - -} // namespace html_viewer - -#endif // COMPONENTS_HTML_VIEWER_HTML_DOCUMENT_H_ diff --git a/components/html_viewer/html_document_application_delegate.cc b/components/html_viewer/html_document_application_delegate.cc index 1182fe2..12a81cb 100644 --- a/components/html_viewer/html_document_application_delegate.cc +++ b/components/html_viewer/html_document_application_delegate.cc @@ -5,11 +5,8 @@ #include "components/html_viewer/html_document_application_delegate.h" #include "base/bind.h" -#include "base/command_line.h" #include "components/html_viewer/global_state.h" -#include "components/html_viewer/html_document.h" #include "components/html_viewer/html_document_oopif.h" -#include "components/html_viewer/html_viewer_switches.h" #include "mojo/application/public/cpp/application_connection.h" #include "mojo/application/public/cpp/application_delegate.h" #include "mojo/application/public/cpp/connect.h" @@ -18,14 +15,6 @@ namespace html_viewer { namespace { -bool EnableOOPIFs() { - if (base::CommandLine::ForCurrentProcess()->HasSwitch( - switches::kDisableOOPIF)) { - return false; - } - return true; -} - HTMLFrame* CreateHTMLFrame(HTMLFrame::CreateParams* params) { return new HTMLFrame(params); } @@ -91,11 +80,6 @@ HTMLDocumentApplicationDelegate::~HTMLDocumentApplicationDelegate() { // Deleting the documents is going to trigger a callback to // OnHTMLDocumentDeleted() and remove from |documents_|. Copy the set so we // don't have to worry about the set being modified out from under us. - std::set<HTMLDocument*> documents(documents_); - for (HTMLDocument* doc : documents) - doc->Destroy(); - DCHECK(documents_.empty()); - std::set<HTMLDocumentOOPIF*> documents2(documents2_); for (HTMLDocumentOOPIF* doc : documents2) doc->Destroy(); @@ -155,12 +139,6 @@ bool HTMLDocumentApplicationDelegate::ConfigureIncomingConnection( return true; } -void HTMLDocumentApplicationDelegate::OnHTMLDocumentDeleted( - HTMLDocument* document) { - DCHECK(documents_.count(document) > 0); - documents_.erase(document); -} - void HTMLDocumentApplicationDelegate::OnHTMLDocumentDeleted2( HTMLDocumentOOPIF* document) { DCHECK(documents2_.count(document) > 0); @@ -174,20 +152,12 @@ void HTMLDocumentApplicationDelegate::OnResponseReceived( mojo::URLResponsePtr response) { // HTMLDocument is destroyed when the hosting view is destroyed, or // explicitly from our destructor. - if (EnableOOPIFs()) { - HTMLDocumentOOPIF* document = new HTMLDocumentOOPIF( - &app_, connection, response.Pass(), global_state_, - base::Bind(&HTMLDocumentApplicationDelegate::OnHTMLDocumentDeleted2, - base::Unretained(this)), - html_frame_creation_callback_); - documents2_.insert(document); - } else { - HTMLDocument::CreateParams params( - &app_, connection, response.Pass(), global_state_, - base::Bind(&HTMLDocumentApplicationDelegate::OnHTMLDocumentDeleted, - base::Unretained(this))); - documents_.insert(new HTMLDocument(¶ms)); - } + HTMLDocumentOOPIF* document = new HTMLDocumentOOPIF( + &app_, connection, response.Pass(), global_state_, + base::Bind(&HTMLDocumentApplicationDelegate::OnHTMLDocumentDeleted2, + base::Unretained(this)), + html_frame_creation_callback_); + documents2_.insert(document); if (connector_queue) { connector_queue->PushRequestsTo(connection); diff --git a/components/html_viewer/html_document_application_delegate.h b/components/html_viewer/html_document_application_delegate.h index d416428..91acbf2 100644 --- a/components/html_viewer/html_document_application_delegate.h +++ b/components/html_viewer/html_document_application_delegate.h @@ -20,7 +20,6 @@ namespace html_viewer { class GlobalState; -class HTMLDocument; class HTMLDocumentOOPIF; // ApplicationDelegate created by the content handler for a specific url. @@ -53,7 +52,6 @@ class HTMLDocumentApplicationDelegate : public mojo::ApplicationDelegate { bool ConfigureIncomingConnection( mojo::ApplicationConnection* connection) override; - void OnHTMLDocumentDeleted(HTMLDocument* document); void OnHTMLDocumentDeleted2(HTMLDocumentOOPIF* document); void OnResponseReceived(mojo::URLLoaderPtr loader, mojo::ApplicationConnection* connection, @@ -70,10 +68,6 @@ class HTMLDocumentApplicationDelegate : public mojo::ApplicationDelegate { // As we create HTMLDocuments they are added here. They are removed when the // HTMLDocument is deleted. - std::set<HTMLDocument*> documents_; - - // As we create HTMLDocuments they are added here. They are removed when the - // HTMLDocument is deleted. std::set<HTMLDocumentOOPIF*> documents2_; HTMLFrameCreationCallback html_frame_creation_callback_; diff --git a/components/html_viewer/html_frame.cc b/components/html_viewer/html_frame.cc index 0d6c948..f17182a 100644 --- a/components/html_viewer/html_frame.cc +++ b/components/html_viewer/html_frame.cc @@ -34,7 +34,6 @@ #include "components/view_manager/public/cpp/view.h" #include "components/view_manager/public/cpp/view_manager.h" #include "components/view_manager/public/interfaces/surfaces.mojom.h" -#include "mandoline/services/navigation/public/interfaces/navigation.mojom.h" #include "mojo/application/public/cpp/application_impl.h" #include "mojo/application/public/cpp/connect.h" #include "mojo/application/public/interfaces/shell.mojom.h" diff --git a/components/html_viewer/html_frame_apptest.cc b/components/html_viewer/html_frame_apptest.cc index d220dea..46366c0 100644 --- a/components/html_viewer/html_frame_apptest.cc +++ b/components/html_viewer/html_frame_apptest.cc @@ -31,20 +31,11 @@ namespace mojo { namespace { -// Switch to enable out of process iframes. -const char kDisableOOPIF[] = "disable--oopifs"; - const char kAddFrameWithEmptyPageScript[] = "var iframe = document.createElement(\"iframe\");" "iframe.src = \"http://127.0.0.1:%u/files/empty_page.html\";" "document.body.appendChild(iframe);"; -bool EnableOOPIFs() { - if (base::CommandLine::ForCurrentProcess()->HasSwitch(kDisableOOPIF)) - return false; - return true; -} - mojo::ApplicationConnection* ApplicationConnectionForFrame(Frame* frame) { return static_cast<FrameConnection*>(frame->user_data()) ->application_connection(); @@ -204,9 +195,6 @@ class HTMLFrameTest : public ViewManagerTestBase { }; TEST_F(HTMLFrameTest, PageWithSingleFrame) { - if (!EnableOOPIFs()) - return; - View* embed_view = window_manager()->CreateView(); FrameConnection* root_connection = @@ -286,9 +274,6 @@ class ExistingFrameNavigationDelegate // Creates two frames. The parent navigates the child frame by way of changing // the location of the child frame. TEST_F(HTMLFrameTest, ChangeLocationOfChildFrame) { - if (!EnableOOPIFs()) - return; - View* embed_view = window_manager()->CreateView(); ExistingFrameNavigationDelegate frame_tree_delegate(application_impl()); @@ -328,9 +313,6 @@ TEST_F(HTMLFrameTest, ChangeLocationOfChildFrame) { } TEST_F(HTMLFrameTest, DynamicallyAddFrameAndVerifyParent) { - if (!EnableOOPIFs()) - return; - Frame* child_frame = LoadEmptyPageAndCreateFrame(nullptr); ASSERT_TRUE(child_frame); @@ -353,9 +335,6 @@ TEST_F(HTMLFrameTest, DynamicallyAddFrameAndVerifyParent) { } TEST_F(HTMLFrameTest, DynamicallyAddFrameAndSeeNameChange) { - if (!EnableOOPIFs()) - return; - Frame* child_frame = LoadEmptyPageAndCreateFrame(nullptr); ASSERT_TRUE(child_frame); @@ -391,9 +370,6 @@ TEST_F(HTMLFrameTest, DynamicallyAddFrameAndSeeNameChange) { // Triggers dynamic addition and removal of a frame. TEST_F(HTMLFrameTest, FrameTreeOfThreeLevels) { - if (!EnableOOPIFs()) - return; - // Create a child frame, and in that child frame create another child frame. Frame* child_frame = LoadEmptyPageAndCreateFrame(nullptr); ASSERT_TRUE(child_frame); @@ -451,9 +427,6 @@ TEST_F(HTMLFrameTest, FrameTreeOfThreeLevels) { // Verifies PostMessage() works across frames. TEST_F(HTMLFrameTest, PostMessage) { - if (!EnableOOPIFs()) - return; - mandoline::TestFrameTreeDelegate frame_tree_delegate; Frame* child_frame = LoadEmptyPageAndCreateFrame(&frame_tree_delegate); ASSERT_TRUE(child_frame); diff --git a/components/html_viewer/html_viewer_switches.cc b/components/html_viewer/html_viewer_switches.cc index ba17238..80c1020 100644 --- a/components/html_viewer/html_viewer_switches.cc +++ b/components/html_viewer/html_viewer_switches.cc @@ -7,8 +7,6 @@ namespace html_viewer { namespace switches { -const char kDisableOOPIF[] = "disable--oopifs"; - const char kOOPIFAlwaysCreateNewFrameTree[] = "oopif-always-create-new-frame-tree"; diff --git a/components/html_viewer/html_viewer_switches.h b/components/html_viewer/html_viewer_switches.h index 5b3b25d..23214d8 100644 --- a/components/html_viewer/html_viewer_switches.h +++ b/components/html_viewer/html_viewer_switches.h @@ -8,9 +8,6 @@ namespace html_viewer { namespace switches { -// Switch to disable out of process iframes. -extern const char kDisableOOPIF[]; - // If true a new HTMLFrameTreeManager is always created, even if a matching // HTMLFrameTreeManager is found. This is useful for tests (or debugging) that // want to synthesize what happens with multi-processes in a single process. |