<commit_before>// Copyright (c) 2013 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 "chrome/browser/ui/validation_message_bubble.h"

#include "chrome/browser/ui/views/validation_message_bubble_delegate.h"
#include "ui/views/widget/widget.h"

namespace {

// A ValidationMessageBubble implementation for Views.
class ValidationMessageBubbleImpl
    : public chrome::ValidationMessageBubble,
      public ValidationMessageBubbleDelegate::Observer {
 public:
  ValidationMessageBubbleImpl(const gfx::Rect& anchor_in_screen,
                              const string16& main_text,
                              const string16& sub_text);

  virtual ~ValidationMessageBubbleImpl() {
    if (delegate_ != NULL)
      delegate_->Hide();
  }

  // ValidationMessageBubbleDelegate::Observer override:
  virtual void WindowClosing() OVERRIDE {
    delegate_ = NULL;
  }

 private:
  ValidationMessageBubbleDelegate* delegate_;

  DISALLOW_COPY_AND_ASSIGN(ValidationMessageBubbleImpl);
};

ValidationMessageBubbleImpl::ValidationMessageBubbleImpl(
    const gfx::Rect& anchor_in_screen,
    const string16& main_text,
    const string16& sub_text) {
  delegate_ = new ValidationMessageBubbleDelegate(
      anchor_in_screen, main_text, sub_text, this);
  views::BubbleDelegateView::CreateBubble(delegate_);
  delegate_->GetWidget()->Show();
}

}  // namespace

namespace chrome {

scoped_ptr<ValidationMessageBubble> ValidationMessageBubble::CreateAndShow(
    content::RenderWidgetHost*,
    const gfx::Rect& anchor_in_screen,
    const string16& main_text,
    const string16& sub_text) {
  scoped_ptr<ValidationMessageBubble> bubble(
      new ValidationMessageBubbleImpl(anchor_in_screen, main_text, sub_text));
  return bubble.Pass();
}

}  // namespace chrome<commit_msg>Views: Form validatation message bubble is closed immediately after opening.<commit_after>// Copyright (c) 2013 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 "chrome/browser/ui/validation_message_bubble.h"

#include "chrome/browser/ui/views/validation_message_bubble_delegate.h"
#include "ui/views/widget/widget.h"

namespace {

// A ValidationMessageBubble implementation for Views.
class ValidationMessageBubbleImpl
    : public chrome::ValidationMessageBubble,
      public ValidationMessageBubbleDelegate::Observer {
 public:
  ValidationMessageBubbleImpl(const gfx::Rect& anchor_in_screen,
                              const string16& main_text,
                              const string16& sub_text);

  virtual ~ValidationMessageBubbleImpl() {
    if (delegate_ != NULL)
      delegate_->Hide();
  }

  // ValidationMessageBubbleDelegate::Observer override:
  virtual void WindowClosing() OVERRIDE {
    delegate_ = NULL;
  }

 private:
  ValidationMessageBubbleDelegate* delegate_;

  DISALLOW_COPY_AND_ASSIGN(ValidationMessageBubbleImpl);
};

ValidationMessageBubbleImpl::ValidationMessageBubbleImpl(
    const gfx::Rect& anchor_in_screen,
    const string16& main_text,
    const string16& sub_text) {
  delegate_ = new ValidationMessageBubbleDelegate(
      anchor_in_screen, main_text, sub_text, this);
  views::BubbleDelegateView::CreateBubble(delegate_);
  delegate_->GetWidget()->ShowInactive();
}

}  // namespace

namespace chrome {

scoped_ptr<ValidationMessageBubble> ValidationMessageBubble::CreateAndShow(
    content::RenderWidgetHost*,
    const gfx::Rect& anchor_in_screen,
    const string16& main_text,
    const string16& sub_text) {
  scoped_ptr<ValidationMessageBubble> bubble(
      new ValidationMessageBubbleImpl(anchor_in_screen, main_text, sub_text));
  return bubble.Pass();
}

}  // namespace chrome
{'fraction_non_alphanumeric': 0.08784313725490196, 'fraction_numerical': 0.008366013071895426, 'mean_word_length': 4.457917261055635, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 13, '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': '3312073', 'n_tokens_mistral': 1129, 'n_tokens_neox': 1067, 'n_words': 246}