<commit_before>// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Copyright (c) 2016 Intel Corporation. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "xwalk/runtime/browser/ui/desktop/exclusive_access_bubble_views.h"

#include <algorithm>
#include <vector>

#include "base/i18n/case_conversion.h"
#include "base/message_loop/message_loop.h"
#include "base/strings/string_split.h"
#include "base/strings/utf_string_conversions.h"
#include "content/public/browser/notification_service.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/events/keycodes/keyboard_codes.h"
#include "ui/gfx/animation/slide_animation.h"
#include "ui/gfx/canvas.h"
#include "ui/gfx/screen.h"
#include "ui/native_theme/native_theme.h"
#include "ui/strings/grit/ui_strings.h"
#include "ui/views/bubble/bubble_border.h"
#include "ui/views/controls/button/label_button.h"
#include "ui/views/controls/link.h"
#include "ui/views/controls/link_listener.h"
#include "ui/views/layout/box_layout.h"
#include "ui/views/view.h"
#include "ui/views/widget/widget.h"
#include "url/gurl.h"
#include "xwalk/grit/xwalk_resources.h"
#include "xwalk/runtime/browser/ui/desktop/exclusive_access_bubble_views_context.h"

#if defined(OS_WIN)
#include "ui/base/l10n/l10n_util_win.h"
#endif

namespace xwalk {

// ExclusiveAccessView ---------------------------------------------------------
namespace {

  // Space between the site info label and the buttons / link.
  const int kMiddlePaddingPx = 30;

