[epiphany] search-engine-manager: get_address() must return NULL



commit 51f01560c999c3276b411c1a63f503a49b30df54
Author: Michael Catanzaro <mcatanzaro igalia com>
Date:   Sat Sep 9 11:37:42 2017 -0500

    search-engine-manager: get_address() must return NULL
    
    The search-engine-dialog relies on get_address() returning NULL to
    detect new search engines. It doesn't function properly otherwise. All
    code using this function just needs to be prepared to handle a NULL
    address.
    
    In contrast, get_address_for_default_engine() really does need to always
    return a result. At least, it's more convenient this way, so that
    calling code doesn't have to handle that manually. Rename the function
    to make this more clear and reduce confusion, as it would be odd to have
    two parallel functions function differently in this respect.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=787458

 embed/ephy-embed-utils.c                   |    2 +-
 lib/ephy-search-engine-manager.c           |    6 +++---
 lib/ephy-search-engine-manager.h           |    2 +-
 src/search-provider/ephy-search-provider.c |    2 +-
 4 files changed, 6 insertions(+), 6 deletions(-)
---
diff --git a/embed/ephy-embed-utils.c b/embed/ephy-embed-utils.c
index 83e6065..3836792 100644
--- a/embed/ephy-embed-utils.c
+++ b/embed/ephy-embed-utils.c
@@ -276,7 +276,7 @@ ephy_embed_utils_autosearch_address (const char *search_key)
 
   shell = ephy_embed_shell_get_default ();
   search_engine_manager = ephy_embed_shell_get_search_engine_manager (shell);
-  address_search = ephy_search_engine_manager_get_address_for_default_engine (search_engine_manager);
+  address_search = ephy_search_engine_manager_get_default_search_address (search_engine_manager);
 
   query_param = soup_form_encode ("q", search_key, NULL);
 #pragma GCC diagnostic push
diff --git a/lib/ephy-search-engine-manager.c b/lib/ephy-search-engine-manager.c
index a37c76d..c6da9eb 100644
--- a/lib/ephy-search-engine-manager.c
+++ b/lib/ephy-search-engine-manager.c
@@ -147,11 +147,11 @@ ephy_search_engine_manager_get_address (EphySearchEngineManager *manager,
   if (info)
     return info->address;
 
-  return FALLBACK_ADDRESS;
+  return NULL;
 }
 
 const char *
-ephy_search_engine_manager_get_address_for_default_engine (EphySearchEngineManager *manager)
+ephy_search_engine_manager_get_default_search_address (EphySearchEngineManager *manager)
 {
   char *name;
   const char *address;
@@ -160,7 +160,7 @@ ephy_search_engine_manager_get_address_for_default_engine (EphySearchEngineManag
   address = ephy_search_engine_manager_get_address (manager, name);
   g_free (name);
 
-  return address;
+  return address ? address : FALLBACK_ADDRESS;
 }
 
 const char *
diff --git a/lib/ephy-search-engine-manager.h b/lib/ephy-search-engine-manager.h
index f038160..f4b9f47 100644
--- a/lib/ephy-search-engine-manager.h
+++ b/lib/ephy-search-engine-manager.h
@@ -39,7 +39,7 @@ G_DECLARE_FINAL_TYPE (EphySearchEngineManager, ephy_search_engine_manager, EPHY,
 EphySearchEngineManager     *ephy_search_engine_manager_new                      (void);
 const char                  *ephy_search_engine_manager_get_address              (EphySearchEngineManager 
*manager,
                                                                                   const char              
*name);
-const char                  *ephy_search_engine_manager_get_address_for_default_engine
+const char                  *ephy_search_engine_manager_get_default_search_address
                                                                                  (EphySearchEngineManager 
*manager);
 const char                  *ephy_search_engine_manager_get_bang                 (EphySearchEngineManager 
*manager,
                                                                                   const char              
*name);
diff --git a/src/search-provider/ephy-search-provider.c b/src/search-provider/ephy-search-provider.c
index 6671e46..6310055 100644
--- a/src/search-provider/ephy-search-provider.c
+++ b/src/search-provider/ephy-search-provider.c
@@ -286,7 +286,7 @@ launch_search (EphySearchProvider *self,
 
   shell = ephy_embed_shell_get_default ();
   search_engine_manager = ephy_embed_shell_get_search_engine_manager (shell);
-  address_search = ephy_search_engine_manager_get_address_for_default_engine (search_engine_manager);
+  address_search = ephy_search_engine_manager_get_default_search_address (search_engine_manager);
 
   search_string = g_strjoinv (" ", terms);
   query_param = soup_form_encode ("q", search_string, NULL);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]