Commit bb243c7e authored by Abigail Klein's avatar Abigail Klein Committed by Commit Bot

[Live Caption] Move caption_bubble to

chrome/browser/ui/views/accessibility.

Move caption_bubble.h and .cc from chrome/browser/accessibility to
chrome/browser/ui/views/accessibility. The CaptionBubble is a View so
it should be in the ui/views directory. The CaptionBubble has as its
anchor view the contents_web_view from BrowserView. BrowserView is in
ui/views, so CaptionBubble too should be limited to only OS's that
include ui/views.

Bug: 1055150
Change-Id: If2c291ce25c5020fa8bd1e222fccb345626b4078
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2119758Reviewed-by: default avatarDominic Mazzoni <dmazzoni@chromium.org>
Reviewed-by: default avatarElly Fong-Jones <ellyjones@chromium.org>
Commit-Queue: Abigail Klein <abigailbklein@google.com>
Cr-Commit-Position: refs/heads/master@{#754493}
parent 0b14d31d
......@@ -3088,8 +3088,6 @@ jumbo_static_library("browser") {
}
} else { # !is_android
sources += [
"accessibility/caption_bubble.cc",
"accessibility/caption_bubble.h",
"accessibility/invert_bubble_prefs.cc",
"accessibility/invert_bubble_prefs.h",
"apps/app_service/app_icon_factory.cc",
......
......@@ -2765,6 +2765,8 @@ jumbo_static_library("ui") {
# This test header is included because it contains forward declarations
# needed for "friend" statements for use in tests.
"translate/translate_bubble_test_utils.h",
"views/accessibility/caption_bubble.cc",
"views/accessibility/caption_bubble.h",
"views/accessibility/invert_bubble_view.cc",
"views/accessibility/invert_bubble_view.h",
"views/accessibility/non_accessible_image_view.cc",
......
......@@ -2,19 +2,16 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/accessibility/caption_bubble.h"
#include "chrome/browser/ui/views/accessibility/caption_bubble.h"
#include <memory>
#include <string>
#include <utility>
#include <vector>
#include "base/strings/utf_string_conversions.h"
#include "ui/base/hit_test.h"
#include "ui/gfx/geometry/insets.h"
#include "ui/views/bubble/bubble_dialog_delegate_view.h"
#include "ui/views/bubble/bubble_frame_view.h"
#include "ui/views/controls/label.h"
#include "ui/views/layout/box_layout.h"
// CaptionBubble implementation of BubbleFrameView.
......@@ -68,20 +65,19 @@ void CaptionBubble::Init() {
set_color(SK_ColorGRAY);
set_close_on_deactivate(false);
label_ = new views::Label();
label_->SetMultiLine(true);
label_->SetMaxLines(2);
label_.SetMultiLine(true);
label_.SetMaxLines(2);
int max_width = GetAnchorView()->width() * 0.8;
label_->SetMaximumWidth(max_width);
label_->SetEnabledColor(SK_ColorWHITE);
label_->SetBackgroundColor(SK_ColorTRANSPARENT);
label_->SetHorizontalAlignment(gfx::HorizontalAlignment::ALIGN_LEFT);
label_->SetLineHeight(18);
label_.SetMaximumWidth(max_width);
label_.SetEnabledColor(SK_ColorWHITE);
label_.SetBackgroundColor(SK_ColorTRANSPARENT);
label_.SetHorizontalAlignment(gfx::HorizontalAlignment::ALIGN_LEFT);
label_.SetLineHeight(18);
std::vector<std::string> font_names = {"Arial", "Helvetica"};
gfx::FontList* font_list = new gfx::FontList(
font_names, gfx::Font::FontStyle::NORMAL, 14, gfx::Font::Weight::NORMAL);
label_->SetFontList(*font_list);
label_.SetFontList(*font_list);
// Add some dummy text while this is in development.
std::string text =
......@@ -90,9 +86,9 @@ void CaptionBubble::Init() {
"life, which have received widespread media coverage. At age 14, Swift "
"became the youngest artist signed by the Sony/ATV Music publishing "
"house and, at age 15, she signed her first record deal.";
label_->SetText(base::ASCIIToUTF16(text));
label_.SetText(base::ASCIIToUTF16(text));
AddChildView(label_);
AddChildView(&label_);
}
bool CaptionBubble::ShouldShowCloseButton() const {
......@@ -111,7 +107,7 @@ views::NonClientFrameView* CaptionBubble::CreateNonClientFrameView(
}
void CaptionBubble::SetText(const std::string& text) {
label_->SetText(base::ASCIIToUTF16(text));
label_.SetText(base::ASCIIToUTF16(text));
}
} // namespace captions
......@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_ACCESSIBILITY_CAPTION_BUBBLE_H_
#define CHROME_BROWSER_ACCESSIBILITY_CAPTION_BUBBLE_H_
#ifndef CHROME_BROWSER_UI_VIEWS_ACCESSIBILITY_CAPTION_BUBBLE_H_
#define CHROME_BROWSER_UI_VIEWS_ACCESSIBILITY_CAPTION_BUBBLE_H_
#include <string>
......@@ -22,6 +22,8 @@ class CaptionBubble : public views::BubbleDialogDelegateView {
public:
explicit CaptionBubble(views::View* anchor);
~CaptionBubble() override;
CaptionBubble(const CaptionBubble&) = delete;
CaptionBubble& operator=(const CaptionBubble&) = delete;
// Create and show the caption bubble.
static void CreateAndShow(views::View* anchor);
......@@ -36,11 +38,9 @@ class CaptionBubble : public views::BubbleDialogDelegateView {
views::Widget* widget) override;
private:
views::Label* label_;
DISALLOW_COPY_AND_ASSIGN(CaptionBubble);
views::Label label_;
};
} // namespace captions
#endif // CHROME_BROWSER_ACCESSIBILITY_CAPTION_BUBBLE_H_
#endif // CHROME_BROWSER_UI_VIEWS_ACCESSIBILITY_CAPTION_BUBBLE_H_
......@@ -27,7 +27,6 @@
#include "base/threading/thread_task_runner_handle.h"
#include "build/build_config.h"
#include "chrome/app/chrome_command_ids.h"
#include "chrome/browser/accessibility/caption_bubble.h"
#include "chrome/browser/app_mode/app_mode_utils.h"
#include "chrome/browser/banners/app_banner_manager.h"
#include "chrome/browser/browser_process.h"
......@@ -74,6 +73,7 @@
#include "chrome/browser/ui/ui_features.h"
#include "chrome/browser/ui/view_ids.h"
#include "chrome/browser/ui/views/accelerator_table.h"
#include "chrome/browser/ui/views/accessibility/caption_bubble.h"
#include "chrome/browser/ui/views/accessibility/invert_bubble_view.h"
#include "chrome/browser/ui/views/autofill/autofill_bubble_handler_impl.h"
#include "chrome/browser/ui/views/bookmarks/bookmark_bar_view.h"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment