| 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 |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/memory/ptr_util.h" | 12 #include "base/memory/ptr_util.h" |
| 13 #include "base/strings/string16.h" | 13 #include "base/strings/string16.h" |
| 14 #include "chrome/browser/chooser_controller/chooser_controller.h" | 14 #include "chrome/browser/chooser_controller/chooser_controller.h" |
| 15 #include "chrome/browser/ui/browser.h" | 15 #include "chrome/browser/ui/browser.h" |
| 16 #include "chrome/browser/ui/browser_window.h" | 16 #include "chrome/browser/ui/browser_window.h" |
| 17 #include "chrome/browser/ui/views/chooser_content_view.h" | 17 #include "chrome/browser/ui/views/chooser_content_view.h" |
| 18 #include "chrome/browser/ui/views/exclusive_access_bubble_views.h" | 18 #include "chrome/browser/ui/views/exclusive_access_bubble_views.h" |
| 19 #include "chrome/browser/ui/views/frame/browser_view.h" | 19 #include "chrome/browser/ui/views/frame/browser_view.h" |
| 20 #include "chrome/browser/ui/views/frame/top_container_view.h" | 20 #include "chrome/browser/ui/views/frame/top_container_view.h" |
| 21 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" | 21 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" |
| 22 #include "chrome/browser/ui/views/location_bar/location_icon_view.h" | 22 #include "chrome/browser/ui/views/location_bar/location_icon_view.h" |
| 23 #include "chrome/browser/ui/website_settings/chooser_bubble_delegate.h" | 23 #include "chrome/browser/ui/website_settings/chooser_bubble_delegate.h" |
| 24 #include "chrome/grit/generated_resources.h" | |
| 25 #include "components/bubble/bubble_controller.h" | 24 #include "components/bubble/bubble_controller.h" |
| 26 #include "components/url_formatter/elide_url.h" | |
| 27 #include "ui/base/l10n/l10n_util.h" | |
| 28 #include "ui/views/controls/styled_label.h" | 25 #include "ui/views/controls/styled_label.h" |
| 29 #include "ui/views/controls/styled_label_listener.h" | 26 #include "ui/views/controls/styled_label_listener.h" |
| 30 #include "ui/views/controls/table/table_view_observer.h" | 27 #include "ui/views/controls/table/table_view_observer.h" |
| 31 #include "ui/views/window/dialog_client_view.h" | 28 #include "ui/views/window/dialog_client_view.h" |
| 32 #include "url/origin.h" | |
| 33 | 29 |
| 34 std::unique_ptr<BubbleUi> ChooserBubbleDelegate::BuildBubbleUi() { | 30 std::unique_ptr<BubbleUi> ChooserBubbleDelegate::BuildBubbleUi() { |
| 35 return base::WrapUnique( | 31 return base::WrapUnique( |
| 36 new ChooserBubbleUiView(browser_, std::move(chooser_controller_))); | 32 new ChooserBubbleUiView(browser_, std::move(chooser_controller_))); |
| 37 } | 33 } |
| 38 | 34 |
| 39 /////////////////////////////////////////////////////////////////////////////// | 35 /////////////////////////////////////////////////////////////////////////////// |
| 40 // View implementation for the chooser bubble. | 36 // View implementation for the chooser bubble. |
| 41 class ChooserBubbleUiViewDelegate : public views::BubbleDialogDelegateView, | 37 class ChooserBubbleUiViewDelegate : public views::BubbleDialogDelegateView, |
| 42 public views::StyledLabelListener, | 38 public views::StyledLabelListener, |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 | 70 |
| 75 // Updates the anchor's arrow and view. Also repositions the bubble so it's | 71 // Updates the anchor's arrow and view. Also repositions the bubble so it's |
| 76 // displayed in the correct location. | 72 // displayed in the correct location. |
| 77 void UpdateAnchor(views::View* anchor_view, | 73 void UpdateAnchor(views::View* anchor_view, |
| 78 views::BubbleBorder::Arrow anchor_arrow); | 74 views::BubbleBorder::Arrow anchor_arrow); |
| 79 | 75 |
| 80 void set_bubble_reference(BubbleReference bubble_reference); | 76 void set_bubble_reference(BubbleReference bubble_reference); |
| 81 void UpdateTableModel() const; | 77 void UpdateTableModel() const; |
| 82 | 78 |
| 83 private: | 79 private: |
| 84 url::Origin origin_; | |
| 85 ChooserContentView* chooser_content_view_; | 80 ChooserContentView* chooser_content_view_; |
| 86 BubbleReference bubble_reference_; | 81 BubbleReference bubble_reference_; |
| 87 | 82 |
| 88 DISALLOW_COPY_AND_ASSIGN(ChooserBubbleUiViewDelegate); | 83 DISALLOW_COPY_AND_ASSIGN(ChooserBubbleUiViewDelegate); |
| 89 }; | 84 }; |
| 90 | 85 |
| 91 ChooserBubbleUiViewDelegate::ChooserBubbleUiViewDelegate( | 86 ChooserBubbleUiViewDelegate::ChooserBubbleUiViewDelegate( |
| 92 views::View* anchor_view, | 87 views::View* anchor_view, |
| 93 views::BubbleBorder::Arrow anchor_arrow, | 88 views::BubbleBorder::Arrow anchor_arrow, |
| 94 std::unique_ptr<ChooserController> chooser_controller) | 89 std::unique_ptr<ChooserController> chooser_controller) |
| 95 : views::BubbleDialogDelegateView(anchor_view, anchor_arrow), | 90 : views::BubbleDialogDelegateView(anchor_view, anchor_arrow), |
| 96 chooser_content_view_(nullptr) { | 91 chooser_content_view_(nullptr) { |
| 97 // ------------------------------------ | 92 // ------------------------------------ |
| 98 // | Chooser bubble title | | 93 // | Chooser bubble title | |
| 99 // | -------------------------------- | | 94 // | -------------------------------- | |
| 100 // | | option 0 | | | 95 // | | option 0 | | |
| 101 // | | option 1 | | | 96 // | | option 1 | | |
| 102 // | | option 2 | | | 97 // | | option 2 | | |
| 103 // | | | | | 98 // | | | | |
| 104 // | | | | | 99 // | | | | |
| 105 // | | | | | 100 // | | | | |
| 106 // | -------------------------------- | | 101 // | -------------------------------- | |
| 107 // | [ Connect ] [ Cancel ] | | 102 // | [ Connect ] [ Cancel ] | |
| 108 // |----------------------------------| | 103 // |----------------------------------| |
| 109 // | Not seeing your device? Get help | | 104 // | Not seeing your device? Get help | |
| 110 // ------------------------------------ | 105 // ------------------------------------ |
| 111 | 106 |
| 112 origin_ = chooser_controller->GetOrigin(); | |
| 113 chooser_content_view_ = | 107 chooser_content_view_ = |
| 114 new ChooserContentView(this, std::move(chooser_controller)); | 108 new ChooserContentView(this, std::move(chooser_controller)); |
| 115 } | 109 } |
| 116 | 110 |
| 117 ChooserBubbleUiViewDelegate::~ChooserBubbleUiViewDelegate() {} | 111 ChooserBubbleUiViewDelegate::~ChooserBubbleUiViewDelegate() {} |
| 118 | 112 |
| 119 base::string16 ChooserBubbleUiViewDelegate::GetWindowTitle() const { | 113 base::string16 ChooserBubbleUiViewDelegate::GetWindowTitle() const { |
| 120 return l10n_util::GetStringFUTF16( | 114 return chooser_content_view_->GetWindowTitle(); |
| 121 IDS_DEVICE_CHOOSER_PROMPT, | |
| 122 url_formatter::FormatOriginForSecurityDisplay( | |
| 123 origin_, url_formatter::SchemeDisplay::OMIT_CRYPTOGRAPHIC)); | |
| 124 } | 115 } |
| 125 | 116 |
| 126 base::string16 ChooserBubbleUiViewDelegate::GetDialogButtonLabel( | 117 base::string16 ChooserBubbleUiViewDelegate::GetDialogButtonLabel( |
| 127 ui::DialogButton button) const { | 118 ui::DialogButton button) const { |
| 128 return chooser_content_view_->GetDialogButtonLabel(button); | 119 return chooser_content_view_->GetDialogButtonLabel(button); |
| 129 } | 120 } |
| 130 | 121 |
| 131 bool ChooserBubbleUiViewDelegate::IsDialogButtonEnabled( | 122 bool ChooserBubbleUiViewDelegate::IsDialogButtonEnabled( |
| 132 ui::DialogButton button) const { | 123 ui::DialogButton button) const { |
| 133 return chooser_content_view_->IsDialogButtonEnabled(button); | 124 return chooser_content_view_->IsDialogButtonEnabled(button); |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 return browser_view->exclusive_access_bubble()->GetView(); | 236 return browser_view->exclusive_access_bubble()->GetView(); |
| 246 | 237 |
| 247 return browser_view->top_container(); | 238 return browser_view->top_container(); |
| 248 } | 239 } |
| 249 | 240 |
| 250 views::BubbleBorder::Arrow ChooserBubbleUiView::GetAnchorArrow() { | 241 views::BubbleBorder::Arrow ChooserBubbleUiView::GetAnchorArrow() { |
| 251 if (browser_->SupportsWindowFeature(Browser::FEATURE_LOCATIONBAR)) | 242 if (browser_->SupportsWindowFeature(Browser::FEATURE_LOCATIONBAR)) |
| 252 return views::BubbleBorder::TOP_LEFT; | 243 return views::BubbleBorder::TOP_LEFT; |
| 253 return views::BubbleBorder::NONE; | 244 return views::BubbleBorder::NONE; |
| 254 } | 245 } |
| OLD | NEW |