Commit 5f6eca4c authored by huangs's avatar huangs Committed by Commit bot

[Favicon] Minor code cleanup.

TBR=jam

Review URL: https://codereview.chromium.org/861333002

Cr-Commit-Position: refs/heads/master@{#313301}
parent 00bef09a
...@@ -14,7 +14,6 @@ ...@@ -14,7 +14,6 @@
#include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h" #include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h"
#include "chrome/common/importer/imported_favicon_usage.h" #include "chrome/common/importer/imported_favicon_usage.h"
#include "chrome/common/url_constants.h" #include "chrome/common/url_constants.h"
#include "components/favicon_base/favicon_types.h"
#include "components/favicon_base/favicon_util.h" #include "components/favicon_base/favicon_util.h"
#include "components/favicon_base/select_favicon_frames.h" #include "components/favicon_base/select_favicon_frames.h"
#include "extensions/common/constants.h" #include "extensions/common/constants.h"
...@@ -22,6 +21,7 @@ ...@@ -22,6 +21,7 @@
#include "ui/gfx/codec/png_codec.h" #include "ui/gfx/codec/png_codec.h"
#include "ui/gfx/favicon_size.h" #include "ui/gfx/favicon_size.h"
#include "ui/gfx/image/image_skia.h" #include "ui/gfx/image/image_skia.h"
#include "url/gurl.h"
using base::Bind; using base::Bind;
......
...@@ -85,7 +85,7 @@ void FaviconSource::StartDataRequest( ...@@ -85,7 +85,7 @@ void FaviconSource::StartDataRequest(
if (parsed.is_icon_url) { if (parsed.is_icon_url) {
// TODO(michaelbai): Change GetRawFavicon to support combination of // TODO(michaelbai): Change GetRawFavicon to support combination of
// IconType. // IconType.
favicon_service->GetRawFavicon( favicon_service->GetRawFavicon(
url, url,
favicon_base::FAVICON, favicon_base::FAVICON,
desired_size_in_pixel, desired_size_in_pixel,
......
...@@ -41,7 +41,7 @@ class Profile; ...@@ -41,7 +41,7 @@ class Profile;
// If the parameter is unspecified, the requested favicon's size defaults // If the parameter is unspecified, the requested favicon's size defaults
// to 16 and the requested scale factor defaults to 1x. // to 16 and the requested scale factor defaults to 1x.
// Example: chrome://favicon/size/16@2x/http://www.google.com/ // Example: chrome://favicon/size/16@2x/http://www.google.com/
// 'urlmodifier' Optional // 'urlmodifier' Optional
// Values: ['iconurl', 'origin'] // Values: ['iconurl', 'origin']
// 'iconurl': Specifies that the url parameter refers to the URL of // 'iconurl': Specifies that the url parameter refers to the URL of
// the favicon image as opposed to the URL of the page that the favicon is // the favicon image as opposed to the URL of the page that the favicon is
......
...@@ -96,24 +96,22 @@ bool ParseFaviconPath(const std::string& path, ...@@ -96,24 +96,22 @@ bool ParseFaviconPath(const std::string& path,
parsed_index += strlen(kIconURLParameter); parsed_index += strlen(kIconURLParameter);
parsed->is_icon_url = true; parsed->is_icon_url = true;
parsed->url = path.substr(parsed_index); parsed->url = path.substr(parsed_index);
} else { } else if (HasSubstringAt(path, parsed_index, kOriginParameter)) {
// URL requests prefixed with "origin/" are converted to a form with an // URL requests prefixed with "origin/" are converted to a form with an
// empty path and a valid scheme. (e.g., example.com --> // empty path and a valid scheme. (e.g., example.com -->
// http://example.com/ or http://example.com/a --> http://example.com/) // http://example.com/ or http://example.com/a --> http://example.com/)
if (HasSubstringAt(path, parsed_index, kOriginParameter)) { parsed_index += strlen(kOriginParameter);
parsed_index += strlen(kOriginParameter); std::string possibly_invalid_url = path.substr(parsed_index);
std::string possibly_invalid_url = path.substr(parsed_index);
// If the URL does not specify a scheme (e.g., example.com instead of // If the URL does not specify a scheme (e.g., example.com instead of
// http://example.com), add "http://" as a default. // http://example.com), add "http://" as a default.
if (!GURL(possibly_invalid_url).has_scheme()) if (!GURL(possibly_invalid_url).has_scheme())
possibly_invalid_url = "http://" + possibly_invalid_url; possibly_invalid_url = "http://" + possibly_invalid_url;
// Strip the path beyond the top-level domain. // Strip the path beyond the top-level domain.
parsed->url = GURL(possibly_invalid_url).GetOrigin().spec(); parsed->url = GURL(possibly_invalid_url).GetOrigin().spec();
} else { } else {
parsed->url = path.substr(parsed_index); parsed->url = path.substr(parsed_index);
}
} }
// The parsed index needs to be returned in order to allow Instant Extended // The parsed index needs to be returned in order to allow Instant Extended
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment