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

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
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..1113ab9945d9cf682cc62cd29370012f1e611fa3 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,19 @@ void NavigationFeature::RemoveDelegate(int tab_id) {
void NavigationFeature::NavigateToUrlText(int tab_id,
const std::string& url_text) {
Kevin M 2016/04/07 20:17:00 Add unit tests for fixing up the URL.
haibinlu 2016/04/07 22:28:59 This is a temp (and wrong) fix for v0.5. not sure
+ // Simplified heuristic for v0.5 only.
Kevin M 2016/04/07 20:12:30 Add explanation as to *what* this is doing.
haibinlu 2016/04/07 22:28:59 Done.
+ // TODO(haibinlu): Remove once omnibox is used.
+ GURL url = url_formatter::FixupURL(url_text, "");
+ if (!url.is_valid() || url.host().find('.') == std::string::npos) {
Kevin M 2016/04/07 20:12:30 Add comment on the reason and behavior of this heu
haibinlu 2016/04/07 22:28:59 Done.
+ url = url_formatter::FixupURL("https://www.google.com/#q=" + url_text, "");
Kevin M 2016/04/07 20:12:30 url_text needs to be querystring encoded in this c
haibinlu 2016/04/07 22:28:59 FixupURL will do that.
Kevin M 2016/04/07 23:00:19 What if the searched text was "1+2"? Would FixupUR
haibinlu 2016/04/07 23:55:09 you are right. it needs encoding.
+ }
+
+ DCHECK(url.is_valid());
Kevin M 2016/04/07 20:12:30 DCHECK is a poor fit here ("url" is built from use
haibinlu 2016/04/07 22:28:59 removed the DCHECK. with FixupURL on google search
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());
}

Powered by Google App Engine
This is Rietveld 408576698