OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/extensions/apps_promo.h" | 5 #include "chrome/browser/extensions/apps_promo.h" |
6 | 6 |
7 #include "base/base64.h" | 7 #include "base/base64.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
11 #include "chrome/browser/prefs/pref_service.h" | 11 #include "chrome/browser/prefs/pref_service.h" |
12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
13 #include "chrome/common/chrome_switches.h" | 13 #include "chrome/common/chrome_switches.h" |
14 #include "chrome/common/extensions/extension.h" | 14 #include "chrome/common/extensions/extension.h" |
15 #include "chrome/common/chrome_notification_types.h" | 15 #include "chrome/common/chrome_notification_types.h" |
16 #include "chrome/common/pref_names.h" | 16 #include "chrome/common/pref_names.h" |
17 #include "content/public/browser/notification_service.h" | 17 #include "content/public/browser/notification_service.h" |
| 18 #include "content/public/common/content_url_request_user_data.h" |
18 #include "content/public/common/url_constants.h" | 19 #include "content/public/common/url_constants.h" |
19 #include "content/public/common/url_fetcher.h" | 20 #include "content/public/common/url_fetcher.h" |
20 #include "net/base/load_flags.h" | 21 #include "net/base/load_flags.h" |
21 #include "net/url_request/url_request_status.h" | 22 #include "net/url_request/url_request_status.h" |
22 | 23 |
23 const int AppsPromo::kDefaultAppsCounterMax = 10; | 24 const int AppsPromo::kDefaultAppsCounterMax = 10; |
24 | 25 |
25 namespace { | 26 namespace { |
26 | 27 |
27 // The default logo for the promo. | 28 // The default logo for the promo. |
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 SavePromo(); | 354 SavePromo(); |
354 } | 355 } |
355 | 356 |
356 void AppsPromoLogoFetcher::FetchLogo() { | 357 void AppsPromoLogoFetcher::FetchLogo() { |
357 CHECK(promo_data_.logo.scheme() == chrome::kHttpsScheme); | 358 CHECK(promo_data_.logo.scheme() == chrome::kHttpsScheme); |
358 | 359 |
359 url_fetcher_.reset(content::URLFetcher::Create( | 360 url_fetcher_.reset(content::URLFetcher::Create( |
360 0, promo_data_.logo, content::URLFetcher::GET, this)); | 361 0, promo_data_.logo, content::URLFetcher::GET, this)); |
361 url_fetcher_->SetRequestContext( | 362 url_fetcher_->SetRequestContext( |
362 g_browser_process->system_request_context()); | 363 g_browser_process->system_request_context()); |
| 364 // No user data, as the request will be cookie-less. |
| 365 url_fetcher_->SetContentURLRequestUserData( |
| 366 new content::ContentURLRequestUserData()); |
363 url_fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | | 367 url_fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | |
364 net::LOAD_DO_NOT_SAVE_COOKIES); | 368 net::LOAD_DO_NOT_SAVE_COOKIES); |
365 url_fetcher_->Start(); | 369 url_fetcher_->Start(); |
366 } | 370 } |
367 | 371 |
368 bool AppsPromoLogoFetcher::HaveCachedLogo() { | 372 bool AppsPromoLogoFetcher::HaveCachedLogo() { |
369 return promo_data_.logo == AppsPromo::GetSourcePromoLogoURL(); | 373 return promo_data_.logo == AppsPromo::GetSourcePromoLogoURL(); |
370 } | 374 } |
371 | 375 |
372 void AppsPromoLogoFetcher::SavePromo() { | 376 void AppsPromoLogoFetcher::SavePromo() { |
373 AppsPromo::SetPromo(promo_data_); | 377 AppsPromo::SetPromo(promo_data_); |
374 | 378 |
375 content::NotificationService::current()->Notify( | 379 content::NotificationService::current()->Notify( |
376 chrome::NOTIFICATION_WEB_STORE_PROMO_LOADED, | 380 chrome::NOTIFICATION_WEB_STORE_PROMO_LOADED, |
377 content::Source<Profile>(profile_), | 381 content::Source<Profile>(profile_), |
378 content::NotificationService::NoDetails()); | 382 content::NotificationService::NoDetails()); |
379 } | 383 } |
380 | 384 |
381 bool AppsPromoLogoFetcher::SupportsLogoURL() { | 385 bool AppsPromoLogoFetcher::SupportsLogoURL() { |
382 URLPattern allowed_urls(URLPattern::SCHEME_HTTPS, kValidLogoPattern); | 386 URLPattern allowed_urls(URLPattern::SCHEME_HTTPS, kValidLogoPattern); |
383 return allowed_urls.MatchesURL(promo_data_.logo); | 387 return allowed_urls.MatchesURL(promo_data_.logo); |
384 } | 388 } |
OLD | NEW |