<commit_before>// Copyright (c) 2010 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/dom_ui/flags_ui.h"

#include <string>

#include "app/l10n_util.h"
#include "app/resource_bundle.h"
#include "base/singleton.h"
#include "base/values.h"
#include "chrome/browser/about_flags.h"
#include "chrome/browser/browser_list.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/browser_thread.h"
#include "chrome/browser/dom_ui/chrome_url_data_manager.h"
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/profile.h"
#include "chrome/common/jstemplate_builder.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/url_constants.h"
#include "grit/browser_resources.h"
#include "grit/chromium_strings.h"
#include "grit/generated_resources.h"
#include "grit/theme_resources.h"

namespace {

///////////////////////////////////////////////////////////////////////////////
//
// FlagsUIHTMLSource
//
///////////////////////////////////////////////////////////////////////////////

class FlagsUIHTMLSource : public ChromeURLDataManager::DataSource {
 public:
  FlagsUIHTMLSource()
      : DataSource(chrome::kChromeUIFlagsHost, MessageLoop::current()) {}

  // Called when the network layer has requested a resource underneath
  // the path we registered.
  virtual void StartDataRequest(const std::string& path,
                                bool is_off_the_record,
                                int request_id);
  virtual std::string GetMimeType(const std::string&) const {
    return "text/html";
  }

 private:
  ~FlagsUIHTMLSource() {}

  DISALLOW_COPY_AND_ASSIGN(FlagsUIHTMLSource);
};

void FlagsUIHTMLSource::StartDataRequest(const std::string& path,
                                        bool is_off_the_record,
                                        int request_id) {
  // Strings used in the JsTemplate file.
  DictionaryValue localized_strings;
  localized_strings.SetString("flagsLongTitle",
      l10n_util::GetStringUTF16(IDS_FLAGS_LONG_TITLE));
  localized_strings.SetString("flagsTableTitle",
      l10n_util::GetStringUTF16(IDS_FLAGS_TABLE_TITLE));
  localized_strings.SetString("flagsNoExperimentsAvailable",
      l10n_util::GetStringUTF16(IDS_FLAGS_NO_EXPERIMENTS_AVAILABLE));
  localized_strings.SetString("flagsWarningHeader", l10n_util::GetStringUTF16(
      IDS_FLAGS_WARNING_HEADER));
  localized_strings.SetString("flagsBlurb", l10n_util::GetStringFUTF16(
      IDS_FLAGS_WARNING_TEXT,
      l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)));
  localized_strings.SetString("flagsRestartNotice", l10n_util::GetStringFUTF16(
      IDS_FLAGS_RESTART_NOTICE,<commit_msg>Fix DCHECK caused by passing a parameter to a string that doesn't have a placeholder.<commit_after>// Copyright (c) 2010 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/dom_ui/flags_ui.h"

#include <string>

#include "app/l10n_util.h"
#include "app/resource_bundle.h"
#include "base/singleton.h"
#include "base/values.h"
#include "chrome/browser/about_flags.h"
#include "chrome/browser/browser_list.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/browser_thread.h"
#include "chrome/browser/dom_ui/chrome_url_data_manager.h"
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/profile.h"
#include "chrome/common/jstemplate_builder.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/url_constants.h"
#include "grit/browser_resources.h"
#include "grit/chromium_strings.h"
#include "grit/generated_resources.h"
#include "grit/theme_resources.h"

namespace {

///////////////////////////////////////////////////////////////////////////////
//
// FlagsUIHTMLSource
//
///////////////////////////////////////////////////////////////////////////////

class FlagsUIHTMLSource : public ChromeURLDataManager::DataSource {
 public:
  FlagsUIHTMLSource()
      : DataSource(chrome::kChromeUIFlagsHost, MessageLoop::current()) {}

  // Called when the network layer has requested a resource underneath
  // the path we registered.
  virtual void StartDataRequest(const std::string& path,
                                bool is_off_the_record,
                                int request_id);
  virtual std::string GetMimeType(const std::string&) const {
    return "text/html";
  }

 private:
  ~FlagsUIHTMLSource() {}

  DISALLOW_COPY_AND_ASSIGN(FlagsUIHTMLSource);
};

void FlagsUIHTMLSource::StartDataRequest(const std::string& path,
                                        bool is_off_the_record,
                                        int request_id) {
  // Strings used in the JsTemplate file.
  DictionaryValue localized_strings;
  localized_strings.SetString("flagsLongTitle",
      l10n_util::GetStringUTF16(IDS_FLAGS_LONG_TITLE));
  localized_strings.SetString("flagsTableTitle",
      l10n_util::GetStringUTF16(IDS_FLAGS_TABLE_TITLE));
  localized_strings.SetString("flagsNoExperimentsAvailable",
      l10n_util::GetStringUTF16(IDS_FLAGS_NO_EXPERIMENTS_AVAILABLE));
  localized_strings.SetString("flagsWarningHeader", l10n_util::GetStringUTF16(
      IDS_FLAGS_WARNING_HEADER));
  localized_strings.SetString("flagsBlurb", l10n_util::GetStringUTF16(
      IDS_FLAGS_WARNING_TEXT));
  localized_strings.SetString("flagsRestartNotice", l10n_util::GetStringFUTF16(
      IDS_FLAGS_RESTART_NOTICE,
{'fraction_non_alphanumeric': 0.15527838033261027, 'fraction_numerical': 0.011569052783803326, 'mean_word_length': 3.2659984579799537, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3607798', 'n_tokens_mistral': 1689, 'n_tokens_neox': 1635, 'n_words': 300}