Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(72)

Side by Side Diff: chrome/browser/ui/views/website_settings/permissions_bubble_view.cc

Issue 882113004: Permission bubble should display URL with appropriate language pref (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: dcheck Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/ui/views/website_settings/permissions_bubble_view.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/views/website_settings/permissions_bubble_view.h" 5 #include "chrome/browser/ui/views/website_settings/permissions_bubble_view.h"
6 6
7 #include "base/prefs/pref_service.h"
7 #include "base/strings/string16.h" 8 #include "base/strings/string16.h"
9 #include "chrome/browser/profiles/profile.h"
8 #include "chrome/browser/ui/views/website_settings/permission_selector_view.h" 10 #include "chrome/browser/ui/views/website_settings/permission_selector_view.h"
9 #include "chrome/browser/ui/views/website_settings/permission_selector_view_obse rver.h" 11 #include "chrome/browser/ui/views/website_settings/permission_selector_view_obse rver.h"
10 #include "chrome/browser/ui/website_settings/permission_bubble_request.h" 12 #include "chrome/browser/ui/website_settings/permission_bubble_request.h"
13 #include "chrome/common/pref_names.h"
11 #include "chrome/grit/generated_resources.h" 14 #include "chrome/grit/generated_resources.h"
12 #include "net/base/net_util.h" 15 #include "net/base/net_util.h"
13 #include "ui/accessibility/ax_view_state.h" 16 #include "ui/accessibility/ax_view_state.h"
14 #include "ui/base/l10n/l10n_util.h" 17 #include "ui/base/l10n/l10n_util.h"
15 #include "ui/base/models/combobox_model.h" 18 #include "ui/base/models/combobox_model.h"
16 #include "ui/base/resource/resource_bundle.h" 19 #include "ui/base/resource/resource_bundle.h"
17 #include "ui/gfx/text_constants.h" 20 #include "ui/gfx/text_constants.h"
18 #include "ui/views/bubble/bubble_delegate.h" 21 #include "ui/views/bubble/bubble_delegate.h"
19 #include "ui/views/controls/button/checkbox.h" 22 #include "ui/views/controls/button/checkbox.h"
20 #include "ui/views/controls/button/label_button.h" 23 #include "ui/views/controls/button/label_button.h"
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 /////////////////////////////////////////////////////////////////////////////// 171 ///////////////////////////////////////////////////////////////////////////////
169 // View implementation for the permissions bubble. 172 // View implementation for the permissions bubble.
170 class PermissionsBubbleDelegateView : public views::BubbleDelegateView, 173 class PermissionsBubbleDelegateView : public views::BubbleDelegateView,
171 public views::ButtonListener, 174 public views::ButtonListener,
172 public views::ComboboxListener, 175 public views::ComboboxListener,
173 public PermissionCombobox::Listener { 176 public PermissionCombobox::Listener {
174 public: 177 public:
175 PermissionsBubbleDelegateView( 178 PermissionsBubbleDelegateView(
176 views::View* anchor, 179 views::View* anchor,
177 PermissionBubbleViewViews* owner, 180 PermissionBubbleViewViews* owner,
181 Profile* profile,
178 const std::vector<PermissionBubbleRequest*>& requests, 182 const std::vector<PermissionBubbleRequest*>& requests,
179 const std::vector<bool>& accept_state, 183 const std::vector<bool>& accept_state,
180 bool customization_mode); 184 bool customization_mode);
181 ~PermissionsBubbleDelegateView() override; 185 ~PermissionsBubbleDelegateView() override;
182 186
183 void Close(); 187 void Close();
184 void SizeToContents(); 188 void SizeToContents();
185 189
186 // BubbleDelegateView: 190 // BubbleDelegateView:
187 bool ShouldShowCloseButton() const override; 191 bool ShouldShowCloseButton() const override;
(...skipping 19 matching lines...) Expand all
207 base::string16 hostname_; 211 base::string16 hostname_;
208 scoped_ptr<PermissionMenuModel> menu_button_model_; 212 scoped_ptr<PermissionMenuModel> menu_button_model_;
209 std::vector<PermissionCombobox*> customize_comboboxes_; 213 std::vector<PermissionCombobox*> customize_comboboxes_;
210 214
211 DISALLOW_COPY_AND_ASSIGN(PermissionsBubbleDelegateView); 215 DISALLOW_COPY_AND_ASSIGN(PermissionsBubbleDelegateView);
212 }; 216 };
213 217
214 PermissionsBubbleDelegateView::PermissionsBubbleDelegateView( 218 PermissionsBubbleDelegateView::PermissionsBubbleDelegateView(
215 views::View* anchor, 219 views::View* anchor,
216 PermissionBubbleViewViews* owner, 220 PermissionBubbleViewViews* owner,
221 Profile* profile,
217 const std::vector<PermissionBubbleRequest*>& requests, 222 const std::vector<PermissionBubbleRequest*>& requests,
218 const std::vector<bool>& accept_state, 223 const std::vector<bool>& accept_state,
219 bool customization_mode) 224 bool customization_mode)
220 : views::BubbleDelegateView(anchor, views::BubbleBorder::TOP_LEFT), 225 : views::BubbleDelegateView(anchor, views::BubbleBorder::TOP_LEFT),
221 owner_(owner), 226 owner_(owner),
222 allow_(NULL), 227 allow_(NULL),
223 deny_(NULL), 228 deny_(NULL),
224 allow_combobox_(NULL) { 229 allow_combobox_(NULL) {
225 DCHECK(!requests.empty()); 230 DCHECK(!requests.empty());
226 231
227 RemoveAllChildViews(true); 232 RemoveAllChildViews(true);
228 customize_comboboxes_.clear(); 233 customize_comboboxes_.clear();
229 set_close_on_esc(false); 234 set_close_on_esc(false);
230 set_close_on_deactivate(false); 235 set_close_on_deactivate(false);
231 236
232 SetLayoutManager(new views::BoxLayout( 237 SetLayoutManager(new views::BoxLayout(
233 views::BoxLayout::kVertical, kBubbleOuterMargin, 0, kItemMajorSpacing)); 238 views::BoxLayout::kVertical, kBubbleOuterMargin, 0, kItemMajorSpacing));
234 239
235 // TODO(gbillock): support other languages than English. 240 DCHECK(profile);
241 std::string languages =
242 profile->GetPrefs()->GetString(prefs::kAcceptLanguages);
sky 2015/01/29 17:40:44 One question though. Can PermissionBubbleViewViews
felt 2015/01/29 19:51:13 Looked into this. Changing the language will promp
236 hostname_ = net::FormatUrl(requests[0]->GetRequestingHostname(), 243 hostname_ = net::FormatUrl(requests[0]->GetRequestingHostname(),
237 "en", 244 languages,
238 net::kFormatUrlOmitUsernamePassword | 245 net::kFormatUrlOmitUsernamePassword |
239 net::kFormatUrlOmitTrailingSlashOnBareHostname, 246 net::kFormatUrlOmitTrailingSlashOnBareHostname,
240 net::UnescapeRule::SPACES, NULL, NULL, NULL); 247 net::UnescapeRule::SPACES, NULL, NULL, NULL);
241 248
242 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); 249 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
243 for (size_t index = 0; index < requests.size(); index++) { 250 for (size_t index = 0; index < requests.size(); index++) {
244 DCHECK(index < accept_state.size()); 251 DCHECK(index < accept_state.size());
245 // The row is laid out containing a leading-aligned label area and a 252 // The row is laid out containing a leading-aligned label area and a
246 // trailing column which will be filled during customization with a 253 // trailing column which will be filled during customization with a
247 // combobox. 254 // combobox.
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 owner_->SetCustomizationMode(); 417 owner_->SetCustomizationMode();
411 else if (combobox->selected_index() == 418 else if (combobox->selected_index() ==
412 CustomizeAllowComboboxModel::INDEX_ALLOW) 419 CustomizeAllowComboboxModel::INDEX_ALLOW)
413 owner_->Accept(); 420 owner_->Accept();
414 } 421 }
415 } 422 }
416 423
417 ////////////////////////////////////////////////////////////////////////////// 424 //////////////////////////////////////////////////////////////////////////////
418 // PermissionBubbleViewViews 425 // PermissionBubbleViewViews
419 426
420 PermissionBubbleViewViews::PermissionBubbleViewViews(views::View* anchor_view) 427 PermissionBubbleViewViews::PermissionBubbleViewViews(
428 views::View* anchor_view,
429 Profile* profile)
421 : anchor_view_(anchor_view), 430 : anchor_view_(anchor_view),
422 delegate_(NULL), 431 delegate_(NULL),
423 bubble_delegate_(NULL) {} 432 bubble_delegate_(NULL),
433 profile_(profile) {}
424 434
425 PermissionBubbleViewViews::~PermissionBubbleViewViews() { 435 PermissionBubbleViewViews::~PermissionBubbleViewViews() {
426 if (delegate_) 436 if (delegate_)
427 delegate_->SetView(NULL); 437 delegate_->SetView(NULL);
428 } 438 }
429 439
430 void PermissionBubbleViewViews::SetDelegate(Delegate* delegate) { 440 void PermissionBubbleViewViews::SetDelegate(Delegate* delegate) {
431 delegate_ = delegate; 441 delegate_ = delegate;
432 } 442 }
433 443
434 void PermissionBubbleViewViews::Show( 444 void PermissionBubbleViewViews::Show(
435 const std::vector<PermissionBubbleRequest*>& requests, 445 const std::vector<PermissionBubbleRequest*>& requests,
436 const std::vector<bool>& values, 446 const std::vector<bool>& values,
437 bool customization_mode) { 447 bool customization_mode) {
438 if (bubble_delegate_ != NULL) 448 if (bubble_delegate_ != NULL)
439 bubble_delegate_->Close(); 449 bubble_delegate_->Close();
440 450
441 bubble_delegate_ = 451 bubble_delegate_ =
442 new PermissionsBubbleDelegateView(anchor_view_, this, 452 new PermissionsBubbleDelegateView(anchor_view_, this, profile_,
443 requests, values, customization_mode); 453 requests, values, customization_mode);
444 views::BubbleDelegateView::CreateBubble(bubble_delegate_)->Show(); 454 views::BubbleDelegateView::CreateBubble(bubble_delegate_)->Show();
445 bubble_delegate_->SizeToContents(); 455 bubble_delegate_->SizeToContents();
446 } 456 }
447 457
448 bool PermissionBubbleViewViews::CanAcceptRequestUpdate() { 458 bool PermissionBubbleViewViews::CanAcceptRequestUpdate() {
449 return !(bubble_delegate_ && bubble_delegate_->IsMouseHovered()); 459 return !(bubble_delegate_ && bubble_delegate_->IsMouseHovered());
450 } 460 }
451 461
452 void PermissionBubbleViewViews::Hide() { 462 void PermissionBubbleViewViews::Hide() {
(...skipping 26 matching lines...) Expand all
479 489
480 void PermissionBubbleViewViews::Deny() { 490 void PermissionBubbleViewViews::Deny() {
481 if (delegate_) 491 if (delegate_)
482 delegate_->Deny(); 492 delegate_->Deny();
483 } 493 }
484 494
485 void PermissionBubbleViewViews::SetCustomizationMode() { 495 void PermissionBubbleViewViews::SetCustomizationMode() {
486 if (delegate_) 496 if (delegate_)
487 delegate_->SetCustomizationMode(); 497 delegate_->SetCustomizationMode();
488 } 498 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/website_settings/permissions_bubble_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698