Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/ui/webui/favicon_source.h" | 5 #include "chrome/browser/ui/webui/favicon_source.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "chrome/browser/history/top_sites.h" | 9 #include "chrome/browser/history/top_sites.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 51 | 51 |
| 52 if (path.size() > 5 && path.substr(0, 5) == "size/") { | 52 if (path.size() > 5 && path.substr(0, 5) == "size/") { |
| 53 size_t slash = path.find("/", 5); | 53 size_t slash = path.find("/", 5); |
| 54 std::string size = path.substr(5, slash - 5); | 54 std::string size = path.substr(5, slash - 5); |
| 55 int pixel_size = atoi(size.c_str()); | 55 int pixel_size = atoi(size.c_str()); |
| 56 CHECK(pixel_size == 32 || pixel_size == 16) << | 56 CHECK(pixel_size == 32 || pixel_size == 16) << |
| 57 "only 32x32 and 16x16 icons are supported"; | 57 "only 32x32 and 16x16 icons are supported"; |
| 58 request_size_map_[request_id] = pixel_size; | 58 request_size_map_[request_id] = pixel_size; |
| 59 url = GURL(path.substr(slash + 1)); | 59 url = GURL(path.substr(slash + 1)); |
| 60 } else { | 60 } else { |
| 61 if (path.size() > 10 && path.substr(0, 10) == "normalize/") { | |
|
Evan Stade
2012/04/14 00:32:43
why isn't this normalization just the default?
Kyle Horimoto
2012/04/16 19:08:15
Essentially, any page can have its own favicon (e.
Evan Stade
2012/04/16 20:45:18
in this case I would not call it "normalize", but
Kyle Horimoto
2012/04/17 21:37:39
Done.
| |
| 62 std::string originalUrl = path.substr(10); | |
| 63 | |
| 64 // If the original URL does not specify a scheme (e.g., example.com | |
| 65 // instead of http://example.com), add "http://" as a default. | |
| 66 if (originalUrl.find("://") == std::string::npos) | |
|
Evan Stade
2012/04/14 00:32:43
probably safest to use GURL for this (it has compl
Kyle Horimoto
2012/04/16 19:08:15
Done.
| |
| 67 originalUrl = "http://" + originalUrl; | |
| 68 | |
| 69 // Strip the path beyond the top-level domain. | |
| 70 url = GURL(originalUrl).GetOrigin(); | |
| 71 } else { | |
| 72 url = GURL(path); | |
| 73 } | |
| 74 | |
| 61 request_size_map_[request_id] = 16; | 75 request_size_map_[request_id] = 16; |
| 62 url = GURL(path); | |
| 63 } | 76 } |
| 64 | 77 |
| 65 // Intercept requests for prepopulated pages. | 78 // Intercept requests for prepopulated pages. |
| 66 for (size_t i = 0; i < arraysize(history::kPrepopulatedPages); i++) { | 79 for (size_t i = 0; i < arraysize(history::kPrepopulatedPages); i++) { |
| 67 if (url.spec() == | 80 if (url.spec() == |
| 68 l10n_util::GetStringUTF8(history::kPrepopulatedPages[i].url_id)) { | 81 l10n_util::GetStringUTF8(history::kPrepopulatedPages[i].url_id)) { |
| 69 request_size_map_.erase(request_id); | 82 request_size_map_.erase(request_id); |
| 70 SendResponse(request_id, | 83 SendResponse(request_id, |
| 71 ResourceBundle::GetSharedInstance().LoadDataResourceBytes( | 84 ResourceBundle::GetSharedInstance().LoadDataResourceBytes( |
| 72 history::kPrepopulatedPages[i].favicon_id)); | 85 history::kPrepopulatedPages[i].favicon_id)); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 129 default_favicon_ = | 142 default_favicon_ = |
| 130 ResourceBundle::GetSharedInstance().LoadDataResourceBytes( | 143 ResourceBundle::GetSharedInstance().LoadDataResourceBytes( |
| 131 IDR_DEFAULT_FAVICON); | 144 IDR_DEFAULT_FAVICON); |
| 132 } | 145 } |
| 133 bytes = default_favicon_; | 146 bytes = default_favicon_; |
| 134 } | 147 } |
| 135 request_size_map_.erase(request_id); | 148 request_size_map_.erase(request_id); |
| 136 | 149 |
| 137 SendResponse(request_id, bytes); | 150 SendResponse(request_id, bytes); |
| 138 } | 151 } |
| OLD | NEW |