Commit 3941fd2b authored by Ryan Hansberry's avatar Ryan Hansberry Committed by Commit Bot

[CrOS MultiDevice] Remove unusued ProximityAuth code.

Change-Id: I0c9c61c9671e6cbfebf419f1f148f268d79eb5e4
Reviewed-on: https://chromium-review.googlesource.com/c/1370855Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Commit-Queue: Ryan Hansberry <hansberry@chromium.org>
Cr-Commit-Position: refs/heads/master@{#615596}
parent cd964bbc
...@@ -168,7 +168,6 @@ jumbo_split_static_library("ui") { ...@@ -168,7 +168,6 @@ jumbo_split_static_library("ui") {
"profile_error_dialog.cc", "profile_error_dialog.cc",
"profile_error_dialog.h", "profile_error_dialog.h",
"protocol_dialog_delegate.h", "protocol_dialog_delegate.h",
"proximity_auth/proximity_auth_error_bubble.h",
"recently_audible_helper.cc", "recently_audible_helper.cc",
"recently_audible_helper.h", "recently_audible_helper.h",
"screen_capture_notification_ui.h", "screen_capture_notification_ui.h",
...@@ -2705,8 +2704,6 @@ jumbo_split_static_library("ui") { ...@@ -2705,8 +2704,6 @@ jumbo_split_static_library("ui") {
"views/profiles/avatar_toolbar_button.h", "views/profiles/avatar_toolbar_button.h",
"views/profiles/signin_view_controller_delegate_views.cc", "views/profiles/signin_view_controller_delegate_views.cc",
"views/profiles/signin_view_controller_delegate_views.h", "views/profiles/signin_view_controller_delegate_views.h",
"views/proximity_auth/proximity_auth_error_bubble_view.cc",
"views/proximity_auth/proximity_auth_error_bubble_view.h",
"views/relaunch_notification/relaunch_notification_controller.cc", "views/relaunch_notification/relaunch_notification_controller.cc",
"views/relaunch_notification/relaunch_notification_controller.h", "views/relaunch_notification/relaunch_notification_controller.h",
"views/relaunch_notification/relaunch_notification_metrics.cc", "views/relaunch_notification/relaunch_notification_metrics.cc",
......
tengs@chromium.org
xiyuan@chromium.org
# COMPONENT: UI>ProximityAuth
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_UI_PROXIMITY_AUTH_PROXIMITY_AUTH_ERROR_BUBBLE_H_
#define CHROME_BROWSER_UI_PROXIMITY_AUTH_PROXIMITY_AUTH_ERROR_BUBBLE_H_
#include "base/macros.h"
#include "base/strings/string16.h"
#include "url/gurl.h"
namespace content {
class WebContents;
}
namespace gfx {
class Range;
class Rect;
}
// Shows an error bubble with the given |message|, with an arrow pointing to the
// |anchor_rect|. If the |link_range| is non-empty, then that range of the
// |message| is drawn as a link with |link_url| as the target. When the link is
// clicked, the target URL opens in a new tab off of the given |web_contents|.
void ShowProximityAuthErrorBubble(const base::string16& message,
const gfx::Range& link_range,
const GURL& link_url,
const gfx::Rect& anchor_rect,
content::WebContents* web_contents);
// Hides the currently displayed error bubble, if any.
void HideProximityAuthErrorBubble();
#endif // CHROME_BROWSER_UI_PROXIMITY_AUTH_PROXIMITY_AUTH_ERROR_BUBBLE_H_
tengs@chromium.org
xiyuan@chromium.org
# COMPONENT: UI>ProximityAuth
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/ui/views/proximity_auth/proximity_auth_error_bubble_view.h"
#include "base/lazy_instance.h"
#include "base/strings/string_util.h"
#include "build/build_config.h"
#include "chrome/browser/ui/browser_dialogs.h"
#include "chrome/browser/ui/proximity_auth/proximity_auth_error_bubble.h"
#include "chrome/grit/theme_resources.h"
#include "content/public/browser/page_navigator.h"
#include "content/public/browser/web_contents.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/range/range.h"
#include "ui/views/bubble/bubble_border.h"
#include "ui/views/controls/image_view.h"
#include "ui/views/controls/styled_label.h"
#include "ui/views/layout/grid_layout.h"
#include "ui/views/widget/widget.h"
using base::WeakPtr;
namespace {
// The bubble's content area width, in device-independent pixels.
const int kBubbleWidth = 296;
// The padding between columns in the bubble.
const int kBubbleIntraColumnPadding = 6;
// The currently visible bubble, or null if there isn't one.
base::LazyInstance<WeakPtr<ProximityAuthErrorBubbleView>>::Leaky g_bubble =
LAZY_INSTANCE_INITIALIZER;
} // namespace
void ShowProximityAuthErrorBubble(const base::string16& message,
const gfx::Range& link_range,
const GURL& link_url,
const gfx::Rect& anchor_rect,
content::WebContents* web_contents) {
// Only one error bubble should be visible at a time.
// Note that it suffices to check just the |message| for equality, because the
// |link_range| and |link_url| are always the same for a given |message|
// value, and there is no way for the bubble's |anchor_rect| to change without
// dismissing the existing bubble.
if (g_bubble.Get() && g_bubble.Get()->message() == message)
return;
HideProximityAuthErrorBubble();
g_bubble.Get() = ProximityAuthErrorBubbleView::Create(
message, link_range, link_url, anchor_rect, web_contents);
views::BubbleDialogDelegateView::CreateBubble(g_bubble.Get().get())->Show();
}
void HideProximityAuthErrorBubble() {
if (g_bubble.Get())
g_bubble.Get()->GetWidget()->Close();
}
// static
WeakPtr<ProximityAuthErrorBubbleView> ProximityAuthErrorBubbleView::Create(
const base::string16& message,
const gfx::Range& link_range,
const GURL& link_url,
const gfx::Rect& anchor_rect,
content::WebContents* web_contents) {
// The created bubble is owned by the views hierarchy.
ProximityAuthErrorBubbleView* bubble = new ProximityAuthErrorBubbleView(
message, link_range, link_url, anchor_rect, web_contents);
return bubble->weak_ptr_factory_.GetWeakPtr();
}
ProximityAuthErrorBubbleView::ProximityAuthErrorBubbleView(
const base::string16& message,
const gfx::Range& link_range,
const GURL& link_url,
const gfx::Rect& anchor_rect,
content::WebContents* web_contents)
: BubbleDialogDelegateView(nullptr, views::BubbleBorder::LEFT_TOP),
WebContentsObserver(web_contents),
message_(message),
link_range_(link_range),
link_url_(link_url),
weak_ptr_factory_(this) {
SetAnchorRect(anchor_rect);
chrome::RecordDialogCreation(chrome::DialogIdentifier::PROXIMITY_AUTH_ERROR);
}
void ProximityAuthErrorBubbleView::Init() {
// Define this grid layout for the bubble:
// ----------------------------
// | icon | padding | message |
// ----------------------------
views::GridLayout* layout =
SetLayoutManager(std::make_unique<views::GridLayout>(this));
views::ColumnSet* columns = layout->AddColumnSet(0);
columns->AddColumn(views::GridLayout::LEADING, views::GridLayout::LEADING,
views::GridLayout::kFixedSize, views::GridLayout::USE_PREF,
0, 0);
columns->AddPaddingColumn(views::GridLayout::kFixedSize,
kBubbleIntraColumnPadding);
columns->AddColumn(views::GridLayout::LEADING, views::GridLayout::LEADING,
views::GridLayout::kFixedSize, views::GridLayout::USE_PREF,
0, 0);
// Construct the views.
std::unique_ptr<views::ImageView> warning_icon(new views::ImageView());
ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
warning_icon->SetImage(*bundle.GetImageSkiaNamed(IDR_WARNING));
std::unique_ptr<views::StyledLabel> label(
new views::StyledLabel(message_, this));
if (!link_range_.is_empty()) {
label->AddStyleRange(link_range_,
views::StyledLabel::RangeStyleInfo::CreateForLink());
}
label->SizeToFit(kBubbleWidth - margins().width() -
warning_icon->size().width() - kBubbleIntraColumnPadding);
// Lay out the views.
layout->StartRow(views::GridLayout::kFixedSize, 0);
layout->AddView(warning_icon.release());
layout->AddView(label.release());
}
ProximityAuthErrorBubbleView::~ProximityAuthErrorBubbleView() {}
int ProximityAuthErrorBubbleView::GetDialogButtons() const {
return ui::DIALOG_BUTTON_NONE;
}
void ProximityAuthErrorBubbleView::WebContentsDestroyed() {
GetWidget()->Close();
}
void ProximityAuthErrorBubbleView::StyledLabelLinkClicked(
views::StyledLabel* label,
const gfx::Range& range,
int event_flags) {
if (!web_contents())
return;
web_contents()->OpenURL(content::OpenURLParams(
link_url_, content::Referrer(), WindowOpenDisposition::NEW_FOREGROUND_TAB,
ui::PAGE_TRANSITION_LINK, false));
}
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_UI_VIEWS_PROXIMITY_AUTH_PROXIMITY_AUTH_ERROR_BUBBLE_VIEW_H_
#define CHROME_BROWSER_UI_VIEWS_PROXIMITY_AUTH_PROXIMITY_AUTH_ERROR_BUBBLE_VIEW_H_
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "base/strings/string16.h"
#include "content/public/browser/web_contents_observer.h"
#include "ui/gfx/range/range.h"
#include "ui/views/bubble/bubble_dialog_delegate_view.h"
#include "ui/views/controls/styled_label_listener.h"
#include "url/gurl.h"
namespace content {
class WebContents;
}
namespace gfx {
class Rect;
}
class ProximityAuthErrorBubbleView : public views::BubbleDialogDelegateView,
public content::WebContentsObserver,
public views::StyledLabelListener {
public:
// Shows an error bubble with the given |message|, with an arrow pointing to
// the |anchor_rect|. If the |link_range| is non-empty, then that range of the
// |message| is drawn as a link with |link_url| as the target. When the link
// is clicked, the target URL opens in a new tab off of the given
// |web_contents|. Returns a weak pointer to the created bubble.
static base::WeakPtr<ProximityAuthErrorBubbleView> Create(
const base::string16& message,
const gfx::Range& link_range,
const GURL& link_url,
const gfx::Rect& anchor_rect,
content::WebContents* web_contents);
const base::string16& message() { return message_; }
private:
ProximityAuthErrorBubbleView(const base::string16& message,
const gfx::Range& link_range,
const GURL& link_url,
const gfx::Rect& anchor_rect,
content::WebContents* web_contents);
~ProximityAuthErrorBubbleView() override;
// views::BubbleDialogDelegateView:
int GetDialogButtons() const override;
void Init() override;
// content::WebContentsObserver:
void WebContentsDestroyed() override;
// views::StyledLabelListener:
void StyledLabelLinkClicked(views::StyledLabel* label,
const gfx::Range& range,
int event_flags) override;
// The message text shown in the bubble.
const base::string16 message_;
// The range of text within |message_| that should be linkified.
const gfx::Range link_range_;
// The target URL of the link shown in the bubble's error message. Ignored if
// there is no link.
const GURL link_url_;
// Vends weak pointers to |this| instance.
base::WeakPtrFactory<ProximityAuthErrorBubbleView> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(ProximityAuthErrorBubbleView);
};
#endif // CHROME_BROWSER_UI_VIEWS_PROXIMITY_AUTH_PROXIMITY_AUTH_ERROR_BUBBLE_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