Move remaining files in c/b/ash/child_accounts/ to ns ash
Some files in chrome/browser/ash/child_accounts/ weren't using namespace
ash. This CL fixes that to remain consistent with the rest of the files
in that directory.
Bug: 1164001
Change-Id: I11a0975836691509499ec934def9427c1913adc5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3041338
Reviewed-by: Lei Zhang <[email protected]>
Commit-Queue: Henrique Ferreiro <[email protected]>
Cr-Commit-Position: refs/heads/master@{#903521}
diff --git a/chrome/browser/ash/child_accounts/child_user_service_factory.h b/chrome/browser/ash/child_accounts/child_user_service_factory.h
index f21bb695..cf3f4d2 100644
--- a/chrome/browser/ash/child_accounts/child_user_service_factory.h
+++ b/chrome/browser/ash/child_accounts/child_user_service_factory.h
@@ -40,9 +40,4 @@
} // namespace ash
-// TODO(https://crbug.com/1164001): remove when ChromOS code migration is done.
-namespace chromeos {
-using ::ash::ChildUserServiceFactory;
-} // namespace chromeos
-
#endif // CHROME_BROWSER_ASH_CHILD_ACCOUNTS_CHILD_USER_SERVICE_FACTORY_H_
diff --git a/chrome/browser/ash/child_accounts/secondary_account_consent_logger.cc b/chrome/browser/ash/child_accounts/secondary_account_consent_logger.cc
index e02a336..abea9f95 100644
--- a/chrome/browser/ash/child_accounts/secondary_account_consent_logger.cc
+++ b/chrome/browser/ash/child_accounts/secondary_account_consent_logger.cc
@@ -32,6 +32,7 @@
#include "services/network/public/mojom/url_response_head.mojom.h"
#include "url/gurl.h"
+namespace ash {
namespace {
constexpr char kConsentApiPath[] =
@@ -74,10 +75,10 @@
})");
std::string GetOrCreateEduCoexistenceId(PrefService* pref_service) {
- std::string id = pref_service->GetString(ash::prefs::kEduCoexistenceId);
+ std::string id = pref_service->GetString(prefs::kEduCoexistenceId);
if (id.empty()) {
id = base::GenerateGUID();
- pref_service->SetString(ash::prefs::kEduCoexistenceId, id);
+ pref_service->SetString(prefs::kEduCoexistenceId, id);
}
return id;
}
@@ -87,10 +88,10 @@
// static
void SecondaryAccountConsentLogger::RegisterPrefs(
PrefRegistrySimple* registry) {
- registry->RegisterStringPref(ash::prefs::kEduCoexistenceId,
+ registry->RegisterStringPref(prefs::kEduCoexistenceId,
std::string() /* default_value */);
registry->RegisterStringPref(
- ash::prefs::kEduCoexistenceSecondaryAccountsInvalidationVersion,
+ prefs::kEduCoexistenceSecondaryAccountsInvalidationVersion,
"iv2153049" /* default_value, the first invalidation version */);
}
@@ -220,3 +221,5 @@
std::move(callback_).Run(Result::kSuccess);
}
+
+} // namespace ash
diff --git a/chrome/browser/ash/child_accounts/secondary_account_consent_logger.h b/chrome/browser/ash/child_accounts/secondary_account_consent_logger.h
index 1b0dac8..b717df7 100644
--- a/chrome/browser/ash/child_accounts/secondary_account_consent_logger.h
+++ b/chrome/browser/ash/child_accounts/secondary_account_consent_logger.h
@@ -32,6 +32,8 @@
class SharedURLLoaderFactory;
} // namespace network
+namespace ash {
+
// Logs parental consent for addition of secondary EDU account.
// Firstly fetches access token with "kid.management.privileged" scope. Then
// logs consent with provided parent id, rapt, coexistence id and text version.
@@ -103,4 +105,12 @@
SEQUENCE_CHECKER(sequence_checker_);
};
+} // namespace ash
+
+// TODO(https://crbug.com/1164001): remove after the //chrome/browser/chromeos
+// source code migration is finished.
+namespace chromeos {
+using ::ash::SecondaryAccountConsentLogger;
+}
+
#endif // CHROME_BROWSER_ASH_CHILD_ACCOUNTS_SECONDARY_ACCOUNT_CONSENT_LOGGER_H_
diff --git a/chrome/browser/ash/child_accounts/secondary_account_consent_logger_unittest.cc b/chrome/browser/ash/child_accounts/secondary_account_consent_logger_unittest.cc
index c8fcc0e..845bb4b 100644
--- a/chrome/browser/ash/child_accounts/secondary_account_consent_logger_unittest.cc
+++ b/chrome/browser/ash/child_accounts/secondary_account_consent_logger_unittest.cc
@@ -25,7 +25,9 @@
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
+namespace ash {
namespace {
+
constexpr char kAccountEmail[] = "[email protected]";
constexpr char kSecondaryEmail[] = "[email protected]";
constexpr char kParentObfuscatedGaiaId[] = "parent-obfuscated-gaia-id";
@@ -67,7 +69,7 @@
void SetUp() {
SecondaryAccountConsentLogger::RegisterPrefs(local_state_.registry());
- local_state_.SetUserPref(ash::prefs::kEduCoexistenceId,
+ local_state_.SetUserPref(prefs::kEduCoexistenceId,
std::make_unique<base::Value>(kChromeSyncId));
}
@@ -225,3 +227,5 @@
base::DictionaryValue request_body = CreateRequestBody();
EXPECT_EQ(test_request_body.value(), request_body);
}
+
+} // namespace ash
diff --git a/chrome/browser/ash/child_accounts/time_limits/web_time_calculation_browsertest.cc b/chrome/browser/ash/child_accounts/time_limits/web_time_calculation_browsertest.cc
index a711f84..68df2b5 100644
--- a/chrome/browser/ash/child_accounts/time_limits/web_time_calculation_browsertest.cc
+++ b/chrome/browser/ash/child_accounts/time_limits/web_time_calculation_browsertest.cc
@@ -44,6 +44,7 @@
#include "ui/base/window_open_disposition.h"
#include "url/gurl.h"
+namespace ash {
namespace {
constexpr char kExampleHost1[] = "www.example.com";
@@ -69,7 +70,7 @@
const std::string& url_in,
WindowOpenDisposition disposition);
- ash::app_time::ChromeAppActivityState GetChromeAppActivityState();
+ app_time::ChromeAppActivityState GetChromeAppActivityState();
private:
void UpdatePolicy();
@@ -78,7 +79,7 @@
base::test::ScopedFeatureList scoped_feature_list_;
- ash::app_time::AppTimeLimitsAllowlistPolicyBuilder builder_;
+ app_time::AppTimeLimitsAllowlistPolicyBuilder builder_;
chromeos::LoggedInUserMixin logged_in_user_mixin_{
&mixin_host_, chromeos::LoggedInUserMixin::LogInType::kChild,
@@ -104,11 +105,10 @@
// During tests, AppService doesn't notify AppActivityRegistry that chrome app
// is installed. Mark chrome as installed here.
- ash::ChildUserService* service =
- ash::ChildUserServiceFactory::GetForBrowserContext(profile_);
- ash::ChildUserService::TestApi test_api(service);
+ auto* service = ChildUserServiceFactory::GetForBrowserContext(profile_);
+ ChildUserService::TestApi test_api(service);
test_api.app_time_controller()->app_registry()->OnAppInstalled(
- ash::app_time::GetChromeAppId());
+ app_time::GetChromeAppId());
}
void WebTimeCalculationBrowserTest::TearDown() {
@@ -141,11 +141,10 @@
return params.navigated_or_inserted_contents;
}
-ash::app_time::ChromeAppActivityState
+app_time::ChromeAppActivityState
WebTimeCalculationBrowserTest::GetChromeAppActivityState() {
- ash::ChildUserService* service =
- chromeos::ChildUserServiceFactory::GetForBrowserContext(profile_);
- ash::ChildUserService::TestApi test_api(service);
+ auto* service = ChildUserServiceFactory::GetForBrowserContext(profile_);
+ ChildUserService::TestApi test_api(service);
auto* web_time_activity_provider =
test_api.app_time_controller()->web_time_activity_provider();
return web_time_activity_provider->chrome_app_activty_state();
@@ -173,11 +172,11 @@
// Create a new tab and navigate it to some url.
Navigate(browser(), kExampleHost2, WindowOpenDisposition::NEW_FOREGROUND_TAB);
- EXPECT_EQ(ash::app_time::ChromeAppActivityState::kActive,
+ EXPECT_EQ(app_time::ChromeAppActivityState::kActive,
GetChromeAppActivityState());
browser()->tab_strip_model()->ActivateTabAt(0);
- EXPECT_EQ(ash::app_time::ChromeAppActivityState::kActiveAllowlisted,
+ EXPECT_EQ(app_time::ChromeAppActivityState::kActiveAllowlisted,
GetChromeAppActivityState());
bool destroyed = browser()->tab_strip_model()->CloseWebContentsAt(
@@ -186,7 +185,7 @@
base::RunLoop().RunUntilIdle();
- EXPECT_EQ(ash::app_time::ChromeAppActivityState::kActive,
+ EXPECT_EQ(app_time::ChromeAppActivityState::kActive,
GetChromeAppActivityState());
}
@@ -200,12 +199,12 @@
browser()->tab_strip_model()->ActivateTabAt(0);
- EXPECT_EQ(ash::app_time::ChromeAppActivityState::kActiveAllowlisted,
+ EXPECT_EQ(app_time::ChromeAppActivityState::kActiveAllowlisted,
GetChromeAppActivityState());
Browser* new_browser = DetachTabToNewBrowser(browser(), 1);
- EXPECT_EQ(ash::app_time::ChromeAppActivityState::kActive,
+ EXPECT_EQ(app_time::ChromeAppActivityState::kActive,
GetChromeAppActivityState());
// Now we have two browser windows. One hosting a allowlisted url and the
@@ -214,16 +213,18 @@
0, TabStripModel::CloseTypes::CLOSE_USER_GESTURE));
base::RunLoop().RunUntilIdle();
- EXPECT_EQ(ash::app_time::ChromeAppActivityState::kActiveAllowlisted,
+ EXPECT_EQ(app_time::ChromeAppActivityState::kActiveAllowlisted,
GetChromeAppActivityState());
EXPECT_TRUE(browser()->tab_strip_model()->CloseWebContentsAt(
0, TabStripModel::CloseTypes::CLOSE_USER_GESTURE));
base::RunLoop().RunUntilIdle();
- EXPECT_EQ(ash::app_time::ChromeAppActivityState::kInactive,
+ EXPECT_EQ(app_time::ChromeAppActivityState::kInactive,
GetChromeAppActivityState());
}
// TODO(yilkal): Write test to check that going to a URL in the current tab of
// the first browser will result in chrome being active or active allowlisted.
+
+} // namespace ash
diff --git a/chrome/browser/ash/child_accounts/time_limits/web_time_limit_enforcer_browsertest.cc b/chrome/browser/ash/child_accounts/time_limits/web_time_limit_enforcer_browsertest.cc
index 3465ecb..05ccf30 100644
--- a/chrome/browser/ash/child_accounts/time_limits/web_time_limit_enforcer_browsertest.cc
+++ b/chrome/browser/ash/child_accounts/time_limits/web_time_limit_enforcer_browsertest.cc
@@ -42,6 +42,7 @@
#include "ui/base/window_open_disposition.h"
#include "url/gurl.h"
+namespace ash {
namespace {
constexpr char kExampleHost[] = "www.example.com";
@@ -84,6 +85,7 @@
run_loop_.Quit();
}
}
+
} // namespace
class WebTimeLimitEnforcerThrottleTest : public MixinBasedInProcessBrowserTest {
@@ -93,9 +95,9 @@
void SetUpOnMainThread() override;
bool IsErrorPageBeingShownInWebContents(content::WebContents* tab);
void AllowlistUrlRegx(const std::string& host);
- void AllowlistApp(const ash::app_time::AppId& app_id);
+ void AllowlistApp(const app_time::AppId& app_id);
void BlockWeb();
- ash::app_time::WebTimeLimitEnforcer* GetWebTimeLimitEnforcer();
+ app_time::WebTimeLimitEnforcer* GetWebTimeLimitEnforcer();
content::WebContents* InstallAndLaunchWebApp(const GURL& url,
bool allowlisted_app);
@@ -104,7 +106,7 @@
base::test::ScopedFeatureList scoped_feature_list_;
- ash::app_time::AppTimeLimitsAllowlistPolicyBuilder builder_;
+ app_time::AppTimeLimitsAllowlistPolicyBuilder builder_;
chromeos::LoggedInUserMixin logged_in_user_mixin_{
&mixin_host_, chromeos::LoggedInUserMixin::LogInType::kChild,
@@ -154,7 +156,7 @@
}
void WebTimeLimitEnforcerThrottleTest::AllowlistApp(
- const ash::app_time::AppId& app_id) {
+ const app_time::AppId& app_id) {
builder_.AppendToAllowlistAppList(app_id);
UpdatePolicy();
}
@@ -164,14 +166,13 @@
base::TimeDelta::FromHours(1));
}
-ash::app_time::WebTimeLimitEnforcer*
+app_time::WebTimeLimitEnforcer*
WebTimeLimitEnforcerThrottleTest::GetWebTimeLimitEnforcer() {
content::WebContents* web_contents =
browser()->tab_strip_model()->GetActiveWebContents();
content::BrowserContext* browser_context = web_contents->GetBrowserContext();
- ash::ChildUserService::TestApi child_user_service =
- ash::ChildUserService::TestApi(
- ash::ChildUserServiceFactory::GetForBrowserContext(browser_context));
+ ChildUserService::TestApi child_user_service = ChildUserService::TestApi(
+ ChildUserServiceFactory::GetForBrowserContext(browser_context));
return child_user_service.web_time_enforcer();
}
@@ -188,7 +189,7 @@
std::move(web_app_info));
if (allowlisted_app)
- AllowlistApp(ash::app_time::AppId(apps::mojom::AppType::kWeb, app_id));
+ AllowlistApp(app_time::AppId(apps::mojom::AppType::kWeb, app_id));
base::RunLoop().RunUntilIdle();
// Add a tab to |browser()| and return the newly added WebContents.
@@ -211,8 +212,8 @@
const user_manager::UserManager* const user_manager =
user_manager::UserManager::Get();
- Profile* profile = ash::ProfileHelper::Get()->GetProfileByUser(
- user_manager->GetActiveUser());
+ auto* profile =
+ ProfileHelper::Get()->GetProfileByUser(user_manager->GetActiveUser());
logged_in_user_mixin_.GetUserPolicyTestHelper()->RefreshPolicyAndWait(
profile);
@@ -417,7 +418,7 @@
ui_test_utils::NavigateToURL(¶ms);
auto* web_contents = params.navigated_or_inserted_contents;
auto* navigation_observer =
- ash::app_time::WebTimeNavigationObserver::FromWebContents(web_contents);
+ app_time::WebTimeNavigationObserver::FromWebContents(web_contents);
std::u16string title = web_contents->GetTitle();
EXPECT_EQ(title, navigation_observer->previous_title());
@@ -456,3 +457,5 @@
// TODO(yilkal): Add AllowlistedSchemeNotBlocked test for chrome://settings
// TODO(yilkal): Add test for blocked web contents without browser window.
+
+} // namespace ash
diff --git a/chrome/browser/ash/child_accounts/time_limits/web_time_limit_error_page/web_time_limit_error_page.cc b/chrome/browser/ash/child_accounts/time_limits/web_time_limit_error_page/web_time_limit_error_page.cc
index 70902df..84be70c 100644
--- a/chrome/browser/ash/child_accounts/time_limits/web_time_limit_error_page/web_time_limit_error_page.cc
+++ b/chrome/browser/ash/child_accounts/time_limits/web_time_limit_error_page/web_time_limit_error_page.cc
@@ -20,6 +20,7 @@
#include "ui/base/webui/jstemplate_builder.h"
#include "ui/base/webui/web_ui_util.h"
+namespace ash {
namespace {
std::u16string GetTimeLimitMessage(base::TimeDelta time_limit) {
@@ -94,3 +95,5 @@
return GetWebTimeLimitErrorPage(block_header, block_message, time_limit,
app_locale, base::UTF8ToUTF16(app_name));
}
+
+} // namespace ash
diff --git a/chrome/browser/ash/child_accounts/time_limits/web_time_limit_error_page/web_time_limit_error_page.h b/chrome/browser/ash/child_accounts/time_limits/web_time_limit_error_page/web_time_limit_error_page.h
index 7ef990aa..9f77a92e 100644
--- a/chrome/browser/ash/child_accounts/time_limits/web_time_limit_error_page/web_time_limit_error_page.h
+++ b/chrome/browser/ash/child_accounts/time_limits/web_time_limit_error_page/web_time_limit_error_page.h
@@ -6,13 +6,14 @@
#define CHROME_BROWSER_ASH_CHILD_ACCOUNTS_TIME_LIMITS_WEB_TIME_LIMIT_ERROR_PAGE_WEB_TIME_LIMIT_ERROR_PAGE_H_
#include <string>
+
#include "third_party/abseil-cpp/absl/types/optional.h"
namespace base {
-
class TimeDelta;
+}
-} // namespace base
+namespace ash {
// Generates the appropriate time limit error page for Chrome.
// |domain| is the domain of the website that is being paused.
@@ -32,4 +33,6 @@
const std::string& app_locale,
const std::string& app_name);
+} // namespace ash
+
#endif // CHROME_BROWSER_ASH_CHILD_ACCOUNTS_TIME_LIMITS_WEB_TIME_LIMIT_ERROR_PAGE_WEB_TIME_LIMIT_ERROR_PAGE_H_
diff --git a/chrome/browser/prefs/browser_prefs.cc b/chrome/browser/prefs/browser_prefs.cc
index 0ea8b6ca..10bcdf6 100644
--- a/chrome/browser/prefs/browser_prefs.cc
+++ b/chrome/browser/prefs/browser_prefs.cc
@@ -1278,7 +1278,7 @@
ash::quick_unlock::RegisterProfilePrefs(registry);
ash::RegisterSamlProfilePrefs(registry);
ash::ScreenTimeController::RegisterProfilePrefs(registry);
- SecondaryAccountConsentLogger::RegisterPrefs(registry);
+ ash::SecondaryAccountConsentLogger::RegisterPrefs(registry);
ash::EduCoexistenceConsentInvalidationController::RegisterProfilePrefs(
registry);
ash::SigninErrorNotifier::RegisterPrefs(registry);