Commit fdb0ef8e authored by grv@chromium.org's avatar grv@chromium.org

Delete AppPromoLogoFetcher (dead code)

The last reference to the class was deleted in https://chromiumcodereview.appspot.com/10539045


BUG=138614

Review URL: https://chromiumcodereview.appspot.com/10831058

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@149235 0039d316-1c4b-4281-b951-d872f2087c98
parent aead1240
...@@ -16,9 +16,6 @@ ...@@ -16,9 +16,6 @@
#include "chrome/common/pref_names.h" #include "chrome/common/pref_names.h"
#include "content/public/browser/notification_service.h" #include "content/public/browser/notification_service.h"
#include "content/public/common/url_constants.h" #include "content/public/common/url_constants.h"
#include "net/base/load_flags.h"
#include "net/url_request/url_fetcher.h"
#include "net/url_request/url_request_status.h"
const int AppsPromo::kDefaultAppsCounterMax = 10; const int AppsPromo::kDefaultAppsCounterMax = 10;
...@@ -34,15 +31,6 @@ const char kDefaultButton[] = "Visit the Chrome Web Store"; ...@@ -34,15 +31,6 @@ const char kDefaultButton[] = "Visit the Chrome Web Store";
const char kDefaultExpire[] = "No thanks"; const char kDefaultExpire[] = "No thanks";
const char kDefaultLink[] = "https://chrome.google.com/webstore"; const char kDefaultLink[] = "https://chrome.google.com/webstore";
// Http success status code.
const int kHttpSuccess = 200;
// The match pattern for valid logo URLs.
const char kValidLogoPattern[] = "https://*.google.com/*.png";
// The prefix for 'data' URL images.
const char kPNGDataURLPrefix[] = "data:image/png;base64,";
// Returns the string pref at |path|, using |fallback| as the default (if there // Returns the string pref at |path|, using |fallback| as the default (if there
// is no pref value present). |fallback| is used for debugging in concert with // is no pref value present). |fallback| is used for debugging in concert with
// --force-apps-promo-visible. // --force-apps-promo-visible.
...@@ -309,77 +297,3 @@ AppsPromo::UserGroup AppsPromo::GetCurrentUserGroup() const { ...@@ -309,77 +297,3 @@ AppsPromo::UserGroup AppsPromo::GetCurrentUserGroup() const {
CHECK(last_promo_id); CHECK(last_promo_id);
return last_promo_id->IsDefaultValue() ? USERS_NEW : USERS_EXISTING; return last_promo_id->IsDefaultValue() ? USERS_NEW : USERS_EXISTING;
} }
AppsPromoLogoFetcher::AppsPromoLogoFetcher(
Profile* profile,
const AppsPromo::PromoData& promo_data)
: profile_(profile),
promo_data_(promo_data) {
if (SupportsLogoURL()) {
if (HaveCachedLogo()) {
promo_data_.logo = AppsPromo::GetPromo().logo;
SavePromo();
} else {
FetchLogo();
}
} else {
// We only care about the source URL when this fetches the logo.
AppsPromo::SetSourcePromoLogoURL(GURL());
SavePromo();
}
}
AppsPromoLogoFetcher::~AppsPromoLogoFetcher() {}
void AppsPromoLogoFetcher::OnURLFetchComplete(
const net::URLFetcher* source) {
std::string data;
std::string base64_data;
CHECK(source == url_fetcher_.get());
source->GetResponseAsString(&data);
if (source->GetStatus().is_success() &&
source->GetResponseCode() == kHttpSuccess &&
base::Base64Encode(data, &base64_data)) {
AppsPromo::SetSourcePromoLogoURL(promo_data_.logo);
promo_data_.logo = GURL(kPNGDataURLPrefix + base64_data);
} else {
// The logo wasn't downloaded correctly or we failed to encode it in
// base64. Reset the source URL so we fetch it again next time. AppsPromo
// will revert to the default logo.
AppsPromo::SetSourcePromoLogoURL(GURL());
}
SavePromo();
}
void AppsPromoLogoFetcher::FetchLogo() {
CHECK(promo_data_.logo.scheme() == chrome::kHttpsScheme);
url_fetcher_.reset(net::URLFetcher::Create(
0, promo_data_.logo, net::URLFetcher::GET, this));
url_fetcher_->SetRequestContext(
g_browser_process->system_request_context());
url_fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES |
net::LOAD_DO_NOT_SAVE_COOKIES);
url_fetcher_->Start();
}
bool AppsPromoLogoFetcher::HaveCachedLogo() {
return promo_data_.logo == AppsPromo::GetSourcePromoLogoURL();
}
void AppsPromoLogoFetcher::SavePromo() {
AppsPromo::SetPromo(promo_data_);
content::NotificationService::current()->Notify(
chrome::NOTIFICATION_WEB_STORE_PROMO_LOADED,
content::Source<Profile>(profile_),
content::NotificationService::NoDetails());
}
bool AppsPromoLogoFetcher::SupportsLogoURL() {
URLPattern allowed_urls(URLPattern::SCHEME_HTTPS, kValidLogoPattern);
return allowed_urls.MatchesURL(promo_data_.logo);
}
...@@ -5,20 +5,14 @@ ...@@ -5,20 +5,14 @@
#ifndef CHROME_BROWSER_EXTENSIONS_APPS_PROMO_H_ #ifndef CHROME_BROWSER_EXTENSIONS_APPS_PROMO_H_
#define CHROME_BROWSER_EXTENSIONS_APPS_PROMO_H_ #define CHROME_BROWSER_EXTENSIONS_APPS_PROMO_H_
#include <set>
#include <string> #include <string>
#include "base/gtest_prod_util.h" #include "base/gtest_prod_util.h"
#include "chrome/common/extensions/extension.h" #include "chrome/common/extensions/extension.h"
#include "net/url_request/url_fetcher_delegate.h"
class PrefService; class PrefService;
class Profile; class Profile;
namespace net {
class URLFetcher;
} // namespace net
// This encapsulates business logic for: // This encapsulates business logic for:
// - Whether to show the apps promo in the launcher // - Whether to show the apps promo in the launcher
// - Whether to expire existing default apps // - Whether to expire existing default apps
...@@ -144,33 +138,4 @@ class AppsPromo { ...@@ -144,33 +138,4 @@ class AppsPromo {
DISALLOW_COPY_AND_ASSIGN(AppsPromo); DISALLOW_COPY_AND_ASSIGN(AppsPromo);
}; };
// Fetches logos over HTTPS, making sure we don't send cookies and that we
// cache the image until its source URL changes.
class AppsPromoLogoFetcher : public net::URLFetcherDelegate {
public:
AppsPromoLogoFetcher(Profile* profile,
const AppsPromo::PromoData& promo_data);
virtual ~AppsPromoLogoFetcher();
virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE;
private:
// Fetches the logo and stores the result as a data URL.
void FetchLogo();
// Checks if the logo was downloaded previously.
bool HaveCachedLogo();
// Sets the apps promo based on the current data and then issues the
// WEB_STORE_PROMO_LOADED notification so open NTPs can inject the promo.
void SavePromo();
// Checks if the promo logo matches https://*.google.com/*.png.
bool SupportsLogoURL();
Profile* profile_;
AppsPromo::PromoData promo_data_;
scoped_ptr<net::URLFetcher> url_fetcher_;
};
#endif // CHROME_BROWSER_EXTENSIONS_APPS_PROMO_H_ #endif // CHROME_BROWSER_EXTENSIONS_APPS_PROMO_H_
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