| Index: chrome/renderer/searchbox/searchbox.cc
|
| diff --git a/chrome/renderer/searchbox/searchbox.cc b/chrome/renderer/searchbox/searchbox.cc
|
| index 9adce8536714bf97658937ee385048a46db5c780..a810e80238e9098c16532466f1bde01c786b44df 100644
|
| --- a/chrome/renderer/searchbox/searchbox.cc
|
| +++ b/chrome/renderer/searchbox/searchbox.cc
|
| @@ -10,6 +10,8 @@
|
| #include "base/strings/string_util.h"
|
| #include "base/strings/utf_string_conversions.h"
|
| #include "chrome/common/chrome_switches.h"
|
| +#include "chrome/common/favicon/big_icon_url_parser.h"
|
| +#include "chrome/common/favicon/fallback_icon_url_parser.h"
|
| #include "chrome/common/favicon/favicon_url_parser.h"
|
| #include "chrome/common/omnibox_focus_state.h"
|
| #include "chrome/common/render_messages.h"
|
| @@ -115,6 +117,57 @@ bool GetRestrictedIDFromFaviconUrl(int render_view_id,
|
| return true;
|
| }
|
|
|
| +bool GetRestrictedIDFromBigIconUrl(int render_view_id,
|
| + const GURL& url,
|
| + std::string* favicon_params,
|
| + InstantRestrictedID* rid) {
|
| + // Strip leading slash.
|
| + std::string raw_path = url.path();
|
| + DCHECK_GT(raw_path.length(), (size_t) 0);
|
| + DCHECK_EQ(raw_path[0], '/');
|
| + raw_path = raw_path.substr(1);
|
| +
|
| + chrome::BigIconUrlParser parser;
|
| + if (!parser.Parse(raw_path))
|
| + return false;
|
| +
|
| + *favicon_params = raw_path.substr(0, parser.path_index());
|
| +
|
| + std::string id_part = raw_path.substr(parser.path_index());
|
| + InstantRestrictedID id;
|
| + if (!GetInstantRestrictedIDFromPath(render_view_id, id_part, &id))
|
| + return true;
|
| +
|
| + *rid = id;
|
| + return true;
|
| +}
|
| +
|
| +bool GetRestrictedIDFromFallbackIconUrl(int render_view_id,
|
| + const GURL& url,
|
| + std::string* favicon_params,
|
| + InstantRestrictedID* rid) {
|
| + // Strip leading slash.
|
| + std::string raw_path = url.path();
|
| + DCHECK_GT(raw_path.length(), (size_t) 0);
|
| + DCHECK_EQ(raw_path[0], '/');
|
| + raw_path = raw_path.substr(1);
|
| +
|
| + chrome::ParsedFallbackIconPath parser;
|
| + if (!parser.Parse(raw_path))
|
| + return false;
|
| +
|
| + *favicon_params = raw_path.substr(0, parser.path_index());
|
| +
|
| + std::string id_part = raw_path.substr(parser.path_index());
|
| + InstantRestrictedID id;
|
| + if (!GetInstantRestrictedIDFromPath(render_view_id, id_part, &id))
|
| + return true;
|
| +
|
| + *rid = id;
|
| + return true;
|
| +}
|
| +
|
| +
|
| // Parses a thumbnail |url| and fills in |id| with the InstantRestrictedID
|
| // obtained from the |url|. |render_view_id| is the ID of the associated
|
| // RenderView.
|
| @@ -210,6 +263,47 @@ bool SearchBox::GenerateFaviconURLFromTransientURL(const GURL& transient_url,
|
| return true;
|
| }
|
|
|
| +bool SearchBox::GenerateBigIconURLFromTransientURL(const GURL& transient_url,
|
| + GURL* url) const {
|
| + std::string favicon_params;
|
| + InstantRestrictedID rid = -1;
|
| + bool success = internal::GetRestrictedIDFromBigIconUrl(
|
| + render_view()->GetRoutingID(), transient_url, &favicon_params, &rid);
|
| + if (!success)
|
| + return false;
|
| +
|
| + InstantMostVisitedItem item;
|
| + std::string item_url;
|
| + if (rid != -1 && GetMostVisitedItemWithID(rid, &item))
|
| + item_url = item.url.spec();
|
| +
|
| + *url = GURL(base::StringPrintf("chrome-search://big-icon/%s%s",
|
| + favicon_params.c_str(),
|
| + item_url.c_str()));
|
| + return true;
|
| +}
|
| +
|
| +bool SearchBox::GenerateFallbackIconURLFromTransientURL(
|
| + const GURL& transient_url,
|
| + GURL* url) const {
|
| + std::string favicon_params;
|
| + InstantRestrictedID rid = -1;
|
| + bool success = internal::GetRestrictedIDFromFallbackIconUrl(
|
| + render_view()->GetRoutingID(), transient_url, &favicon_params, &rid);
|
| + if (!success)
|
| + return false;
|
| +
|
| + InstantMostVisitedItem item;
|
| + std::string item_url;
|
| + if (rid != -1 && GetMostVisitedItemWithID(rid, &item))
|
| + item_url = item.url.spec();
|
| +
|
| + *url = GURL(base::StringPrintf("chrome-search://fallback-icon/%s%s",
|
| + favicon_params.c_str(),
|
| + item_url.c_str()));
|
| + return true;
|
| +}
|
| +
|
| bool SearchBox::GenerateThumbnailURLFromTransientURL(const GURL& transient_url,
|
| GURL* url) const {
|
| InstantRestrictedID rid = 0;
|
|
|