Skip to content

Commit

Permalink
Fix some -Wshadow instances: chrome/browser/ui/
Browse files Browse the repository at this point in the history
Bug: 1344231
Change-Id: I8d4a310b57ab12fda42aa439f5ed0d8708ae7924
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3908391
Commit-Queue: Peter Kasting <pkasting@chromium.org>
Reviewed-by: Elly Fong-Jones <ellyjones@chromium.org>
Auto-Submit: Peter Kasting <pkasting@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1053633}
  • Loading branch information
pkasting authored and Chromium LUCI CQ committed Sep 30, 2022
1 parent 3adcff6 commit ab42a2c
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 46 deletions.
7 changes: 2 additions & 5 deletions chrome/browser/ui/app_list/arc/arc_app_launcher.cc
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,12 @@ bool ArcAppLauncher::MaybeLaunchApp(const std::string& app_id,
return false;
}

auto readiness = apps::Readiness::kUnknown;
proxy->AppRegistryCache().ForOneApp(
app_id, [&readiness](const apps::AppUpdate& update) {
readiness = update.Readiness();
});

if (readiness != apps::Readiness::kReady)
return false;
} else if (readiness != apps::Readiness::kReady) {
}
if (readiness != apps::Readiness::kReady) {
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -445,22 +445,23 @@ void AppLaunchEventLogger::LogClicksEachHour(
}

void AppLaunchEventLogger::Log(AppLaunchEvent app_launch_event) {
auto app = app_features_map_.find(app_launch_event.app_id());
if (app == app_features_map_.end()) {
auto app_iter = app_features_map_.find(app_launch_event.app_id());
if (app_iter == app_features_map_.end()) {
RecordAppTypeClicked(AppLaunchEvent_AppType_OTHER);
return;
}
RecordAppTypeClicked(app->second.app_type());
const AppLaunchFeatures& features = app_iter->second;
RecordAppTypeClicked(features.app_type());
ukm::SourceId launch_source_id =
GetSourceId(app->second.app_type(), app_launch_event.app_id(),
app->second.arc_package_name(), app->second.pwa_url());
GetSourceId(features.app_type(), app_launch_event.app_id(),
features.arc_package_name(), features.pwa_url());

base::Time now(base::Time::Now());
const base::TimeDelta duration = now - start_time_;
all_clicks_last_hour_->Log(duration);
all_clicks_last_24_hours_->Log(duration);

if (app->second.is_policy_compliant() &&
if (features.is_policy_compliant() &&
launch_source_id != ukm::kInvalidSourceId) {
ukm::builders::AppListAppLaunch app_launch(launch_source_id);
if (app_launch_event.launched_from() ==
Expand All @@ -469,7 +470,7 @@ void AppLaunchEventLogger::Log(AppLaunchEvent app_launch_event) {
AppLaunchEvent_LaunchedFrom_SEARCH_BOX) {
app_launch.SetPositionIndex(app_launch_event.index());
}
app_launch.SetAppType(app->second.app_type())
app_launch.SetAppType(features.app_type())
.SetLaunchedFrom(app_launch_event.launched_from())
.SetDayOfWeek(DayOfWeek(now))
.SetHourOfDay(HourOfDay(now))
Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/ui/ash/arc_open_url_delegate_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -373,8 +373,8 @@ void ArcOpenUrlDelegateImpl::OpenWebAppFromArc(const GURL& url) {
if (!arc_tracker)
return;

for (const auto& app_id : prefs->GetAppsForPackage(package_name.value()))
arc_tracker->CloseWindows(app_id);
for (const auto& id : prefs->GetAppsForPackage(package_name.value()))
arc_tracker->CloseWindows(id);
}

void ArcOpenUrlDelegateImpl::OpenArcCustomTab(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ class NetworkStateNotifierTest : public BrowserWithTestWindowTest {

protected:
void SetupESimNetwork() {
const char kCellularEsimServicePath[] = "/service/cellular_esim1";
const char kTestEuiccPath[] = "euicc_path";
const char kTestEidName[] = "eid";
const char kTestIccid[] = "iccid";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,8 @@ void AppServiceInstanceRegistryHelper::OnWindowVisibilityChanged(
return;
}

apps::InstanceState state = CalculateVisibilityState(window, visible);
OnInstances(app_constants::kChromeAppId, window, std::string(), state);
OnInstances(app_constants::kChromeAppId, window, std::string(),
CalculateVisibilityState(window, visible));

if (!base::Contains(browser_window_to_tab_windows_, window))
return;
Expand All @@ -283,8 +283,8 @@ void AppServiceInstanceRegistryHelper::OnWindowVisibilityChanged(
const std::string app_id = GetAppId(it);
if (app_id.empty())
continue;
apps::InstanceState state = CalculateVisibilityState(it, visible);
OnInstances(app_id, it, std::string(), state);
OnInstances(app_id, it, std::string(),
CalculateVisibilityState(it, visible));
}
}

Expand Down Expand Up @@ -317,8 +317,8 @@ void AppServiceInstanceRegistryHelper::SetWindowActivated(
return;
}

apps::InstanceState state = CalculateActivatedState(window, active);
OnInstances(app_constants::kChromeAppId, window, std::string(), state);
OnInstances(app_constants::kChromeAppId, window, std::string(),
CalculateActivatedState(window, active));

if (!base::Contains(browser_window_to_tab_windows_, window))
return;
Expand All @@ -335,7 +335,7 @@ void AppServiceInstanceRegistryHelper::SetWindowActivated(
if (!contents)
return;

apps::InstanceState state = static_cast<apps::InstanceState>(
constexpr auto kState = static_cast<apps::InstanceState>(
apps::InstanceState::kStarted | apps::InstanceState::kRunning |
apps::InstanceState::kActive | apps::InstanceState::kVisible);
auto* contents_window = GetWindow(contents);
Expand All @@ -351,7 +351,7 @@ void AppServiceInstanceRegistryHelper::SetWindowActivated(
// browser window.
UpdateTabWindow(app_id, contents_window);

OnInstances(app_id, contents_window, std::string(), state);
OnInstances(app_id, contents_window, std::string(), kState);
return;
}

Expand All @@ -361,8 +361,7 @@ void AppServiceInstanceRegistryHelper::SetWindowActivated(
const std::string app_id = GetAppId(it);
if (app_id.empty())
continue;
apps::InstanceState state = CalculateActivatedState(it, active);
OnInstances(app_id, it, std::string(), state);
OnInstances(app_id, it, std::string(), CalculateActivatedState(it, active));
}
}

Expand Down
10 changes: 5 additions & 5 deletions chrome/browser/ui/views/tabs/tab_drag_controller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2059,21 +2059,21 @@ void TabDragController::MaximizeAttachedWindow() {

void TabDragController::BringWindowUnderPointToFront(
const gfx::Point& point_in_screen) {
gfx::NativeWindow window;
if (GetLocalProcessWindow(point_in_screen, true, &window) ==
gfx::NativeWindow native_window;
if (GetLocalProcessWindow(point_in_screen, true, &native_window) ==
Liveness::DELETED) {
return;
}

// Only bring browser windows to front - only windows with a
// TabDragContext can be tab drag targets.
if (!CanAttachTo(window))
if (!CanAttachTo(native_window))
return;

if (window &&
if (native_window &&
!base::FeatureList::IsEnabled(views::features::kWidgetLayering)) {
views::Widget* widget_window =
views::Widget::GetWidgetForNativeWindow(window);
views::Widget::GetWidgetForNativeWindow(native_window);
if (!widget_window)
return;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,18 +78,19 @@ base::Value BuildTracingModel(
&common_model.system_model().memory_events(),
arc::ArcValueEvent::Type::kWakenessfullMode);
for (const auto& wakefulness_mode_event : wakefulness_mode_events) {
const int64_t timestamp =
const int64_t wakefulness_mode_timestamp =
(wakefulness_mode_event.first - base::TimeTicks()).InMicroseconds();
wakenessfull_mode.MaybeAdd(timestamp,
wakenessfull_mode.MaybeAdd(wakefulness_mode_timestamp,
static_cast<int>(wakefulness_mode_event.second));
}
arc::ArcValueEventTrimmer throttling(
&common_model.system_model().memory_events(),
arc::ArcValueEvent::Type::kThrottlingMode);
for (const auto& throttling_event : throttling_events) {
const int64_t timestamp =
const int64_t throttling_timestamp =
(throttling_event.first - base::TimeTicks()).InMicroseconds();
throttling.MaybeAdd(timestamp, static_cast<int>(throttling_event.second));
throttling.MaybeAdd(throttling_timestamp,
static_cast<int>(throttling_event.second));
}

// Flush automatically normalizes the model.
Expand Down
3 changes: 1 addition & 2 deletions chrome/browser/ui/webui/chromeos/login/l10n_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,7 @@ base::Value::List GetLanguageList(
std::set<std::string> language_codes;
// Collect the language codes from the supported input methods.
for (const auto& descriptor : descriptors) {
const std::vector<std::string>& languages = descriptor.language_codes();
for (const auto& language : languages)
for (const auto& language : descriptor.language_codes())
language_codes.insert(language);
}

Expand Down
23 changes: 13 additions & 10 deletions chrome/browser/ui/window_sizer/window_sizer_chromeos_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -418,8 +418,9 @@ TEST_F(WindowSizerChromeOSTest, PlaceNewWindows) {

// Make sure that popups do not get changed.
{
Browser::CreateParams params_popup(Browser::TYPE_POPUP, &profile_, true);
auto new_popup = CreateWindowlessBrowser(params_popup);
Browser::CreateParams params_new_popup(Browser::TYPE_POPUP, &profile_,
true);
auto new_popup = CreateWindowlessBrowser(params_new_popup);
gfx::Rect window_bounds;
GetWindowBounds(new_popup.get(), gfx::Rect(), display_id,
gfx::Rect(50, 100, 300, 150), bottom_s1600x1200, PERSISTED,
Expand Down Expand Up @@ -757,14 +758,16 @@ TEST_F(WindowSizerChromeOSTest, DefaultStateBecomesMaximized) {
TEST_F(WindowSizerChromeOSTest, DefaultBoundsInTargetDisplay) {
UpdateDisplay("500x500,600x600");

// By default windows are placed on the primary display.
aura::Window* first_root = ash::Shell::GetAllRootWindows()[0];
EXPECT_EQ(first_root, ash::Shell::GetRootWindowForNewWindows());
gfx::Rect bounds;
ui::WindowShowState show_state;
WindowSizer::GetBrowserWindowBoundsAndShowState(gfx::Rect(), nullptr, &bounds,
&show_state);
EXPECT_TRUE(first_root->GetBoundsInScreen().Contains(bounds));
{
// By default windows are placed on the primary display.
aura::Window* first_root = ash::Shell::GetAllRootWindows()[0];
EXPECT_EQ(first_root, ash::Shell::GetRootWindowForNewWindows());
gfx::Rect bounds;
ui::WindowShowState show_state;
WindowSizer::GetBrowserWindowBoundsAndShowState(gfx::Rect(), nullptr,
&bounds, &show_state);
EXPECT_TRUE(first_root->GetBoundsInScreen().Contains(bounds));
}

{
// When the second display is active new windows are placed there.
Expand Down

0 comments on commit ab42a2c

Please sign in to comment.