OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/banners/app_banner_data_fetcher.h" | 5 #include "chrome/browser/banners/app_banner_data_fetcher.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "chrome/browser/banners/app_banner_metrics.h" | 10 #include "chrome/browser/banners/app_banner_metrics.h" |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 content::WebContents* web_contents, | 68 content::WebContents* web_contents, |
69 base::WeakPtr<Delegate> delegate, | 69 base::WeakPtr<Delegate> delegate, |
70 int ideal_icon_size) | 70 int ideal_icon_size) |
71 : WebContentsObserver(web_contents), | 71 : WebContentsObserver(web_contents), |
72 ideal_icon_size_(ideal_icon_size), | 72 ideal_icon_size_(ideal_icon_size), |
73 weak_delegate_(delegate), | 73 weak_delegate_(delegate), |
74 is_active_(false) { | 74 is_active_(false) { |
75 } | 75 } |
76 | 76 |
77 void AppBannerDataFetcher::Start(const GURL& validated_url) { | 77 void AppBannerDataFetcher::Start(const GURL& validated_url) { |
78 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 78 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
79 | 79 |
80 content::WebContents* web_contents = GetWebContents(); | 80 content::WebContents* web_contents = GetWebContents(); |
81 DCHECK(web_contents); | 81 DCHECK(web_contents); |
82 | 82 |
83 is_active_ = true; | 83 is_active_ = true; |
84 validated_url_ = validated_url; | 84 validated_url_ = validated_url; |
85 web_contents->GetManifest( | 85 web_contents->GetManifest( |
86 base::Bind(&AppBannerDataFetcher::OnDidGetManifest, this)); | 86 base::Bind(&AppBannerDataFetcher::OnDidGetManifest, this)); |
87 } | 87 } |
88 | 88 |
89 void AppBannerDataFetcher::Cancel() { | 89 void AppBannerDataFetcher::Cancel() { |
90 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 90 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
91 if (is_active_) { | 91 if (is_active_) { |
92 FOR_EACH_OBSERVER(Observer, observer_list_, | 92 FOR_EACH_OBSERVER(Observer, observer_list_, |
93 OnDecidedWhetherToShow(this, false)); | 93 OnDecidedWhetherToShow(this, false)); |
94 is_active_ = false; | 94 is_active_ = false; |
95 } | 95 } |
96 } | 96 } |
97 | 97 |
98 void AppBannerDataFetcher::ReplaceWebContents( | 98 void AppBannerDataFetcher::ReplaceWebContents( |
99 content::WebContents* web_contents) { | 99 content::WebContents* web_contents) { |
100 Observe(web_contents); | 100 Observe(web_contents); |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 if (!manifest.start_url.is_valid()) | 353 if (!manifest.start_url.is_valid()) |
354 return false; | 354 return false; |
355 if (manifest.name.is_null() && manifest.short_name.is_null()) | 355 if (manifest.name.is_null() && manifest.short_name.is_null()) |
356 return false; | 356 return false; |
357 if (!DoesManifestContainRequiredIcon(manifest)) | 357 if (!DoesManifestContainRequiredIcon(manifest)) |
358 return false; | 358 return false; |
359 return true; | 359 return true; |
360 } | 360 } |
361 | 361 |
362 } // namespace banners | 362 } // namespace banners |
OLD | NEW |