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

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

Issue 2379923002: Implement "appinstalled" event on Android. (Closed)
Patch Set: Rebase. Created 4 years 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
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"
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/strings/string_number_conversions.h" 12 #include "base/strings/string_number_conversions.h"
13 #include "base/time/time.h" 13 #include "base/time/time.h"
14 #include "chrome/browser/banners/app_banner_metrics.h" 14 #include "chrome/browser/banners/app_banner_metrics.h"
15 #include "chrome/browser/banners/app_banner_settings_helper.h" 15 #include "chrome/browser/banners/app_banner_settings_helper.h"
16 #include "chrome/browser/browser_process.h" 16 #include "chrome/browser/browser_process.h"
17 #include "chrome/browser/engagement/site_engagement_service.h" 17 #include "chrome/browser/engagement/site_engagement_service.h"
18 #include "chrome/browser/profiles/profile.h" 18 #include "chrome/browser/profiles/profile.h"
19 #include "chrome/common/chrome_switches.h" 19 #include "chrome/common/chrome_switches.h"
20 #include "components/rappor/public/rappor_utils.h" 20 #include "components/rappor/public/rappor_utils.h"
21 #include "components/rappor/rappor_service_impl.h" 21 #include "components/rappor/rappor_service_impl.h"
22 #include "content/public/browser/navigation_handle.h" 22 #include "content/public/browser/navigation_handle.h"
23 #include "content/public/browser/render_frame_host.h" 23 #include "content/public/browser/render_frame_host.h"
24 #include "content/public/browser/web_contents.h" 24 #include "content/public/browser/web_contents.h"
25 #include "content/public/common/origin_util.h" 25 #include "content/public/common/origin_util.h"
26 #include "mojo/public/cpp/bindings/interface_request.h"
26 #include "services/service_manager/public/cpp/interface_provider.h" 27 #include "services/service_manager/public/cpp/interface_provider.h"
27 #include "third_party/skia/include/core/SkBitmap.h" 28 #include "third_party/skia/include/core/SkBitmap.h"
28 #include "ui/display/display.h" 29 #include "ui/display/display.h"
29 #include "ui/display/screen.h" 30 #include "ui/display/screen.h"
30 31
31 namespace { 32 namespace {
32 33
33 int gCurrentRequestID = -1; 34 int gCurrentRequestID = -1;
34 int gTimeDeltaInDaysForTesting = 0; 35 int gTimeDeltaInDaysForTesting = 0;
35 36
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 124
124 // Any existing binding is invalid when we request a new banner. 125 // Any existing binding is invalid when we request a new banner.
125 if (binding_.is_bound()) 126 if (binding_.is_bound())
126 binding_.Close(); 127 binding_.Close();
127 128
128 manager_->GetData( 129 manager_->GetData(
129 ParamsToGetManifest(), 130 ParamsToGetManifest(),
130 base::Bind(&AppBannerManager::OnDidGetManifest, GetWeakPtr())); 131 base::Bind(&AppBannerManager::OnDidGetManifest, GetWeakPtr()));
131 } 132 }
132 133
134 void AppBannerManager::OnInstall() {
135 blink::mojom::InstallationServicePtr installation_service;
136 web_contents()->GetMainFrame()->GetRemoteInterfaces()->GetInterface(
137 mojo::GetProxy(&installation_service));
138 DCHECK(installation_service);
139 installation_service->OnInstall();
140 }
141
133 void AppBannerManager::SendBannerAccepted(int request_id) { 142 void AppBannerManager::SendBannerAccepted(int request_id) {
134 if (request_id != gCurrentRequestID) 143 if (request_id != gCurrentRequestID)
135 return; 144 return;
136 145
137 DCHECK(event_.is_bound()); 146 DCHECK(event_.is_bound());
138 event_->BannerAccepted(GetBannerType()); 147 event_->BannerAccepted(GetBannerType());
139 } 148 }
140 149
141 void AppBannerManager::SendBannerDismissed(int request_id) { 150 void AppBannerManager::SendBannerDismissed(int request_id) {
142 if (request_id != gCurrentRequestID) 151 if (request_id != gCurrentRequestID)
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after
535 // Simulate a non-canceled OnBannerPromptReply to show the delayed banner. 544 // Simulate a non-canceled OnBannerPromptReply to show the delayed banner.
536 // Don't reset |was_canceled_by_page_| yet for metrics purposes. 545 // Don't reset |was_canceled_by_page_| yet for metrics purposes.
537 OnBannerPromptReply(blink::mojom::AppBannerPromptReply::NONE, referrer_); 546 OnBannerPromptReply(blink::mojom::AppBannerPromptReply::NONE, referrer_);
538 } else { 547 } else {
539 // Log that the prompt request was made for when we get the prompt reply. 548 // Log that the prompt request was made for when we get the prompt reply.
540 page_requested_prompt_ = true; 549 page_requested_prompt_ = true;
541 } 550 }
542 } 551 }
543 552
544 } // namespace banners 553 } // namespace banners
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698