Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2064)

Unified Diff: chrome/browser/extensions/apps_promo.h

Issue 7820003: Add support to download web store promo logos over https. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: cleanup Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/extensions/apps_promo.cc » ('j') | chrome/browser/extensions/apps_promo.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/apps_promo.h
diff --git a/chrome/browser/extensions/apps_promo.h b/chrome/browser/extensions/apps_promo.h
index 171518095a5324817ddcc866af09f6d4c01d9887..590d9f7f8af21000e92eea95c8d5fd5d8332cdcb 100644
--- a/chrome/browser/extensions/apps_promo.h
+++ b/chrome/browser/extensions/apps_promo.h
@@ -11,8 +11,10 @@
#include "base/gtest_prod_util.h"
#include "chrome/common/extensions/extension.h"
+#include "content/common/url_fetcher.h"
class PrefService;
+class Profile;
// This encapsulates business logic for:
// - Whether to show the apps promo in the launcher
@@ -32,56 +34,53 @@ class AppsPromo {
USERS_EXISTING = 1 << 1,
};
+ // Holds all the data that specifies a promo for the apps section of the NTP.
+ struct PromoData {
+ PromoData();
+ PromoData(const std::string& id,
+ const std::string& header,
+ const std::string& button,
+ const GURL& link,
+ const std::string& expire,
+ const GURL& logo,
+ int user_group);
+ ~PromoData();
+
+ std::string id;
+ std::string header;
+ std::string button;
+ GURL link;
+ std::string expire;
Mihai Parparita -not on Chrome 2011/08/31 23:26:23 A comment pointing to PromoResourceService::Unpack
jstritar 2011/09/01 16:10:13 Done.
+ GURL logo;
+ int user_group;
+ };
+
// Register our preferences. Parts of the promo content are stored in Local
// State since they're independent of the user profile.
static void RegisterPrefs(PrefService* local_state);
static void RegisterUserPrefs(PrefService* prefs);
- // Removes the current promo data.
- static void ClearPromo();
-
// Returns true if a promo is available for the current locale.
static bool IsPromoSupportedForLocale();
// Returns true if the web store is active for the existing locale.
static bool IsWebStoreSupportedForLocale();
- // Gets the ID of the current promo.
- static std::string GetPromoId();
-
- // Gets the text for the promo button.
- static std::string GetPromoButtonText();
-
- // Gets the text for the promo header.
- static std::string GetPromoHeaderText();
-
- // Gets the promo link.
- static GURL GetPromoLink();
-
- // Gets the URL of the promo logo image.
- static GURL GetPromoLogo();
-
- // Gets the text for the promo "hide this" link.
- static std::string GetPromoExpireText();
-
- // Gets the user groups for which we should maximize the promo and apps
- // section. The return value is a bitwise OR of UserGroup enums.
- static int GetPromoUserGroup();
-
- // Called to set the current promo data. The default web store logo will be
- // used if |logo| is empty or not valid.
- static void SetPromo(const std::string& id,
- const std::string& header_text,
- const std::string& button_text,
- const GURL& link,
- const std::string& expire_text,
- const GURL& logo,
- const int user_group);
-
// Sets whether the web store and apps section is supported for the current
// locale.
static void SetWebStoreSupportedForLocale(bool supported);
+ // Accesses the current promo data. The default logo will be used if
+ // |promo_data.logo| is empty or not a valid 'data' URL.
+ static void ClearPromo();
+ static PromoData GetPromo();
+ static void SetPromo(PromoData promo_data);
+
+ // Gets the original URL of the logo. This should only be set when the logo
Mihai Parparita -not on Chrome 2011/08/31 23:26:23 "Source URL" might be a better name than "original
jstritar 2011/09/01 16:10:13 Done.
+ // was served over https.
Mihai Parparita -not on Chrome 2011/08/31 23:26:23 Nit: capitalize HTTPS (applies to other parts of t
jstritar 2011/09/01 16:10:13 Done.
+ static GURL GetPromoLogoOriginal();
Mihai Parparita -not on Chrome 2011/08/31 23:26:23 Get/SetOriginalPromoLogoUrl reads a bit better.
jstritar 2011/09/01 16:10:13 Done. Updated to Get/SetSourcePromoLogoURL.
+ static void SetPromoLogoOriginal(GURL original_url);
+
explicit AppsPromo(PrefService* prefs);
~AppsPromo();
@@ -145,4 +144,30 @@ class AppsPromo {
DISALLOW_COPY_AND_ASSIGN(AppsPromo);
};
+// Fetches logos over https, making sure we don't send cookies and that we
+// cache the image as long as possible.
Mihai Parparita -not on Chrome 2011/08/31 23:26:23 Not seeing anything that would make us "cache the
jstritar 2011/09/01 16:10:13 Hehe, yeah I guess that isn't quite accurate. I up
+class AppsPromoLogoDownloader : public URLFetcher::Delegate {
+ public:
+ AppsPromoLogoDownloader(Profile* profile,
+ AppsPromo::PromoData promo_data);
+ ~AppsPromoLogoDownloader();
+
+ virtual void OnURLFetchComplete(const URLFetcher* source) OVERRIDE;
+
+ private:
+ // Fetches the logo and stores the result as a data URL.
+ void FetchLogo();
+
+ // 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();
+
+ // Returns true if the logo needs to be downloaded.
+ bool ShouldFetchLogo();
+
+ Profile* profile_;
+ AppsPromo::PromoData promo_data_;
+ scoped_ptr<URLFetcher> url_fetcher_;
+};
+
#endif // CHROME_BROWSER_EXTENSIONS_APPS_PROMO_H_
« no previous file with comments | « no previous file | chrome/browser/extensions/apps_promo.cc » ('j') | chrome/browser/extensions/apps_promo.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698