Commit fe8107bf authored by wutao's avatar wutao Committed by Commit Bot

app_list: Handle foreign tab update in AppSearchProvider

This patch handles the foreign tab update in AppSearchProvider, so that
the suggested results can be updated in home launcher.

Bug: 843839
Test: manual.
Change-Id: I4895cdaa475dcb4eaedebada90629eaff6743857
Reviewed-on: https://chromium-review.googlesource.com/1140522
Commit-Queue: Tao Wu <wutao@chromium.org>
Reviewed-by: default avatarJenny Zhang <jennyz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#577656}
parent 8854e43a
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#include "chrome/browser/extensions/extension_ui_util.h" #include "chrome/browser/extensions/extension_ui_util.h"
#include "chrome/browser/extensions/extension_util.h" #include "chrome/browser/extensions/extension_util.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/browser/sync/profile_sync_service_factory.h"
#include "chrome/browser/ui/app_list/app_list_model_updater.h" #include "chrome/browser/ui/app_list/app_list_model_updater.h"
#include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h" #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h"
#include "chrome/browser/ui/app_list/arc/arc_app_utils.h" #include "chrome/browser/ui/app_list/arc/arc_app_utils.h"
...@@ -45,6 +46,9 @@ ...@@ -45,6 +46,9 @@
#include "chrome/browser/ui/app_list/search/crostini_app_result.h" #include "chrome/browser/ui/app_list/search/crostini_app_result.h"
#include "chrome/browser/ui/app_list/search/extension_app_result.h" #include "chrome/browser/ui/app_list/search/extension_app_result.h"
#include "chrome/browser/ui/app_list/search/internal_app_result.h" #include "chrome/browser/ui/app_list/search/internal_app_result.h"
#include "components/browser_sync/profile_sync_service.h"
#include "components/sync/driver/sync_service.h"
#include "components/sync/driver/sync_service_observer.h"
#include "extensions/browser/extension_prefs.h" #include "extensions/browser/extension_prefs.h"
#include "extensions/browser/extension_registry.h" #include "extensions/browser/extension_registry.h"
#include "extensions/browser/extension_system.h" #include "extensions/browser/extension_system.h"
...@@ -345,12 +349,23 @@ class ArcDataSource : public AppSearchProvider::DataSource, ...@@ -345,12 +349,23 @@ class ArcDataSource : public AppSearchProvider::DataSource,
DISALLOW_COPY_AND_ASSIGN(ArcDataSource); DISALLOW_COPY_AND_ASSIGN(ArcDataSource);
}; };
class InternalDataSource : public AppSearchProvider::DataSource { class InternalDataSource : public AppSearchProvider::DataSource,
syncer::SyncServiceObserver {
public: public:
InternalDataSource(Profile* profile, AppSearchProvider* owner) InternalDataSource(Profile* profile, AppSearchProvider* owner)
: AppSearchProvider::DataSource(profile, owner) {} : AppSearchProvider::DataSource(profile, owner) {
browser_sync::ProfileSyncService* service =
ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile);
if (service)
service->AddObserver(this);
}
~InternalDataSource() override = default; ~InternalDataSource() override {
browser_sync::ProfileSyncService* service =
ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile());
if (service)
service->RemoveObserver(this);
}
// AppSearchProvider::DataSource overrides: // AppSearchProvider::DataSource overrides:
void AddApps(AppSearchProvider::Apps* apps) override { void AddApps(AppSearchProvider::Apps* apps) override {
...@@ -382,6 +397,11 @@ class InternalDataSource : public AppSearchProvider::DataSource { ...@@ -382,6 +397,11 @@ class InternalDataSource : public AppSearchProvider::DataSource {
list_controller, is_recommended); list_controller, is_recommended);
} }
// syncer::SyncServiceObserver overrides:
void OnForeignSessionUpdated(syncer::SyncService* sync) override {
owner()->RefreshAppsAndUpdateResults(/*force_inline=*/false);
}
private: private:
DISALLOW_COPY_AND_ASSIGN(InternalDataSource); DISALLOW_COPY_AND_ASSIGN(InternalDataSource);
}; };
......
...@@ -10,12 +10,10 @@ ...@@ -10,12 +10,10 @@
#include "ash/public/cpp/app_list/internal_app_id_constants.h" #include "ash/public/cpp/app_list/internal_app_id_constants.h"
#include "chrome/browser/favicon/large_icon_service_factory.h" #include "chrome/browser/favicon/large_icon_service_factory.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/browser/sync/profile_sync_service_factory.h"
#include "chrome/browser/ui/app_list/app_context_menu.h" #include "chrome/browser/ui/app_list/app_context_menu.h"
#include "chrome/browser/ui/app_list/app_list_controller_delegate.h" #include "chrome/browser/ui/app_list/app_list_controller_delegate.h"
#include "chrome/browser/ui/app_list/internal_app/internal_app_metadata.h" #include "chrome/browser/ui/app_list/internal_app/internal_app_metadata.h"
#include "chrome/browser/ui/app_list/search/search_util.h" #include "chrome/browser/ui/app_list/search/search_util.h"
#include "components/browser_sync/profile_sync_service.h"
#include "components/favicon/core/favicon_server_fetcher_params.h" #include "components/favicon/core/favicon_server_fetcher_params.h"
#include "components/favicon/core/large_icon_service.h" #include "components/favicon/core/large_icon_service.h"
#include "components/favicon_base/fallback_icon_style.h" #include "components/favicon_base/fallback_icon_style.h"
...@@ -38,21 +36,11 @@ InternalAppResult::InternalAppResult(Profile* profile, ...@@ -38,21 +36,11 @@ InternalAppResult::InternalAppResult(Profile* profile,
if (id() == kInternalAppIdContinueReading) { if (id() == kInternalAppIdContinueReading) {
large_icon_service_ = large_icon_service_ =
LargeIconServiceFactory::GetForBrowserContext(profile); LargeIconServiceFactory::GetForBrowserContext(profile);
browser_sync::ProfileSyncService* service =
ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile);
service->AddObserver(this);
service->TriggerRefresh(syncer::ModelTypeSet(syncer::SESSIONS));
UpdateContinueReadingFavicon(/*continue_to_google_server=*/true); UpdateContinueReadingFavicon(/*continue_to_google_server=*/true);
} }
} }
InternalAppResult::~InternalAppResult() { InternalAppResult::~InternalAppResult() = default;
if (id() == kInternalAppIdContinueReading) {
browser_sync::ProfileSyncService* service =
ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile());
service->RemoveObserver(this);
}
}
void InternalAppResult::ExecuteLaunchCommand(int event_flags) { void InternalAppResult::ExecuteLaunchCommand(int event_flags) {
Open(event_flags); Open(event_flags);
...@@ -74,10 +62,6 @@ void InternalAppResult::Open(int event_flags) { ...@@ -74,10 +62,6 @@ void InternalAppResult::Open(int event_flags) {
OpenInternalApp(id(), profile(), event_flags); OpenInternalApp(id(), profile(), event_flags);
} }
void InternalAppResult::OnForeignSessionUpdated(syncer::SyncService* sync) {
UpdateContinueReadingFavicon(/*continue_to_google_server=*/true);
}
void InternalAppResult::UpdateContinueReadingFavicon( void InternalAppResult::UpdateContinueReadingFavicon(
bool continue_to_google_server) { bool continue_to_google_server) {
base::string16 title; base::string16 title;
......
...@@ -12,7 +12,6 @@ ...@@ -12,7 +12,6 @@
#include "base/task/cancelable_task_tracker.h" #include "base/task/cancelable_task_tracker.h"
#include "chrome/browser/ui/app_list/search/app_result.h" #include "chrome/browser/ui/app_list/search/app_result.h"
#include "components/favicon_base/favicon_types.h" #include "components/favicon_base/favicon_types.h"
#include "components/sync/driver/sync_service_observer.h"
#include "url/gurl.h" #include "url/gurl.h"
class AppListControllerDelegate; class AppListControllerDelegate;
...@@ -26,15 +25,11 @@ namespace favicon_base { ...@@ -26,15 +25,11 @@ namespace favicon_base {
struct LargeIconImageResult; struct LargeIconImageResult;
} // namespace favicon_base } // namespace favicon_base
namespace syncer {
class SyncService;
} // namespace syncer
namespace app_list { namespace app_list {
class AppContextMenu; class AppContextMenu;
class InternalAppResult : public AppResult, syncer::SyncServiceObserver { class InternalAppResult : public AppResult {
public: public:
InternalAppResult(Profile* profile, InternalAppResult(Profile* profile,
const std::string& app_id, const std::string& app_id,
...@@ -53,9 +48,6 @@ class InternalAppResult : public AppResult, syncer::SyncServiceObserver { ...@@ -53,9 +48,6 @@ class InternalAppResult : public AppResult, syncer::SyncServiceObserver {
// ChromeSearchResult overrides: // ChromeSearchResult overrides:
AppContextMenu* GetAppContextMenu() override; AppContextMenu* GetAppContextMenu() override;
// syncer::SyncServiceObserver overrides:
void OnForeignSessionUpdated(syncer::SyncService* sync) override;
// Get large icon image from servers and update icon for continue reading. // Get large icon image from servers and update icon for continue reading.
// If there is no cache hit on LargeIconService and // If there is no cache hit on LargeIconService and
// |continue_to_google_server| is true, will try to download the icon from // |continue_to_google_server| is true, will try to download the icon from
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment