-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor feature params to a separate file in //c/b. Also, move the feature params inside a function call instead of FeatureParam. This enables us to modify the return value based on multiple different field trial experiments which is needed in the next CL. Functionally, this is a no-op change. (cherry picked from commit 110df0c) Bug: b/286111571,1449021 Change-Id: I697e00379749cb5275701db50fd7f2c064d084bf Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4606829 Reviewed-by: Michael Crouse <mcrouse@chromium.org> Commit-Queue: Tarun Bansal <tbansal@chromium.org> Cr-Original-Commit-Position: refs/heads/main@{#1155942} Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4610473 Commit-Queue: Michael Crouse <mcrouse@chromium.org> Auto-Submit: Tarun Bansal <tbansal@chromium.org> Cr-Commit-Position: refs/branch-heads/5790@{#726} Cr-Branched-From: 1d71a33-refs/heads/main@{#1148114}
- Loading branch information
Showing
15 changed files
with
146 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// Copyright 2023 The Chromium Authors | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "chrome/browser/companion/core/utils.h" | ||
|
||
#include "chrome/browser/companion/core/constants.h" | ||
#include "chrome/browser/companion/core/features.h" | ||
|
||
namespace companion { | ||
|
||
std::string GetHomepageURLForCompanion() { | ||
std::string url = base::GetFieldTrialParamValueByFeature( | ||
features::kSidePanelCompanion, "companion-homepage-url"); | ||
if (url.empty()) { | ||
return std::string("https://lens.google.com/companion"); | ||
} | ||
return url; | ||
} | ||
|
||
std::string GetImageUploadURLForCompanion() { | ||
std::string url = base::GetFieldTrialParamValueByFeature( | ||
features::kSidePanelCompanion, "companion-image-upload-url"); | ||
if (url.empty()) { | ||
return std::string("https://lens.google.com/upload"); | ||
} | ||
return url; | ||
} | ||
|
||
bool ShouldEnableOpenCompanionForImageSearch() { | ||
if (base::FeatureList::IsEnabled(features::kSidePanelCompanion)) { | ||
return base::GetFieldTrialParamByFeatureAsBool( | ||
features::kSidePanelCompanion, "open-companion-for-image-search", true); | ||
} | ||
return false; | ||
} | ||
|
||
bool ShouldEnableOpenCompanionForWebSearch() { | ||
if (base::FeatureList::IsEnabled(features::kSidePanelCompanion)) { | ||
return base::GetFieldTrialParamByFeatureAsBool( | ||
features::kSidePanelCompanion, "open-companion-for-web-search", true); | ||
} | ||
return false; | ||
} | ||
bool ShouldOpenLinksInCurrentTab() { | ||
if (base::FeatureList::IsEnabled(features::kSidePanelCompanion)) { | ||
return base::GetFieldTrialParamByFeatureAsBool( | ||
features::kSidePanelCompanion, "open-links-in-current-tab", true); | ||
} | ||
return false; | ||
} | ||
|
||
std::string GetExpsRegistrationSuccessPageURLs() { | ||
return base::GetFieldTrialParamValueByFeature( | ||
features::kCompanionEnabledByObservingExpsNavigations, | ||
"exps-registration-success-page-urls"); | ||
} | ||
|
||
} // namespace companion |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Copyright 2023 The Chromium Authors | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#ifndef CHROME_BROWSER_COMPANION_CORE_UTILS_H_ | ||
#define CHROME_BROWSER_COMPANION_CORE_UTILS_H_ | ||
|
||
#include <string> | ||
|
||
namespace companion { | ||
|
||
std::string GetHomepageURLForCompanion(); | ||
std::string GetImageUploadURLForCompanion(); | ||
bool ShouldEnableOpenCompanionForImageSearch(); | ||
bool ShouldEnableOpenCompanionForWebSearch(); | ||
bool ShouldOpenLinksInCurrentTab(); | ||
std::string GetExpsRegistrationSuccessPageURLs(); | ||
|
||
} // namespace companion | ||
|
||
#endif // CHROME_BROWSER_COMPANION_CORE_UTILS_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Copyright 2023 The Chromium Authors | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "chrome/browser/companion/core/utils.h" | ||
|
||
#include "chrome/browser/companion/core/constants.h" | ||
#include "chrome/browser/companion/core/features.h" | ||
#include "content/public/test/test_utils.h" | ||
#include "testing/gtest/include/gtest/gtest.h" | ||
|
||
namespace companion { | ||
|
||
namespace { | ||
|
||
class CompanionCoreUtilsTest : public testing::Test {}; | ||
|
||
TEST_F(CompanionCoreUtilsTest, HomepageURLForCompanion) { | ||
EXPECT_EQ("https://lens.google.com/companion", GetHomepageURLForCompanion()); | ||
} | ||
|
||
TEST_F(CompanionCoreUtilsTest, ImageUploadURLForCompanion) { | ||
EXPECT_EQ("https://lens.google.com/upload", GetImageUploadURLForCompanion()); | ||
} | ||
|
||
} // namespace | ||
|
||
} // namespace companion |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters