Skip to content

Commit

Permalink
Remove apps::mojom::AppLaunchSource (part 1).
Browse files Browse the repository at this point in the history
apps::mojom::LaunchSource is used for the launch source. This CL is
used to remove the AppLaunchSource parameter in below functions:
CreateAppIdLaunchParamsWithEventFlags
CreateAppLaunchParamsForIntent
CreateAppLaunchParamsWithEventFlags

This CL is pure refactor, and no functionn change.

There will be follow up CLs to remove apps::mojom::AppLaunchSource.
TODO:
1. Remove AppLaunchSource from apps::AppLaunchParams.
2. Remove AppLaunchSource from AppService mojom types.mojom.

BUG=1113502, 1253250

Change-Id: I1ca9cd676afa3b966371cc6ab958aa53ffa9cab0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3218750
Reviewed-by: Ben Wells <benwells@chromium.org>
Reviewed-by: Dominick Ng <dominickn@chromium.org>
Reviewed-by: Erik Chen <erikchen@chromium.org>
Commit-Queue: Nancy Wang <nancylingwang@chromium.org>
Cr-Commit-Position: refs/heads/main@{#931867}
  • Loading branch information
Nancy Wang authored and Chromium LUCI CQ committed Oct 15, 2021
1 parent 7fbe698 commit 35e41eb
Show file tree
Hide file tree
Showing 12 changed files with 23 additions and 24 deletions.
9 changes: 5 additions & 4 deletions chrome/browser/apps/app_service/launch_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ Browser* CreateBrowserWithNewTabPage(Profile* profile) {
AppLaunchParams CreateAppIdLaunchParamsWithEventFlags(
const std::string& app_id,
int event_flags,
apps::mojom::AppLaunchSource source,
apps::mojom::LaunchSource launch_source,
int64_t display_id,
apps::mojom::LaunchContainer fallback_container) {
WindowOpenDisposition raw_disposition =
Expand All @@ -85,18 +85,19 @@ AppLaunchParams CreateAppIdLaunchParamsWithEventFlags(
container = fallback_container;
disposition = WindowOpenDisposition::NEW_FOREGROUND_TAB;
}
return AppLaunchParams(app_id, container, disposition, source, display_id);
return AppLaunchParams(app_id, container, disposition,
GetAppLaunchSource(launch_source), display_id);
}

apps::AppLaunchParams CreateAppLaunchParamsForIntent(
const std::string& app_id,
int32_t event_flags,
apps::mojom::AppLaunchSource source,
apps::mojom::LaunchSource launch_source,
int64_t display_id,
apps::mojom::LaunchContainer fallback_container,
apps::mojom::IntentPtr&& intent) {
auto params = CreateAppIdLaunchParamsWithEventFlags(
app_id, event_flags, source, display_id, fallback_container);
app_id, event_flags, launch_source, display_id, fallback_container);

if (intent->url.has_value()) {
params.source = apps::mojom::AppLaunchSource::kSourceIntentUrl;
Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/apps/app_service/launch_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,14 @@ Browser* CreateBrowserWithNewTabPage(Profile* profile);
AppLaunchParams CreateAppIdLaunchParamsWithEventFlags(
const std::string& app_id,
int event_flags,
apps::mojom::AppLaunchSource source,
apps::mojom::LaunchSource source,
int64_t display_id,
apps::mojom::LaunchContainer fallback_container);

apps::AppLaunchParams CreateAppLaunchParamsForIntent(
const std::string& app_id,
int32_t event_flags,
apps::mojom::AppLaunchSource source,
apps::mojom::LaunchSource source,
int64_t display_id,
apps::mojom::LaunchContainer fallback_container,
apps::mojom::IntentPtr&& intent);
Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/apps/app_service/launch_utils_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class LaunchUtilsTest : public testing::Test {
return apps::CreateAppIdLaunchParamsWithEventFlags(
app_id,
apps::GetEventFlags(container, disposition, preferred_container),
apps::mojom::AppLaunchSource::kSourceChromeInternal,
apps::mojom::LaunchSource::kFromChromeInternal,
display::kInvalidDisplayId, fallback_container);
}

Expand Down Expand Up @@ -87,7 +87,7 @@ TEST_F(LaunchUtilsTest, UseIntentFullUrlInLaunchParams) {

auto params = apps::CreateAppLaunchParamsForIntent(
app_id, apps::GetEventFlags(container, disposition, true),
apps::mojom::AppLaunchSource::kSourceIntentUrl,
apps::mojom::LaunchSource::kFromChromeInternal,
display::kInvalidDisplayId,
apps::mojom::LaunchContainer::kLaunchContainerWindow, std::move(intent));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ content::WebContents* ExtensionAppsBase::LaunchAppWithIntentImpl(
}

auto params = apps::CreateAppLaunchParamsForIntent(
app_id, event_flags, GetAppLaunchSource(launch_source),
app_id, event_flags, launch_source,
window_info ? window_info->display_id : display::kInvalidDisplayId,
extensions::GetLaunchContainer(extensions::ExtensionPrefs::Get(profile_),
extension),
Expand Down Expand Up @@ -387,7 +387,7 @@ void ExtensionAppsBase::Launch(const std::string& app_id,

// The app will be created for the currently active profile.
AppLaunchParams params = CreateAppLaunchParamsWithEventFlags(
profile_, extension, event_flags, GetAppLaunchSource(launch_source),
profile_, extension, event_flags, launch_source,
window_info ? window_info->display_id : display::kInvalidDisplayId);
ash::ShelfLaunchSource source = ConvertLaunchSource(launch_source);
if ((source == ash::LAUNCH_FROM_APP_LIST ||
Expand Down
3 changes: 1 addition & 2 deletions chrome/browser/lacros/lacros_extension_apps_controller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,7 @@ void LacrosExtensionAppsController::Launch(
extensions::LaunchContainer launch_container = extensions::GetLaunchContainer(
extensions::ExtensionPrefs::Get(profile), extension);
auto params = apps::CreateAppLaunchParamsForIntent(
extension->id(), ui::EF_NONE,
apps::GetAppLaunchSource(launch_params->launch_source),
extension->id(), ui::EF_NONE, launch_params->launch_source,
display::kInvalidDisplayId, launch_container, std::move(intent));
OpenApplication(profile, std::move(params));

Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/ui/ash/shelf/shelf_controller_helper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ void ShelfControllerHelper::LaunchApp(const ash::ShelfID& id,

apps::AppLaunchParams params = CreateAppLaunchParamsWithEventFlags(
profile_, extension, event_flags,
apps::mojom::AppLaunchSource::kSourceAppLauncher, display_id);
ShelfLaunchSourceToAppsLaunchSource(source), display_id);
if ((source == ash::LAUNCH_FROM_APP_LIST ||
source == ash::LAUNCH_FROM_APP_LIST_SEARCH) &&
app_id == extensions::kWebStoreAppId) {
Expand Down
5 changes: 3 additions & 2 deletions chrome/browser/ui/extensions/app_launch_params.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,11 @@ apps::AppLaunchParams CreateAppLaunchParamsWithEventFlags(
Profile* profile,
const extensions::Extension* extension,
int event_flags,
apps::mojom::AppLaunchSource source,
apps::mojom::LaunchSource launch_source,
int64_t display_id) {
apps::mojom::LaunchContainer fallback_container =
extensions::GetLaunchContainer(ExtensionPrefs::Get(profile), extension);
return apps::CreateAppIdLaunchParamsWithEventFlags(
extension->id(), event_flags, source, display_id, fallback_container);
extension->id(), event_flags, launch_source, display_id,
fallback_container);
}
2 changes: 1 addition & 1 deletion chrome/browser/ui/extensions/app_launch_params.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ apps::AppLaunchParams CreateAppLaunchParamsWithEventFlags(
Profile* profile,
const extensions::Extension* extension,
int event_flags,
apps::mojom::AppLaunchSource source,
apps::mojom::LaunchSource source,
int64_t display_id);

#endif // CHROME_BROWSER_UI_EXTENSIONS_APP_LAUNCH_PARAMS_H_
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ absl::optional<apps::AppLaunchParams> CreateSystemWebAppLaunchParams(
// TODO(crbug/1113502): Plumb through better launch sources from callsites.
apps::AppLaunchParams params = apps::CreateAppIdLaunchParamsWithEventFlags(
app_id.value(), /*event_flags=*/0,
apps::mojom::AppLaunchSource::kSourceChromeInternal, display_id,
apps::mojom::LaunchSource::kFromChromeInternal, display_id,
/*fallback_container=*/
ConvertDisplayModeToAppLaunchContainer(display_mode));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class WebShareTargetBrowserTest : public WebAppControllerBrowserTest {
const GURL& expected_url) {
apps::AppLaunchParams params = apps::CreateAppLaunchParamsForIntent(
app_id,
/*event_flags=*/0, apps::mojom::AppLaunchSource::kSourceAppLauncher,
/*event_flags=*/0, apps::mojom::LaunchSource::kFromSharesheet,
display::kDefaultDisplayId,
apps::mojom::LaunchContainer::kLaunchContainerWindow,
std::move(intent));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@ content::WebContents* WebAppPublisherHelper::Launch(
DisplayMode display_mode = registrar().GetAppEffectiveDisplayMode(app_id);

apps::AppLaunchParams params = apps::CreateAppIdLaunchParamsWithEventFlags(
web_app->app_id(), event_flags, apps::GetAppLaunchSource(launch_source),
web_app->app_id(), event_flags, launch_source,
window_info ? window_info->display_id : display::kInvalidDisplayId,
/*fallback_container=*/
ConvertDisplayModeToAppLaunchContainer(display_mode));
Expand All @@ -604,8 +604,7 @@ content::WebContents* WebAppPublisherHelper::LaunchAppWithFiles(
apps::mojom::FilePathsPtr file_paths) {
DisplayMode display_mode = registrar().GetAppEffectiveDisplayMode(app_id);
apps::AppLaunchParams params = apps::CreateAppIdLaunchParamsWithEventFlags(
app_id, event_flags, apps::GetAppLaunchSource(launch_source),
display::kInvalidDisplayId,
app_id, event_flags, launch_source, display::kInvalidDisplayId,
/*fallback_container=*/
ConvertDisplayModeToAppLaunchContainer(display_mode));
if (file_paths) {
Expand Down Expand Up @@ -1174,7 +1173,7 @@ content::WebContents* WebAppPublisherHelper::LaunchAppWithIntentImpl(
}

auto params = apps::CreateAppLaunchParamsForIntent(
app_id, event_flags, apps::GetAppLaunchSource(launch_source), display_id,
app_id, event_flags, launch_source, display_id,
ConvertDisplayModeToAppLaunchContainer(
registrar().GetAppEffectiveDisplayMode(app_id)),
std::move(intent));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,8 +264,7 @@ void WebAppsPublisherHost::Launch(crosapi::mojom::LaunchParamsPtr launch_params,
return;
}
auto params = apps::CreateAppLaunchParamsForIntent(
launch_params->app_id, ui::EF_NONE,
apps::GetAppLaunchSource(launch_params->launch_source),
launch_params->app_id, ui::EF_NONE, launch_params->launch_source,
display::kDefaultDisplayId,
ConvertDisplayModeToAppLaunchContainer(
registrar().GetAppEffectiveDisplayMode(launch_params->app_id)),
Expand Down

0 comments on commit 35e41eb

Please sign in to comment.