Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / mojo / services / html_viewer / html_viewer.cc
index 24a8050..518f28e 100644 (file)
@@ -2,6 +2,7 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
+#include "base/macros.h"
 #include "base/message_loop/message_loop.h"
 #include "base/threading/thread.h"
 #include "mojo/application/application_runner_chromium.h"
 
 namespace mojo {
 
+// Switches for html_viewer to be used with "--args-for". For example:
+// --args-for='mojo:html_viewer --enable-mojo-media-renderer'
+
+// Enable mojo::MediaRenderer in media pipeline instead of using the internal
+// media::Renderer implementation.
+const char kEnableMojoMediaRenderer[] = "--enable-mojo-media-renderer";
+
 class HTMLViewer;
 
 class ContentHandlerImpl : public InterfaceImpl<ContentHandler> {
  public:
-  ContentHandlerImpl(Shell* shell,
-                     scoped_refptr<base::MessageLoopProxy> compositor_thread,
+  ContentHandlerImpl(scoped_refptr<base::MessageLoopProxy> compositor_thread,
                      WebMediaPlayerFactory* web_media_player_factory)
-      : shell_(shell),
-        compositor_thread_(compositor_thread),
+      : compositor_thread_(compositor_thread),
         web_media_player_factory_(web_media_player_factory) {}
-  virtual ~ContentHandlerImpl() {}
+  ~ContentHandlerImpl() override {}
 
  private:
   // Overridden from ContentHandler:
-  virtual void OnConnect(
-      const mojo::String& url,
-      URLResponsePtr response,
-      InterfaceRequest<ServiceProvider> service_provider_request) OVERRIDE {
+  void StartApplication(ShellPtr shell, URLResponsePtr response) override {
     new HTMLDocumentView(response.Pass(),
-                         service_provider_request.Pass(),
-                         shell_,
+                         shell.Pass(),
                          compositor_thread_,
                          web_media_player_factory_);
   }
 
-  Shell* shell_;
   scoped_refptr<base::MessageLoopProxy> compositor_thread_;
   WebMediaPlayerFactory* web_media_player_factory_;
 
@@ -62,46 +63,51 @@ class HTMLViewer : public ApplicationDelegate,
  public:
   HTMLViewer() : compositor_thread_("compositor thread") {}
 
-  virtual ~HTMLViewer() { blink::shutdown(); }
+  ~HTMLViewer() override { blink::shutdown(); }
 
  private:
   // Overridden from ApplicationDelegate:
-  virtual void Initialize(ApplicationImpl* app) OVERRIDE {
-    shell_ = app->shell();
+  void Initialize(ApplicationImpl* app) override {
     blink_platform_impl_.reset(new BlinkPlatformImpl(app));
     blink::initialize(blink_platform_impl_.get());
 #if !defined(COMPONENT_BUILD)
-  base::i18n::InitializeICU();
+    base::i18n::InitializeICU();
 
-  ui::RegisterPathProvider();
+    ui::RegisterPathProvider();
 
-  base::FilePath ui_test_pak_path;
-  CHECK(PathService::Get(ui::UI_TEST_PAK, &ui_test_pak_path));
-  ui::ResourceBundle::InitSharedInstanceWithPakPath(ui_test_pak_path);
+    base::FilePath ui_test_pak_path;
+    CHECK(PathService::Get(ui::UI_TEST_PAK, &ui_test_pak_path));
+    ui::ResourceBundle::InitSharedInstanceWithPakPath(ui_test_pak_path);
 #endif
 
+    bool enable_mojo_media_renderer = false;
+    for (const auto& arg : app->args()) {
+      if (arg == kEnableMojoMediaRenderer) {
+        enable_mojo_media_renderer = true;
+        break;
+      }
+    }
+
     compositor_thread_.Start();
     web_media_player_factory_.reset(new WebMediaPlayerFactory(
-        compositor_thread_.message_loop_proxy()));
+        compositor_thread_.message_loop_proxy(), enable_mojo_media_renderer));
   }
 
-  virtual bool ConfigureIncomingConnection(ApplicationConnection* connection)
-      OVERRIDE {
+  bool ConfigureIncomingConnection(ApplicationConnection* connection) override {
     connection->AddService(this);
     return true;
   }
 
   // Overridden from InterfaceFactory<ContentHandler>
-  virtual void Create(ApplicationConnection* connection,
-                      InterfaceRequest<ContentHandler> request) OVERRIDE {
+  void Create(ApplicationConnection* connection,
+              InterfaceRequest<ContentHandler> request) override {
     BindToRequest(
-        new ContentHandlerImpl(shell_, compositor_thread_.message_loop_proxy(),
+        new ContentHandlerImpl(compositor_thread_.message_loop_proxy(),
                                web_media_player_factory_.get()),
         &request);
   }
 
   scoped_ptr<BlinkPlatformImpl> blink_platform_impl_;
-  Shell* shell_;
   base::Thread compositor_thread_;
   scoped_ptr<WebMediaPlayerFactory> web_media_player_factory_;