text:
from __future__ import absolute_import, division, print_function

import numbers
import cPickle

import numpy as np

import theano
import theano.tensor as tt
from theano.ifelse import ifelse
from theano.sandbox.rng_mrg import MRG_RandomStreams as RandomStreams

floatX = theano.config.floatX

def cast_floatX(n):
  return np.asarray(n, dtype=floatX)

class Model(object):

  def __init__(self, config):

    self._params = []                                             # shared variables for learned parameters
    self._sticky_hidden_states = []                               # shared variables which are reset before each epoch
    self._np_rng = np.random.RandomState(config.seed // 2 + 123)
    self._theano_rng = RandomStreams(config.seed // 2 + 321)      # generates random numbers directly on GPU
    self._init_scale = config.init_scale
    self._is_training = tt.iscalar('is_training')
    self._lr = theano.shared(cast_floatX(config.learning_rate), 'lr')

    input_data = tt.imatrix('input_data')     # (batch_size, num_steps)
    targets = tt.imatrix('targets')           # (batch_size, num_steps)
    noise_x = tt.matrix('noise_x')            # (batch_size, num_steps)

    # Embed input words and apply variational dropout (for each sample, the embedding of
    # a dropped word-type consists of all zeros at all occurrences of word-type in sample).
    embedding = self.make_param((config.vocab_size, config.hidden_size), 'uniform')
    inputs = embedding[input_data.T]          # (num_steps, batch_size, hidden_size)
    inputs = self.apply_dropout(inputs, tt.shape_padright(noise_x.T))

    rhn_updates = []
    for _ in range(config.num_layers):
      # y shape: (num_steps, batch_size, hidden_size)
      y, sticky_state_updates = self.RHNLayer(
        inputs,
        config.depth, config.batch_size, config.hidden_size,
        config.drop_i, config.drop_s,
        config.init_T_bias, config.init_other_bias,
        config.tied_noise)
      rhn_updates += sticky_state_updates
      inputs = y

    noise_o = self.get_dropout_noise((config.batch_size, config.hidden_size), config.drop_o)
    outputs = self.apply_dropout(y, tt.shape_padleft(noise_o))               # (num_steps, batch_size, hidden_size)

    # logits
    softmax_w = embedding.T if config.tied_embeddings else self.make_param((config.hidden_size, config.vocab_size), 'uniform')
    softmax_b = self.make_param((config.vocab_size,), config.init_other_bias)
    logits = tt.dot(outputs, softmax_w) + softmax_b                          # (num_steps, batch_size, vocab_size)

    # probabilities and prediction loss
    flat_logits = logits.reshape((config.batch_size * config.num_steps, config.vocab_size))
    flat_probs = tt.nnet.softmax(flat_logits)
    flat_targets = targets.T.flatten()                                       # (batch_size * num_steps,)
    xentropies = tt.nnet.categorical_crossentropy(flat_probs, flat_targets)  # (batch_size * num_steps,)
    pred_loss = xentropies.sum() / config.batch_size

    # weight decay
    l2_loss = 0.5 * tt.sum(tt.stack([tt.sum(p**2) for p in self._params]))

    loss = pred_loss + config.weight_decay * l2_loss
    grads = theano.grad(loss, self._params)

    # gradient clipping
    global_grad_norm = tt.sqrt(tt.sum(tt.stack([tt.sum(g**2) for g in grads])))
    clip_factor = ifelse(global_grad_norm < config.max_grad_norm,
      cast_floatX(1),
      tt.cast(config.max_grad_norm / global_grad_norm, floatX))

    param_updates = [(p, p - self._lr * clip_factor * g) for p, g in zip(self._params, grads)]

    self.train = theano.function(
      [input_data, targets, noise_x],
      loss,
      givens = {self._is_training: np.int32(1)},
      updates = rhn_updates + param_updates)

    self.evaluate = theano.function(
      [input_data, targets],
      loss,
      # Note that noise_x is unused in computation graph of this function since _is_training is false.
      givens = {self._is_training: np.int32(0), noise_x: tt.zeros((config.batch_size, config.num_steps))},
      updates = rhn_updates)

    self._num_params = np.sum([param.get_value().size for param in self._params])

    if config.load_model:
      self.load(config.load_model)

  @property
  def lr(self):
    return self._lr.get_value()

  @property
  def num_params(self):
    return self._num_params

  def make_param(self, shape, init_scheme):
    """Create Theano shared variables, which are used as trainable model parameters."""
    if isinstance(init_scheme, numbers.Number):
      init_value = np.full(shape, init_scheme, floatX)
    elif init_scheme == 'uniform':
      init_value = self._np_rng.uniform(low=-self._init_scale, high=self._init_scale, size=shape).astype(floatX)
    else:
      raise AssertionError('unsupported init_scheme')
    p = theano.shared(init_value)
    self._params.append(p)
    return p

  def apply_dropout(self, x, noise):
    return ifelse(self._is_training, noise * x, x)

  def get_dropout_noise(self, shape, dropout_p):
    keep_p = 1 - dropout_p
    noise = cast_floatX(1. / keep_p) * self._theano_rng.binomial(size=shape, p=keep_p, n=1, dtype=floatX)
    return noise

  def assign_lr(self, lr):
    self._lr.set_value(cast_floatX(lr))

  def reset_hidden_state(self):
    for sticky_hidden_state in self._sticky_hidden_states:
      sticky_hidden_state.set_value(np.zeros_like(sticky_hidden_state.get_value()))

  def save(self, save_path):
    with open(save_path, 'wb') as f:
      for p in self._params:
        cPickle.dump(p.get_value(), f, protocol=cPickle.HIGHEST_PROTOCOL)

  def load(self, load_path):
    with open(load_path, 'rb') as f:
      for p in self._params:
        p.set_value(cPickle.load(f))

  def linear(self, x, in_size, out_size, bias, bias_init=None):
    assert bias == (bias_init is not None)
    w = self.make_param((in_size, out_size), 'uniform')
    y = tt.dot(x, w)
    if bias:
      b = self.make_param((out_size,), bias_init)
      y += b
    return y

  def RHNLayer(self, inputs, depth, batch_size, hidden_size, drop_i, drop_s, init_T_bias, init_H_bias, tied_noise):
    """Variational Recurrent Highway Layer (Theano implementation).

    References:
      Zilly, J, Srivastava, R, Koutnik, J, Schmidhuber, J., "Recurrent Highway Networks", 2016
    Args:
      inputs: Theano variable, shape (num_steps, batch_size, hidden_size).
      depth: int, the number of RHN inner layers i.e. the number of micro-timesteps per timestep.
      drop_i: float, probability of dropout over inputs.
      drop_s: float, probability of dropout over recurrent hidden state.
      init_T_bias: a valid bias_init argument for linear(), initialization of bias of transform gate T.
      init_H_bias: a valid bias_init argument for linear(), initialization of bias of non-linearity H.
      tied_noise: boolean, whether to use the same dropout masks when calculating H and when calculating T.
    Returns:
      y: Theano variable, recurrent hidden states at each timestep. Shape (num_steps, batch_size, hidden_size).
      sticky_state_updates: a list of (shared variable, new shared variable value).
    """
    # We first compute the linear transformation of the inputs over all timesteps.
    # This is done outside of scan() in order to speed up computation.
    # The result is then fed into scan()'s step function, one timestep at a time.
    noise_i_for_H = self.get_dropout_noise((batch_size, hidden_size), drop_i)
    noise_i_for_T = self.get_dropout_noise((batch_size, hidden_size), drop_i) if not tied_noise else noise_i_for_H

    i_for_H = self.apply_dropout(inputs, noise_i_for_H)
    i_for_T = self.apply_dropout(inputs, noise_i_for_T)

    i_for_H = self.linear(i_for_H, in_size=hidden_size, out_size=hidden_size, bias=True, bias_init=init_H_bias)
    i_for_T = self.linear(i_for_T, in_size=hidden_size, out_size=hidden_size, bias=True, bias_init=init_T_bias)

    # Dropout noise for recurrent hidden state.
    noise_s = self.get_dropout_noise((batch_size, hidden_size), drop_s)
    if not tied_noise:
      noise_s = tt.stack(noise_s, self.get_dropout_noise((batch_size, hidden_size), drop_s))

    def step_fn(i_for_H_t, i_for_T_t, y_tm1, noise_s):
      """
      Args:
        Elements of sequences given to scan():
          i_for_H_t: linear trans. of inputs for calculating non-linearity H at timestep t. Shape (batch_size, hidden_size).
          i_for_T_t: linear trans. of inputs for calculating transform gate T at timestep t. Shape (batch_size, hidden_size).
        Result of previous step function invocation (equals the outputs_info given to scan() on first timestep):
          y_tm1: Shape (batch_size, hidden_size).
        Non-sequences given to scan() (these are the same at all timesteps):
          noise_s: (batch_size, hidden_size) or (2, batch_size, hidden_size), depending on value of tied_noise.
      """
      tanh, sigm = tt.tanh, tt.nnet.sigmoid
      noise_s_for_H = noise_s if tied_noise else noise_s[0]
      noise_s_for_T = noise_s if tied_noise else noise_s[1]

      s_lm1 = y_tm1
      for l in range(depth):
        s_lm1_for_H = self.apply_dropout(s_lm1, noise_s_for_H)
        s_lm1_for_T = self.apply_dropout(s_lm1, noise_s_for_T)
        if l == 0:
          # On the first micro-timestep of each timestep we already have bias
          # terms summed into i_for_H_t and into i_for_T_t.
          H = tanh(i_for_H_t + self.linear(s_lm1_for_H, in_size=hidden_size, out_size=hidden_size, bias=False))
          T = sigm(i_for_T_t + self.linear(s_lm1_for_T, in_size=hidden_size, out_size=hidden_size, bias=False))
        else:
          H = tanh(self.linear(s_lm1_for_H, in_size=hidden_size, out_size=hidden_size, bias=True, bias_init=init_H_bias))
          T = sigm(self.linear(s_lm1_for_T, in_size=hidden_size, out_size=hidden_size, bias=True, bias_init=init_T_bias))
        s_l = (H - s_lm1) * T + s_lm1
        s_lm1 = s_l

      y_t = s_l
      return y_t

    # The recurrent hidden state of the RHN is sticky (the last hidden state of one batch is carried over to the next batch,
    # to be used as an initial hidden state).  These states are kept in shared variables and are reset before every epoch.
    y_0 = theano.shared(np.zeros((batch_size, hidden_size), floatX))
    self._sticky_hidden_states.append(y_0)

    y, _ = theano.scan(step_fn,
      sequences = [i_for_H, i_for_T],
      outputs_info = [y_0],
      non_sequences = [noise_s])

    y_last = y[-1]
    sticky_state_updates = [(y_0, y_last)]

    return y, sticky_state_updates


text:
package com.com.exoplayer.player;

import android.content.Context;
import android.media.MediaCodec;
import android.os.Handler;
import android.widget.TextView;

import com.com.exoplayer.player.DemoPlayer.RendererBuilderCallback;
import com.google.android.exoplayer.MediaCodecAudioTrackRenderer;
import com.google.android.exoplayer.MediaCodecUtil.DecoderQueryException;
import com.google.android.exoplayer.MediaCodecVideoTrackRenderer;
import com.google.android.exoplayer.TrackRenderer;
import com.google.android.exoplayer.audio.AudioCapabilities;
import com.google.android.exoplayer.chunk.VideoFormatSelectorUtil;
import com.google.android.exoplayer.hls.HlsChunkSource;
import com.google.android.exoplayer.hls.HlsMasterPlaylist;
import com.google.android.exoplayer.hls.HlsPlaylist;
import com.google.android.exoplayer.hls.HlsPlaylistParser;
import com.google.android.exoplayer.hls.HlsSampleSource;
import com.google.android.exoplayer.metadata.Id3Parser;
import com.google.android.exoplayer.metadata.MetadataTrackRenderer;
import com.google.android.exoplayer.text.eia608.Eia608TrackRenderer;
import com.google.android.exoplayer.upstream.DataSource;
import com.google.android.exoplayer.upstream.DefaultBandwidthMeter;
import com.google.android.exoplayer.upstream.DefaultUriDataSource;
import com.google.android.exoplayer.util.ManifestFetcher;
import com.google.android.exoplayer.util.ManifestFetcher.ManifestCallback;

import java.io.IOException;
import java.util.Map;

public class HlsRendererBuilder implements DemoPlayer.RendererBuilder, ManifestCallback<HlsPlaylist> {

  private static final int REQUESTED_BUFFER_SIZE = 18 * 1024 * 1024;
  private static final long REQUESTED_BUFFER_DURATION_MS = 40000;

  private final Context context;
  private final String userAgent;
  private final String url;
  private final TextView debugTextView;
  private final AudioCapabilities audioCapabilities;

  private DemoPlayer player;
  private RendererBuilderCallback callback;

  public HlsRendererBuilder(Context context, String userAgent, String url, TextView debugTextView,
      AudioCapabilities audioCapabilities) {
    this.context = context;
    this.userAgent = userAgent;
    this.url = url;
    this.debugTextView = debugTextView;
    this.audioCapabilities = audioCapabilities;
  }

  @Override
  public void buildRenderers(DemoPlayer player, RendererBuilderCallback callback) {
    this.player = player;
    this.callback = callback;
    HlsPlaylistParser parser = new HlsPlaylistParser();
    ManifestFetcher<HlsPlaylist> playlistFetcher = new ManifestFetcher<HlsPlaylist>(url,
        new DefaultUriDataSource(context, userAgent), parser);
    playlistFetcher.singleLoad(player.getMainHandler().getLooper(), this);
  }

  @Override
  public void onSingleManifestError(IOException e) {
    callback.onRenderersError(e);
  }

  @Override
  public void onSingleManifest(HlsPlaylist manifest) {
    Handler mainHandler = player.getMainHandler();
    DefaultBandwidthMeter bandwidthMeter = new DefaultBandwidthMeter();

    int[] variantIndices = null;
    if (manifest instanceof HlsMasterPlaylist) {
      HlsMasterPlaylist masterPlaylist = (HlsMasterPlaylist) manifest;
      try {
        variantIndices = VideoFormatSelectorUtil.selectVideoFormatsForDefaultDisplay(
                context, masterPlaylist.variants, null, false);
      } catch (DecoderQueryException e) {
        callback.onRenderersError(e);
        return;
      }
    }

    DataSource dataSource = new DefaultUriDataSource(context, bandwidthMeter, userAgent);
    HlsChunkSource chunkSource = new HlsChunkSource(dataSource, url, manifest, bandwidthMeter,
        variantIndices, HlsChunkSource.ADAPTIVE_MODE_SPLICE, audioCapabilities);
    HlsSampleSource sampleSource = new HlsSampleSource(chunkSource, true, 3, REQUESTED_BUFFER_SIZE,
        REQUESTED_BUFFER_DURATION_MS, mainHandler, player, DemoPlayer.TYPE_VIDEO);
    MediaCodecVideoTrackRenderer videoRenderer = new MediaCodecVideoTrackRenderer(sampleSource,
        MediaCodec.VIDEO_SCALING_MODE_SCALE_TO_FIT, 5000, mainHandler, player, 50);
    MediaCodecAudioTrackRenderer audioRenderer = new MediaCodecAudioTrackRenderer(sampleSource);

    MetadataTrackRenderer<Map<String, Object>> id3Renderer =
        new MetadataTrackRenderer<Map<String, Object>>(sampleSource, new Id3Parser(),
            player.getId3MetadataRenderer(), mainHandler.getLooper());

    Eia608TrackRenderer closedCaptionRenderer = new Eia608TrackRenderer(sampleSource, player,
        mainHandler.getLooper());

    // Build the debug renderer.
    TrackRenderer debugRenderer = debugTextView != null
        ? new DebugTrackRenderer(debugTextView, player, videoRenderer) : null;

    TrackRenderer[] renderers = new TrackRenderer[DemoPlayer.RENDERER_COUNT];
    renderers[DemoPlayer.TYPE_VIDEO] = videoRenderer;
    renderers[DemoPlayer.TYPE_AUDIO] = audioRenderer;
    renderers[DemoPlayer.TYPE_TIMED_METADATA] = id3Renderer;
    renderers[DemoPlayer.TYPE_TEXT] = closedCaptionRenderer;
    renderers[DemoPlayer.TYPE_DEBUG] = debugRenderer;
    callback.onRenderers(null, null, renderers);
  }

}

redpajama_set_name: RedPajamaGithub


text:
categories:
    - Release
tags:
    - gh-pages

title: 1.95.0
---

{{page.title}} is live and ready for [download](https://github.com/MaibornWolff/codecharta/releases/tag/{{page.title}}). This version brings the following:

### Added 🚀

-   Focused gradient option for color metric. Only applies a gradient between the two set borders. [#2750](https://github.com/MaibornWolff/codecharta/pull/2750)

### Changed

-   Mark SCMLogParserV2 as stable and deprecate SCMLogParser for Git [2725](https://github.com/MaibornWolff/codecharta/pull/2725)
    -   Rename SCMLogParserV2 to GitLogParser
    -   Rename SCMLogParser to SVNLogParser and remove git parsing

### Fixed 🐞

-   Set initially correct attribute type of primary edge metric in attribute sidebar [#2731](https://github.com/MaibornWolff/codecharta/issues/2731)
-   Fix switching secondary metrics to median aggregation in attribute sidebar [#2630](https://github.com/MaibornWolff/codecharta/issues/2630)


text:
using Elastic.Clients.Elasticsearch.Fluent;
using Elastic.Clients.Elasticsearch.Serialization;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text.Json;
using System.Text.Json.Serialization;

#nullable restore
namespace Elastic.Clients.Elasticsearch.Core.Search;
public sealed partial class LaplaceSmoothingModel
{
	[JsonInclude]
	[JsonPropertyName("alpha")]
	public double Alpha { get; set; }

	public static implicit operator SmoothingModel(LaplaceSmoothingModel laplaceSmoothingModel) => Core.Search.SmoothingModel.Laplace(laplaceSmoothingModel);
}

public sealed partial class LaplaceSmoothingModelDescriptor : SerializableDescriptor<LaplaceSmoothingModelDescriptor>
{
	internal LaplaceSmoothingModelDescriptor(Action<LaplaceSmoothingModelDescriptor> configure) => configure.Invoke(this);
	public LaplaceSmoothingModelDescriptor() : base()
	{
	}

	private double AlphaValue { get; set; }

	public LaplaceSmoothingModelDescriptor Alpha(double alpha)
	{
		AlphaValue = alpha;
		return Self;
	}

	protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
	{
		writer.WriteStartObject();
		writer.WritePropertyName("alpha");
		writer.WriteNumberValue(AlphaValue);
		writer.WriteEndObject();
	}
}


text:
package chapter17;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import chapter15.MessagePanel;

public class ScrollBarDemo extends JFrame {
	/**
	 *
	 */
	private static final long serialVersionUID = 1L;
	// Create horizontal and vertical scroll bars
	private JScrollBar jscbHort = new JScrollBar(JScrollBar.HORIZONTAL);
	private JScrollBar jscbVert = new JScrollBar(JScrollBar.VERTICAL);

	// Create a MessagePanel
	private MessagePanel messagePanel = new MessagePanel("Welcome to Java");

	public static void main(String[] args) {
		ScrollBarDemo frame = new ScrollBarDemo();
		frame.setTitle("ScrollBarDemo");
		frame.setLocationRelativeTo(null); // Center the frame
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.pack();
		frame.setVisible(true);
	}

	public ScrollBarDemo() {
		// Add scroll bars and message panel to the frame
		setLayout(new BorderLayout());
		add(messagePanel, BorderLayout.CENTER);
		add(jscbVert, BorderLayout.EAST);
		add(jscbHort, BorderLayout.SOUTH);

		// Register listener for the scroll bars
		jscbHort.addAdjustmentListener(new AdjustmentListener() {
			public void adjustmentValueChanged(AdjustmentEvent e) {
				// getValue() and getMaximumValue() return int, but for better
				// precision, use double
				double value = jscbHort.getValue();
				double maximumValue = jscbHort.getMaximum();
				double newX = (value * messagePanel.getWidth() / maximumValue);
				messagePanel.setXCoordinate((int) newX);
			}
		});
		jscbVert.addAdjustmentListener(new AdjustmentListener() {
			public void adjustmentValueChanged(AdjustmentEvent e) {
				// getValue() and getMaximumValue() return int, but for better
				// precision, use double
				double value = jscbVert.getValue();
				double maximumValue = jscbVert.getMaximum();
				double newY = (value * messagePanel.getHeight() / maximumValue);
				messagePanel.setYCoordinate((int) newY);
			}
		});
	}
}


text:
/* jshint camelcase: false*/
/* global describe, beforeEach, it, inject, expect */
(function() {
  'use strict';

  describe('scceUser.directives', function() {
    var $compile, $scope, $httpBackend, elem, fix;

    beforeEach(module(
      'scceUser.directives',
      'views/sccoreeducation/user/login.html',
      'scCoreEducationMocked.fixtures'
    ));

    beforeEach(inject(function(_$compile_, _$rootScope_, SC_CORE_EDUCATION_FIXTURES, _$httpBackend_) {
      $compile = _$compile_;
      $scope = _$rootScope_;
      fix = SC_CORE_EDUCATION_FIXTURES;
      $httpBackend = _$httpBackend_;
    }));

    describe('scceUserLogin', function() {

      beforeEach(function() {
        elem = $compile('<scce-user-login></scce-user-login>')($scope);
      });

      it('should initially show loading message', function() {
        $httpBackend.whenGET(fix.urls.login).respond(fix.data.user);
        $scope.$digest();
        expect(elem.find('li:eq(0) p').text()).toBe('Loading current user info...');
      });

      it('should initially show the user name if he\'s logged in', function() {
        $httpBackend.whenGET(fix.urls.login).respond(fix.data.user);
        $scope.$digest();
        $httpBackend.flush();
        expect(elem.find('li:eq(0) p').text()).toBe('Signed in as Damien Lebrun');
      });

      it('should initially show the logout url if the user is logged in', function() {
        $httpBackend.whenGET(fix.urls.login).respond(fix.data.user);
        $scope.$digest();
        $httpBackend.flush();
        expect(elem.find('li:eq(1) a').text().trim()).toBe('logout');
        expect(elem.find('li:eq(1) a').prop('href')).toBeTruthy();
      });

      it('should initially show the login url if the user is logged out', function() {
        $httpBackend.whenGET(fix.urls.login).respond(fix.data.loginError);
        $scope.$digest();
        $httpBackend.flush();
        expect(elem.find('li:eq(1) a').text().trim()).toBe('login');
        expect(elem.find('li:eq(1) a').prop('href')).toBeTruthy();
      });

    });

  });

})();


text:
<?php

namespace English\DawgspeakBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use English\DawgspeakBundle\Entity\Def;
use English\DawgspeakBundle\Form\DefType;

/**
 * Def controller.
 *
 * @Route("/def")
 */
class DefController extends Controller
{
    /**
     * Lists all Def entities.
     *
     * @Route("/", name="def")
     * @Template()
     */
    public function indexAction()
    {
        $em = $this->getDoctrine()->getManager();

        $entities = $em->getRepository('EnglishDawgspeakBundle:Def')->findDef();

        return array('entities' => $entities);
    }

    /**
     * Lists all Def entities by alpha.
     *
     * @Route("/{alpha}/list", name="def_list")
     * @Template("EnglishDawgspeakBundle:Def:index.html.twig")
     */
    public function alphaAction($alpha)
    {
        $em = $this->getDoctrine()->getManager();

        $entities = $em->getRepository('EnglishDawgspeakBundle:Def')->findDefAlpha($alpha);

        return array('entities' => $entities);
    }

    /**
     * Finds and displays a Def entity.
     *
     * @Route("/{id}/show", name="def_show")
     * @Template()
     */
    public function showAction($id)
    {
        $em = $this->getDoctrine()->getManager();

        $entity = $em->getRepository('EnglishDawgspeakBundle:Def')->find($id);

        if (!$entity) {
            throw $this->createNotFoundException('Unable to find Def entity.');
        }

        $deleteForm = $this->createDeleteForm($id);

        return array(
            'entity'      => $entity,
            'delete_form' => $deleteForm->createView(),        );
    }

    /**
     * Displays a form to create a new Def entity.
     *
     * @Route("/new", name="def_new")
     * @Template()
     */
    public function newAction()
    {
        $entity = new Def();
        $form   = $this->createForm(new DefType(), $entity);

        return array(
            'entity' => $entity,
            'form'   => $form->createView()
        );
    }

    /**
     * Creates a new Def entity.
     *
     * @Route("/create", name="def_create")
     * @Method("post")
     * @Template("EnglishDawgspeakBundle:Def:new.html.twig")
     */
    public function createAction()
    {
        $entity  = new Def();
        $request = $this->getRequest();
        $form    = $this->createForm(new DefType(), $entity);
        $form->submit($request);

        if ($form->isValid()) {
            $em = $this->getDoctrine()->getManager();
            $em->persist($entity);
            $em->flush();

            return $this->redirect($this->generateUrl('def_show', array('id' => $entity->getId())));

        }

        return array(
            'entity' => $entity,
            'form'   => $form->createView()
        );
    }

    /**
     * Displays a form to edit an existing Def entity.
     *
     * @Route("/{id}/edit", name="def_edit")
     * @Template()
     */
    public function editAction($id)
    {
        $em = $this->getDoctrine()->getManager();

        $entity = $em->getRepository('EnglishDawgspeakBundle:Def')->find($id);

        if (!$entity) {
            throw $this->createNotFoundException('Unable to find Def entity.');
        }

        $editForm = $this->createForm(new DefType(), $entity);
        $deleteForm = $this->createDeleteForm($id);

        return array(
            'entity'      => $entity,
            'edit_form'   => $editForm->createView(),
            'delete_form' => $deleteForm->createView(),
        );
    }

    /**
     * Edits an existing Def entity.
     *
     * @Route("/{id}/update", name="def_update")
     * @Method("post")
     * @Template("EnglishDawgspeakBundle:Def:edit.html.twig")
     */
    public function updateAction($id)
    {
        $em = $this->getDoctrine()->getManager();

        $entity = $em->getRepository('EnglishDawgspeakBundle:Def')->find($id);

        if (!$entity) {
            throw $this->createNotFoundException('Unable to find Def entity.');
        }

        $editForm   = $this->createForm(new DefType(), $entity);
        $deleteForm = $this->createDeleteForm($id);

        $request = $this->getRequest();

        $editForm->submit($request);

        if ($editForm->isValid()) {
            $em->persist($entity);
            $em->flush();

            return $this->redirect($this->generateUrl('def_show', array('id' => $id)));
        }

        return array(
            'entity'      => $entity,
            'edit_form'   => $editForm->createView(),
            'delete_form' => $deleteForm->createView(),
        );
    }

    /**
     * Deletes a Def entity.
     *
     * @Route("/{id}/delete", name="def_delete")
     * @Method("post")
     */
    public function deleteAction($id)
    {
        $form = $this->createDeleteForm($id);
        $request = $this->getRequest();

        $form->submit($request);

        if ($form->isValid()) {
            $em = $this->getDoctrine()->getManager();
            $entity = $em->getRepository('EnglishDawgspeakBundle:Def')->find($id);

            if (!$entity) {
                throw $this->createNotFoundException('Unable to find Def entity.');
            }

            $em->remove($entity);
            $em->flush();
        }

        return $this->redirect($this->generateUrl('def'));
    }

    private function createDeleteForm($id)
    {
        return $this->createFormBuilder(array('id' => $id))
            ->add('id', 'hidden')
            ->getForm()
        ;
    }
}


text:
<?php

namespace Pessoa\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
 * SonuserUsers
 *
 * @ORM\Table(name="sonuser_users")
 * @ORM\Entity
 */
class SonuserUsers
{
    /**
     * @var integer
     *
     * @ORM\Column(name="ID", type="integer", nullable=false)
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="IDENTITY")
     */
    private $id;

    /**
     * @var string
     *
     * @ORM\Column(name="NOME", type="string", length=255, nullable=false)
     */
    private $nome;

    /**
     * @var string
     *
     * @ORM\Column(name="EMAIL", type="string", length=255, nullable=false)
     */
    private $email;

    /**
     * @var string
     *
     * @ORM\Column(name="PASSWORD", type="string", length=255, nullable=true)
     */
    private $password;

    /**
     * @var string
     *
     * @ORM\Column(name="SALT", type="string", length=255, nullable=true)
     */
    private $salt;

    /**
     * @var string
     *
     * @ORM\Column(name="ACTIVE", type="string", length=1, nullable=true)
     */
    private $active;

    /**
     * @var string
     *
     * @ORM\Column(name="ACTIVATION_KEY", type="string", length=255, nullable=true)
     */
    private $activationKey;

    /**
     * @var \DateTime
     *
     * @ORM\Column(name="UPDATED_AT", type="datetime", nullable=false)
     */
    private $updatedAt;

    /**
     * @var \DateTime
     *
     * @ORM\Column(name="CREATED_AT", type="datetime", nullable=false)
     */
    private $createdAt;

    /**
     * Get id
     *
     * @return integer
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * Set nome
     *
     * @param string $nome
     * @return SonuserUsers
     */
    public function setNome($nome)
    {
        $this->nome = $nome;

        return $this;
    }

    /**
     * Get nome
     *
     * @return string
     */
    public function getNome()
    {
        return $this->nome;
    }

    /**
     * Set email
     *
     * @param string $email
     * @return SonuserUsers
     */
    public function setEmail($email)
    {
        $this->email = $email;

        return $this;
    }

    /**
     * Get email
     *
     * @return string
     */
    public function getEmail()
    {
        return $this->email;
    }

    /**
     * Set password
     *
     * @param string $password
     * @return SonuserUsers
     */
    public function setPassword($password)
    {
        $this->password = $password;

        return $this;
    }

    /**
     * Get password
     *
     * @return string
     */
    public function getPassword()
    {
        return $this->password;
    }

    /**
     * Set salt
     *
     * @param string $salt
     * @return SonuserUsers
     */
    public function setSalt($salt)
    {
        $this->salt = $salt;

        return $this;
    }

    /**
     * Get salt
     *
     * @return string
     */
    public function getSalt()
    {
        return $this->salt;
    }

    /**
     * Set active
     *
     * @param string $active
     * @return SonuserUsers
     */
    public function setActive($active)
    {
        $this->active = $active;

        return $this;
    }

    /**
     * Get active
     *
     * @return string
     */
    public function getActive()
    {
        return $this->active;
    }

    /**
     * Set activationKey
     *
     * @param string $activationKey
     * @return SonuserUsers
     */
    public function setActivationKey($activationKey)
    {
        $this->activationKey = $activationKey;

        return $this;
    }

    /**
     * Get activationKey
     *
     * @return string
     */
    public function getActivationKey()
    {
        return $this->activationKey;
    }

    /**
     * Set updatedAt
     *
     * @param \DateTime $updatedAt
     * @return SonuserUsers
     */
    public function setUpdatedAt($updatedAt)
    {
        $this->updatedAt = $updatedAt;

        return $this;
    }

    /**
     * Get updatedAt
     *
     * @return \DateTime
     */
    public function getUpdatedAt()
    {
        return $this->updatedAt;
    }

    /**
     * Set createdAt
     *
     * @param \DateTime $createdAt
     * @return SonuserUsers
     */
    public function setCreatedAt($createdAt)
    {
        $this->createdAt = $createdAt;

        return $this;
    }

    /**
     * Get createdAt
     *
     * @return \DateTime
     */
    public function getCreatedAt()
    {
        return $this->createdAt;
    }
}


text:
#include "abstractfinder.h"
#include <QPropertyAnimation>
#include <QGraphicsOpacityEffect>
#include <QStylePainter>
#include <QStyleOption>
#include <QApplication>
#include <QHBoxLayout>
#include <QKeyEvent>
#include <QEvent>

AbstractFinder::AbstractFinder(QWidget* parent) : QWidget(parent)
{
    d.offset = -1;
    d.error = false;

    parent->installEventFilter(this);
    setGraphicsEffect(new QGraphicsOpacityEffect(this));

    d.lineEdit = new QLineEdit(this);
    d.lineEdit->setAttribute(Qt::WA_MacShowFocusRect, false);
    d.lineEdit->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);

    d.prevButton = new QToolButton(this);
    d.prevButton->setObjectName("prev");
    d.prevButton->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred);
    connect(d.prevButton, SIGNAL(clicked()), this, SLOT(findPrevious()));

    d.nextButton = new QToolButton(this);
    d.nextButton->setObjectName("next");
    d.nextButton->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred);
    connect(d.nextButton, SIGNAL(clicked()), this, SLOT(findNext()));

    QHBoxLayout* layout = new QHBoxLayout(this);
    layout->addWidget(d.lineEdit);
    layout->addWidget(d.prevButton);
    layout->addWidget(d.nextButton);
    layout->setSpacing(0);
    layout->setMargin(0);

    connect(d.lineEdit, SIGNAL(returnPressed()), this, SIGNAL(returnPressed()));
    connect(d.lineEdit, SIGNAL(textEdited(QString)), this, SLOT(find(QString)));
}

AbstractFinder::~AbstractFinder()
{
    emit destroyed(this);
}

QString AbstractFinder::text() const
{
    return d.lineEdit->text();
}

void AbstractFinder::setText(const QString& text)
{
    d.lineEdit->setText(text);
}

int AbstractFinder::offset() const
{
    return d.offset;
}

void AbstractFinder::setOffset(int offset)
{
    d.offset = offset;
    relocate();
}

bool AbstractFinder::hasError() const
{
    return d.error;
}

void AbstractFinder::setError(bool error)
{
    if (d.error != error) {
        d.error = error;
        // force restyle
        setStyleSheet(QString());
        d.lineEdit->setStyleSheet(QString());
        d.nextButton->setEnabled(!error);
        d.prevButton->setEnabled(!error);
    }
}

bool AbstractFinder::eventFilter(QObject* object, QEvent* event)
{
    Q_UNUSED(object);
    if (event->type() == QEvent::Resize)
        relocate();
    return false;
}

void AbstractFinder::findNext()
{
    find(d.lineEdit->text(), true, false, false);
}

void AbstractFinder::findPrevious()
{
    find(d.lineEdit->text(), false, true, false);
}

void AbstractFinder::doFind()
{
    setFixedHeight(d.lineEdit->sizeHint().height() + 1);
    setOffset(-sizeHint().height());
    relocate();
    animateShow();
    reFind();
}

void AbstractFinder::reFind()
{
    d.lineEdit->setFocus(Qt::ShortcutFocusReason);
    d.lineEdit->selectAll();
}

void AbstractFinder::animateShow()
{
    QPropertyAnimation *animation = new QPropertyAnimation(this, "offset");
    animation->setDuration(50);
    animation->setEndValue(-1);
    animation->start(QAbstractAnimation::DeleteWhenStopped);
    setVisible(true);
}

void AbstractFinder::animateHide()
{
    QPropertyAnimation *animation = new QPropertyAnimation(this, "offset");
    animation->setDuration(50);
    animation->setEndValue(-sizeHint().height());
    animation->start(QAbstractAnimation::DeleteWhenStopped);
    connect(animation, SIGNAL(destroyed()), this, SLOT(hide()));
    connect(animation, SIGNAL(destroyed()), this, SLOT(deleteLater()));
}


text:
@charset "utf-8";

.flexigrid td,.flexigrid input,.flexigrid textarea,.flexigrid select,
.flexigrid button,.flexigrid div { color: #555; font-size: 12px; font-family: "Microsoft Yahei", "Lucida Grande", Verdana, Lucida, Helvetica, Arial, sans-serif; }
.flexigrid input, .flexigrid button, .flexigrid select, .flexigrid textarea { outline: none }
.pcontrol input {margin-bottom: 0px;}

.flexigrid ul, ol, li { list-style-image: none; list-style-type: none; }
.flexigrid .nDiv ul,.flexigrid .nDiv ol { margin:0px 0px 0px 5px;}

.flexigrid { margin-bottom:11px; position: relative; z-index: 1; overflow: hidden; }
/*f表格标题块*/
.flexigrid .mDiv { background-color: #efefef; color: #333; white-space: nowrap; display: block;
  border-bottom: solid 1px #C8C8C8; position: relative; z-index: 4;
    background-image: -webkit-gradient(linear, 0 0%, 0 100%, from(#fdfdfd), to(#eaeaea));
    background-image:-webkit-linear-gradient(top, #fdfdfd 0%, #eaeaea 100%);
    background-image: -moz-linear-gradient(top, #fdfdfd 0%, #eaeaea 100%);
    background-image: -ms-linear-gradient(top, #fdfdfd 0%, #eaeaea 100%);
    background-image: -o-linear-gradient(top, #fdfdfd 0%, #eaeaea 100%);
    background-image: -linear-gradient(top, #fdfdfd 0%, #eaeaea 100%);
    filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#fdfdfd', endColorstr='#eaeaea',GradientType=0 );
    border-bottom: 1px solid #CDCDCD;
    height: 30px; padding-top:6px;padding-bottom:5px;}
/*标题*/
.flexigrid .mDiv .ftitle { font-size: 0; *word-spacing:-1px/*IE6、7*/;
height: 24px; float: left;}
.flexigrid .mDiv .ftitle h3,
.flexigrid .mDiv .ftitle h5 { font-size: 12px; font-weight: normal; line-height: 24px; color: #999; vertical-align: bottom; letter-spacing: normal; display: inline-block; *display: inline/*IE7*/;
padding: 0; *zoom:1/*IE7*/;
}
.flexigrid .mDiv .ftitle h3 { color: #666666; font-weight:bold; }
.flexigrid .mDiv .ftitle h3 { margin:0px 10px 0px 10px; line-height:30px; }
.flexigrid .mDiv .ftitle h5 { margin:0px 0px 0px 5px; line-height:30px; }
/*数据统计数*/
.flexigrid .pReload { color: #999; background-color: #efefef; width: 24px; height: 24px; float: left; text-align: center; line-height: 24px; margin: 0 0 0 20px; position: relative; z-index: 1;
background-image: -webkit-gradient(linear, 0 0%, 0 100%, from(#fdfdfd), to(#eaeaea));
    background-image:-webkit-linear-gradient(top, #fdfdfd 0%, #eaeaea 100%);
    background-image: -moz-linear-gradient(top, #fdfdfd 0%, #eaeaea 100%);
    background-image: -ms-linear-gradient(top, #fdfdfd 0%, #eaeaea 100%);
    background-image: -o-linear-gradient(top, #fdfdfd 0%, #eaeaea 100%);
    background-image: -linear-gradient(top, #fdfdfd 0%, #eaeaea 100%);
    filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#fdfdfd', endColorstr='#eaeaea',GradientType=0 );
  }
.flexigrid .pReload:hover { color: #333; background-color: #E6E6E6; border-radius: 5px; cursor: pointer; }
.flexigrid .pReload i { font-size: 14px; margin: 0; }
.flexigrid .pReload.loading i { color: #090; display: inline-block; -webkit-animation: fa-spin 0.2s infinite linear; animation: fa-spin 0.2s infinite linear; }

/*操作间隔*/
.flexigrid .mDiv .sline { width: 0; height: 16px; float: left; margin: 4px; border-left: dotted 1px #D7D7D7; }
/*操作按钮*/
.flexigrid .nBtn { color: #999; background-color: #efefef; width: 100px; height: 24px; float: left; position: relative; z-index: 1; cursor: pointer;
  background-image: -webkit-gradient(linear, 0 0%, 0 100%, from(#fdfdfd), to(#eaeaea));
    background-image:-webkit-linear-gradient(top, #fdfdfd 0%, #eaeaea 100%);
    background-image: -moz-linear-gradient(top, #fdfdfd 0%, #eaeaea 100%);
    background-image: -ms-linear-gradient(top, #fdfdfd 0%, #eaeaea 100%);
    background-image: -o-linear-gradient(top, #fdfdfd 0%, #eaeaea 100%);
    background-image: -linear-gradient(top, #fdfdfd 0%, #eaeaea 100%);
    filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#fdfdfd', endColorstr='#eaeaea',GradientType=0 );
  }
.flexigrid .nBtn .hBtn { text-align: center; line-height: 24px; width: 24px; height: 24px; border: solid 1px transparent; position: absolute; z-index: 2; top: 0; left: -1px; }
.flexigrid .nBtn:hover .hBtn { color: #333; background-color: #FFF; border-radius: 4px 4px 0 0; border-color: #D7D7D7; border-bottom: 0; }
.flexigrid .nBtn i { font-size: 14px; margin: 0; }
/*菜单配置下拉框*/
.flexigrid .nDiv { background-color: #FFF; padding: 5px 0 5px 5px; border: 1px solid #D7D7D7; border-radius: 0 0 4px 4px; overflow: auto; position: absolute; z-index: 1; top: 23px; left: -1px; box-shadow: 3px 3px 0 rgba(0,0,0,0.05); }
.flexigrid .nDiv h5 { font-size: 12px; font-weight: normal; line-height: 24px; color: #F60; }
.flexigrid .nDiv .ps-container { display: block; max-height: 150px; padding: 0 10px 10px 0; overflow: hidden; position: relative; z-index: auto; }
.flexigrid .nDiv ul { width: 100%; }
.flexigrid .nDiv li { font-size: 0; *word-spacing:-1px/*IE6、7*/;
line-height: 20px; text-align: left; padding: 2px 10px 2px 0; border-bottom: dotted 1px #E6E6E6; }
.flexigrid .nDiv li:hover { color: #666; background: #F5F5F5; }
.flexigrid .nDiv li span { font-size: 12px; vertical-align: middle; letter-spacing: normal; display: inline-block; *display: inline/*IE7*/;
*zoom:1/*IE7*/;
}
.flexigrid .nDiv li span.ndcol1 { margin-right: 5px; }
.flexigrid .nDiv .ps-scrollbar-x-rail { display: none !important; }
/*表格搜索*/
.flexigrid .sDiv { float: right; position: relative; overflow: hidden; }
.flexigrid .sDiv2 { margin-top:3px;margin-right:10px; font-size: 0; *word-spacing:-1px/*IE6、7*/;
display: inline-block; vertical-align: middle; *display: inline/*IE7*/;
*zoom:1/*IE7*/;
border: solid 1px #D7D7D7; }
.flexigrid .sDiv2:hover { border-color: #2cbca3; }
.flexigrid .sDiv2 .qsbox,
.flexigrid .sDiv2 .select,
.flexigrid .sDiv2 .btn { border: none; border-radius: 0; padding:0px 10px; font-size: 12px; vertical-align: top; letter-spacing: normal; display: inline-block; *display: inline/*IE7*/;
*zoom:1/*IE7*/;
border-radius: 0; }
.flexigrid .sDiv2 .select { background-color: #efefef; width: auto; height: 22px; margin-bottom:0px; }
.flexigrid .sDiv2 input { margin-bottom:0px;}
.flexigrid .sDiv2 .qsbox { background-color: #efefef; font-size: 12px; line-height: 20px; width: 120px; height: 20px; padding: 1px 5px; }
.flexigrid .sDiv2 .qsbox:hover, .flexigrid .sDiv2 .qsbox:fouce {
box-shadow: none;
}
.flexigrid .sDiv2 .btn { height: 22px; cursor: pointer; border-left: solid 1px #D7D7D7; }
.flexigrid .sDiv2:hover .btn,
.flexigrid .sDiv2 .btn:hover { color: #FFF; background-color: #2cbca3; }
.flexigrid .sDiv .a_search { color: #3b639f; display: inline-block; vertical-align: middle; *display: inline/*IE7*/; margin-left: 8px; *zoom:1/*IE7*/;}
.flexigrid .sDiv .a_search i { font-size: 14px; margin-right: 4px; }
.flexigrid .sDiv .a_search:hover { color: #CD0200; }
/*数据表格头*/
.flexigrid .hDiv { background-color: #F5F5F5; clear: both; border-style: solid none; border-width: 1px 0; border-color: #FFF transparent; position: relative; z-index: 1; overflow: hidden; }
.flexigrid .hDiv table { }
.flexigrid .hDiv th div { }
.flexigrid .hDivBox { float: none; }
.flexigrid .hDiv i.ico-check { background: url(../img/flexigrid_pic.png) no-repeat 0 0; display: inline-block; width: 20px; height: 20px; cursor: pointer; }
.flexigrid .hDiv .trSelected i.ico-check { background-position: -20px 0; }
.flexigrid .hDiv .sorted { background-color: #E6E6E6; }
.flexigrid .hDiv .thOver { }
.flexigrid .hDiv .thOver div,
.flexigrid .hDiv .sorted.thOver div { padding-bottom: 6px; border-bottom: 2px solid #2cbca3; cursor: pointer; }
.flexigrid .hDiv .sorted div { padding-bottom: 5px; }
.flexigrid .hDiv .thMove { background: #fff; color: #fff; }
.flexigrid .hDiv .sorted.thMove div { border-bottom: 1px solid #fff; padding-bottom: 4px }
.flexigrid .hDiv .thMove div { background: #fff !important; }
.flexigrid .hDiv th .sdesc { background: url(../img/dn.png) no-repeat center top; }
.flexigrid .hDiv th .sasc { background: url(../img/up.png) no-repeat center top; }
/*调节表格列宽*/
.flexigrid .cDrag { float: left; position: absolute; z-index: 2; overflow: visible; }
.flexigrid .cDrag div { background: none; display: block; width: 3px; height: 24px; float: left; position: absolute; cursor: col-resize; }
.flexigrid .cDrag div:hover,
.flexigrid .cDrag div.dragging {
filter:progid:DXImageTransform.Microsoft.gradient(enabled='true', startColorstr='#19000000', endColorstr='#19000000'); background: rgba(0,0,0,0.1); border: solid #FFF; border-width: 0 1px; }
/*批量操作条*/
.flexigrid .tDiv { background-color: #FAFAFA; border-top: 1px solid #C8C8C8; border-bottom: 1px solid #D7D7D7; position: relative; z-index: 3; overflow: hidden; }
.flexigrid .tDiv2 { font-size: 0; *word-spacing:-1px/*IE6、7*/;
padding: 6px 0 6px 6px; float: left; overflow: hidden; }
.flexigrid .btnseparator { float: left; height: 22px; border-left: 1px solid #ccc; border-right: 1px solid #fff; margin: 1px; }
.flexigrid .fbutton { vertical-align: top; letter-spacing: normal; display: inline-block; *display: inline/*IE7*/;
padding-right: 8px; margin-left: 8px; margin-right: -1px; border-right: dotted 1px #D7D7D7; *zoom:1/*IE7*/;
cursor: pointer; }
.flexigrid .fbutton div { font-size: 12px; line-height: 20px; color: #999; background-color: #FFFFFF; height: 20px; padding: 2px 7px; border: solid 1px #F0F0F0; border-radius: 4px; }
.flexigrid .fbutton .add:hover,
.flexigrid .fbutton.fbOver .add:hover { color: #1BBC9D; border-color: #1BBC9D; }
.flexigrid .fbutton .del:hover,
.flexigrid .fbutton.fbOver .del:hover { color: #E84C3D; border-color: #E84C3D; }
.flexigrid .fbutton .csv:hover,
.flexigrid .fbutton.fbOver .csv:hover { color: #9C59B8; border-color: #9C59B8; }
/*数据表格内容部分*/
.flexigrid .bDiv { background: #fff; min-height: 300px; position: relative; z-index: 2; overflow: auto; }
.flexigrid .bDiv table { width: 100%; }
.flexigrid .bDiv td { color: #777; vertical-align: top; white-space: nowrap; padding: 0; margin: 0; border-bottom: 1px solid E6E6E6; }
.flexigrid .bDiv td div { }
.flexigrid .bDiv a { color: #3b639f; }
.flexigrid .bDiv a:hover { text-decoration: underline; color: #CD0200; }
.flexigrid .bDiv td i.ico-check { background: url(../img/flexigrid_pic.png) no-repeat 0 0; display: inline-block; width: 20px; height: 20px; }
.flexigrid .bDiv .trSelected td i.ico-check { background-position: -20px 0; }
.flexigrid .bDiv td .on,
.flexigrid .bDiv td .yes { color: #1BBC9D; cursor: default; }
.flexigrid .bDiv td .off,
.flexigrid .bDiv td .no { color: #BEC3C7; cursor: default; }
.flexigrid .bDiv td.normal { color: #C30; }
.flexigrid .bDiv td.abnormal { color: #090; }
.flexigrid .bDiv td.column-a { background-color: #F6EEFB; }
.flexigrid .bDiv td.column-b { background-color: #F9F3D7; }
.flexigrid .bDiv td.column-c { background-color: #FBEEE0; }
/*数据表格查看操作项*/
.flexigrid .bDiv .handle div { font-size: 0; *word-spacing:-1px/*IE6、7*/;
}
.flexigrid .bDiv a.btn { font-size: 12px; font-weight: normal; line-height: 20px; color: #999; background: #FFF none; vertical-align: top; letter-spacing: normal; display: inline-block; *display: inline/*IE7*/;
*zoom:1/*IE7*/;
height: 20px; padding: 1px 6px; margin: 0 5px 0 0; border: solid 1px #F5F5F5; border-radius: 4px; cursor: pointer !important; }
.flexigrid .bDiv a.btn:hover { color: #555; text-decoration: none; box-shadow: 2px 2px 0 rgba(0,0,0,0.1); }
.flexigrid .bDiv a.red:hover { color: #FFF; background-color: #E84C3D; border-color: #C1392B; }
.flexigrid .bDiv a.blue:hover { color: #FFF; background-color: #3598DC; border-color: #2A80B9; }
.flexigrid .bDiv a.green:hover { color: #FFF; background-color: #1BBC9D; border-color: #16A086; }
.flexigrid .bDiv a.orange:hover { color: #FFF; background-color: #FFBF40; border-color: #FFBF40; }
.flexigrid .bDiv a.purple:hover { color: #FFF; background-color: #9C59B8; border-color: #8F44AD; }
.flexigrid .bDiv a.pomegranate:hover { }
.flexigrid .bDiv a.belize-hole:hover { color: #FFF; background-color: #E84C3D; border-color: #C1392B; }
.flexigrid .bDiv .handle span { font-size: 12px; }
.flexigrid .bDiv span.btn { font-size: 12px; vertical-align: top; letter-spacing: normal; display: inline-block; *display: inline/*IE7*/;
*zoom:1/*IE7*/;
position: relative; z-index: 1; cursor: default; }
.flexigrid .bDiv span.btn:hover { z-index: 3; box-shadow: 2px 2px 0 rgba(0,0,0,0.1); }
.flexigrid .bDiv span.btn em { color: #999; line-height: 20px; background-color: #FFF; display: block; height: 20px; padding: 1px 6px; border: solid 1px #F5F5F5; border-radius: 4px 0 0 4px; position: relative; z-index: 2; }
.flexigrid .bDiv span.btn:hover em { color: #FFF; background-color: #9C59B8; border-color: #8F44AD #9C59B8 #8F44AD #8F44AD; }
.flexigrid .bDiv span.btn em i { font-size: 14px; vertical-align: middle; margin-right: 4px; }
.flexigrid .bDiv span.btn em .arrow { font-size: 0px; line-height: 0; vertical-align: middle; display: inline-block; width: 0px; height: 0px; float: none; margin: 0 0 0 4px; border-width: 4px; border-color: #999 transparent transparent transparent; border-style: solid dashed dashed dashed; -webkit-transition: .2s ease-in; -moz-transition: -webkit-transform .2s ease-in; -o-transition: -webkit-transform .2s ease-in; transition: .2s ease-in; }
.flexigrid .bDiv span.btn:hover .arrow { border-color: #FFF transparent transparent transparent; FILTER: progid:DXImageTransform.Microsoft.BasicImage(rotation=2);
-moz-transform: rotate(270deg); -moz-transform-origin: 50% 30%; -webkit-transform: rotate(270deg); -webkit-transform-origin: 50% 30%; -o-transform: rotate(270deg); -o-transform-origin: 50% 30%; transform: rotate(270deg); transform-origin: 50% 30%; }
.flexigrid .bDiv span.btn ul { background-color: #9C59B8; display: none; border: solid 1px #8F44AD; border-radius: 0 4px 4px 0; margin-left: -2px; position: absolute; z-index: 1; top: 0; left: 100%; overflow: hidden; box-shadow: 3px 3px 0 rgba(0,0,0,0.1); }
.flexigrid .bDiv tr:last-child span.btn ul { bottom: 0; top: auto; }
.flexigrid .bDiv tr:first-child span.btn ul { bottom: auto; top: 0; }
.flexigrid .bDiv tr:nth-last-child(2) span.btn ul { bottom: auto; top: 0; }
.flexigrid .bDiv tr:nth-child(1) span.btn ul,
.flexigrid .bDiv tr:nth-child(2) span.btn ul,
.flexigrid .bDiv tr:nth-child(3) span.btn ul { bottom: auto; top: 0; }
.flexigrid .bDiv span.btn:hover ul { display: block; padding: 0 5px; }
.flexigrid .bDiv span.btn ul li { border-bottom: dotted 1px #C69FD7; clear: both; margin-bottom: -1px; }
.flexigrid .bDiv span.btn ul li a { color: #FFF; display: block; line-height: 24px; text-align: right; height: 24px; padding: 0 5px; }
.flexigrid .bDiv span.btn ul li a:hover { text-decoration: underline; }
.flexigrid .bDiv span.btn ul li a.expire { color: #FF0 !important; }
.flexigrid .bDiv a.expired { color: #F30; }
.flexigrid .bDiv a.expire { color: #F93; }
i.fa-external-link { color: #999 !important; font-size: 9px !important; margin-left: 4px; margin-right: 0; }
.flexigrid .bDiv .user-avatar { background-color: #FFF; vertical-align: middle; display: inline-block; width: 22px; height: 22px; margin-right: 6px; border: solid 1px #D7D7D7; border-radius: 50%; }
.flexigrid .bDiv .pic-thumb-tip { color: #777; }
.flexigrid .bDiv .pic-thumb-tip i { font-size: 14px; }
.flexigrid .bDiv .pic-thumb-tip:hover { color: #333; }
/*数据表格查询为空*/
.no-data,
.flexigrid .bDiv .no-data { font-size: 14px; color: #999; width: 100% !important; height: 24px; border: 0 none !important; text-align: center; padding: 100px 0; }
.flexigrid .bDiv .trSelected .no-data,
.flexigrid .bDiv .no-data:hover { color: #999 !important; background-color: transparent !important; }
.no-data i,
.flexigrid .bDiv .no-data i { font-size: 18px; margin-right: 6px; color: #FC0; }
.flexigrid .bDiv .handle-btn { }
/*hDiv\bDiv\colCopy同步项*/
.flexigrid .hDiv th,
.flexigrid .bDiv td { vertical-align: top !important; text-align: left; border-bottom: solid 1px #F5F5F5; overflow: visible; }
.flexigrid .hDiv th div,
.flexigrid .bDiv td div,
.colCopy div { display: block; line-height: 22px; text-overflow: ellipsis; white-space: nowrap; height: 22px; padding: 8px; overflow: hidden; }
.flexigrid .bDiv td div { padding: 10px 8px; }
.flexigrid .hDiv .sign div,
.flexigrid .bDiv .sign div { min-width: 24px !important; max-width: 24px !important; }
.flexigrid .hDiv .handle div,
.flexigrid .bDiv .handle div { overflow: visible; min-width: 80px !important; max-width: 300px !important; }
.flexigrid .hDiv .handle-s div,
.flexigrid .bDiv .handle-s div { overflow: visible; min-width: 60px !important; max-width: 60px !important; }
.flexigrid.hideBody { height: 26px !important; border-bottom: 1px solid #ccc; }
.ie6fullwidthbug { border-right: 0px solid #ccc; padding-right: 2px; }
.flexigrid .bDiv table.autoht { width: 100%; margin-bottom: 0px; border-bottom: 0px; }
.flexigrid .nBtn.srtd { background: url(../img/wbg.gif) repeat-x 0px -1px; }
.flexigrid .hDiv th,
.colCopy { font-weight: 600; white-space: nowrap; cursor: default; overflow: hidden; }
.colCopy { color: #333; filter:progid:DXImageTransform.Microsoft.gradient(enabled='true', startColorstr='#E5FFFFFF', endColorstr='#E5FFFFFF');
background: rgba(255,255,255,0.9); border: dotted 1px #D7D7D7; overflow: hidden; box-shadow: 4px 4px 0 rgba(0,0,0,0.05); z-index: 9; }
.flexigrid tr td.sorted { background-color: #F9F9F9; border-bottom: 1px solid #E6E6E6 }
.flexigrid tr td.sorted div { bckground: #FFF7CF }
.flexigrid tr.erow td { background: #FDFDFD; border-bottom: 1px solid #F5F5F5; }
.flexigrid tr.erow td.sorted { background: #F0F0F0; border-bottom: 1px solid #E6E6E6; }
.flexigrid tr.erow td.sorted div { }
.flexigrid div.bDiv tr:hover td,
.flexigrid div.bDiv tr:hover td.sorted,
.flexigrid div.bDiv tr.trOver td.sorted,
.flexigrid div.bDiv tr.trOver td { background: #F4FCFA; }
.flexigrid div.bDiv tr.trSelected:hover td,
.flexigrid div.bDiv tr.trSelected:hover td.sorted,
.flexigrid div.bDiv tr.trOver.trSelected td.sorted,
.flexigrid div.bDiv tr.trOver.trSelected td,
.flexigrid tr.trSelected td.sorted,
.flexigrid tr.trSelected td { color: #333; background: #FFFFDF; border-color: transparent; border-bottom: 1px solid #FFEFBF; }
.flexigrid .pDiv { background-color: #F5F5F5; border-style: solid; border-color: #D7D7D7 transparent #C8C8C8 transparent; border-width: 1px 0; position: relative; z-index: 3; }
.flexigrid .pDiv .pDiv2 { padding: 6px 0; margin: 0; border-color: #FFF; border-style: solid; border-width: 1px 0; position: relative; z-index: 1; }
.flexigrid .pGroup-left { color: #777; line-height: 24px; height: 24px; position: absolute; z-index: 1; top: 6px; left: 12px; }
.flexigrid .pGroup-left .select { font-family: Arial, Helvetica, sans-serif; vertical-align: middle; display: inline-block; *display: inline;
width: 60px; height: 24px; background-color: transparent; padding: 0; margin: 0 6px 0 0; border-radius: 0; border: none; *zoom: 1;text-align:center;
}
.flexigrid .pGroup-right { color: #777; line-height: 24px; height: 24px; position: absolute; z-index: 1; top: 6px; right: 12px; }
/*f表格翻页控制*/
.flexigrid .pGroup-middle { font-size: 0; *word-spacing:-1px/*IE6、7*/;
text-align: center; margin: 0 auto; width: 250px; height: 24px; float: none; z-index: auto; }
.flexigrid .pGroup-middle .pButton,
.flexigrid .pGroup-middle .pcontrol,
.flexigrid .pGroup-middle .pcontrol input,
.flexigrid .pGroup-middle .pcontrol span { vertical-align: middle; letter-spacing: normal; display: inline-block; *display: inline/*IE7*/;
*zoom:1/*IE7*/;
}
.flexigrid .pGroup-middle .pButton { color: #999; background-color: transparent; text-align: center; width: 24px; height: 24px; padding: 0; margin-right: 8px; border-radius: 4px; cursor: pointer; overflow: hidden; }
.flexigrid .pGroup-middle .pButton:hover { color: #333; background-color: #CCC; padding: 0; border: 0; }
.flexigrid .pGroup-middle .pButton i { line-height: 24px; font-size: 14px; }
.flexigrid .pGroup-middle .pcontrol { font-size: 12px; line-height: 20px; color: #999; *word-spacing:-1px/*IE6、7*/;
margin-right: 10px; }
.flexigrid .pGroup-middle .pcontrol input { color: #333; background-color: transparent; text-decoration: underline; text-align: center; width: 20px; padding: 0; border: none; border-radius: 0; }
.flexigrid .pGroup-middle .pcontrol input:hover,
.flexigrid .pGroup-middle .pcontrol input:focus { background-color: #FFF; box-shadow: none; }
.pPageStat { display: block; line-height: 40px; text-align: center; color: #FFF; position: absolute; top: -40px; left: 0px; right: 0px; filter:progid:DXImageTransform.Microsoft.gradient(enabled='true', startColorstr='#7F000000', endColorstr='#7F000000');
background: rgba(0,0,0,0.5); width: 100%; }
.flexigrid .pGroup-middle .pcontrol span { margin-right: 2px; }
.flexigrid .pDiv .pButton.pBtnOver { width: 20px; height: 20px; border: 1px solid #ccc; cursor: pointer; }
.flexigrid .pDiv .pButton span { display: block; width: 20px; height: 20px; float: left; }
.flexigrid .pDiv .pButton:hover span,
.flexigrid .pDiv .pButton.pBtnOver span { width: 19px; height: 19px; border-top: 1px solid #fff; border-left: 1px solid #fff; }
.flexigrid div.iDiv { border: 1px solid #316ac5; position: absolute; overflow: visible; background: none; }
.flexigrid div.iDiv input,
.flexigrid div.iDiv select,
.flexigrid div.iDiv textarea { font-family: Arial, Helvetica, sans-serif; font-size: 11px; }
.flexigrid div.iDiv input.tb { border: 0px; padding: 0px; width: 100%; height: 100%; padding: 0px; background: none; }
.flexigrid div.hGrip { position: absolute; top: 0px; right: 0px; height: 5px; width: 5px; background: url(../img/line.gif) repeat-x center; margin-right: 1px; cursor: col-resize; }
.flexigrid div.hGrip:hover,
.flexigrid div.hGrip.hgOver { border-right: 1px solid #999; margin-right: 0px; }
.flexigrid div.vGrip { height: 5px; overflow: hidden; position: relative; background: #fafafa url(../img/wbg.gif) repeat-x 0px -1px; border: 1px solid #ccc; border-top: 0px; text-align: center; cursor: row-resize; display: none; }
.flexigrid div.vGrip span { display: block; margin: 1px auto; width: 20px; height: 1px; overflow: hidden; border-top: 1px solid #aaa; border-bottom: 1px solid #aaa; background: none; }
.flexigrid span.cdropleft { display: block; background: url(../img/prev.gif) no-repeat -4px center; width: 24px; height: 24px; position: relative; top: -24px; margin-bottom: -24px; z-index: 3; }
.flexigrid div.hDiv span.cdropright { display: block; background: url(../img/next.gif) no-repeat 12px center; width: 24px; height: 24px; float: right; position: relative; top: -24px; margin-bottom: -24px; }
/* ie adjustments */
.flexigrid.ie .hDiv th div,
.colCopy.ie div/* common inner cell properties*/ { overflow: hidden; }

/* 同步调用表格时搜索栏 */
.flex-table-search { font-size: 0; line-height: 0; display: block; height: 0; position: relative; z-index: 3; }
.flex-table-search .sDiv { font-size: 0; border: 1px solid #d7d7d7; display: block; position: absolute; z-index: 1; right: 0; top: 10px; }
.flex-table-search .sDiv:hover { border-color: #2cbca3; }
.flex-table-search .sDiv .select,
.flex-table-search .sDiv .qsbox,
.flex-table-search .sDiv .btn { font-size: 12px; *word-spacing:-1px/*IE6、7*/;
vertical-align: middle; display: inline-block; *display: inline/*IE7*/;
border: medium none; border-radius: 0; *zoom:1/*IE7*/;
}
.flex-table-search .sDiv .select { background-color: #fff; width: auto; height: 22px; }
.flex-table-search .sDiv .qsbox { line-height: 20px; background-color: #fff; width: 120px; height: 20px; padding: 1px 5px; }
.flex-table-search .sDiv .btn { color: #555; background-color: #E7E7E7; line-height: 22px; height: 22px; border-left: 1px solid #d7d7d7; padding: 0 10px; cursor: pointer; }
.flex-table-search .sDiv:hover .btn,
.flex-table-search .sDiv .btn:hover { color: #FFF; text-decoration: none; background-color: #2cbca3; }
.flexirid-layout { position: relative; z-index: 1; display: block; overflow: hidden; }


text:
// Copyright 2019 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "components/password_manager/core/browser/password_generation_manager.h"

#include <map>
#include <unordered_set>
#include <utility>

#include "base/callback.h"
#include "base/ranges/algorithm.h"
#include "components/password_manager/core/browser/form_saver.h"
#include "components/password_manager/core/browser/password_form_manager_for_ui.h"
#include "components/password_manager/core/browser/password_manager_client.h"
#include "components/password_manager/core/browser/password_manager_driver.h"
#include "components/password_manager/core/browser/password_manager_util.h"
#include "components/password_manager/core/common/password_manager_features.h"

namespace password_manager {
namespace {

std::vector<PasswordForm> DeepCopyVector(
    const std::vector<const PasswordForm*>& forms) {
  std::vector<PasswordForm> result;
  result.reserve(forms.size());
  for (const PasswordForm* form : forms)
    result.emplace_back(*form);
  return result;
}

// Implementation of the UI model for "Update password?" bubble in case there is
// a conflict in generation.
class PasswordDataForUI : public PasswordFormManagerForUI {
 public:
  PasswordDataForUI(PasswordForm pending_form,
                    const std::vector<const PasswordForm*>& matches,
                    const std::vector<const PasswordForm*>& federated,
                    base::RepeatingCallback<void(bool, const PasswordForm&)>
                        bubble_interaction);
  ~PasswordDataForUI() override = default;
  PasswordDataForUI(const PasswordDataForUI&) = delete;
  PasswordDataForUI& operator=(const PasswordDataForUI&) = delete;

  // PasswordFormManagerForUI:
  const GURL& GetURL() const override;
  const std::vector<const PasswordForm*>& GetBestMatches() const override;
  std::vector<const PasswordForm*> GetFederatedMatches() const override;
  const PasswordForm& GetPendingCredentials() const override;
  metrics_util::CredentialSourceType GetCredentialSource() const override;
  PasswordFormMetricsRecorder* GetMetricsRecorder() override;
  base::span<const InteractionsStats> GetInteractionsStats() const override;
  std::vector<const PasswordForm*> GetInsecureCredentials() const override;
  bool IsBlocklisted() const override;
  bool WasUnblocklisted() const override;
  bool IsMovableToAccountStore() const override;
  void Save() override;
  void Update(const PasswordForm& credentials_to_update) override;
  void OnUpdateUsernameFromPrompt(const std::u16string& new_username) override;
  void OnUpdatePasswordFromPrompt(const std::u16string& new_password) override;
  void OnNopeUpdateClicked() override;
  void OnNeverClicked() override;
  void OnNoInteraction(bool is_update) override;
  void Blocklist() override;
  void OnPasswordsRevealed() override;
  void MoveCredentialsToAccountStore() override;
  void BlockMovingCredentialsToAccountStore() override;

 private:
  PasswordForm pending_form_;
  std::vector<const PasswordForm*> matches_;
  const std::vector<PasswordForm> federated_matches_;
  const std::vector<PasswordForm> non_federated_matches_;

  // Observer that waits for bubble interaction.
  // The first parameter is true iff the bubble was accepted.
  // The second parameter is the pending form.
  base::RepeatingCallback<void(bool, const PasswordForm&)>
      bubble_interaction_cb_;
};

PasswordDataForUI::PasswordDataForUI(
    PasswordForm pending_form,
    const std::vector<const PasswordForm*>& matches,
    const std::vector<const PasswordForm*>& federated,
    base::RepeatingCallback<void(bool, const PasswordForm&)> bubble_interaction)
    : pending_form_(std::move(pending_form)),
      federated_matches_(DeepCopyVector(federated)),
      non_federated_matches_(DeepCopyVector(matches)),
      bubble_interaction_cb_(std::move(bubble_interaction)) {
  for (const PasswordForm& form : non_federated_matches_)
    matches_.push_back(&form);
}

const GURL& PasswordDataForUI::GetURL() const {
  return pending_form_.url;
}

const std::vector<const PasswordForm*>& PasswordDataForUI::GetBestMatches()
    const {
  return matches_;
}

std::vector<const PasswordForm*> PasswordDataForUI::GetFederatedMatches()
    const {
  std::vector<const PasswordForm*> result(federated_matches_.size());
  std::transform(federated_matches_.begin(), federated_matches_.end(),
                 result.begin(),
                 [](const PasswordForm& form) { return &form; });
  return result;
}

const PasswordForm& PasswordDataForUI::GetPendingCredentials() const {
  return pending_form_;
}

metrics_util::CredentialSourceType PasswordDataForUI::GetCredentialSource()
    const {
  return metrics_util::CredentialSourceType::kPasswordManager;
}

PasswordFormMetricsRecorder* PasswordDataForUI::GetMetricsRecorder() {
  return nullptr;
}

base::span<const InteractionsStats> PasswordDataForUI::GetInteractionsStats()
    const {
  return {};
}

std::vector<const PasswordForm*> PasswordDataForUI::GetInsecureCredentials()
    const {
  return {};
}

bool PasswordDataForUI::IsBlocklisted() const {
  // 'true' would suppress the bubble.
  return false;
}

bool PasswordDataForUI::WasUnblocklisted() const {
  // This information should not be relevant hereconst.
  return false;
}

bool PasswordDataForUI::IsMovableToAccountStore() const {
  // This is irrelevant for the generation conflict resolution bubble.
  return false;
}

void PasswordDataForUI::Save() {
  bubble_interaction_cb_.Run(true, pending_form_);
}

void PasswordDataForUI::Update(const PasswordForm&) {
  // The method is obsolete.
  NOTREACHED();
}

void PasswordDataForUI::OnUpdateUsernameFromPrompt(
    const std::u16string& new_username) {
  pending_form_.username_value = new_username;
}

void PasswordDataForUI::OnUpdatePasswordFromPrompt(
    const std::u16string& new_password) {
  // Ignore. The generated password can be edited in-place.
}

void PasswordDataForUI::OnNopeUpdateClicked() {
  bubble_interaction_cb_.Run(false, pending_form_);
}

void PasswordDataForUI::OnNeverClicked() {
  bubble_interaction_cb_.Run(false, pending_form_);
}

void PasswordDataForUI::OnNoInteraction(bool is_update) {
  bubble_interaction_cb_.Run(false, pending_form_);
}

void PasswordDataForUI::Blocklist() {}

void PasswordDataForUI::OnPasswordsRevealed() {}

void PasswordDataForUI::MoveCredentialsToAccountStore() {}

void PasswordDataForUI::BlockMovingCredentialsToAccountStore() {}

// Returns a form from |matches| that causes a name conflict with |generated|.
const PasswordForm* FindUsernameConflict(
    const PasswordForm& generated,
    const std::vector<const PasswordForm*>& matches) {
  for (const auto* form : matches) {
    if (form->username_value == generated.username_value)
      return form;
  }
  return nullptr;
}

// For the given |password| string, return a set of characters inside the string
// that satisfies |belongs_to_character_class| boolean predicate.
std::unordered_set<char16_t> FindSetOfCharacterClassInPassword(
    const std::u16string& password,
    const base::FunctionRef<bool(char16_t)>& belongs_to_character_class) {
  std::unordered_set<char16_t> result;
  base::ranges::copy_if(password, std::inserter(result, result.begin()),
                        belongs_to_character_class);
  return result;
}

void EmitUmaForCharacterClassChange(const std::string& uma_character_class,
                                    CharacterClassPresenceChange change) {
  base::UmaHistogramEnumeration(
      "PasswordGeneration.EditsInGeneratedPassword." + uma_character_class,
      change);
}

// For the given 2 strings calculates character class presence change, e.g if
// numerics were deleted('abcde123' => 'abcde') or only some characters
// belonging to the class are changed('abcde123' => 'acbde456'). Also emits UMA
// metrics on the change. Returns true if the character class was added or
// removed.
bool CalculateAndEmitPresenceChangeForCharacterClass(
    const std::u16string& suggested_password,
    const std::u16string& submitted_password,
    const base::FunctionRef<bool(char16_t)>& belongs_to_character_class,
    const std::string& uma_character_class) {
  std::unordered_set<char16_t> suggested_character_set =
      FindSetOfCharacterClassInPassword(suggested_password,
                                        belongs_to_character_class);
  std::unordered_set<char16_t> submitted_character_set =
      FindSetOfCharacterClassInPassword(submitted_password,
                                        belongs_to_character_class);

  if (suggested_character_set == submitted_character_set) {
    EmitUmaForCharacterClassChange(uma_character_class,
                                   CharacterClassPresenceChange::kNoChange);
    return false;
  }

  if (suggested_character_set.empty() != submitted_character_set.empty()) {
    EmitUmaForCharacterClassChange(uma_character_class,
                                   submitted_character_set.empty()
                                       ? CharacterClassPresenceChange::kDeleted
                                       : CharacterClassPresenceChange::kAdded);
    return true;
  }

  EmitUmaForCharacterClassChange(
      uma_character_class,
      CharacterClassPresenceChange::kSpecificCharactersChanged);
  return false;
}

// Emits UMA metrics on changes (character classes, length and together as a
// mask) between generated and submitted passwords.
void SendUmaHistogramsOnGeneratedPasswordAttributeChanges(
    const std::u16string& generated_password,
    const std::u16string& submitted_password) {
  bool letters_presence_changed =
      CalculateAndEmitPresenceChangeForCharacterClass(
          generated_password, submitted_password,
          password_manager_util::IsLetter, "Letters");
  // Also emit dedicated metrics for upper- and lowercase letters specifically
  // just in case there are websites that treat them differently (e.g. allow
  // only lowercase letters).
  CalculateAndEmitPresenceChangeForCharacterClass(
      generated_password, submitted_password,
      password_manager_util::IsUppercaseLetter, "Uppercase");
  CalculateAndEmitPresenceChangeForCharacterClass(
      generated_password, submitted_password,
      password_manager_util::IsLowercaseLetter, "Lowercase");
  bool numerics_presence_changed =
      CalculateAndEmitPresenceChangeForCharacterClass(
          generated_password, submitted_password,
          password_manager_util::IsNumeric, "Numerics");
  bool symbols_presence_changed =
      CalculateAndEmitPresenceChangeForCharacterClass(
          generated_password, submitted_password,
          password_manager_util::IsSpecialSymbol, "Symbols");

  bool length_changed = generated_password.size() != submitted_password.size();

  if (length_changed && !letters_presence_changed &&
      !numerics_presence_changed && !symbols_presence_changed) {
    // Only length changed and no character class presence is changed. If
    // character class presence is changed, length increase/decrease will
    // be a side effect. This metric will calculate whether our password is too
    // long or too short, so that it would be possible to adapt length if
    // necessary.
    base::UmaHistogramBoolean(
        "PasswordGeneration.EditsInGeneratedPassword.AlteredLengthIncreased",
        generated_password.size() < submitted_password.size());
  }

  // Make sure the order of attributes coincides with the order of attributes in
  // the metric.
  uint8_t attributes_mask =
      (length_changed << 0) | (letters_presence_changed << 1) |
      (numerics_presence_changed << 2) | (symbols_presence_changed << 3);
  if (attributes_mask != 0) {
    base::UmaHistogramExactLinear(
        "PasswordGeneration.EditsInGeneratedPassword.AttributesMask",
        attributes_mask, 16 /*exclusive_max*/);
  }
}

}  // namespace

PasswordGenerationManager::PasswordGenerationManager(
    PasswordManagerClient* client)
    : client_(client) {}

PasswordGenerationManager::~PasswordGenerationManager() = default;

std::unique_ptr<PasswordGenerationManager> PasswordGenerationManager::Clone()
    const {
  auto clone = std::make_unique<PasswordGenerationManager>(client_);
  clone->presaved_ = presaved_;
  return clone;
}

void PasswordGenerationManager::GeneratedPasswordAccepted(
    PasswordForm generated,
    const std::vector<const PasswordForm*>& non_federated_matches,
    const std::vector<const PasswordForm*>& federated_matches,
    base::WeakPtr<PasswordManagerDriver> driver) {
  // Clear the username value if there are already saved credentials with
  // the same username in order to prevent overwriting.
  if (FindUsernameConflict(generated, non_federated_matches)) {
    generated.username_value.clear();
    const PasswordForm* conflict =
        FindUsernameConflict(generated, non_federated_matches);
    if (conflict) {
      auto bubble_launcher = std::make_unique<PasswordDataForUI>(
          std::move(generated), non_federated_matches, federated_matches,
          base::BindRepeating(&PasswordGenerationManager::OnPresaveBubbleResult,
                              weak_factory_.GetWeakPtr(), std::move(driver)));
      client_->PromptUserToSaveOrUpdatePassword(std::move(bubble_launcher),
                                                true);
      return;
    }
  }
  driver->GeneratedPasswordAccepted(generated.password_value);
}

void PasswordGenerationManager::PresaveGeneratedPassword(
    PasswordForm generated,
    const std::vector<const PasswordForm*>& matches,
    FormSaver* form_saver) {
  DCHECK(!generated.password_value.empty());
  // Clear the username value if there are already saved credentials with
  // the same username in order to prevent overwriting.
  if (FindUsernameConflict(generated, matches))
    generated.username_value.clear();
  generated.date_created = base::Time::Now();
  if (presaved_) {
    form_saver->UpdateReplace(generated, {} /* matches */,
                              std::u16string() /* old_password */,
                              presaved_.value() /* old_primary_key */);
  } else {
    form_saver->Save(generated, {} /* matches */,
                     std::u16string() /* old_password */);
    initial_generated_password_ = generated.password_value;
  }
  presaved_ = std::move(generated);
}

void PasswordGenerationManager::PasswordNoLongerGenerated(
    FormSaver* form_saver) {
  DCHECK(presaved_);
  form_saver->Remove(*presaved_);
  presaved_.reset();
  initial_generated_password_.clear();
}

void PasswordGenerationManager::CommitGeneratedPassword(
    PasswordForm generated,
    const std::vector<const PasswordForm*>& matches,
    const std::u16string& old_password,
    FormSaver* form_saver) {
  DCHECK(presaved_);
  generated.date_last_used = base::Time::Now();
  generated.date_created = base::Time::Now();
  if (initial_generated_password_ != generated.password_value) {
    // If the generated password was edited, send UMA metrics on what kind of
    // changes were there.
    SendUmaHistogramsOnGeneratedPasswordAttributeChanges(
        initial_generated_password_, generated.password_value);
  }
  form_saver->UpdateReplace(generated, matches, old_password,
                            presaved_.value() /* old_primary_key */);
}

void PasswordGenerationManager::OnPresaveBubbleResult(
    const base::WeakPtr<PasswordManagerDriver>& driver,
    bool accepted,
    const PasswordForm& pending) {
  weak_factory_.InvalidateWeakPtrs();
  if (driver && accepted) {
    // See https://crbug.com/1210341 for when `driver` might be null due to a
    // compromised renderer.
    driver->GeneratedPasswordAccepted(pending.password_value);
  }
}

}  // namespace password_manager


text:
<?php

namespace FL\FacebookPagesBundle\Action\Auth;

use FL\FacebookPagesBundle\Storage\PageManagerStorageInterface;
use FL\FacebookPagesBundle\Storage\PageReviewStorageInterface;
use FL\FacebookPagesBundle\Storage\PageStorageInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;

class Clear
{
    /**
     * @var PageManagerStorageInterface
     */
    private $pageManagerStorage;

    /**
     * @var PageStorageInterface
     */
    private $pageStorage;

    /**
     * @var PageReviewStorageInterface
     */
    private $pageReviewStorage;

    /**
     * @var string
     */
    private $redirectAfterAuthorization;

    /**
     * @param PageManagerStorageInterface $pageManagerStorage
     * @param PageStorageInterface        $pageStorage
     * @param PageReviewStorageInterface  $pageReviewStore
     * @param string                      $redirectAfterAuthorization
     */
    public function __construct(
        PageManagerStorageInterface $pageManagerStorage,
        PageStorageInterface $pageStorage,
        PageReviewStorageInterface $pageReviewStore,
        string $redirectAfterAuthorization
    ) {
        $this->pageManagerStorage = $pageManagerStorage;
        $this->pageStorage = $pageStorage;
        $this->pageReviewStorage = $pageReviewStore;
        $this->redirectAfterAuthorization = $redirectAfterAuthorization;
    }

    /**
     * @return RedirectResponse
     */
    public function __invoke(): RedirectResponse
    {
        $this->pageStorage->clearAll();
        $this->pageManagerStorage->clearAll();
        $this->pageReviewStorage->clearAll();

        return new RedirectResponse($this->redirectAfterAuthorization);
    }
}


text:
make CC=$CXX
mkdir -p $PREFIX/bin
cp mstmap $PREFIX/bin