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

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"
28 #include "third_party/WebKit/public/platform/modules/installation/installation.m ojom.h"
27 #include "third_party/skia/include/core/SkBitmap.h" 29 #include "third_party/skia/include/core/SkBitmap.h"
28 #include "ui/display/display.h" 30 #include "ui/display/display.h"
29 #include "ui/display/screen.h" 31 #include "ui/display/screen.h"
30 32
31 namespace { 33 namespace {
32 34
33 int gCurrentRequestID = -1; 35 int gCurrentRequestID = -1;
34 int gTimeDeltaInDaysForTesting = 0; 36 int gTimeDeltaInDaysForTesting = 0;
35 37
36 // Returns |size_in_px| in dp, i.e. divided by the current device scale factor. 38 // Returns |size_in_px| in dp, i.e. divided by the current device scale factor.
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 125
124 // Any existing binding is invalid when we request a new banner. 126 // Any existing binding is invalid when we request a new banner.
125 if (binding_.is_bound()) 127 if (binding_.is_bound())
126 binding_.Close(); 128 binding_.Close();
127 129
128 manager_->GetData( 130 manager_->GetData(
129 ParamsToGetManifest(), 131 ParamsToGetManifest(),
130 base::Bind(&AppBannerManager::OnDidGetManifest, GetWeakPtr())); 132 base::Bind(&AppBannerManager::OnDidGetManifest, GetWeakPtr()));
131 } 133 }
132 134
135 void AppBannerManager::OnInstall() {
136 blink::mojom::InstallationServicePtr installation_service;
137 web_contents()->GetMainFrame()->GetRemoteInterfaces()->GetInterface(
138 mojo::GetProxy(&installation_service));
139 DCHECK(installation_service);
140 installation_service->OnInstall();
141 }
142
133 void AppBannerManager::SendBannerAccepted(int request_id) { 143 void AppBannerManager::SendBannerAccepted(int request_id) {
134 if (request_id != gCurrentRequestID) 144 if (request_id != gCurrentRequestID)
135 return; 145 return;
136 146
137 DCHECK(event_.is_bound()); 147 DCHECK(event_.is_bound());
138 event_->BannerAccepted(GetBannerType()); 148 event_->BannerAccepted(GetBannerType());
139 } 149 }
140 150
141 void AppBannerManager::SendBannerDismissed(int request_id) { 151 void AppBannerManager::SendBannerDismissed(int request_id) {
142 if (request_id != gCurrentRequestID) 152 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. 545 // Simulate a non-canceled OnBannerPromptReply to show the delayed banner.
536 // Don't reset |was_canceled_by_page_| yet for metrics purposes. 546 // Don't reset |was_canceled_by_page_| yet for metrics purposes.
537 OnBannerPromptReply(blink::mojom::AppBannerPromptReply::NONE, referrer_); 547 OnBannerPromptReply(blink::mojom::AppBannerPromptReply::NONE, referrer_);
538 } else { 548 } else {
539 // Log that the prompt request was made for when we get the prompt reply. 549 // Log that the prompt request was made for when we get the prompt reply.
540 page_requested_prompt_ = true; 550 page_requested_prompt_ = true;
541 } 551 }
542 } 552 }
543 553
544 } // namespace banners 554 } // namespace banners
OLDNEW
« no previous file with comments | « chrome/browser/banners/app_banner_manager.h ('k') | chrome/test/data/banners/appinstalled_test_page.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698