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_notification_types.h" | 13 #include "chrome/common/chrome_notification_types.h" |
14 #include "chrome/common/chrome_switches.h" | 14 #include "chrome/common/chrome_switches.h" |
15 #include "chrome/common/extensions/extension.h" | 15 #include "chrome/common/extensions/extension.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/url_constants.h" | 18 #include "content/public/common/url_constants.h" |
19 #include "content/public/common/url_fetcher.h" | |
20 #include "net/base/load_flags.h" | 19 #include "net/base/load_flags.h" |
| 20 #include "net/url_request/url_fetcher.h" |
21 #include "net/url_request/url_request_status.h" | 21 #include "net/url_request/url_request_status.h" |
22 | 22 |
23 const int AppsPromo::kDefaultAppsCounterMax = 10; | 23 const int AppsPromo::kDefaultAppsCounterMax = 10; |
24 | 24 |
25 namespace { | 25 namespace { |
26 | 26 |
27 // The default logo for the promo. | 27 // The default logo for the promo. |
28 const char kDefaultLogo[] = "chrome://theme/IDR_WEBSTORE_ICON"; | 28 const char kDefaultLogo[] = "chrome://theme/IDR_WEBSTORE_ICON"; |
29 | 29 |
30 // The default promo data (this is only used for testing with | 30 // The default promo data (this is only used for testing with |
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
350 // will revert to the default logo. | 350 // will revert to the default logo. |
351 AppsPromo::SetSourcePromoLogoURL(GURL()); | 351 AppsPromo::SetSourcePromoLogoURL(GURL()); |
352 } | 352 } |
353 | 353 |
354 SavePromo(); | 354 SavePromo(); |
355 } | 355 } |
356 | 356 |
357 void AppsPromoLogoFetcher::FetchLogo() { | 357 void AppsPromoLogoFetcher::FetchLogo() { |
358 CHECK(promo_data_.logo.scheme() == chrome::kHttpsScheme); | 358 CHECK(promo_data_.logo.scheme() == chrome::kHttpsScheme); |
359 | 359 |
360 url_fetcher_.reset(content::URLFetcher::Create( | 360 url_fetcher_.reset(net::URLFetcher::Create( |
361 0, promo_data_.logo, net::URLFetcher::GET, this)); | 361 0, promo_data_.logo, net::URLFetcher::GET, this)); |
362 url_fetcher_->SetRequestContext( | 362 url_fetcher_->SetRequestContext( |
363 g_browser_process->system_request_context()); | 363 g_browser_process->system_request_context()); |
364 url_fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | | 364 url_fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | |
365 net::LOAD_DO_NOT_SAVE_COOKIES); | 365 net::LOAD_DO_NOT_SAVE_COOKIES); |
366 url_fetcher_->Start(); | 366 url_fetcher_->Start(); |
367 } | 367 } |
368 | 368 |
369 bool AppsPromoLogoFetcher::HaveCachedLogo() { | 369 bool AppsPromoLogoFetcher::HaveCachedLogo() { |
370 return promo_data_.logo == AppsPromo::GetSourcePromoLogoURL(); | 370 return promo_data_.logo == AppsPromo::GetSourcePromoLogoURL(); |
371 } | 371 } |
372 | 372 |
373 void AppsPromoLogoFetcher::SavePromo() { | 373 void AppsPromoLogoFetcher::SavePromo() { |
374 AppsPromo::SetPromo(promo_data_); | 374 AppsPromo::SetPromo(promo_data_); |
375 | 375 |
376 content::NotificationService::current()->Notify( | 376 content::NotificationService::current()->Notify( |
377 chrome::NOTIFICATION_WEB_STORE_PROMO_LOADED, | 377 chrome::NOTIFICATION_WEB_STORE_PROMO_LOADED, |
378 content::Source<Profile>(profile_), | 378 content::Source<Profile>(profile_), |
379 content::NotificationService::NoDetails()); | 379 content::NotificationService::NoDetails()); |
380 } | 380 } |
381 | 381 |
382 bool AppsPromoLogoFetcher::SupportsLogoURL() { | 382 bool AppsPromoLogoFetcher::SupportsLogoURL() { |
383 URLPattern allowed_urls(URLPattern::SCHEME_HTTPS, kValidLogoPattern); | 383 URLPattern allowed_urls(URLPattern::SCHEME_HTTPS, kValidLogoPattern); |
384 return allowed_urls.MatchesURL(promo_data_.logo); | 384 return allowed_urls.MatchesURL(promo_data_.logo); |
385 } | 385 } |
OLD | NEW |