[M40 Merge][Tizen3.0][WRT] Refactor ewk_send_widget_info API
authorKrzysztof Czech <k.czech@samsung.com>
Wed, 13 May 2015 12:18:48 +0000 (14:18 +0200)
committerYoungsoo Choi <kenshin.choi@samsung.com>
Tue, 10 Jul 2018 06:57:09 +0000 (06:57 +0000)
Associate widget's information with efl context. This is part of
the refactoring started here http://107.108.218.239/bugzilla/show_bug.cgi?id=10976.

bug: http://107.108.218.239/bugzilla/show_bug.cgi?id=12843
Reviewed by: Antonio Gomes, Hyunhak Kim, Jaesik Chang, arno renevier

Change-Id: I67158821a0ba56625e54df516bf88ae20475b262
Signed-off-by: yh106.jung <yh106.jung@samsung.com>
tizen_src/ewk/efl_integration/common/content_switches_efl.cc
tizen_src/ewk/efl_integration/common/content_switches_efl.h
tizen_src/ewk/efl_integration/common/render_messages_ewk.h
tizen_src/ewk/efl_integration/content_browser_client_efl.cc
tizen_src/ewk/efl_integration/eweb_context.cc
tizen_src/ewk/efl_integration/eweb_context.h
tizen_src/ewk/efl_integration/renderer/content_renderer_client_efl.cc
tizen_src/ewk/efl_integration/wrt/wrt_widget_host.cc
tizen_src/ewk/efl_integration/wrt/wrt_widget_host.h
tizen_src/ewk/efl_integration/wrt/wrtwidget.cc

index 6ea914b..d237009 100644 (file)
@@ -13,6 +13,12 @@ namespace switches {
 const char kEnableViewMode[]    = "enable-view-mode";
 const char kInjectedBundlePath[] = "injected-bundle-path";
 
+// Widget Info
+const char kTizenId[] = "widget-id";
+const char kWidgetScale[] = "widget-scale";
+const char kWidgetTheme[] = "widget-theme";
+const char kWidgetEncodedBundle[] = "widget-encoded-bundle";
+
 // Don't dump stuff here, follow the same order as the header.
 
 }  // namespace switches
index 6ece3a8..a50c64d 100644 (file)
@@ -18,6 +18,10 @@ namespace switches {
 // different modes using CSS Media Queries.
 CONTENT_EXPORT extern const char kEnableViewMode[];
 CONTENT_EXPORT extern const char kInjectedBundlePath[];
+CONTENT_EXPORT extern const char kTizenId[];
+CONTENT_EXPORT extern const char kWidgetScale[];
+CONTENT_EXPORT extern const char kWidgetTheme[];
+CONTENT_EXPORT extern const char kWidgetEncodedBundle[];
 
 // DON'T ADD RANDOM STUFF HERE. Put it in the main section above in
 // alphabetical order, or in one of the ifdefs (also in order in each section).
index 0acb26b..2ccf3ce 100644 (file)
@@ -130,12 +130,6 @@ IPC_STRUCT_TRAITS_END()
 IPC_ENUM_TRAITS(blink::WebViewMode)
 
 
-IPC_MESSAGE_CONTROL4(WrtMsg_SetWidgetInfo,
-                     std::string,            // result: tizen_id
-                     double,         // result: scale
-                     std::string,    // result: theme
-                     std::string)    // result: encodedBundle
-
 IPC_MESSAGE_CONTROL2(WrtMsg_ParseUrl,
                      int,            // result: request_id
                      GURL)           // result: url
index c8d9618..7dc6a73 100644 (file)
@@ -6,6 +6,7 @@
 
 #include "command_line_efl.h"
 #include "base/memory/scoped_ptr.h"
+#include "base/strings/string_number_conversions.h"
 #include "browser_main_parts_efl.h"
 #include "browser_context_efl.h"
 #include "eweb_context.h"
@@ -94,9 +95,29 @@ void ContentBrowserClientEfl::AppendExtraCommandLineSwitches(base::CommandLine*
                 host->GetBrowserContext())->WebContext()) {
           const std::string& injectedBundlePath =
               context->GetInjectedBundlePath();
-          if (!injectedBundlePath.empty())
+          if (!injectedBundlePath.empty()) {
             command_line->AppendSwitchASCII(
                 switches::kInjectedBundlePath, injectedBundlePath);
+
+            const std::string& tizen_id = context->GetTizenId();
+            command_line->AppendSwitchASCII(
+                switches::kTizenId, tizen_id);
+
+            double scale = context->GetWidgetScale();
+            command_line->AppendSwitchASCII(
+                switches::kWidgetScale, base::DoubleToString(scale));
+
+            const std::string& widget_theme =
+                context->GetWidgetTheme();
+            command_line->AppendSwitchASCII(
+                switches::kWidgetTheme, widget_theme);
+
+            const std::string& widget_encoded_bundle =
+                context->GetWidgetEncodedBundle();
+            command_line->AppendSwitchASCII(
+                switches::kWidgetEncodedBundle,
+                widget_encoded_bundle);
+          }
         }
       }
     }
