| 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_finder.h" | 17 #include "chrome/browser/ui/browser_finder.h" |
| 18 #include "chrome/browser/ui/browser_window.h" | 18 #include "chrome/browser/ui/browser_window.h" |
| 19 #import "chrome/browser/ui/chrome_style.h" | 19 #import "chrome/browser/ui/chrome_style.h" |
| 20 #import "chrome/browser/ui/cocoa/base_bubble_controller.h" | 20 #import "chrome/browser/ui/cocoa/base_bubble_controller.h" |
| 21 #import "chrome/browser/ui/cocoa/browser_window_controller.h" | 21 #import "chrome/browser/ui/cocoa/browser_window_controller.h" |
| 22 #import "chrome/browser/ui/cocoa/browser_window_utils.h" | 22 #import "chrome/browser/ui/cocoa/browser_window_utils.h" |
| 23 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_button.h" | 23 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_button.h" |
| 24 #import "chrome/browser/ui/cocoa/hover_close_button.h" | 24 #import "chrome/browser/ui/cocoa/hover_close_button.h" |
| 25 #import "chrome/browser/ui/cocoa/info_bubble_view.h" | 25 #import "chrome/browser/ui/cocoa/info_bubble_view.h" |
| 26 #import "chrome/browser/ui/cocoa/info_bubble_window.h" | 26 #import "chrome/browser/ui/cocoa/info_bubble_window.h" |
| 27 #import "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h" | 27 #import "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h" |
| 28 #include "chrome/grit/generated_resources.h" | 28 #include "chrome/grit/generated_resources.h" |
| 29 #include "components/url_formatter/elide_url.h" |
| 29 #include "content/public/browser/native_web_keyboard_event.h" | 30 #include "content/public/browser/native_web_keyboard_event.h" |
| 30 #import "third_party/google_toolbox_for_mac/src/AppKit/GTMUILocalizerAndLayoutTw
eaker.h" | 31 #import "third_party/google_toolbox_for_mac/src/AppKit/GTMUILocalizerAndLayoutTw
eaker.h" |
| 31 #include "ui/base/cocoa/cocoa_base_utils.h" | 32 #include "ui/base/cocoa/cocoa_base_utils.h" |
| 32 #import "ui/base/cocoa/controls/hyperlink_button_cell.h" | 33 #import "ui/base/cocoa/controls/hyperlink_button_cell.h" |
| 33 #include "ui/base/cocoa/window_size_constants.h" | 34 #include "ui/base/cocoa/window_size_constants.h" |
| 34 #include "ui/base/l10n/l10n_util.h" | 35 #include "ui/base/l10n/l10n_util.h" |
| 35 #include "ui/base/l10n/l10n_util_mac.h" | 36 #include "ui/base/l10n/l10n_util_mac.h" |
| 36 #include "url/gurl.h" | 37 #include "url/gurl.h" |
| 37 #include "url/origin.h" | 38 #include "url/origin.h" |
| 38 | 39 |
| (...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 447 return browser_->window()->GetNativeWindow(); | 448 return browser_->window()->GetNativeWindow(); |
| 448 } | 449 } |
| 449 | 450 |
| 450 - (base::scoped_nsobject<NSTextField>)bubbleTitle { | 451 - (base::scoped_nsobject<NSTextField>)bubbleTitle { |
| 451 base::scoped_nsobject<NSTextField> titleView( | 452 base::scoped_nsobject<NSTextField> titleView( |
| 452 [[NSTextField alloc] initWithFrame:NSZeroRect]); | 453 [[NSTextField alloc] initWithFrame:NSZeroRect]); |
| 453 [titleView setDrawsBackground:NO]; | 454 [titleView setDrawsBackground:NO]; |
| 454 [titleView setBezeled:NO]; | 455 [titleView setBezeled:NO]; |
| 455 [titleView setEditable:NO]; | 456 [titleView setEditable:NO]; |
| 456 [titleView setSelectable:NO]; | 457 [titleView setSelectable:NO]; |
| 457 [titleView | 458 [titleView setStringValue: |
| 458 setStringValue:l10n_util::GetNSStringF( | 459 l10n_util::GetNSStringF( |
| 459 IDS_CHOOSER_BUBBLE_PROMPT, | 460 IDS_CHOOSER_BUBBLE_PROMPT, |
| 460 base::ASCIIToUTF16( | 461 url_formatter::FormatOriginForSecurityDisplay( |
| 461 chooserBubbleController_->GetOrigin().host()))]; | 462 chooserBubbleController_->GetOrigin(), |
| 463 url_formatter::SchemeDisplay::OMIT_CRYPTOGRAPHIC))]; |
| 462 [titleView setFont:[NSFont systemFontOfSize:[NSFont systemFontSize]]]; | 464 [titleView setFont:[NSFont systemFontOfSize:[NSFont systemFontSize]]]; |
| 463 // The height is arbitrary as it will be adjusted later. | 465 // The height is arbitrary as it will be adjusted later. |
| 464 [titleView setFrameSize:NSMakeSize(kChooserBubbleWidth - 2 * kMarginX, 0.0f)]; | 466 [titleView setFrameSize:NSMakeSize(kChooserBubbleWidth - 2 * kMarginX, 0.0f)]; |
| 465 [GTMUILocalizerAndLayoutTweaker sizeToFitFixedWidthTextField:titleView]; | 467 [GTMUILocalizerAndLayoutTweaker sizeToFitFixedWidthTextField:titleView]; |
| 466 return titleView; | 468 return titleView; |
| 467 } | 469 } |
| 468 | 470 |
| 469 - (base::scoped_nsobject<NSButton>)buttonWithTitle:(NSString*)title | 471 - (base::scoped_nsobject<NSButton>)buttonWithTitle:(NSString*)title |
| 470 action:(SEL)action { | 472 action:(SEL)action { |
| 471 base::scoped_nsobject<NSButton> button( | 473 base::scoped_nsobject<NSButton> button( |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 600 [chooser_bubble_ui_controller_ onOptionAdded:static_cast<NSInteger>(index)]; | 602 [chooser_bubble_ui_controller_ onOptionAdded:static_cast<NSInteger>(index)]; |
| 601 } | 603 } |
| 602 | 604 |
| 603 void ChooserBubbleUiCocoa::OnOptionRemoved(size_t index) { | 605 void ChooserBubbleUiCocoa::OnOptionRemoved(size_t index) { |
| 604 [chooser_bubble_ui_controller_ onOptionRemoved:static_cast<NSInteger>(index)]; | 606 [chooser_bubble_ui_controller_ onOptionRemoved:static_cast<NSInteger>(index)]; |
| 605 } | 607 } |
| 606 | 608 |
| 607 void ChooserBubbleUiCocoa::OnBubbleClosing() { | 609 void ChooserBubbleUiCocoa::OnBubbleClosing() { |
| 608 chooser_bubble_ui_controller_ = nil; | 610 chooser_bubble_ui_controller_ = nil; |
| 609 } | 611 } |
| OLD | NEW |