Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1043)

Unified Diff: mojo/services/html_viewer/html_viewer.cc

Issue 489493004: Update view manager to support content handling. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: blah to the blizzah Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: mojo/services/html_viewer/html_viewer.cc
diff --git a/mojo/services/html_viewer/html_viewer.cc b/mojo/services/html_viewer/html_viewer.cc
index aa8d46bfb299d1bc5330006a5c5aa56880c4da95..59c48b6afb3bec953b13815f96a2371cbf324f46 100644
--- a/mojo/services/html_viewer/html_viewer.cc
+++ b/mojo/services/html_viewer/html_viewer.cc
@@ -9,109 +9,74 @@
#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/public/cpp/application/service_provider_impl.h"
#include "mojo/services/html_viewer/blink_platform_impl.h"
#include "mojo/services/html_viewer/html_document_view.h"
-#include "mojo/services/public/cpp/view_manager/types.h"
-#include "mojo/services/public/cpp/view_manager/view.h"
-#include "mojo/services/public/cpp/view_manager/view_manager.h"
-#include "mojo/services/public/cpp/view_manager/view_manager_client_factory.h"
-#include "mojo/services/public/cpp/view_manager/view_manager_delegate.h"
-#include "mojo/services/public/interfaces/navigation/navigation.mojom.h"
+#include "mojo/services/public/interfaces/content_handler/content_handler.mojom.h"
#include "third_party/WebKit/public/web/WebKit.h"
namespace mojo {
class HTMLViewer;
-class NavigatorImpl : public InterfaceImpl<Navigator> {
+class ContentHandlerImpl : public InterfaceImpl<ContentHandler> {
public:
- explicit NavigatorImpl(HTMLViewer* viewer) : viewer_(viewer) {}
- virtual ~NavigatorImpl() {}
+ explicit ContentHandlerImpl(ApplicationConnection* application_connection)
+ : application_connection_(application_connection) {
+ }
+ virtual ~ContentHandlerImpl() {}
private:
- // Overridden from Navigator:
- virtual void Navigate(
- uint32_t view_id,
- NavigationDetailsPtr navigation_details,
- ResponseDetailsPtr response_details) OVERRIDE;
+ // Overridden from ContentHandler:
+ virtual void OnConnect(
+ const mojo::String& url,
+ ContentHandlerResponsePtr response,
+ InterfaceRequest<ServiceProvider> service_provider) OVERRIDE {
+ ServiceProviderImpl* exported_services =
+ new ServiceProviderImpl(application_connection_);
+ BindToRequest(exported_services, &service_provider);
+ scoped_ptr<ServiceProvider> remote(
+ exported_services->CreateRemoteServiceProvider());
+ new HTMLDocumentView(response.Pass(), remote.Pass(), exported_services,
+ application_connection_);
+ }
- HTMLViewer* viewer_;
+ ApplicationConnection* application_connection_;
- DISALLOW_COPY_AND_ASSIGN(NavigatorImpl);
+ DISALLOW_COPY_AND_ASSIGN(ContentHandlerImpl);
};
-class HTMLViewer : public ApplicationDelegate, public ViewManagerDelegate {
+class HTMLViewer : public ApplicationDelegate {
public:
HTMLViewer()
- : application_impl_(NULL),
- document_view_(NULL),
- navigator_factory_(this),
- view_manager_client_factory_(this) {}
- virtual ~HTMLViewer() {
- blink::shutdown();
+ : content_handler_factory_(NULL) {
}
- void Load(ResponseDetailsPtr response_details) {
- // Need to wait for OnEmbed.
- response_details_ = response_details.Pass();
- MaybeLoad();
+ virtual ~HTMLViewer() {
+ blink::shutdown();
}
private:
// Overridden from ApplicationDelegate:
virtual void Initialize(ApplicationImpl* app) OVERRIDE {
- application_impl_ = app;
blink_platform_impl_.reset(new BlinkPlatformImpl(app));
blink::initialize(blink_platform_impl_.get());
}
virtual bool ConfigureIncomingConnection(ApplicationConnection* connection)
OVERRIDE {
- connection->AddService(&navigator_factory_);
- connection->AddService(&view_manager_client_factory_);
+ content_handler_factory_.set_context(connection);
+ connection->AddService(&content_handler_factory_);
return true;
}
- // Overridden from ViewManagerDelegate:
- virtual void OnEmbed(ViewManager* view_manager,
- View* root,
- ServiceProviderImpl* exported_services,
- scoped_ptr<ServiceProvider> imported_services) OVERRIDE {
- document_view_ = new HTMLDocumentView(
- application_impl_->ConnectToApplication("mojo://mojo_window_manager/")->
- GetServiceProvider(),
- view_manager);
- document_view_->AttachToView(root);
- MaybeLoad();
- }
- virtual void OnViewManagerDisconnected(ViewManager* view_manager) OVERRIDE {
- base::MessageLoop::current()->Quit();
- }
-
- void MaybeLoad() {
- if (document_view_ && response_details_ && response_details_->response)
- document_view_->Load(response_details_->response.Pass());
- }
-
scoped_ptr<BlinkPlatformImpl> blink_platform_impl_;
- ApplicationImpl* application_impl_;
-
- // TODO(darin): Figure out proper ownership of this instance.
- HTMLDocumentView* document_view_;
- ResponseDetailsPtr response_details_;
- InterfaceFactoryImplWithContext<NavigatorImpl, HTMLViewer> navigator_factory_;
- ViewManagerClientFactory view_manager_client_factory_;
+ InterfaceFactoryImplWithContext<ContentHandlerImpl, ApplicationConnection>
+ content_handler_factory_;
DISALLOW_COPY_AND_ASSIGN(HTMLViewer);
};
-void NavigatorImpl::Navigate(
- uint32_t view_id,
- NavigationDetailsPtr navigation_details,
- ResponseDetailsPtr response_details) {
- viewer_->Load(response_details.Pass());
-}
-
} // namespace mojo
MojoResult MojoMain(MojoHandle shell_handle) {
« no previous file with comments | « mojo/services/html_viewer/html_document_view.cc ('k') | mojo/services/public/interfaces/content_handler/content_handler.mojom » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698