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

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

Issue 2671653002: Webapps: Clear AppBannerManagerAndroid::native_app_data_ prior to native app check (Closed)
Patch Set: Merge branch 'master' into install_banner Created 3 years, 10 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 | « chrome/browser/banners/app_banner_manager.h ('k') | no next file » | 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_manager.h" 5 #include "chrome/browser/banners/app_banner_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 if (IsDebugMode()) { 297 if (IsDebugMode()) {
298 LogErrorToConsole(web_contents, code, GetStatusParam(code)); 298 LogErrorToConsole(web_contents, code, GetStatusParam(code));
299 } else { 299 } else {
300 // Ensure that we haven't yet logged a status code for this page. 300 // Ensure that we haven't yet logged a status code for this page.
301 DCHECK(need_to_log_status_); 301 DCHECK(need_to_log_status_);
302 TrackInstallableStatusCode(code); 302 TrackInstallableStatusCode(code);
303 need_to_log_status_ = false; 303 need_to_log_status_ = false;
304 } 304 }
305 } 305 }
306 306
307 void AppBannerManager::ResetCurrentPageData() {
308 active_media_players_.clear();
309 manifest_ = content::Manifest();
310 manifest_url_ = GURL();
311 validated_url_ = GURL();
312 referrer_.erase();
313 }
314
307 void AppBannerManager::Stop() { 315 void AppBannerManager::Stop() {
308 if (was_canceled_by_page_ && !page_requested_prompt_) { 316 if (was_canceled_by_page_ && !page_requested_prompt_) {
309 TrackBeforeInstallEvent( 317 TrackBeforeInstallEvent(
310 BEFORE_INSTALL_EVENT_PROMPT_NOT_CALLED_AFTER_PREVENT_DEFAULT); 318 BEFORE_INSTALL_EVENT_PROMPT_NOT_CALLED_AFTER_PREVENT_DEFAULT);
311 ReportStatus(web_contents(), RENDERER_CANCELLED); 319 ReportStatus(web_contents(), RENDERER_CANCELLED);
312 } 320 }
313 321
314 // In every non-debug run through the banner pipeline, we should have called 322 // In every non-debug run through the banner pipeline, we should have called
315 // ReportStatus() and set need_to_log_status_ to false. The only case where 323 // ReportStatus() and set need_to_log_status_ to false. The only case where
316 // we don't is if we're still active and waiting for a callback from the 324 // we don't is if we're still active and waiting for a callback from the
317 // InstallableManager (e.g. the renderer crashes or the browser is shutting 325 // InstallableManager (e.g. the renderer crashes or the browser is shutting
318 // down). These situations are explicitly not logged. 326 // down). These situations are explicitly not logged.
319 DCHECK(!need_to_log_status_ || is_active_); 327 DCHECK(!need_to_log_status_ || is_active_);
320 328
321 weak_factory_.InvalidateWeakPtrs(); 329 weak_factory_.InvalidateWeakPtrs();
322 binding_.Close(); 330 binding_.Close();
323 controller_.reset(); 331 controller_.reset();
324 event_.reset(); 332 event_.reset();
325 333
326 is_active_ = false; 334 is_active_ = false;
327 was_canceled_by_page_ = false; 335 was_canceled_by_page_ = false;
328 page_requested_prompt_ = false; 336 page_requested_prompt_ = false;
329 need_to_log_status_ = false; 337 need_to_log_status_ = false;
330 validated_url_ = GURL();
331 referrer_.erase();
332 } 338 }
333 339
334 void AppBannerManager::SendBannerPromptRequest() { 340 void AppBannerManager::SendBannerPromptRequest() {
335 RecordCouldShowBanner(); 341 RecordCouldShowBanner();
336 342
337 TrackBeforeInstallEvent(BEFORE_INSTALL_EVENT_CREATED); 343 TrackBeforeInstallEvent(BEFORE_INSTALL_EVENT_CREATED);
338 event_request_id_ = ++gCurrentRequestID; 344 event_request_id_ = ++gCurrentRequestID;
339 345
340 web_contents()->GetMainFrame()->GetRemoteInterfaces()->GetInterface( 346 web_contents()->GetMainFrame()->GetRemoteInterfaces()->GetInterface(
341 mojo::MakeRequest(&controller_)); 347 mojo::MakeRequest(&controller_));
(...skipping 14 matching lines...) Expand all
356 // start. This may be the first navigation, or we may have stopped 362 // start. This may be the first navigation, or we may have stopped
357 // observing if the banner flow was triggered on the previous page. 363 // observing if the banner flow was triggered on the previous page.
358 SiteEngagementObserver::Observe(SiteEngagementService::Get( 364 SiteEngagementObserver::Observe(SiteEngagementService::Get(
359 Profile::FromBrowserContext(web_contents()->GetBrowserContext()))); 365 Profile::FromBrowserContext(web_contents()->GetBrowserContext())));
360 } 366 }
361 } 367 }
362 368
363 void AppBannerManager::DidFinishNavigation(content::NavigationHandle* handle) { 369 void AppBannerManager::DidFinishNavigation(content::NavigationHandle* handle) {
364 if (handle->IsInMainFrame() && handle->HasCommitted() && 370 if (handle->IsInMainFrame() && handle->HasCommitted() &&
365 !handle->IsSamePage()) { 371 !handle->IsSamePage()) {
366 active_media_players_.clear(); 372 ResetCurrentPageData();
367 if (is_active_) 373 if (is_active_)
368 Stop(); 374 Stop();
369 } 375 }
370 } 376 }
371 377
372 void AppBannerManager::DidFinishLoad( 378 void AppBannerManager::DidFinishLoad(
373 content::RenderFrameHost* render_frame_host, 379 content::RenderFrameHost* render_frame_host,
374 const GURL& validated_url) { 380 const GURL& validated_url) {
375 // Don't start the banner flow unless the main frame has finished loading. 381 // Don't start the banner flow unless the main frame has finished loading.
376 if (render_frame_host->GetParent()) 382 if (render_frame_host->GetParent())
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
531 // Simulate a non-canceled OnBannerPromptReply to show the delayed banner. 537 // Simulate a non-canceled OnBannerPromptReply to show the delayed banner.
532 // Don't reset |was_canceled_by_page_| yet for metrics purposes. 538 // Don't reset |was_canceled_by_page_| yet for metrics purposes.
533 OnBannerPromptReply(blink::mojom::AppBannerPromptReply::NONE, referrer_); 539 OnBannerPromptReply(blink::mojom::AppBannerPromptReply::NONE, referrer_);
534 } else { 540 } else {
535 // Log that the prompt request was made for when we get the prompt reply. 541 // Log that the prompt request was made for when we get the prompt reply.
536 page_requested_prompt_ = true; 542 page_requested_prompt_ = true;
537 } 543 }
538 } 544 }
539 545
540 } // namespace banners 546 } // namespace banners
OLDNEW
« no previous file with comments | « chrome/browser/banners/app_banner_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698