Commit d5abaad2 authored by felt's avatar felt Committed by Commit bot

Permission bubble should display URL with appropriate language pref

BUG=444586
TEST=
1. Change language to RTL language
2. Set chrome://flags/#enable-permissions-bubbles to 'Enabled'
3. Go to https://adrifelt.github.io/demos/bubble-demo.html
4. Verify that URL is displayed correctly

Review URL: https://codereview.chromium.org/882113004

Cr-Commit-Position: refs/heads/master@{#313795}
parent a137906a
......@@ -540,8 +540,10 @@ void BrowserView::InitStatusBubble() {
}
void BrowserView::InitPermissionBubbleView() {
std::string languages =
browser_->profile()->GetPrefs()->GetString(prefs::kAcceptLanguages);
permission_bubble_view_.reset(new PermissionBubbleViewViews(
GetLocationBarView()->location_icon_view()));
GetLocationBarView()->location_icon_view(), languages));
}
gfx::Rect BrowserView::GetToolbarBounds() const {
......
......@@ -175,6 +175,7 @@ class PermissionsBubbleDelegateView : public views::BubbleDelegateView,
PermissionsBubbleDelegateView(
views::View* anchor,
PermissionBubbleViewViews* owner,
const std::string& languages,
const std::vector<PermissionBubbleRequest*>& requests,
const std::vector<bool>& accept_state,
bool customization_mode);
......@@ -214,6 +215,7 @@ class PermissionsBubbleDelegateView : public views::BubbleDelegateView,
PermissionsBubbleDelegateView::PermissionsBubbleDelegateView(
views::View* anchor,
PermissionBubbleViewViews* owner,
const std::string& languages,
const std::vector<PermissionBubbleRequest*>& requests,
const std::vector<bool>& accept_state,
bool customization_mode)
......@@ -232,9 +234,8 @@ PermissionsBubbleDelegateView::PermissionsBubbleDelegateView(
SetLayoutManager(new views::BoxLayout(
views::BoxLayout::kVertical, kBubbleOuterMargin, 0, kItemMajorSpacing));
// TODO(gbillock): support other languages than English.
hostname_ = net::FormatUrl(requests[0]->GetRequestingHostname(),
"en",
languages,
net::kFormatUrlOmitUsernamePassword |
net::kFormatUrlOmitTrailingSlashOnBareHostname,
net::UnescapeRule::SPACES, NULL, NULL, NULL);
......@@ -417,10 +418,13 @@ void PermissionsBubbleDelegateView::OnPerformAction(
//////////////////////////////////////////////////////////////////////////////
// PermissionBubbleViewViews
PermissionBubbleViewViews::PermissionBubbleViewViews(views::View* anchor_view)
PermissionBubbleViewViews::PermissionBubbleViewViews(
views::View* anchor_view,
const std::string& languages)
: anchor_view_(anchor_view),
delegate_(NULL),
bubble_delegate_(NULL) {}
bubble_delegate_(NULL),
languages_(languages) {}
PermissionBubbleViewViews::~PermissionBubbleViewViews() {
if (delegate_)
......@@ -439,7 +443,7 @@ void PermissionBubbleViewViews::Show(
bubble_delegate_->Close();
bubble_delegate_ =
new PermissionsBubbleDelegateView(anchor_view_, this,
new PermissionsBubbleDelegateView(anchor_view_, this, languages_,
requests, values, customization_mode);
views::BubbleDelegateView::CreateBubble(bubble_delegate_)->Show();
bubble_delegate_->SizeToContents();
......
......@@ -5,6 +5,8 @@
#ifndef CHROME_BROWSER_UI_VIEWS_WEBSITE_SETTINGS_PERMISSIONS_BUBBLE_VIEW_H_
#define CHROME_BROWSER_UI_VIEWS_WEBSITE_SETTINGS_PERMISSIONS_BUBBLE_VIEW_H_
#include <string>
#include "base/compiler_specific.h"
#include "base/macros.h"
#include "chrome/browser/ui/website_settings/permission_bubble_view.h"
......@@ -17,7 +19,8 @@ class PermissionsBubbleDelegateView;
class PermissionBubbleViewViews : public PermissionBubbleView {
public:
explicit PermissionBubbleViewViews(views::View* anchor_view);
PermissionBubbleViewViews(views::View* anchor_view,
const std::string& languages);
~PermissionBubbleViewViews() override;
// PermissionBubbleView:
......@@ -39,6 +42,7 @@ class PermissionBubbleViewViews : public PermissionBubbleView {
views::View* anchor_view_;
Delegate* delegate_;
PermissionsBubbleDelegateView* bubble_delegate_;
const std::string languages_;
DISALLOW_COPY_AND_ASSIGN(PermissionBubbleViewViews);
};
......
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