<commit_before>// Copyright (c) 2011 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/gtk/about_chrome_dialog.h"

#include <gtk/gtk.h>

#include <string>
#include <vector>

#include "base/utf_string_conversions.h"
#include "chrome/browser/google/google_util.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/gtk/gtk_chrome_link_button.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_version_info.h"
#include "chrome/common/url_constants.h"
#include "grit/chromium_strings.h"
#include "grit/generated_resources.h"
#include "grit/locale_settings.h"
#include "grit/theme_resources.h"
#include "ui/base/gtk/gtk_hig_constants.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/image/cairo_cached_surface.h"
#include "ui/gfx/image/image.h"
#include "webkit/glue/webkit_glue.h"

namespace {

// Left or right margin.
const int kPanelHorizMargin = 13;

// Top or bottom margin.
const int kPanelVertMargin = 20;

// Extra spacing between product name and version number.
const int kExtraLineSpacing = 5;

// These are used as placeholder text around the links in the text in the about
// dialog.
const char* kBeginLinkChr = "BEGIN_LINK_CHR";
const char* kBeginLinkOss = "BEGIN_LINK_OSS";
// We don't actually use this one.
// const char* kEndLinkChr = "END_LINK_CHR";
const char* kEndLinkOss = "END_LINK_OSS";
const char* kBeginLink = "BEGIN_LINK";
const char* kEndLink = "END_LINK";

void OnResponse(GtkWidget* dialog, int response_id) {
  // We're done.
  gtk_widget_destroy(dialog);
}

GtkWidget* MakeMarkupLabel(const char* format, const std::string& str) {
  GtkWidget* label = gtk_label_new(NULL);
  char* markup = g_markup_printf_escaped(format, str.c_str());
  gtk_label_set_markup(GTK_LABEL(label), markup);
  g_free(markup);

  // Left align it.
  gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);

  return label;
}

void OnLinkButtonClick(GtkWidget* button, const char* url) {
  BrowserList::GetLastActive()->OpenURL(OpenURLParams(
      GURL(url), content::Referrer(), NEW_WINDOW, content::PAGE_TRANSITION_LINK,
      false));
}

const char* GetChromiumUrl() {
  CR_DEFINE_STATIC_LOCAL(GURL, url, (google_util::AppendGoogleLocaleParam(
      GURL(chrome::kChromiumProjectURL))));
  return url.spec().c_str();
}

gboolean OnEventBoxExpose(GtkWidget* event_box,
                          GdkEventExpose* expose,
                          gboolean user_data) {
  cairo_t* cr = gdk_cairo_create(GDK_DRAWABLE(event_box->window));
  gdk_cairo_rectangle(cr, &expose->area);
  cairo_clip(cr);

  ResourceBundle& rb = ResourceBundle::GetSharedInstance();
  gfx::CairoCachedSurface* background =
      rb.GetNativeImageNamed(IDR_ABOUT_BACKGROUND).ToCairo();
  background->SetSource(cr, event_box, 0, 0);

  cairo_pattern_set_extend(cairo_get_source(cr), CAIRO_EXTEND_REPEAT);
  gdk_cairo_rectangle(cr, &expose->area);
  cairo_fill(cr);
  cairo_destroy(cr);<commit_msg>GTK: Use the correct IDR constant to fix the about box.<commit_after>// Copyright (c) 2011 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/gtk/about_chrome_dialog.h"

#include <gtk/gtk.h>

#include <string>
#include <vector>

#include "base/utf_string_conversions.h"
#include "chrome/browser/google/google_util.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/gtk/gtk_chrome_link_button.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_version_info.h"
#include "chrome/common/url_constants.h"
#include "grit/chromium_strings.h"
#include "grit/generated_resources.h"
#include "grit/locale_settings.h"
#include "grit/theme_resources.h"
#include "ui/base/gtk/gtk_hig_constants.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/image/cairo_cached_surface.h"
#include "ui/gfx/image/image.h"
#include "webkit/glue/webkit_glue.h"

namespace {

// Left or right margin.
const int kPanelHorizMargin = 13;

// Top or bottom margin.
const int kPanelVertMargin = 20;

// Extra spacing between product name and version number.
const int kExtraLineSpacing = 5;

// These are used as placeholder text around the links in the text in the about
// dialog.
const char* kBeginLinkChr = "BEGIN_LINK_CHR";
const char* kBeginLinkOss = "BEGIN_LINK_OSS";
// We don't actually use this one.
// const char* kEndLinkChr = "END_LINK_CHR";
const char* kEndLinkOss = "END_LINK_OSS";
const char* kBeginLink = "BEGIN_LINK";
const char* kEndLink = "END_LINK";

void OnResponse(GtkWidget* dialog, int response_id) {
  // We're done.
  gtk_widget_destroy(dialog);
}

GtkWidget* MakeMarkupLabel(const char* format, const std::string& str) {
  GtkWidget* label = gtk_label_new(NULL);
  char* markup = g_markup_printf_escaped(format, str.c_str());
  gtk_label_set_markup(GTK_LABEL(label), markup);
  g_free(markup);

  // Left align it.
  gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);

  return label;
}

void OnLinkButtonClick(GtkWidget* button, const char* url) {
  BrowserList::GetLastActive()->OpenURL(OpenURLParams(
      GURL(url), content::Referrer(), NEW_WINDOW, content::PAGE_TRANSITION_LINK,
      false));
}

const char* GetChromiumUrl() {
  CR_DEFINE_STATIC_LOCAL(GURL, url, (google_util::AppendGoogleLocaleParam(
      GURL(chrome::kChromiumProjectURL))));
  return url.spec().c_str();
}

gboolean OnEventBoxExpose(GtkWidget* event_box,
                          GdkEventExpose* expose,
                          gboolean user_data) {
  cairo_t* cr = gdk_cairo_create(GDK_DRAWABLE(event_box->window));
  gdk_cairo_rectangle(cr, &expose->area);
  cairo_clip(cr);

  ResourceBundle& rb = ResourceBundle::GetSharedInstance();
  gfx::CairoCachedSurface* background =
      rb.GetNativeImageNamed(IDR_ABOUT_BACKGROUND_COLOR).ToCairo();
  background->SetSource(cr, event_box, 0, 0);

  cairo_pattern_set_extend(cairo_get_source(cr), CAIRO_EXTEND_REPEAT);
  gdk_cairo_rectangle(cr, &expose->area);
  cairo_fill(cr);
  cairo_destroy(cr);
{'fraction_non_alphanumeric': 0.12385466034755134, 'fraction_numerical': 0.006003159557661927, 'mean_word_length': 5.064176245210728, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 19, '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': '6429353', 'n_tokens_mistral': 2336, 'n_tokens_neox': 2249, 'n_words': 471}