Fixed url checking code in LoadUrl()
authorJongHeon Choi <j-h.choi@samsung.com>
Wed, 22 Jun 2016 00:29:49 +0000 (09:29 +0900)
committerJongHeon Choi <j-h.choi@samsung.com>
Thu, 23 Jun 2016 07:03:20 +0000 (16:03 +0900)
runtime/browser/web_view_impl.cc
runtime/browser/web_view_impl.h

index be62935..8c4c5a6 100644 (file)
@@ -99,19 +99,24 @@ WebViewImpl::~WebViewImpl() {
 void WebViewImpl::LoadUrl(const std::string& url, const std::string& mime) {
   SCOPE_PROFILE();
   if (!mime.empty()) {
-    mime_ = mime;
-    auto mime_override_cb = [](const char* url, const char* mime,
-                               char** new_mime, void* data) -> Eina_Bool{
+    mime_set_cb_ = [url, mime]
+                   (const char* request_url, const char* request_mime,
+                    char** new_mime, void* data) {
       WebViewImpl* view = static_cast<WebViewImpl*>(data);
       if (view != nullptr &&
           common::utils::BaseName(url) ==
-            common::utils::BaseName(view->GetUrl())) {
-        *new_mime = strdup(view->mime().c_str());
+          common::utils::BaseName(request_url)) {
+        *new_mime = strdup(mime.c_str());
         LOGGER(DEBUG) << "ewk's new_mime: " << *new_mime;
         return EINA_TRUE;
       }
       return EINA_FALSE;
     };
+    auto mime_override_cb = [](const char* url, const char* mime,
+                                 char** new_mime, void* data) -> Eina_Bool {
+      WebViewImpl* view = static_cast<WebViewImpl*>(data);
+      return view->mime_set_cb_(url, mime, new_mime, data);
+    };
     ewk_context_mime_override_callback_set(context_, mime_override_cb, this);
   }
   ewk_view_url_set(ewk_view_, url.c_str());
index 2979d7b..9695e88 100644 (file)
@@ -51,7 +51,6 @@ class WebViewImpl {
 
   void SetEventListener(WebView::EventListener* listener);
   Evas_Object* evas_object() const;
-  std::string mime() const { return mime_; }
 
  private:
   void OnKeyEvent(Eext_Callback_Type key_type);
@@ -80,6 +79,8 @@ class WebViewImpl {
   void InitRotaryEventCallback();
 #endif  // ROTARY_EVENT_FEATURE_SUPPORT
 
+  std::function<bool (const char*, const char*, char**, void*)> mime_set_cb_;
+
   NativeWindow* window_;
   Ewk_Context* context_;
   Evas_Object* ewk_view_;
@@ -88,7 +89,6 @@ class WebViewImpl {
   WebView* view_;
   std::map<const std::string, Evas_Smart_Cb> smart_callbacks_;
   bool fullscreen_;
-  std::string mime_;
   Evas_Smart* evas_smart_class_;
   Ewk_View_Smart_Class ewk_smart_class_;
   bool internal_popup_opened_;