| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <Cocoa/Cocoa.h> | 5 #import <Cocoa/Cocoa.h> |
| 6 | 6 |
| 7 #import "chrome/browser/ui/cocoa/theme_install_bubble_view.h" | 7 #import "chrome/browser/ui/cocoa/theme_install_bubble_view.h" |
| 8 | 8 |
| 9 #include "base/logging.h" |
| 9 #include "base/memory/scoped_nsobject.h" | 10 #include "base/memory/scoped_nsobject.h" |
| 10 #include "chrome/common/chrome_notification_types.h" | 11 #include "chrome/common/chrome_notification_types.h" |
| 11 #include "content/common/notification_service.h" | 12 #include "content/public/browser/notification_service.h" |
| 12 #include "grit/generated_resources.h" | 13 #include "grit/generated_resources.h" |
| 13 #include "ui/base/l10n/l10n_util_mac.h" | 14 #include "ui/base/l10n/l10n_util_mac.h" |
| 14 | 15 |
| 15 namespace { | 16 namespace { |
| 16 | 17 |
| 17 // The alpha of the bubble. | 18 // The alpha of the bubble. |
| 18 static const float kBubbleAlpha = 0.75; | 19 static const float kBubbleAlpha = 0.75; |
| 19 | 20 |
| 20 // The roundedness of the edges of our bubble. | 21 // The roundedness of the edges of our bubble. |
| 21 static const int kBubbleCornerRadius = 4; | 22 static const int kBubbleCornerRadius = 4; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 | 58 |
| 58 NSView* parent_view = [window contentView]; | 59 NSView* parent_view = [window contentView]; |
| 59 NSRect parent_bounds = [parent_view bounds]; | 60 NSRect parent_bounds = [parent_view bounds]; |
| 60 if (parent_bounds.size.height < [cocoa_view_ preferredSize].height) | 61 if (parent_bounds.size.height < [cocoa_view_ preferredSize].height) |
| 61 Close(); | 62 Close(); |
| 62 | 63 |
| 63 // Close when theme has been installed. | 64 // Close when theme has been installed. |
| 64 registrar_.Add( | 65 registrar_.Add( |
| 65 this, | 66 this, |
| 66 chrome::NOTIFICATION_BROWSER_THEME_CHANGED, | 67 chrome::NOTIFICATION_BROWSER_THEME_CHANGED, |
| 67 NotificationService::AllBrowserContextsAndSources()); | 68 content::NotificationService::AllBrowserContextsAndSources()); |
| 68 | 69 |
| 69 // Close when we are installing an extension, not a theme. | 70 // Close when we are installing an extension, not a theme. |
| 70 registrar_.Add( | 71 registrar_.Add( |
| 71 this, | 72 this, |
| 72 chrome::NOTIFICATION_NO_THEME_DETECTED, | 73 chrome::NOTIFICATION_NO_THEME_DETECTED, |
| 73 NotificationService::AllSources()); | 74 content::NotificationService::AllSources()); |
| 74 registrar_.Add( | 75 registrar_.Add( |
| 75 this, | 76 this, |
| 76 chrome::NOTIFICATION_EXTENSION_INSTALLED, | 77 chrome::NOTIFICATION_EXTENSION_INSTALLED, |
| 77 NotificationService::AllSources()); | 78 content::NotificationService::AllSources()); |
| 78 registrar_.Add( | 79 registrar_.Add( |
| 79 this, | 80 this, |
| 80 chrome::NOTIFICATION_EXTENSION_INSTALL_ERROR, | 81 chrome::NOTIFICATION_EXTENSION_INSTALL_ERROR, |
| 81 NotificationService::AllSources()); | 82 content::NotificationService::AllSources()); |
| 82 | 83 |
| 83 // Don't let the bubble overlap the confirm dialog. | 84 // Don't let the bubble overlap the confirm dialog. |
| 84 registrar_.Add( | 85 registrar_.Add( |
| 85 this, | 86 this, |
| 86 chrome::NOTIFICATION_EXTENSION_WILL_SHOW_CONFIRM_DIALOG, | 87 chrome::NOTIFICATION_EXTENSION_WILL_SHOW_CONFIRM_DIALOG, |
| 87 NotificationService::AllSources()); | 88 content::NotificationService::AllSources()); |
| 88 | 89 |
| 89 // Add the view. | 90 // Add the view. |
| 90 [cocoa_view_ setFrame:parent_bounds]; | 91 [cocoa_view_ setFrame:parent_bounds]; |
| 91 [cocoa_view_ setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable]; | 92 [cocoa_view_ setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable]; |
| 92 [parent_view addSubview:cocoa_view_ | 93 [parent_view addSubview:cocoa_view_ |
| 93 positioned:NSWindowAbove | 94 positioned:NSWindowAbove |
| 94 relativeTo:nil]; | 95 relativeTo:nil]; |
| 95 [cocoa_view_ layout]; | 96 [cocoa_view_ layout]; |
| 96 } | 97 } |
| 97 | 98 |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 | 181 |
| 181 [[[NSColor blackColor] colorWithAlphaComponent:kBubbleAlpha] set]; | 182 [[[NSColor blackColor] colorWithAlphaComponent:kBubbleAlpha] set]; |
| 182 [[NSBezierPath bezierPathWithRoundedRect:grayRect_ | 183 [[NSBezierPath bezierPathWithRoundedRect:grayRect_ |
| 183 xRadius:kBubbleCornerRadius | 184 xRadius:kBubbleCornerRadius |
| 184 yRadius:kBubbleCornerRadius] fill]; | 185 yRadius:kBubbleCornerRadius] fill]; |
| 185 | 186 |
| 186 [message_.get() drawInRect:textRect_]; | 187 [message_.get() drawInRect:textRect_]; |
| 187 } | 188 } |
| 188 | 189 |
| 189 @end | 190 @end |
| OLD | NEW |