<commit_before>// Copyright (c) 2006-2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "views/focus/focus_manager.h"

#include "views/view.h"
#include "views/widget/widget_win.h"

namespace views {

void FocusManager::ClearNativeFocus() {
  // Keep the top root window focused so we get keyboard events.
  ::SetFocus(widget_->GetNativeView());
}

void FocusManager::FocusNativeView(gfx::NativeView native_view) {
  // Only reset focus if hwnd is not already focused.
  if (native_view && ::GetFocus() != native_view)
    ::SetFocus(native_view);
}

// static
FocusManager* FocusManager::GetFocusManagerForNativeView(
    gfx::NativeView native_view) {
  WidgetWin* widget = WidgetWin::GetRootWidget(native_view);<commit_msg>Committing on behalf of dtseng.<commit_after>// Copyright (c) 2006-2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "views/focus/focus_manager.h"

#include "views/view.h"
#include "views/widget/widget_win.h"

namespace views {

void FocusManager::ClearNativeFocus() {
  // Keep the top root window focused so we get keyboard events.
  ::SetFocus(widget_->GetNativeView());

  // We need to let assistive technologies know which child view got focus so
  // they can obtain the proper accessibility object for that child view.
  if (focused_view_) {
    ::NotifyWinEvent(EVENT_OBJECT_FOCUS, widget_->GetNativeView(), OBJID_CLIENT,
                     static_cast<LONG>(focused_view_->GetID()));
  }
}

void FocusManager::FocusNativeView(gfx::NativeView native_view) {
  // Only reset focus if hwnd is not already focused.
  if (native_view && ::GetFocus() != native_view)
    ::SetFocus(native_view);
}

// static
FocusManager* FocusManager::GetFocusManagerForNativeView(
    gfx::NativeView native_view) {
  WidgetWin* widget = WidgetWin::GetRootWidget(native_view);
{'fraction_non_alphanumeric': 0.10912698412698413, 'fraction_numerical': 0.007936507936507936, 'mean_word_length': 4.556473829201102, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5195214', 'n_tokens_mistral': 607, 'n_tokens_neox': 592, 'n_words': 185}