| 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 #import "chrome/browser/ui/cocoa/website_settings/permission_bubble_controller.h
" | 5 #import "chrome/browser/ui/cocoa/website_settings/permission_bubble_controller.h
" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/mac/bind_objc_block.h" | 9 #include "base/mac/bind_objc_block.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 #include "chrome/browser/ui/cocoa/website_settings/split_block_button.h" | 26 #include "chrome/browser/ui/cocoa/website_settings/split_block_button.h" |
| 27 #include "chrome/browser/ui/cocoa/website_settings/website_settings_utils_cocoa.
h" | 27 #include "chrome/browser/ui/cocoa/website_settings/website_settings_utils_cocoa.
h" |
| 28 #include "chrome/browser/ui/website_settings/permission_bubble_request.h" | 28 #include "chrome/browser/ui/website_settings/permission_bubble_request.h" |
| 29 #include "chrome/browser/ui/website_settings/permission_bubble_view.h" | 29 #include "chrome/browser/ui/website_settings/permission_bubble_view.h" |
| 30 #include "chrome/browser/ui/website_settings/permission_menu_model.h" | 30 #include "chrome/browser/ui/website_settings/permission_menu_model.h" |
| 31 #include "chrome/grit/generated_resources.h" | 31 #include "chrome/grit/generated_resources.h" |
| 32 #include "content/public/browser/native_web_keyboard_event.h" | 32 #include "content/public/browser/native_web_keyboard_event.h" |
| 33 #include "content/public/browser/user_metrics.h" | 33 #include "content/public/browser/user_metrics.h" |
| 34 #include "grit/components_strings.h" | 34 #include "grit/components_strings.h" |
| 35 #include "skia/ext/skia_utils_mac.h" | 35 #include "skia/ext/skia_utils_mac.h" |
| 36 #include "ui/base/cocoa/cocoa_base_utils.h" |
| 36 #import "ui/base/cocoa/controls/hyperlink_text_view.h" | 37 #import "ui/base/cocoa/controls/hyperlink_text_view.h" |
| 37 #import "ui/base/cocoa/menu_controller.h" | 38 #import "ui/base/cocoa/menu_controller.h" |
| 38 #include "ui/base/cocoa/window_size_constants.h" | 39 #include "ui/base/cocoa/window_size_constants.h" |
| 39 #include "ui/base/l10n/l10n_util_mac.h" | 40 #include "ui/base/l10n/l10n_util_mac.h" |
| 40 #include "ui/base/models/simple_menu_model.h" | 41 #include "ui/base/models/simple_menu_model.h" |
| 41 | 42 |
| 42 using base::UserMetricsAction; | 43 using base::UserMetricsAction; |
| 43 | 44 |
| 44 namespace { | 45 namespace { |
| 45 | 46 |
| (...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 447 if ([self hasLocationBar]) { | 448 if ([self hasLocationBar]) { |
| 448 LocationBarViewMac* location_bar = | 449 LocationBarViewMac* location_bar = |
| 449 [[[self getExpectedParentWindow] windowController] locationBarBridge]; | 450 [[[self getExpectedParentWindow] windowController] locationBarBridge]; |
| 450 anchor = location_bar->GetPageInfoBubblePoint(); | 451 anchor = location_bar->GetPageInfoBubblePoint(); |
| 451 } else { | 452 } else { |
| 452 // Center the bubble if there's no location bar. | 453 // Center the bubble if there's no location bar. |
| 453 NSRect contentFrame = [[[self getExpectedParentWindow] contentView] frame]; | 454 NSRect contentFrame = [[[self getExpectedParentWindow] contentView] frame]; |
| 454 anchor = NSMakePoint(NSMidX(contentFrame), NSMaxY(contentFrame)); | 455 anchor = NSMakePoint(NSMidX(contentFrame), NSMaxY(contentFrame)); |
| 455 } | 456 } |
| 456 | 457 |
| 457 return [[self getExpectedParentWindow] convertBaseToScreen:anchor]; | 458 return ui::ConvertPointFromWindowToScreen([self getExpectedParentWindow], |
| 459 anchor); |
| 458 } | 460 } |
| 459 | 461 |
| 460 - (bool)hasLocationBar { | 462 - (bool)hasLocationBar { |
| 461 return browser_->SupportsWindowFeature(Browser::FEATURE_LOCATIONBAR); | 463 return browser_->SupportsWindowFeature(Browser::FEATURE_LOCATIONBAR); |
| 462 } | 464 } |
| 463 | 465 |
| 464 - (info_bubble::BubbleArrowLocation)getExpectedArrowLocation { | 466 - (info_bubble::BubbleArrowLocation)getExpectedArrowLocation { |
| 465 return [self hasLocationBar] ? info_bubble::kTopLeft : info_bubble::kNoArrow; | 467 return [self hasLocationBar] ? info_bubble::kTopLeft : info_bubble::kNoArrow; |
| 466 } | 468 } |
| 467 | 469 |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 614 | 616 |
| 615 + (void)alignCenterOf:(NSView*)viewA verticallyToCenterOf:(NSView*)viewB { | 617 + (void)alignCenterOf:(NSView*)viewA verticallyToCenterOf:(NSView*)viewB { |
| 616 NSRect frameA = [viewA frame]; | 618 NSRect frameA = [viewA frame]; |
| 617 NSRect frameB = [viewB frame]; | 619 NSRect frameB = [viewB frame]; |
| 618 frameA.origin.y = | 620 frameA.origin.y = |
| 619 NSMinY(frameB) + std::floor((NSHeight(frameB) - NSHeight(frameA)) / 2); | 621 NSMinY(frameB) + std::floor((NSHeight(frameB) - NSHeight(frameA)) / 2); |
| 620 [viewA setFrameOrigin:frameA.origin]; | 622 [viewA setFrameOrigin:frameA.origin]; |
| 621 } | 623 } |
| 622 | 624 |
| 623 @end // implementation PermissionBubbleController | 625 @end // implementation PermissionBubbleController |
| OLD | NEW |