diff options
author | aa <aa@chromium.org> | 2014-09-10 23:57:51 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-09-11 07:03:49 +0000 |
commit | 9d091c28a8b6c3b8117462cb661a8c3967fb27e7 (patch) | |
tree | 78e8763d216959b063a7db7aaf93d5c8f57b3a8d /mojo | |
parent | 47fd5efc2beccec3a4eff5ea8953df08d7012d3b (diff) | |
download | chromium_src-9d091c28a8b6c3b8117462cb661a8c3967fb27e7.zip chromium_src-9d091c28a8b6c3b8117462cb661a8c3967fb27e7.tar.gz chromium_src-9d091c28a8b6c3b8117462cb661a8c3967fb27e7.tar.bz2 |
Various mojom cleanup from ContentHandler changes.
Review URL: https://codereview.chromium.org/549273002
Cr-Commit-Position: refs/heads/master@{#294342}
Diffstat (limited to 'mojo')
-rw-r--r-- | mojo/examples/browser/browser.cc | 6 | ||||
-rw-r--r-- | mojo/examples/embedded_app/embedded_app.cc | 7 | ||||
-rw-r--r-- | mojo/examples/media_viewer/media_viewer.cc | 6 | ||||
-rw-r--r-- | mojo/examples/window_manager/debug_panel.cc | 6 | ||||
-rw-r--r-- | mojo/examples/window_manager/debug_panel.h | 7 | ||||
-rw-r--r-- | mojo/examples/window_manager/window_manager.cc | 21 | ||||
-rw-r--r-- | mojo/mojo.gyp | 1 | ||||
-rw-r--r-- | mojo/mojo_examples.gypi | 2 | ||||
-rw-r--r-- | mojo/mojo_services.gypi | 33 | ||||
-rw-r--r-- | mojo/services/BUILD.gn | 1 | ||||
-rw-r--r-- | mojo/services/html_viewer/html_document_view.cc | 5 | ||||
-rw-r--r-- | mojo/services/launcher/DEPS | 3 | ||||
-rw-r--r-- | mojo/services/launcher/launcher.cc | 184 | ||||
-rw-r--r-- | mojo/services/public/interfaces/launcher/BUILD.gn | 16 | ||||
-rw-r--r-- | mojo/services/public/interfaces/launcher/launcher.mojom | 30 | ||||
-rw-r--r-- | mojo/services/public/interfaces/navigation/navigation.mojom | 21 |
16 files changed, 23 insertions, 326 deletions
diff --git a/mojo/examples/browser/browser.cc b/mojo/examples/browser/browser.cc index 4b03492..8937383 100644 --- a/mojo/examples/browser/browser.cc +++ b/mojo/examples/browser/browser.cc @@ -229,9 +229,9 @@ class Browser : public ApplicationDelegate, if (key_event.key_code() == ui::VKEY_RETURN) { GURL url(sender->text()); printf("User entered this URL: %s\n", url.spec().c_str()); - NavigationDetailsPtr nav_details(NavigationDetails::New()); - nav_details->request->url = String::From(url); - navigator_host_->RequestNavigate(TARGET_NEW_NODE, nav_details.Pass()); + URLRequestPtr request(URLRequest::New()); + request->url = String::From(url); + navigator_host_->RequestNavigate(TARGET_NEW_NODE, request.Pass()); } return false; } diff --git a/mojo/examples/embedded_app/embedded_app.cc b/mojo/examples/embedded_app/embedded_app.cc index d2fa56b..715a38e 100644 --- a/mojo/examples/embedded_app/embedded_app.cc +++ b/mojo/examples/embedded_app/embedded_app.cc @@ -81,13 +81,12 @@ class EmbeddedApp virtual void OnViewInputEvent(View* view, const EventPtr& event) OVERRIDE { if (event->action == EVENT_TYPE_MOUSE_RELEASED) { if (event->flags & EVENT_FLAGS_LEFT_MOUSE_BUTTON) { - NavigationDetailsPtr nav_details(NavigationDetails::New()); - nav_details->request->url = - "http://www.aaronboodman.com/z_dropbox/test.html"; + URLRequestPtr request(URLRequest::New()); + request->url = "http://www.aaronboodman.com/z_dropbox/test.html"; NavigatorHostPtr navigator_host; ConnectToService(windows_[view->id()]->embedder_service_provider.get(), &navigator_host); - navigator_host->RequestNavigate(TARGET_SOURCE_NODE, nav_details.Pass()); + navigator_host->RequestNavigate(TARGET_SOURCE_NODE, request.Pass()); } } } diff --git a/mojo/examples/media_viewer/media_viewer.cc b/mojo/examples/media_viewer/media_viewer.cc index c5de1c2..ea42fe7 100644 --- a/mojo/examples/media_viewer/media_viewer.cc +++ b/mojo/examples/media_viewer/media_viewer.cc @@ -210,12 +210,6 @@ class MediaViewer private: typedef std::map<std::string, std::string> HandlerMap; - struct PendingNavigateRequest { - uint32_t view_id; - NavigationDetailsPtr navigation_details; - ResponseDetailsPtr response_details; - }; - // Overridden from ApplicationDelegate: virtual void Initialize(ApplicationImpl* app) OVERRIDE { diff --git a/mojo/examples/window_manager/debug_panel.cc b/mojo/examples/window_manager/debug_panel.cc index 1290017..c65785c 100644 --- a/mojo/examples/window_manager/debug_panel.cc +++ b/mojo/examples/window_manager/debug_panel.cc @@ -125,9 +125,9 @@ void DebugPanel::ButtonPressed(views::Button* sender, const ui::Event& event) { } void DebugPanel::Navigate(const std::string& url) { - NavigationDetailsPtr details(NavigationDetails::New()); - details->request->url = url; - delegate_->RequestNavigate(view_->id(), TARGET_NEW_NODE, details.Pass()); + URLRequestPtr request(URLRequest::New()); + request->url = url; + delegate_->RequestNavigate(view_->id(), TARGET_NEW_NODE, request.Pass()); } } // namespace examples diff --git a/mojo/examples/window_manager/debug_panel.h b/mojo/examples/window_manager/debug_panel.h index 90e4da8..3a771aa 100644 --- a/mojo/examples/window_manager/debug_panel.h +++ b/mojo/examples/window_manager/debug_panel.h @@ -33,9 +33,10 @@ class DebugPanel : public views::LayoutManager, public views::ButtonListener { class Delegate { public: virtual void CloseTopWindow() = 0; - virtual void RequestNavigate( - uint32 source_view_id, Target target, - NavigationDetailsPtr nav_details) = 0; + virtual void RequestNavigate(uint32 source_view_id, + Target target, + URLRequestPtr url_request) = 0; + protected: virtual ~Delegate(){} }; diff --git a/mojo/examples/window_manager/window_manager.cc b/mojo/examples/window_manager/window_manager.cc index e15453e..bdf9609 100644 --- a/mojo/examples/window_manager/window_manager.cc +++ b/mojo/examples/window_manager/window_manager.cc @@ -22,7 +22,6 @@ #include "mojo/services/public/cpp/view_manager/view_observer.h" #include "mojo/services/public/cpp/view_manager/window_manager_delegate.h" #include "mojo/services/public/interfaces/input_events/input_events.mojom.h" -#include "mojo/services/public/interfaces/launcher/launcher.mojom.h" #include "mojo/services/public/interfaces/navigation/navigation.mojom.h" #include "mojo/services/window_manager/window_manager_app.h" #include "mojo/views/views_init.h" @@ -74,9 +73,7 @@ class NavigatorHostImpl : public InterfaceImpl<NavigatorHost> { private: virtual void DidNavigateLocally(const mojo::String& url) OVERRIDE; - virtual void RequestNavigate( - Target target, - NavigationDetailsPtr nav_details) OVERRIDE; + virtual void RequestNavigate(Target target, URLRequestPtr request) OVERRIDE; WindowManager* window_manager_; Id view_id_; @@ -342,11 +339,10 @@ class WindowManager CloseWindow(windows_.back()->view()->id()); } - virtual void RequestNavigate( - uint32 source_view_id, - Target target, - NavigationDetailsPtr nav_details) OVERRIDE { - OnLaunch(source_view_id, target, nav_details->request->url); + virtual void RequestNavigate(uint32 source_view_id, + Target target, + URLRequestPtr request) OVERRIDE { + OnLaunch(source_view_id, target, request->url); } private: @@ -452,8 +448,6 @@ class WindowManager // TODO(beng): proper layout manager!! Id CreateLauncherUI() { - NavigationDetailsPtr nav_details; - ResponseDetailsPtr response; View* view = view_manager_->GetViewById(content_view_id_); gfx::Rect bounds = view->bounds(); bounds.Inset(kBorderInset, kBorderInset); @@ -557,9 +551,8 @@ void NavigatorHostImpl::DidNavigateLocally(const mojo::String& url) { window_manager_->DidNavigateLocally(view_id_, url); } -void NavigatorHostImpl::RequestNavigate(Target target, - NavigationDetailsPtr nav_details) { - window_manager_->RequestNavigate(view_id_, target, nav_details.Pass()); +void NavigatorHostImpl::RequestNavigate(Target target, URLRequestPtr request) { + window_manager_->RequestNavigate(view_id_, target, request.Pass()); } } // namespace examples diff --git a/mojo/mojo.gyp b/mojo/mojo.gyp index 75dad88..2bebd13 100644 --- a/mojo/mojo.gyp +++ b/mojo/mojo.gyp @@ -37,7 +37,6 @@ 'mojo_geometry_lib', 'mojo_html_viewer', 'mojo_js', - 'mojo_launcher', 'mojo_native_viewport_service_lib', 'mojo_network_service', 'mojo_pepper_container_app', diff --git a/mojo/mojo_examples.gypi b/mojo/mojo_examples.gypi index 154e426..ddfc312 100644 --- a/mojo/mojo_examples.gypi +++ b/mojo/mojo_examples.gypi @@ -246,7 +246,6 @@ 'mojo_content_handler_bindings', 'mojo_media_viewer_bindings', 'mojo_network_bindings', - 'mojo_launcher_bindings', 'mojo_view_manager_lib', '<(mojo_system_for_loadable_module)', ], @@ -657,7 +656,6 @@ 'mojo_geometry_lib', 'mojo_input_events_lib', 'mojo_keyboard_bindings', - 'mojo_launcher_bindings', 'mojo_navigation_bindings', 'mojo_view_manager_lib', 'mojo_views_support', diff --git a/mojo/mojo_services.gypi b/mojo/mojo_services.gypi index f9847b6..c5a68a4 100644 --- a/mojo/mojo_services.gypi +++ b/mojo/mojo_services.gypi @@ -20,7 +20,6 @@ 'mojo_content_handler_bindings', 'mojo_navigation_bindings', 'mojo_network_bindings', - 'mojo_launcher_bindings', 'mojo_view_manager_lib', '<(mojo_system_for_loadable_module)', ], @@ -462,38 +461,6 @@ ], }, { - # GN version: //mojo/services/public/interfaces/launcher - 'target_name': 'mojo_launcher_bindings', - 'type': 'static_library', - 'sources': [ - 'services/public/interfaces/launcher/launcher.mojom', - ], - 'includes': [ 'public/tools/bindings/mojom_bindings_generator.gypi' ], - 'export_dependent_settings': [ - 'mojo_base.gyp:mojo_cpp_bindings', - ], - 'dependencies': [ - 'mojo_base.gyp:mojo_cpp_bindings', - 'mojo_navigation_bindings', - ], - }, - { - 'target_name': 'mojo_launcher', - 'type': 'loadable_module', - 'dependencies': [ - '../base/base.gyp:base', - '../url/url.gyp:url_lib', - 'mojo_base.gyp:mojo_cpp_bindings', - 'mojo_base.gyp:mojo_application_chromium', - 'mojo_launcher_bindings', - 'mojo_network_bindings', - '<(mojo_system_for_loadable_module)', - ], - 'sources': [ - 'services/launcher/launcher.cc', - ], - }, - { # GN version: //mojo/services/public/interfaces/view_manager 'target_name': 'mojo_view_manager_bindings', 'type': 'static_library', diff --git a/mojo/services/BUILD.gn b/mojo/services/BUILD.gn index f78a0f9..f297fb2 100644 --- a/mojo/services/BUILD.gn +++ b/mojo/services/BUILD.gn @@ -11,7 +11,6 @@ group("services") { "//mojo/services/public/interfaces/content_handler", "//mojo/services/public/interfaces/geometry", "//mojo/services/public/interfaces/input_events", - "//mojo/services/public/interfaces/launcher", "//mojo/services/public/interfaces/native_viewport", "//mojo/services/public/interfaces/navigation", "//mojo/services/public/interfaces/network", diff --git a/mojo/services/html_viewer/html_document_view.cc b/mojo/services/html_viewer/html_document_view.cc index 6b64012..d0c48f8 100644 --- a/mojo/services/html_viewer/html_document_view.cc +++ b/mojo/services/html_viewer/html_document_view.cc @@ -191,12 +191,9 @@ blink::WebNavigationPolicy HTMLDocumentView::decidePolicyForNavigation( if (CanNavigateLocally(frame, request)) return default_policy; - NavigationDetailsPtr nav_details(NavigationDetails::New()); - nav_details->request = URLRequest::From(request); - navigator_host_->RequestNavigate( WebNavigationPolicyToNavigationTarget(default_policy), - nav_details.Pass()); + URLRequest::From(request).Pass()); return blink::WebNavigationPolicyIgnore; } diff --git a/mojo/services/launcher/DEPS b/mojo/services/launcher/DEPS deleted file mode 100644 index 28f1ec1..0000000 --- a/mojo/services/launcher/DEPS +++ /dev/null @@ -1,3 +0,0 @@ -include_rules = [ - "+mojo/services/public", -] diff --git a/mojo/services/launcher/launcher.cc b/mojo/services/launcher/launcher.cc deleted file mode 100644 index 7971551..0000000 --- a/mojo/services/launcher/launcher.cc +++ /dev/null @@ -1,184 +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 "base/bind.h" -#include "base/compiler_specific.h" -#include "base/message_loop/message_loop.h" -#include "base/strings/string_tokenizer.h" -#include "base/strings/string_util.h" -#include "mojo/public/c/system/main.h" -#include "mojo/public/cpp/application/application_connection.h" -#include "mojo/public/cpp/application/application_delegate.h" -#include "mojo/public/cpp/application/application_impl.h" -#include "mojo/public/cpp/application/application_runner_chromium.h" -#include "mojo/public/cpp/application/interface_factory_impl.h" -#include "mojo/services/public/cpp/view_manager/types.h" -#include "mojo/services/public/interfaces/launcher/launcher.mojom.h" -#include "mojo/services/public/interfaces/network/network_service.mojom.h" -#include "mojo/services/public/interfaces/network/url_loader.mojom.h" -#include "url/gurl.h" - -namespace mojo { - -namespace { - -typedef mojo::Callback<void(String handler_url, String view_url, - ResponseDetailsPtr response)> LaunchCallback; - -} - -class LauncherApp; - -class LauncherConnection : public InterfaceImpl<Launcher> { - public: - explicit LauncherConnection(LauncherApp* app) : app_(app) {} - virtual ~LauncherConnection() {} - - private: - // Overridden from Launcher: - virtual void Launch(NavigationDetailsPtr nav_details, - const LaunchCallback& callback) OVERRIDE; - - LauncherApp* app_; - - DISALLOW_COPY_AND_ASSIGN(LauncherConnection); -}; - -class LaunchInstance { - public: - LaunchInstance(LauncherApp* app, - const LaunchCallback& callback, - NavigationDetailsPtr nav_details); - virtual ~LaunchInstance() {} - - private: - void OnReceivedResponse(URLResponsePtr response); - - std::string GetContentType(const Array<String>& headers) { - for (size_t i = 0; i < headers.size(); ++i) { - base::StringTokenizer t(headers[i], ": ;="); - while (t.GetNext()) { - if (!t.token_is_delim() && - LowerCaseEqualsASCII(t.token(), "content-type")) { - while (t.GetNext()) { - if (!t.token_is_delim()) - return t.token(); - } - } - } - } - return ""; - } - - void ScheduleDestroy() { - if (destroy_scheduled_) - return; - destroy_scheduled_ = true; - base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); - } - - LauncherApp* app_; - bool destroy_scheduled_; - const LaunchCallback callback_; - URLLoaderPtr url_loader_; - ScopedDataPipeConsumerHandle response_body_stream_; - - DISALLOW_COPY_AND_ASSIGN(LaunchInstance); -}; - -class LauncherApp : public ApplicationDelegate { - public: - LauncherApp() : launcher_connection_factory_(this) { - handler_map_["text/html"] = "mojo:mojo_html_viewer"; - handler_map_["image/png"] = "mojo:mojo_media_viewer"; - } - virtual ~LauncherApp() {} - - URLLoaderPtr CreateURLLoader() { - URLLoaderPtr loader; - network_service_->CreateURLLoader(Get(&loader)); - return loader.Pass(); - } - - std::string GetHandlerForContentType(const std::string& content_type) { - HandlerMap::const_iterator it = handler_map_.find(content_type); - return it != handler_map_.end() ? it->second : ""; - } - - private: - typedef std::map<std::string, std::string> HandlerMap; - - // Overridden from ApplicationDelegate: - virtual void Initialize(ApplicationImpl* app) MOJO_OVERRIDE { - app->ConnectToService("mojo:mojo_network_service", &network_service_); - } - - virtual bool ConfigureIncomingConnection(ApplicationConnection* connection) - MOJO_OVERRIDE { - connection->AddService(&launcher_connection_factory_); - return true; - } - - InterfaceFactoryImplWithContext<LauncherConnection, LauncherApp> - launcher_connection_factory_; - - HandlerMap handler_map_; - NetworkServicePtr network_service_; - - DISALLOW_COPY_AND_ASSIGN(LauncherApp); -}; - -void LauncherConnection::Launch(NavigationDetailsPtr nav_details, - const LaunchCallback& callback) { - GURL url(nav_details->request->url.To<std::string>()); - - // For Mojo URLs, the handler can always be found at the origin. - // TODO(aa): Return error for invalid URL? - if (url.is_valid() && url.SchemeIs("mojo")) { - callback.Run(url.GetOrigin().spec(), - nav_details->request->url, - ResponseDetailsPtr()); - return; - } - new LaunchInstance(app_, callback, nav_details.Pass()); -} - -LaunchInstance::LaunchInstance(LauncherApp* app, - const LaunchCallback& callback, - NavigationDetailsPtr nav_details) - : app_(app), - destroy_scheduled_(false), - callback_(callback) { - URLRequestPtr request = nav_details->request.Pass(); - request->auto_follow_redirects = true; - - url_loader_ = app_->CreateURLLoader(); - url_loader_->Start(request.Pass(), - base::Bind(&LaunchInstance::OnReceivedResponse, - base::Unretained(this))); -} - -void LaunchInstance::OnReceivedResponse(URLResponsePtr response) { - if (!response->error) { - std::string content_type = GetContentType(response->headers); - std::string handler_url = app_->GetHandlerForContentType(content_type); - if (handler_url.empty()) { - DLOG(WARNING) << "No handler for content type: " << content_type; - } else { - ResponseDetailsPtr nav_response(ResponseDetails::New()); - nav_response->loader = url_loader_.Pass(); - nav_response->response = response.Pass(); - String response_url = nav_response->response->url; - callback_.Run(handler_url, response_url, nav_response.Pass()); - } - } - ScheduleDestroy(); -} - -} // namespace mojo - -MojoResult MojoMain(MojoHandle shell_handle) { - mojo::ApplicationRunnerChromium runner(new mojo::LauncherApp); - return runner.Run(shell_handle); -} diff --git a/mojo/services/public/interfaces/launcher/BUILD.gn b/mojo/services/public/interfaces/launcher/BUILD.gn deleted file mode 100644 index 02dc51c..0000000 --- a/mojo/services/public/interfaces/launcher/BUILD.gn +++ /dev/null @@ -1,16 +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. - -import("//mojo/public/tools/bindings/mojom.gni") - -# GYP version: mojo/mojo_services.gypi:mojo_launcher_bindings -mojom("launcher") { - sources = [ - "launcher.mojom", - ] - - deps = [ - "//mojo/services/public/interfaces/navigation", - ] -} diff --git a/mojo/services/public/interfaces/launcher/launcher.mojom b/mojo/services/public/interfaces/launcher/launcher.mojom deleted file mode 100644 index 46f0dcc..0000000 --- a/mojo/services/public/interfaces/launcher/launcher.mojom +++ /dev/null @@ -1,30 +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. - -import "mojo/services/public/interfaces/navigation/navigation.mojom" - -module mojo { - -interface Launcher { - // Determines the correct handler application that can render a given URL. - // - // Sometimes this is known statically from the URL (e.g., from its scheme, or - // because we already have an application locally that has said it can handle - // the URL. Other times, we will actually fetch |url| to examine its - // content-type and/or sniff it to determine the correct handler. - // - // When the caller receives the result, it should connect to the application - // at |handler_url| and navigate it to |view_url|. - // - // Note: |view_url| might not be the same as |url|, e.g., in the case of - // redirects. Applications should navigate to view_url, not |url| or - // response->url. - // - // Note: |response| can be NULL in the case where a request was not needed to - // determine the correct handler. - Launch(NavigationDetails? details) => - (string? handler_url, string? view_url, ResponseDetails? response); -}; - -} diff --git a/mojo/services/public/interfaces/navigation/navigation.mojom b/mojo/services/public/interfaces/navigation/navigation.mojom index abaa69e..6a9e94f9 100644 --- a/mojo/services/public/interfaces/navigation/navigation.mojom +++ b/mojo/services/public/interfaces/navigation/navigation.mojom @@ -18,30 +18,13 @@ enum Target { NEW_NODE }; -struct NavigationDetails { - // TODO(mpcomplete): will we ever need more than the URLRequest? Can - // we pass that around directly? - URLRequest? request = default; -}; - -struct ResponseDetails { - // TODO(beng): consider providing access to URLRequest too. Currently it is - // not possible to obtain from the URLLoader. - - URLResponse? response; - - // The URLLoader instance that generated the response. This must be kept - // alive until the response body has been completely consumed. - URLLoader? loader; -}; - // Embedders that support navigation of implement this interface. interface NavigatorHost { - RequestNavigate(Target target, NavigationDetails? details); + RequestNavigate(Target target, URLRequest request); // Applications call this to inform hosts of navigations they performed // locally. For example, pushState() navigations in an HTML application. - DidNavigateLocally(string? url); + DidNavigateLocally(string url); }; } |