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 // Normally, favicons are fetched for the page currently being viewed. | |
| 62 // The password manager, however, manages passwords for entire domains. | |
|
Evan Stade
2012/04/17 21:44:44
this comment should describe the behavior, and a c
Kyle Horimoto
2012/04/17 22:13:38
Done.
| |
| 63 // Each of its URL requests are prefixed with "origin/" to represent that | |
| 64 // the favicon fetched should belong to the domain with an empty path. | |
| 65 if (path.size() > 7 && path.substr(0, 7) == "origin/") { | |
| 66 std::string originalUrl = path.substr(7); | |
| 67 | |
| 68 // If the original URL does not specify a scheme (e.g., example.com | |
| 69 // instead of http://example.com), add "http://" as a default. | |
| 70 if (!GURL(originalUrl).has_scheme()) | |
| 71 originalUrl = "http://" + originalUrl; | |
| 72 | |
| 73 // Strip the path beyond the top-level domain. | |
| 74 url = GURL(originalUrl).GetOrigin(); | |
| 75 } else { | |
| 76 url = GURL(path); | |
| 77 } | |
| 78 | |
| 61 request_size_map_[request_id] = 16; | 79 request_size_map_[request_id] = 16; |
| 62 url = GURL(path); | |
| 63 } | 80 } |
| 64 | 81 |
| 65 // Intercept requests for prepopulated pages. | 82 // Intercept requests for prepopulated pages. |
| 66 for (size_t i = 0; i < arraysize(history::kPrepopulatedPages); i++) { | 83 for (size_t i = 0; i < arraysize(history::kPrepopulatedPages); i++) { |
| 67 if (url.spec() == | 84 if (url.spec() == |
| 68 l10n_util::GetStringUTF8(history::kPrepopulatedPages[i].url_id)) { | 85 l10n_util::GetStringUTF8(history::kPrepopulatedPages[i].url_id)) { |
| 69 request_size_map_.erase(request_id); | 86 request_size_map_.erase(request_id); |
| 70 SendResponse(request_id, | 87 SendResponse(request_id, |
| 71 ResourceBundle::GetSharedInstance().LoadDataResourceBytes( | 88 ResourceBundle::GetSharedInstance().LoadDataResourceBytes( |
| 72 history::kPrepopulatedPages[i].favicon_id)); | 89 history::kPrepopulatedPages[i].favicon_id)); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 129 default_favicon_ = | 146 default_favicon_ = |
| 130 ResourceBundle::GetSharedInstance().LoadDataResourceBytes( | 147 ResourceBundle::GetSharedInstance().LoadDataResourceBytes( |
| 131 IDR_DEFAULT_FAVICON); | 148 IDR_DEFAULT_FAVICON); |
| 132 } | 149 } |
| 133 bytes = default_favicon_; | 150 bytes = default_favicon_; |
| 134 } | 151 } |
| 135 request_size_map_.erase(request_id); | 152 request_size_map_.erase(request_id); |
| 136 | 153 |
| 137 SendResponse(request_id, bytes); | 154 SendResponse(request_id, bytes); |
| 138 } | 155 } |
| OLD | NEW |