Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/chooser_bubble_ui_view.h" | 5 #include "chrome/browser/ui/views/website_settings/chooser_bubble_ui_view.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 | 10 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 65 | 65 |
| 66 // Updates the anchor's arrow and view. Also repositions the bubble so it's | 66 // Updates the anchor's arrow and view. Also repositions the bubble so it's |
| 67 // displayed in the correct location. | 67 // displayed in the correct location. |
| 68 void UpdateAnchor(views::View* anchor_view, | 68 void UpdateAnchor(views::View* anchor_view, |
| 69 views::BubbleBorder::Arrow anchor_arrow); | 69 views::BubbleBorder::Arrow anchor_arrow); |
| 70 | 70 |
| 71 void set_bubble_reference(BubbleReference bubble_reference); | 71 void set_bubble_reference(BubbleReference bubble_reference); |
| 72 void UpdateTableView() const; | 72 void UpdateTableView() const; |
| 73 | 73 |
| 74 private: | 74 private: |
| 75 // |footnote_link_| will transfer its ownership of the pointer to its | |
| 76 // caller when CreateFootnoteView() is called. | |
| 77 std::unique_ptr<views::StyledLabel> footnote_link_; | |
| 75 ChooserContentView* chooser_content_view_; | 78 ChooserContentView* chooser_content_view_; |
| 76 BubbleReference bubble_reference_; | 79 BubbleReference bubble_reference_; |
| 77 | 80 |
| 78 DISALLOW_COPY_AND_ASSIGN(ChooserBubbleUiViewDelegate); | 81 DISALLOW_COPY_AND_ASSIGN(ChooserBubbleUiViewDelegate); |
| 79 }; | 82 }; |
| 80 | 83 |
| 81 ChooserBubbleUiViewDelegate::ChooserBubbleUiViewDelegate( | 84 ChooserBubbleUiViewDelegate::ChooserBubbleUiViewDelegate( |
| 82 views::View* anchor_view, | 85 views::View* anchor_view, |
| 83 views::BubbleBorder::Arrow anchor_arrow, | 86 views::BubbleBorder::Arrow anchor_arrow, |
| 84 std::unique_ptr<ChooserController> chooser_controller) | 87 std::unique_ptr<ChooserController> chooser_controller) |
| 85 : views::BubbleDialogDelegateView(anchor_view, anchor_arrow), | 88 : views::BubbleDialogDelegateView(anchor_view, anchor_arrow), |
| 86 chooser_content_view_(nullptr) { | 89 chooser_content_view_(nullptr) { |
| 87 // ------------------------------------ | 90 // ------------------------------------ |
| 88 // | Chooser bubble title | | 91 // | Chooser bubble title | |
| 89 // | -------------------------------- | | 92 // | -------------------------------- | |
| 90 // | | option 0 | | | 93 // | | option 0 | | |
| 91 // | | option 1 | | | 94 // | | option 1 | | |
| 92 // | | option 2 | | | 95 // | | option 2 | | |
| 93 // | | | | | 96 // | | | | |
| 94 // | | | | | 97 // | | | | |
| 95 // | | | | | 98 // | | | | |
| 96 // | -------------------------------- | | 99 // | -------------------------------- | |
| 97 // | [ Connect ] [ Cancel ] | | 100 // | [ Connect ] [ Cancel ] | |
| 98 // |----------------------------------| | 101 // |----------------------------------| |
| 99 // | Get help | | 102 // | Get help | |
| 100 // ------------------------------------ | 103 // ------------------------------------ |
| 101 | 104 |
| 102 chooser_content_view_ = | 105 footnote_link_.reset(new views::StyledLabel(base::string16(), nullptr)); |
| 103 new ChooserContentView(this, std::move(chooser_controller)); | 106 chooser_content_view_ = new ChooserContentView( |
|
sky
2016/11/09 17:55:47
MakeUnique on all these.
juncai
2016/11/09 20:25:02
|chooser_content_view_| is a raw pointer of Choose
| |
| 107 this, std::move(chooser_controller), footnote_link_.get()); | |
| 104 } | 108 } |
| 105 | 109 |
| 106 ChooserBubbleUiViewDelegate::~ChooserBubbleUiViewDelegate() {} | 110 ChooserBubbleUiViewDelegate::~ChooserBubbleUiViewDelegate() {} |
| 107 | 111 |
| 108 base::string16 ChooserBubbleUiViewDelegate::GetWindowTitle() const { | 112 base::string16 ChooserBubbleUiViewDelegate::GetWindowTitle() const { |
| 109 return chooser_content_view_->GetWindowTitle(); | 113 return chooser_content_view_->GetWindowTitle(); |
| 110 } | 114 } |
| 111 | 115 |
| 112 base::string16 ChooserBubbleUiViewDelegate::GetDialogButtonLabel( | 116 base::string16 ChooserBubbleUiViewDelegate::GetDialogButtonLabel( |
| 113 ui::DialogButton button) const { | 117 ui::DialogButton button) const { |
| 114 return chooser_content_view_->GetDialogButtonLabel(button); | 118 return chooser_content_view_->GetDialogButtonLabel(button); |
| 115 } | 119 } |
| 116 | 120 |
| 117 bool ChooserBubbleUiViewDelegate::IsDialogButtonEnabled( | 121 bool ChooserBubbleUiViewDelegate::IsDialogButtonEnabled( |
| 118 ui::DialogButton button) const { | 122 ui::DialogButton button) const { |
| 119 return chooser_content_view_->IsDialogButtonEnabled(button); | 123 return chooser_content_view_->IsDialogButtonEnabled(button); |
| 120 } | 124 } |
| 121 | 125 |
| 122 views::View* ChooserBubbleUiViewDelegate::CreateFootnoteView() { | 126 views::View* ChooserBubbleUiViewDelegate::CreateFootnoteView() { |
| 123 return chooser_content_view_->CreateFootnoteView(); | 127 DCHECK(footnote_link_); |
| 128 return footnote_link_.release(); | |
| 124 } | 129 } |
| 125 | 130 |
| 126 bool ChooserBubbleUiViewDelegate::Accept() { | 131 bool ChooserBubbleUiViewDelegate::Accept() { |
| 127 chooser_content_view_->Accept(); | 132 chooser_content_view_->Accept(); |
| 128 if (bubble_reference_) | 133 if (bubble_reference_) |
| 129 bubble_reference_->CloseBubble(BUBBLE_CLOSE_ACCEPTED); | 134 bubble_reference_->CloseBubble(BUBBLE_CLOSE_ACCEPTED); |
| 130 return true; | 135 return true; |
| 131 } | 136 } |
| 132 | 137 |
| 133 bool ChooserBubbleUiViewDelegate::Cancel() { | 138 bool ChooserBubbleUiViewDelegate::Cancel() { |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 228 return browser_view->exclusive_access_bubble()->GetView(); | 233 return browser_view->exclusive_access_bubble()->GetView(); |
| 229 | 234 |
| 230 return browser_view->top_container(); | 235 return browser_view->top_container(); |
| 231 } | 236 } |
| 232 | 237 |
| 233 views::BubbleBorder::Arrow ChooserBubbleUiView::GetAnchorArrow() { | 238 views::BubbleBorder::Arrow ChooserBubbleUiView::GetAnchorArrow() { |
| 234 if (browser_->SupportsWindowFeature(Browser::FEATURE_LOCATIONBAR)) | 239 if (browser_->SupportsWindowFeature(Browser::FEATURE_LOCATIONBAR)) |
| 235 return views::BubbleBorder::TOP_LEFT; | 240 return views::BubbleBorder::TOP_LEFT; |
| 236 return views::BubbleBorder::NONE; | 241 return views::BubbleBorder::NONE; |
| 237 } | 242 } |
| OLD | NEW |