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

#include <gtk/gtk.h>

#include "base/logging.h"
#include "base/string_util.h"
#include "chrome/browser/tab_contents/web_contents.h"
#include "chrome/browser/tab_contents/web_contents_view.h"
#include "chrome/common/l10n_util.h"
#include "chrome/common/message_box_flags.h"
#include "grit/generated_resources.h"

namespace {

void OnDialogResponse(GtkDialog* dialog, gint response_id,
                      AppModalDialog* app_modal_dialog) {
  switch (response_id) {
    case GTK_RESPONSE_OK:
      // The first arg is the prompt text and the second is true if we want to
      // suppress additional popups from the page.
      app_modal_dialog->OnAccept(std::wstring(), false);
      break;

    case GTK_RESPONSE_CANCEL:
    case GTK_RESPONSE_DELETE_EVENT: // User hit the X on the dialog.
      app_modal_dialog->OnCancel();
      break;

    default:
      NOTREACHED();
  }
  gtk_widget_destroy(GTK_WIDGET(dialog));
  delete app_modal_dialog;
}

}  // namespace

AppModalDialog::~AppModalDialog() {
}

void AppModalDialog::CreateAndShowDialog() {
  GtkButtonsType buttons;
  GtkMessageType message_type;
  switch (dialog_flags_) {
    case MessageBox::kIsJavascriptAlert:
      buttons = GTK_BUTTONS_OK;
      message_type = GTK_MESSAGE_WARNING;
      break;

    case MessageBox::kIsJavascriptConfirm:
      if (is_before_unload_dialog_) {
        // onbeforeunload also uses a confirm prompt, it just has custom
        // buttons.  We add the buttons using gtk_dialog_add_button below.
        buttons = GTK_BUTTONS_NONE;
      } else {
        buttons = GTK_BUTTONS_OK_CANCEL;
      }
      message_type = GTK_MESSAGE_QUESTION;
      break;

    case MessageBox::kIsJavascriptPrompt:
      // We need to make a custom message box for javascript prompts. For now
      // just have an OK button and send back an empty string. Maybe we can
      // cram a GtkEntry into the content area of the message box via
      // gtk_dialog_get_content_area.
      // http://crbug.com/9623
      NOTIMPLEMENTED();
      buttons = GTK_BUTTONS_OK;
      message_type = GTK_MESSAGE_QUESTION;
      break;<commit_msg>Fix a gcc warning about uninitialized variables.<commit_after>// Copyright (c) 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 "chrome/browser/app_modal_dialog.h"

#include <gtk/gtk.h>

#include "base/logging.h"
#include "base/string_util.h"
#include "chrome/browser/tab_contents/web_contents.h"
#include "chrome/browser/tab_contents/web_contents_view.h"
#include "chrome/common/l10n_util.h"
#include "chrome/common/message_box_flags.h"
#include "grit/generated_resources.h"

namespace {

void OnDialogResponse(GtkDialog* dialog, gint response_id,
                      AppModalDialog* app_modal_dialog) {
  switch (response_id) {
    case GTK_RESPONSE_OK:
      // The first arg is the prompt text and the second is true if we want to
      // suppress additional popups from the page.
      app_modal_dialog->OnAccept(std::wstring(), false);
      break;

    case GTK_RESPONSE_CANCEL:
    case GTK_RESPONSE_DELETE_EVENT: // User hit the X on the dialog.
      app_modal_dialog->OnCancel();
      break;

    default:
      NOTREACHED();
  }
  gtk_widget_destroy(GTK_WIDGET(dialog));
  delete app_modal_dialog;
}

}  // namespace

AppModalDialog::~AppModalDialog() {
}

void AppModalDialog::CreateAndShowDialog() {
  GtkButtonsType buttons = GTK_BUTTONS_NONE;
  GtkMessageType message_type = GTK_MESSAGE_OTHER;
  switch (dialog_flags_) {
    case MessageBox::kIsJavascriptAlert:
      buttons = GTK_BUTTONS_OK;
      message_type = GTK_MESSAGE_WARNING;
      break;

    case MessageBox::kIsJavascriptConfirm:
      if (is_before_unload_dialog_) {
        // onbeforeunload also uses a confirm prompt, it just has custom
        // buttons.  We add the buttons using gtk_dialog_add_button below.
        buttons = GTK_BUTTONS_NONE;
      } else {
        buttons = GTK_BUTTONS_OK_CANCEL;
      }
      message_type = GTK_MESSAGE_QUESTION;
      break;

    case MessageBox::kIsJavascriptPrompt:
      // We need to make a custom message box for javascript prompts. For now
      // just have an OK button and send back an empty string. Maybe we can
      // cram a GtkEntry into the content area of the message box via
      // gtk_dialog_get_content_area.
      // http://crbug.com/9623
      NOTIMPLEMENTED();
      buttons = GTK_BUTTONS_OK;
      message_type = GTK_MESSAGE_QUESTION;
      break;
{'fraction_non_alphanumeric': 0.08389402859545837, 'fraction_numerical': 0.004205214465937763, 'mean_word_length': 3.2397504456327986, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, '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': '5201475', 'n_tokens_mistral': 1543, 'n_tokens_neox': 1509, 'n_words': 403}