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

Unified Diff: blimp/client/feature/navigation_feature.cc

Issue 1869783005: [Blimp Client] Fixes up URL before sending it to Engine. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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
« no previous file with comments | « blimp/client/DEPS ('k') | blimp/engine/session/blimp_engine_session.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: blimp/client/feature/navigation_feature.cc
diff --git a/blimp/client/feature/navigation_feature.cc b/blimp/client/feature/navigation_feature.cc
index 973862d44983e27d1b7d070e4d4312d7562664ee..33e5a11206d05c1a00df387802eacb003ad8a0af 100644
--- a/blimp/client/feature/navigation_feature.cc
+++ b/blimp/client/feature/navigation_feature.cc
@@ -10,6 +10,7 @@
#include "blimp/common/create_blimp_message.h"
#include "blimp/common/proto/blimp_message.pb.h"
#include "blimp/common/proto/navigation.pb.h"
+#include "components/url_formatter/url_fixer.h"
#include "net/base/net_errors.h"
#include "url/gurl.h"
@@ -39,11 +40,24 @@ void NavigationFeature::RemoveDelegate(int tab_id) {
void NavigationFeature::NavigateToUrlText(int tab_id,
const std::string& url_text) {
+ // Fixes up url, e.g., convert "google.com" to "http://google.com".
+ // It also converts "starwar" to "http://starwar/" (a valid GURL but no
Kevin M 2016/04/07 23:00:19 starwar => "example" (don't want trademarks in cod
haibinlu 2016/04/07 23:55:09 Done.
+ // website). In order to use search instead in this case, we check
+ // the host part of the URL to see if it contains '.', and use search
+ // instead if it does not. Note that this heuristic is not correct, since
+ // valid GURL such as "chrome://version/" do not have '.'. The heuristic is
+ // used only for v0.5 and useful for dev&test.
+ // TODO(haibinlu): Remove once omnibox is used.
+ GURL url = url_formatter::FixupURL(url_text, "");
+ if (!url.is_valid() || url.host().find('.') == std::string::npos) {
+ url = url_formatter::FixupURL("https://www.google.com/#q=" + url_text, "");
+ }
+
NavigationMessage* navigation_message;
scoped_ptr<BlimpMessage> blimp_message =
CreateBlimpMessage(&navigation_message, tab_id);
navigation_message->set_type(NavigationMessage::LOAD_URL);
- navigation_message->mutable_load_url()->set_url(url_text);
+ navigation_message->mutable_load_url()->set_url(url.spec());
outgoing_message_processor_->ProcessMessage(std::move(blimp_message),
net::CompletionCallback());
}
« no previous file with comments | « blimp/client/DEPS ('k') | blimp/engine/session/blimp_engine_session.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698