| OLD | NEW |
| 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/permission_bubble/permission_prompt_impl.h" | 5 #include "chrome/browser/ui/views/permission_bubble/permission_prompt_impl.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 public: | 52 public: |
| 53 PermissionsBubbleDialogDelegateView( | 53 PermissionsBubbleDialogDelegateView( |
| 54 PermissionPromptImpl* owner, | 54 PermissionPromptImpl* owner, |
| 55 const std::vector<PermissionRequest*>& requests); | 55 const std::vector<PermissionRequest*>& requests); |
| 56 ~PermissionsBubbleDialogDelegateView() override; | 56 ~PermissionsBubbleDialogDelegateView() override; |
| 57 | 57 |
| 58 void CloseBubble(); | 58 void CloseBubble(); |
| 59 | 59 |
| 60 // BubbleDialogDelegateView: | 60 // BubbleDialogDelegateView: |
| 61 bool ShouldShowCloseButton() const override; | 61 bool ShouldShowCloseButton() const override; |
| 62 const gfx::FontList& GetTitleFontList() const override; | |
| 63 base::string16 GetWindowTitle() const override; | 62 base::string16 GetWindowTitle() const override; |
| 63 void AddedToWidget() override; |
| 64 void OnWidgetDestroying(views::Widget* widget) override; | 64 void OnWidgetDestroying(views::Widget* widget) override; |
| 65 void GetAccessibleNodeData(ui::AXNodeData* node_data) override; | 65 void GetAccessibleNodeData(ui::AXNodeData* node_data) override; |
| 66 bool Cancel() override; | 66 bool Cancel() override; |
| 67 bool Accept() override; | 67 bool Accept() override; |
| 68 bool Close() override; | 68 bool Close() override; |
| 69 int GetDefaultDialogButton() const override; | 69 int GetDefaultDialogButton() const override; |
| 70 int GetDialogButtons() const override; | 70 int GetDialogButtons() const override; |
| 71 base::string16 GetDialogButtonLabel(ui::DialogButton button) const override; | 71 base::string16 GetDialogButtonLabel(ui::DialogButton button) const override; |
| 72 void SizeToContents() override; | 72 void SizeToContents() override; |
| 73 | 73 |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 | 144 |
| 145 void PermissionsBubbleDialogDelegateView::CloseBubble() { | 145 void PermissionsBubbleDialogDelegateView::CloseBubble() { |
| 146 owner_ = nullptr; | 146 owner_ = nullptr; |
| 147 GetWidget()->Close(); | 147 GetWidget()->Close(); |
| 148 } | 148 } |
| 149 | 149 |
| 150 bool PermissionsBubbleDialogDelegateView::ShouldShowCloseButton() const { | 150 bool PermissionsBubbleDialogDelegateView::ShouldShowCloseButton() const { |
| 151 return true; | 151 return true; |
| 152 } | 152 } |
| 153 | 153 |
| 154 const gfx::FontList& PermissionsBubbleDialogDelegateView::GetTitleFontList() | |
| 155 const { | |
| 156 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | |
| 157 return rb.GetFontList(ui::ResourceBundle::BaseFont); | |
| 158 } | |
| 159 | |
| 160 base::string16 PermissionsBubbleDialogDelegateView::GetWindowTitle() const { | 154 base::string16 PermissionsBubbleDialogDelegateView::GetWindowTitle() const { |
| 161 return l10n_util::GetStringFUTF16(IDS_PERMISSIONS_BUBBLE_PROMPT, | 155 return l10n_util::GetStringFUTF16(IDS_PERMISSIONS_BUBBLE_PROMPT, |
| 162 display_origin_); | 156 display_origin_); |
| 163 } | 157 } |
| 164 | 158 |
| 159 void PermissionsBubbleDialogDelegateView::AddedToWidget() { |
| 160 std::unique_ptr<views::Label> title = |
| 161 views::BubbleFrameView::CreateDefaultTitleLabel(GetWindowTitle()); |
| 162 title->SetFontList(ui::ResourceBundle::GetSharedInstance().GetFontList( |
| 163 ui::ResourceBundle::BaseFont)); |
| 164 GetBubbleFrameView()->SetTitleView(std::move(title)); |
| 165 } |
| 166 |
| 165 void PermissionsBubbleDialogDelegateView::SizeToContents() { | 167 void PermissionsBubbleDialogDelegateView::SizeToContents() { |
| 166 BubbleDialogDelegateView::SizeToContents(); | 168 BubbleDialogDelegateView::SizeToContents(); |
| 167 } | 169 } |
| 168 | 170 |
| 169 void PermissionsBubbleDialogDelegateView::OnWidgetDestroying( | 171 void PermissionsBubbleDialogDelegateView::OnWidgetDestroying( |
| 170 views::Widget* widget) { | 172 views::Widget* widget) { |
| 171 views::BubbleDialogDelegateView::OnWidgetDestroying(widget); | 173 views::BubbleDialogDelegateView::OnWidgetDestroying(widget); |
| 172 if (owner_) { | 174 if (owner_) { |
| 173 owner_->Closing(); | 175 owner_->Closing(); |
| 174 owner_ = nullptr; | 176 owner_ = nullptr; |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 343 | 345 |
| 344 void PermissionPromptImpl::Accept() { | 346 void PermissionPromptImpl::Accept() { |
| 345 if (delegate_) | 347 if (delegate_) |
| 346 delegate_->Accept(); | 348 delegate_->Accept(); |
| 347 } | 349 } |
| 348 | 350 |
| 349 void PermissionPromptImpl::Deny() { | 351 void PermissionPromptImpl::Deny() { |
| 350 if (delegate_) | 352 if (delegate_) |
| 351 delegate_->Deny(); | 353 delegate_->Deny(); |
| 352 } | 354 } |
| OLD | NEW |