Skip to content

Commit

Permalink
[APS] Call into the server connector on first login.
Browse files Browse the repository at this point in the history
On first login, make a call into the AppPreloadServerConnector's
StartAppInstallationForFirstLogin method. Pass in a callback that will
handle the response and set the appropriate pref once done.

Bug: b/246674182
Change-Id: I119147a2664925b6dd6a78393f223f775309ae50
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3895491
Auto-Submit: Jeevan Shikaram <jshikaram@chromium.org>
Reviewed-by: Melissa Zhang <melzhang@chromium.org>
Commit-Queue: Jeevan Shikaram <jshikaram@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1047331}
  • Loading branch information
jeevan-shikaram authored and Chromium LUCI CQ committed Sep 15, 2022
1 parent a122b82 commit 230bc9e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@

#include <memory>

#include "base/bind.h"
#include "base/logging.h"
#include "chrome/browser/apps/app_preload_service/app_preload_service_factory.h"
#include "chrome/browser/apps/app_preload_service/device_info_manager.h"
#include "chrome/browser/profiles/profile.h"
#include "components/pref_registry/pref_registry_syncable.h"
#include "components/prefs/pref_service.h"
Expand Down Expand Up @@ -62,6 +64,13 @@ void AppPreloadService::RegisterProfilePrefs(
}

void AppPreloadService::StartAppInstallationForFirstLogin() {
server_connector_->GetAppsForFirstLogin(
DeviceInfoManager(profile_),
base::BindOnce(&AppPreloadService::OnGetAppsForFirstLoginCompleted,
weak_ptr_factory_.GetWeakPtr()));
}

void AppPreloadService::OnGetAppsForFirstLoginCompleted() {
DictionaryPrefUpdate(profile_->GetPrefs(), prefs::kApsStateManager)
->GetDict()
.Set(kFirstLoginFlowCompletedKey, true);
Expand Down
7 changes: 7 additions & 0 deletions chrome/browser/apps/app_preload_service/app_preload_service.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

#include "base/gtest_prod_util.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/weak_ptr.h"
#include "base/values.h"
#include "chrome/browser/apps/app_preload_service/app_preload_server_connector.h"
#include "components/keyed_service/core/keyed_service.h"
Expand Down Expand Up @@ -43,10 +44,16 @@ class AppPreloadService : public KeyedService {
friend class AppPreloadServiceTest;
FRIEND_TEST_ALL_PREFIXES(AppPreloadServiceTest, FirstLoginPrefSet);

// Processes the list of apps retrieved by the server connector.
void OnGetAppsForFirstLoginCompleted();

const base::Value::Dict& GetStateManager() const;

raw_ptr<Profile> profile_;
std::unique_ptr<AppPreloadServerConnector> server_connector_;

// |weak_ptr_factory_| must be the last member of this class.
base::WeakPtrFactory<AppPreloadService> weak_ptr_factory_{this};
};

} // namespace apps
Expand Down

0 comments on commit 230bc9e

Please sign in to comment.