  // Opacity of the background (out of 255).
  const unsigned char kBackgroundOpacity = 180;

}  // namespace

class ExclusiveAccessBubbleViews::ExclusiveAccessView
    : public views::View,
      public views::ButtonListener,
      public views::LinkListener {
 public:
  ExclusiveAccessView(ExclusiveAccessBubbleViews* bubble,
                      const base::string16& accelerator,
                      ExclusiveAccessBubble::Type bubble_type);
  ~ExclusiveAccessView() override;

  // views::ButtonListener
  void ButtonPressed(views::Button* sender, const ui::Event& event) override;

  // views::LinkListener
  void LinkClicked(views::Link* source, int event_flags) override;

  void UpdateContent(ExclusiveAccessBubble::Type bubble_type);

 private:
  ExclusiveAccessBubbleViews* bubble_;

  // Clickable hint text for exiting fullscreen mode. (Non-simplified mode
  // only.)
  views::Link* link_;
  // Informational label: 'www.foo.com has gone fullscreen'. (Non-simplified
  // mode only.)
  views::Label* message_label_;
  const base::string16 browser_fullscreen_exit_accelerator_;
  DISALLOW_COPY_AND_ASSIGN(ExclusiveAccessView);
};

ExclusiveAccessBubbleViews::ExclusiveAccessView::ExclusiveAccessView(
    ExclusiveAccessBubbleViews* bubble,
    const base::string16& accelerator,
    ExclusiveAccessBubble::Type bubble_type)
    : bubble_(bubble),
      link_(nullptr),
      message_label_(nullptr),
      browser_fullscreen_exit_accelerator_(accelerator) {
  views::BubbleBorder::Shadow shadow_type = views::BubbleBorder::BIG_SHADOW;
#if defined(OS_LINUX)
  // Use a smaller shadow on Linux (including ChromeOS) as the shadow assets can
  // overlap each other in a fullscreen notification bubble.
  // See http://crbug.com/462983.
  shadow_type = views::BubbleBorder::SMALL_SHADOW;
#endif

  SkColor background_color = SkColorSetA(SK_ColorBLACK, kBackgroundOpacity);
  SkColor foreground_color = SK_ColorWHITE;
  scoped_ptr<views::BubbleBorder> bubble_border(new views::BubbleBorder(
      views::BubbleBorder::NONE, shadow_type, background_color));
  set_background(new views::BubbleBackground(bubble_border.get()));
  SetBorder(bubble_border.Pass());
  SetFocusable(false);

  ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
  const gfx::FontList& medium_font_list =
      rb.GetFontList(ui::ResourceBundle::MediumFont);

  message_label_ = new views::Label(base::string16(), medium_font_list);
  message_label_->SetEnabledColor(foreground_color);
  message_label_->SetBackgroundColor(background_color);

  link_ = new views::Link();
  link_->SetFocusable(false);
  link_->set_listener(this);
  link_->SetFontList(medium_font_list);
  link_->SetPressedColor(foreground_color);
  link_->SetEnabledColor(foreground_color);
  link_->SetBackgroundColor(background_color);
  link_->SetVisible(false);

  DCHECK(message_label_);
  AddChildView(message_label_);
  AddChildView(link_);

  views::BoxLayout* layout = new views::BoxLayout(
      views::BoxLayout::kHorizontal, kPaddingPx, kPaddingPx, kMiddlePaddingPx);
  SetLayoutManager(layout);<commit_msg>Use std::move instead of scoped_ptr::Pass().<commit_after>// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Copyright (c) 2016 Intel Corporation. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "xwalk/runtime/browser/ui/desktop/exclusive_access_bubble_views.h"

#include <algorithm>
#include <vector>

#include "base/i18n/case_conversion.h"
#include "base/message_loop/message_loop.h"
#include "base/strings/string_split.h"
#include "base/strings/utf_string_conversions.h"
#include "content/public/browser/notification_service.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/events/keycodes/keyboard_codes.h"
#include "ui/gfx/animation/slide_animation.h"
#include "ui/gfx/canvas.h"
#include "ui/gfx/screen.h"
#include "ui/native_theme/native_theme.h"
#include "ui/strings/grit/ui_strings.h"
#include "ui/views/bubble/bubble_border.h"
#include "ui/views/controls/button/label_button.h"
#include "ui/views/controls/link.h"
#include "ui/views/controls/link_listener.h"
#include "ui/views/layout/box_layout.h"
#include "ui/views/view.h"
#include "ui/views/widget/widget.h"
#include "url/gurl.h"
#include "xwalk/grit/xwalk_resources.h"
#include "xwalk/runtime/browser/ui/desktop/exclusive_access_bubble_views_context.h"

#if defined(OS_WIN)
#include "ui/base/l10n/l10n_util_win.h"
#endif

namespace xwalk {

// ExclusiveAccessView ---------------------------------------------------------
namespace {

  // Space between the site info label and the buttons / link.
  const int kMiddlePaddingPx = 30;

  // Opacity of the background (out of 255).
  const unsigned char kBackgroundOpacity = 180;

}  // namespace

class ExclusiveAccessBubbleViews::ExclusiveAccessView
    : public views::View,
      public views::ButtonListener,
      public views::LinkListener {
 public:
  ExclusiveAccessView(ExclusiveAccessBubbleViews* bubble,
                      const base::string16& accelerator,
                      ExclusiveAccessBubble::Type bubble_type);
  ~ExclusiveAccessView() override;

  // views::ButtonListener
  void ButtonPressed(views::Button* sender, const ui::Event& event) override;

  // views::LinkListener
  void LinkClicked(views::Link* source, int event_flags) override;

  void UpdateContent(ExclusiveAccessBubble::Type bubble_type);

 private:
  ExclusiveAccessBubbleViews* bubble_;

  // Clickable hint text for exiting fullscreen mode. (Non-simplified mode
  // only.)
  views::Link* link_;
  // Informational label: 'www.foo.com has gone fullscreen'. (Non-simplified
  // mode only.)
  views::Label* message_label_;
  const base::string16 browser_fullscreen_exit_accelerator_;
  DISALLOW_COPY_AND_ASSIGN(ExclusiveAccessView);
};

ExclusiveAccessBubbleViews::ExclusiveAccessView::ExclusiveAccessView(
    ExclusiveAccessBubbleViews* bubble,
    const base::string16& accelerator,
    ExclusiveAccessBubble::Type bubble_type)
    : bubble_(bubble),
      link_(nullptr),
      message_label_(nullptr),
      browser_fullscreen_exit_accelerator_(accelerator) {
  views::BubbleBorder::Shadow shadow_type = views::BubbleBorder::BIG_SHADOW;
#if defined(OS_LINUX)
  // Use a smaller shadow on Linux (including ChromeOS) as the shadow assets can
  // overlap each other in a fullscreen notification bubble.
  // See http://crbug.com/462983.
  shadow_type = views::BubbleBorder::SMALL_SHADOW;
#endif

  SkColor background_color = SkColorSetA(SK_ColorBLACK, kBackgroundOpacity);
  SkColor foreground_color = SK_ColorWHITE;
  scoped_ptr<views::BubbleBorder> bubble_border(new views::BubbleBorder(
      views::BubbleBorder::NONE, shadow_type, background_color));
  set_background(new views::BubbleBackground(bubble_border.get()));
  SetBorder(std::move(bubble_border));
  SetFocusable(false);

  ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
  const gfx::FontList& medium_font_list =
      rb.GetFontList(ui::ResourceBundle::MediumFont);

  message_label_ = new views::Label(base::string16(), medium_font_list);
  message_label_->SetEnabledColor(foreground_color);
  message_label_->SetBackgroundColor(background_color);

  link_ = new views::Link();
  link_->SetFocusable(false);
  link_->set_listener(this);
  link_->SetFontList(medium_font_list);
  link_->SetPressedColor(foreground_color);
  link_->SetEnabledColor(foreground_color);
  link_->SetBackgroundColor(background_color);
  link_->SetVisible(false);

  DCHECK(message_label_);
  AddChildView(message_label_);
  AddChildView(link_);

  views::BoxLayout* layout = new views::BoxLayout(
      views::BoxLayout::kHorizontal, kPaddingPx, kPaddingPx, kMiddlePaddingPx);
  SetLayoutManager(layout);
{'fraction_non_alphanumeric': 0.12705483084102237, 'fraction_numerical': 0.008484462827447237, 'mean_word_length': 5.048749198203977, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '7485421', 'n_tokens_mistral': 3057, 'n_tokens_neox': 2944, 'n_words': 575}