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_switches.h" | 14 #include "chrome/common/chrome_switches.h" |
14 #include "chrome/common/extensions/extension.h" | 15 #include "chrome/common/extensions/extension.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/url_constants.h" | 18 #include "content/public/common/url_constants.h" |
19 #include "content/public/common/url_fetcher.h" | 19 #include "content/public/common/url_fetcher.h" |
20 #include "net/base/load_flags.h" | 20 #include "net/base/load_flags.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 { |
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
324 } else { | 324 } else { |
325 // We only care about the source URL when this fetches the logo. | 325 // We only care about the source URL when this fetches the logo. |
326 AppsPromo::SetSourcePromoLogoURL(GURL()); | 326 AppsPromo::SetSourcePromoLogoURL(GURL()); |
327 SavePromo(); | 327 SavePromo(); |
328 } | 328 } |
329 } | 329 } |
330 | 330 |
331 AppsPromoLogoFetcher::~AppsPromoLogoFetcher() {} | 331 AppsPromoLogoFetcher::~AppsPromoLogoFetcher() {} |
332 | 332 |
333 void AppsPromoLogoFetcher::OnURLFetchComplete( | 333 void AppsPromoLogoFetcher::OnURLFetchComplete( |
334 const content::URLFetcher* source) { | 334 const net::URLFetcher* source) { |
335 std::string data; | 335 std::string data; |
336 std::string base64_data; | 336 std::string base64_data; |
337 | 337 |
338 CHECK(source == url_fetcher_.get()); | 338 CHECK(source == url_fetcher_.get()); |
339 source->GetResponseAsString(&data); | 339 source->GetResponseAsString(&data); |
340 | 340 |
341 if (source->GetStatus().is_success() && | 341 if (source->GetStatus().is_success() && |
342 source->GetResponseCode() == kHttpSuccess && | 342 source->GetResponseCode() == kHttpSuccess && |
343 base::Base64Encode(data, &base64_data)) { | 343 base::Base64Encode(data, &base64_data)) { |
344 AppsPromo::SetSourcePromoLogoURL(promo_data_.logo); | 344 AppsPromo::SetSourcePromoLogoURL(promo_data_.logo); |
(...skipping 30 matching lines...) Expand all Loading... |
375 content::NotificationService::current()->Notify( | 375 content::NotificationService::current()->Notify( |
376 chrome::NOTIFICATION_WEB_STORE_PROMO_LOADED, | 376 chrome::NOTIFICATION_WEB_STORE_PROMO_LOADED, |
377 content::Source<Profile>(profile_), | 377 content::Source<Profile>(profile_), |
378 content::NotificationService::NoDetails()); | 378 content::NotificationService::NoDetails()); |
379 } | 379 } |
380 | 380 |
381 bool AppsPromoLogoFetcher::SupportsLogoURL() { | 381 bool AppsPromoLogoFetcher::SupportsLogoURL() { |
382 URLPattern allowed_urls(URLPattern::SCHEME_HTTPS, kValidLogoPattern); | 382 URLPattern allowed_urls(URLPattern::SCHEME_HTTPS, kValidLogoPattern); |
383 return allowed_urls.MatchesURL(promo_data_.logo); | 383 return allowed_urls.MatchesURL(promo_data_.logo); |
384 } | 384 } |
OLD | NEW |