| Index: blimp/client/feature/navigation_feature.cc
|
| diff --git a/blimp/client/feature/navigation_feature.cc b/blimp/client/feature/navigation_feature.cc
|
| index 9128c64ec2320d64231ee2e999bcdd3171b5a014..34922363c31c9f7ba0b82d393e55fdf79b318457 100644
|
| --- a/blimp/client/feature/navigation_feature.cc
|
| +++ b/blimp/client/feature/navigation_feature.cc
|
| @@ -10,8 +10,11 @@
|
| #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"
|
| +#include "url/url_canon.h"
|
| +#include "url/url_util.h"
|
|
|
| namespace blimp {
|
| namespace client {
|
| @@ -39,11 +42,28 @@ 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 "example" to "http://example/" (a valid GURL but no
|
| + // 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, std::string());
|
| + if (!url.is_valid() || url.host_piece().find('.') == std::string::npos) {
|
| + url::RawCanonOutputT<char> buffer;
|
| + url::EncodeURIComponent(url_text.data(), url_text.size(), &buffer);
|
| + std::string encoded_query(buffer.data(), buffer.length());
|
| + url = GURL("https://www.google.com/#q=" + encoded_query);
|
| + DCHECK(url.is_valid());
|
| + }
|
| +
|
| NavigationMessage* navigation_message;
|
| std::unique_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());
|
| }
|
|
|