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

Side by Side Diff: chrome/browser/banners/app_banner_data_fetcher.cc

Issue 1017883002: [App banners] Add browser test for canceling banners (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Renaming variable Created 5 years, 9 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 unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/banners/app_banner_data_fetcher_browsertest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "chrome/browser/banners/app_banner_metrics.h" 9 #include "chrome/browser/banners/app_banner_metrics.h"
10 #include "chrome/browser/banners/app_banner_settings_helper.h" 10 #include "chrome/browser/banners/app_banner_settings_helper.h"
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 133
134 void AppBannerDataFetcher::OnBannerPromptReply( 134 void AppBannerDataFetcher::OnBannerPromptReply(
135 content::RenderFrameHost* render_frame_host, 135 content::RenderFrameHost* render_frame_host,
136 int request_id, 136 int request_id,
137 blink::WebAppBannerPromptReply reply) { 137 blink::WebAppBannerPromptReply reply) {
138 content::WebContents* web_contents = GetWebContents(); 138 content::WebContents* web_contents = GetWebContents();
139 if (!is_active_ || !web_contents || request_id != gCurrentRequestID) { 139 if (!is_active_ || !web_contents || request_id != gCurrentRequestID) {
140 Cancel(); 140 Cancel();
141 return; 141 return;
142 } 142 }
143 is_active_ = false;
144 143
145 // The renderer might have requested the prompt to be canceled. 144 // The renderer might have requested the prompt to be canceled.
146 if (reply == blink::WebAppBannerPromptReply::Cancel) { 145 if (reply == blink::WebAppBannerPromptReply::Cancel) {
147 // TODO(mlamouri,benwells): we should probably record that to behave 146 // TODO(mlamouri,benwells): we should probably record that to behave
148 // differently with regard to showing the banner. 147 // differently with regard to showing the banner.
149 Cancel(); 148 Cancel();
150 return; 149 return;
151 } 150 }
152 151
153 // Definitely going to show the banner now. 152 // Definitely going to show the banner now.
154 FOR_EACH_OBSERVER(Observer, observer_list_, 153 FOR_EACH_OBSERVER(Observer, observer_list_,
155 OnDecidedWhetherToShow(this, true)); 154 OnDecidedWhetherToShow(this, true));
156 155
157 infobars::InfoBar* infobar = CreateBanner(app_icon_.get(), app_title_); 156 infobars::InfoBar* infobar = CreateBanner(app_icon_.get(), app_title_);
158 if (infobar) { 157 if (infobar) {
159 InfoBarService::FromWebContents(web_contents)->AddInfoBar( 158 InfoBarService::FromWebContents(web_contents)->AddInfoBar(
160 make_scoped_ptr(infobar)); 159 make_scoped_ptr(infobar));
161 } 160 }
161 is_active_ = false;
162 } 162 }
163 163
164 AppBannerDataFetcher::~AppBannerDataFetcher() { 164 AppBannerDataFetcher::~AppBannerDataFetcher() {
165 FOR_EACH_OBSERVER(Observer, observer_list_, OnFetcherDestroyed(this)); 165 FOR_EACH_OBSERVER(Observer, observer_list_, OnFetcherDestroyed(this));
166 } 166 }
167 167
168 std::string AppBannerDataFetcher::GetBannerType() { 168 std::string AppBannerDataFetcher::GetBannerType() {
169 return "web"; 169 return "web";
170 } 170 }
171 171
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 if (!manifest.start_url.is_valid()) 341 if (!manifest.start_url.is_valid())
342 return false; 342 return false;
343 if (manifest.name.is_null() && manifest.short_name.is_null()) 343 if (manifest.name.is_null() && manifest.short_name.is_null())
344 return false; 344 return false;
345 if (!DoesManifestContainRequiredIcon(manifest)) 345 if (!DoesManifestContainRequiredIcon(manifest))
346 return false; 346 return false;
347 return true; 347 return true;
348 } 348 }
349 349
350 } // namespace banners 350 } // namespace banners
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/banners/app_banner_data_fetcher_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698