| 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 #import "chrome/browser/ui/cocoa/website_settings/chooser_bubble_ui_cocoa.h" | 5 #import "chrome/browser/ui/cocoa/website_settings/chooser_bubble_ui_cocoa.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <cmath> | 10 #include <cmath> |
| 11 | 11 |
| 12 #include "base/mac/scoped_nsobject.h" | 12 #include "base/mac/scoped_nsobject.h" |
| 13 #include "base/memory/ptr_util.h" | 13 #include "base/memory/ptr_util.h" |
| 14 #include "base/strings/sys_string_conversions.h" | 14 #include "base/strings/sys_string_conversions.h" |
| 15 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
| 16 #include "chrome/browser/ui/browser.h" | 16 #include "chrome/browser/ui/browser.h" |
| 17 #include "chrome/browser/ui/browser_window.h" | 17 #include "chrome/browser/ui/browser_window.h" |
| 18 #import "chrome/browser/ui/cocoa/base_bubble_controller.h" | 18 #import "chrome/browser/ui/cocoa/base_bubble_controller.h" |
| 19 #import "chrome/browser/ui/cocoa/browser_window_controller.h" | 19 #import "chrome/browser/ui/cocoa/browser_window_controller.h" |
| 20 #import "chrome/browser/ui/cocoa/browser_window_utils.h" | 20 #import "chrome/browser/ui/cocoa/browser_window_utils.h" |
| 21 #import "chrome/browser/ui/cocoa/chooser_content_view.h" | 21 #import "chrome/browser/ui/cocoa/chooser_content_view_cocoa.h" |
| 22 #import "chrome/browser/ui/cocoa/info_bubble_view.h" | 22 #import "chrome/browser/ui/cocoa/info_bubble_view.h" |
| 23 #import "chrome/browser/ui/cocoa/info_bubble_window.h" | 23 #import "chrome/browser/ui/cocoa/info_bubble_window.h" |
| 24 #import "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h" | 24 #import "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h" |
| 25 #include "chrome/browser/ui/website_settings/chooser_bubble_delegate.h" | 25 #include "chrome/browser/ui/website_settings/chooser_bubble_delegate.h" |
| 26 #include "chrome/grit/generated_resources.h" | 26 #include "chrome/grit/generated_resources.h" |
| 27 #include "components/bubble/bubble_controller.h" | 27 #include "components/bubble/bubble_controller.h" |
| 28 #include "components/url_formatter/elide_url.h" | 28 #include "components/url_formatter/elide_url.h" |
| 29 #include "content/public/browser/native_web_keyboard_event.h" | 29 #include "content/public/browser/native_web_keyboard_event.h" |
| 30 #include "ui/base/cocoa/cocoa_base_utils.h" | 30 #include "ui/base/cocoa/cocoa_base_utils.h" |
| 31 #include "ui/base/cocoa/window_size_constants.h" | 31 #include "ui/base/cocoa/window_size_constants.h" |
| 32 #include "ui/base/l10n/l10n_util.h" | 32 #include "ui/base/l10n/l10n_util.h" |
| 33 #include "ui/base/l10n/l10n_util_mac.h" | 33 #include "ui/base/l10n/l10n_util_mac.h" |
| 34 #include "url/gurl.h" | 34 #include "url/gurl.h" |
| 35 #include "url/origin.h" | 35 #include "url/origin.h" |
| 36 | 36 |
| 37 std::unique_ptr<BubbleUi> ChooserBubbleDelegate::BuildBubbleUi() { | 37 std::unique_ptr<BubbleUi> ChooserBubbleDelegate::BuildBubbleUi() { |
| 38 return base::WrapUnique( | 38 return base::WrapUnique( |
| 39 new ChooserBubbleUiCocoa(browser_, chooser_controller())); | 39 new ChooserBubbleUiCocoa(browser_, chooser_controller())); |
| 40 } | 40 } |
| 41 | 41 |
| 42 @interface ChooserBubbleUiController | 42 @interface ChooserBubbleUiController |
| 43 : BaseBubbleController<NSTableViewDataSource, NSTableViewDelegate> { | 43 : BaseBubbleController<NSTableViewDataSource, NSTableViewDelegate> { |
| 44 @private | 44 @private |
| 45 // Bridge to the C++ class that created this object. | 45 // Bridge to the C++ class that created this object. |
| 46 ChooserBubbleUiCocoa* bridge_; // Weak. | 46 ChooserBubbleUiCocoa* bridge_; // Weak. |
| 47 bool buttonPressed_; | 47 bool buttonPressed_; |
| 48 | 48 |
| 49 base::scoped_nsobject<ChooserContentView> chooserContentView_; | 49 base::scoped_nsobject<ChooserContentViewCocoa> chooserContentView_; |
| 50 NSTableView* tableView_; // Weak. | 50 NSTableView* tableView_; // Weak. |
| 51 NSButton* connectButton_; // Weak. | 51 NSButton* connectButton_; // Weak. |
| 52 NSButton* cancelButton_; // Weak. | 52 NSButton* cancelButton_; // Weak. |
| 53 NSButton* helpButton_; // Weak. | 53 NSButton* helpButton_; // Weak. |
| 54 | 54 |
| 55 Browser* browser_; // Weak. | 55 Browser* browser_; // Weak. |
| 56 ChooserController* chooserController_; // Weak. | 56 ChooserController* chooserController_; // Weak. |
| 57 } | 57 } |
| 58 | 58 |
| 59 // Designated initializer. |browser| and |bridge| must both be non-nil. | 59 // Designated initializer. |browser| and |bridge| must both be non-nil. |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 - (void)parentWindowDidResize:(NSNotification*)notification { | 161 - (void)parentWindowDidResize:(NSNotification*)notification { |
| 162 [self setAnchorPoint:[self getExpectedAnchorPoint]]; | 162 [self setAnchorPoint:[self getExpectedAnchorPoint]]; |
| 163 } | 163 } |
| 164 | 164 |
| 165 - (void)parentWindowDidMove:(NSNotification*)notification { | 165 - (void)parentWindowDidMove:(NSNotification*)notification { |
| 166 DCHECK(bridge_); | 166 DCHECK(bridge_); |
| 167 [self setAnchorPoint:[self getExpectedAnchorPoint]]; | 167 [self setAnchorPoint:[self getExpectedAnchorPoint]]; |
| 168 } | 168 } |
| 169 | 169 |
| 170 - (void)show { | 170 - (void)show { |
| 171 chooserContentView_.reset([[ChooserContentView alloc] | 171 chooserContentView_.reset([[ChooserContentViewCocoa alloc] |
| 172 initWithChooserTitle: | 172 initWithChooserTitle: |
| 173 l10n_util::GetNSStringF( | 173 l10n_util::GetNSStringF( |
| 174 IDS_CHOOSER_BUBBLE_PROMPT, | 174 IDS_CHOOSER_BUBBLE_PROMPT, |
| 175 url_formatter::FormatOriginForSecurityDisplay( | 175 url_formatter::FormatOriginForSecurityDisplay( |
| 176 chooserController_->GetOrigin(), | 176 chooserController_->GetOrigin(), |
| 177 url_formatter::SchemeDisplay::OMIT_CRYPTOGRAPHIC))]); | 177 url_formatter::SchemeDisplay::OMIT_CRYPTOGRAPHIC))]); |
| 178 | 178 |
| 179 tableView_ = [chooserContentView_ tableView]; | 179 tableView_ = [chooserContentView_ tableView]; |
| 180 connectButton_ = [chooserContentView_ connectButton]; | 180 connectButton_ = [chooserContentView_ connectButton]; |
| 181 cancelButton_ = [chooserContentView_ cancelButton]; | 181 cancelButton_ = [chooserContentView_ cancelButton]; |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 395 [chooser_bubble_ui_controller_ onOptionAdded:static_cast<NSInteger>(index)]; | 395 [chooser_bubble_ui_controller_ onOptionAdded:static_cast<NSInteger>(index)]; |
| 396 } | 396 } |
| 397 | 397 |
| 398 void ChooserBubbleUiCocoa::OnOptionRemoved(size_t index) { | 398 void ChooserBubbleUiCocoa::OnOptionRemoved(size_t index) { |
| 399 [chooser_bubble_ui_controller_ onOptionRemoved:static_cast<NSInteger>(index)]; | 399 [chooser_bubble_ui_controller_ onOptionRemoved:static_cast<NSInteger>(index)]; |
| 400 } | 400 } |
| 401 | 401 |
| 402 void ChooserBubbleUiCocoa::OnBubbleClosing() { | 402 void ChooserBubbleUiCocoa::OnBubbleClosing() { |
| 403 chooser_bubble_ui_controller_ = nil; | 403 chooser_bubble_ui_controller_ = nil; |
| 404 } | 404 } |
| OLD | NEW |