index ba59819..a7fe64f 100644 (file)
@@ -192,7 +192,10 @@ bool EwkMimeOverrideCallback::TriggerCallback(const std::string& url_spec,
 }
 
 void EWebContext::SendWidgetInfo(const std::string& tizen_id, double scale, const string &theme, const string &encoded_bundle) {
-  WrtWidgetHost::Get()->SetWidgetInfo(tizen_id, scale, theme, encoded_bundle);
+  tizen_id_ = tizen_id;
+  widget_scale_ = scale;
+  widget_theme_ = theme;
+  widget_encoded_bundle_ = encoded_bundle;
 }
 
 void EWebContext::SendWrtMessage(const Ewk_Wrt_Message_Data& data) {
@@ -224,7 +227,8 @@ bool EWebContext::OverrideMimeForURL(const std::string& url_spec,
 
 EWebContext::EWebContext(bool incognito)
     : m_pixmap(0),
-      inspector_server_(NULL) {
+      inspector_server_(NULL),
+      widget_scale_(0) {
   CHECK(EwkGlobalData::GetInstance());
 
   browser_context_.reset(new BrowserContextEfl(this, incognito));
index 088f95c..eaca43d 100644 (file)
@@ -112,6 +112,10 @@ class EWebContext {
   bool InspectorServerStop();
 
   const std::string& GetInjectedBundlePath() const { return injected_bundle_path_; }
+  const std::string& GetTizenId() const { return tizen_id_; }
+  const std::string& GetWidgetTheme() const { return widget_theme_; }
+  const std::string& GetWidgetEncodedBundle() const { return widget_encoded_bundle_; }
+  double GetWidgetScale() const { return widget_scale_; }
 
  private:
   EWebContext(bool incognito);
@@ -125,6 +129,12 @@ class EWebContext {
   scoped_ptr<Ewk_Cookie_Manager> ewk_cookie_manager_;
   std::string proxy_uri_;
   std::string injected_bundle_path_;
+  // widget info
+  std::string tizen_id_;
+  std::string widget_theme_;
+  std::string widget_encoded_bundle_;
+  double widget_scale_;
+
   scoped_ptr<EwkDidStartDownloadCallback> start_download_callback_;
   scoped_ptr<EwkMimeOverrideCallback> mime_override_callback_;
   int m_pixmap;
index e548eaf..a18a5cb 100644 (file)
@@ -10,6 +10,7 @@
 
 #include "base/command_line.h"
 #include "base/path_service.h"
+#include "base/strings/string_number_conversions.h"
 #include "common/content_switches_efl.h"
 #include "common/render_messages_ewk.h"
 #include "content/common/paths_efl.h"
@@ -77,10 +78,25 @@ void ContentRendererClientEfl::RenderThreadStarted()
 {
   content::RenderThread* thread = content::RenderThread::Get();
 
-  if (base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kInjectedBundlePath)) {
+  const base::CommandLine& command_line = *base::CommandLine::ForCurrentProcess();
+  if (command_line.HasSwitch(switches::kInjectedBundlePath)) {
     wrt_widget_.reset(new WrtWidget);
     thread->AddObserver(wrt_widget_->GetObserver());
     wrt_url_parser_.reset(new WrtUrlParseImpl(wrt_widget_.get()));
+
+    std::string tizen_id = command_line.GetSwitchValueASCII(
+        switches::kTizenId);
+    std::string theme = command_line.GetSwitchValueASCII(
+        switches::kWidgetTheme);
+    std::string encoded_bundle = command_line.GetSwitchValueASCII(
+        switches::kWidgetEncodedBundle);
+    std::string scale = command_line.GetSwitchValueASCII(
+        switches::kWidgetScale);
+    double scale_factor = 0;
+    base::StringToDouble(scale, &scale_factor);
+
+    wrt_widget_->SetWidgetInfo(tizen_id, scale_factor,
+                              theme, encoded_bundle);
   }
 
   render_process_observer_.reset(new RenderProcessObserverEfl(this));
index 2e3ba1f..af0d103 100644 (file)
@@ -72,8 +72,7 @@ WrtWidgetHost* WrtWidgetHost::Get() {
 }
 
 WrtWidgetHost::WrtWidgetHost()
-    : message_filter_(new WrtWidgetHostMessageFilter(this)),
-      in_wrt_(false) {
+    : message_filter_(new WrtWidgetHostMessageFilter(this)) {
 }
 
 void WrtWidgetHost::GetUrlForRequest(
@@ -95,32 +94,21 @@ void WrtWidgetHost::GetUrlForRequest(
   callback.Run(GURL());
 }
 
-void WrtWidgetHost::SetWidgetInfo(const std::string& tizen_id,
-                                  double scale,
-                                  const std::string& theme,
-                                  const std::string& encoded_bundle) {
-  // TODO shouldn't it be confirmed by WRT that this is really a launch
-  // of the widget identified by widget_id?
-  if (SendToAllRenderers(
-          new WrtMsg_SetWidgetInfo(tizen_id, scale, theme, encoded_bundle))) {
-    // TODO(z.kostrzewa) This should be determined (somehow) on application
-    // startup. Can it be done via Application Framework/Package Manager?
-    in_wrt_ = true;
-    tizen_id_ = tizen_id;
-  }
-}
-
 void WrtWidgetHost::SendWrtMessage(
     const Ewk_Wrt_Message_Data& message) {
   SendToAllRenderers(new WrtMsg_SendWrtMessage(message));
 }
 
+// It's only used by the wrt_file_protocol_handler which is not going to be used in the future
+// Candidate for deletion.
 bool WrtWidgetHost::InWrt() const {
-  return in_wrt_;
+  return false;
 }
 
-const std::string& WrtWidgetHost::TizenId() const {
-  return tizen_id_;
+// It's only used by the wrt_file_protocol_handler which is not going to be used in the future
+// Candidate for deletion.
+std::string WrtWidgetHost::TizenId() const {
+  return std::string();
 }
 
 void WrtWidgetHost::OnUrlRetrieved(int callback_id, const GURL& url) {
index b0b8477..58d25f3 100644 (file)
@@ -28,14 +28,11 @@ class WrtWidgetHost {
   void GetUrlForRequest(net::URLRequest* request,
                         base::Callback<void(const GURL&)> callback);
 
-  void SetWidgetInfo(const std::string& tizen_id, double scale, const std::string& theme,
-                     const std::string& encoded_bundle);
-
   void SendWrtMessage(const Ewk_Wrt_Message_Data& message);
 
   bool InWrt() const;
 
-  const std::string& TizenId() const;
+  std::string TizenId() const;
 
  private:
   friend class WrtWidgetHostMessageFilter;
@@ -49,8 +46,6 @@ class WrtWidgetHost {
   scoped_refptr<WrtWidgetHostMessageFilter> message_filter_;
   base::AtomicSequenceNumber callback_id_generator_;
   callbacks_type callbacks_;
-  bool in_wrt_;
-  std::string tizen_id_;
 
   DISALLOW_COPY_AND_ASSIGN(WrtWidgetHost);
 };
index c138439..f26a832 100644 (file)
@@ -22,7 +22,6 @@ class WrtRenderThreadObserver : public content::RenderProcessObserver {
   bool OnControlMessageReceived(const IPC::Message& message) override {
     bool handled = true;
     IPC_BEGIN_MESSAGE_MAP(WrtRenderThreadObserver, message)
-      IPC_MESSAGE_FORWARD(WrtMsg_SetWidgetInfo, wrt_widget_, WrtWidget::SetWidgetInfo)
       IPC_MESSAGE_FORWARD(WrtMsg_SendWrtMessage, wrt_widget_, WrtWidget::MessageReceived)
       IPC_MESSAGE_HANDLER(WrtMsg_ParseUrl, ParseUrl)
       IPC_MESSAGE_UNHANDLED(handled = false)