Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(508)

Side by Side Diff: chrome/browser/ui/cocoa/theme_install_bubble_view.mm

Issue 7327007: Moving notification types which are chrome specific to a new header file chrome_notification_type... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/memory/scoped_nsobject.h" 9 #include "base/memory/scoped_nsobject.h"
10 #include "chrome/common/chrome_notification_types.h"
10 #include "content/common/notification_service.h" 11 #include "content/common/notification_service.h"
11 #include "grit/generated_resources.h" 12 #include "grit/generated_resources.h"
12 #include "ui/base/l10n/l10n_util_mac.h" 13 #include "ui/base/l10n/l10n_util_mac.h"
13 14
14 namespace { 15 namespace {
15 16
16 // The alpha of the bubble. 17 // The alpha of the bubble.
17 static const float kBubbleAlpha = 0.75; 18 static const float kBubbleAlpha = 0.75;
18 19
19 // The roundedness of the edges of our bubble. 20 // The roundedness of the edges of our bubble.
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 DCHECK(window); 56 DCHECK(window);
56 57
57 NSView* parent_view = [window contentView]; 58 NSView* parent_view = [window contentView];
58 NSRect parent_bounds = [parent_view bounds]; 59 NSRect parent_bounds = [parent_view bounds];
59 if (parent_bounds.size.height < [cocoa_view_ preferredSize].height) 60 if (parent_bounds.size.height < [cocoa_view_ preferredSize].height)
60 Close(); 61 Close();
61 62
62 // Close when theme has been installed. 63 // Close when theme has been installed.
63 registrar_.Add( 64 registrar_.Add(
64 this, 65 this,
65 NotificationType::BROWSER_THEME_CHANGED, 66 chrome::NOTIFICATION_BROWSER_THEME_CHANGED,
66 NotificationService::AllSources()); 67 NotificationService::AllSources());
67 68
68 // Close when we are installing an extension, not a theme. 69 // Close when we are installing an extension, not a theme.
69 registrar_.Add( 70 registrar_.Add(
70 this, 71 this,
71 NotificationType::NO_THEME_DETECTED, 72 chrome::NOTIFICATION_NO_THEME_DETECTED,
72 NotificationService::AllSources()); 73 NotificationService::AllSources());
73 registrar_.Add( 74 registrar_.Add(
74 this, 75 this,
75 NotificationType::EXTENSION_INSTALLED, 76 chrome::NOTIFICATION_EXTENSION_INSTALLED,
76 NotificationService::AllSources()); 77 NotificationService::AllSources());
77 registrar_.Add( 78 registrar_.Add(
78 this, 79 this,
79 NotificationType::EXTENSION_INSTALL_ERROR, 80 chrome::NOTIFICATION_EXTENSION_INSTALL_ERROR,
80 NotificationService::AllSources()); 81 NotificationService::AllSources());
81 82
82 // Don't let the bubble overlap the confirm dialog. 83 // Don't let the bubble overlap the confirm dialog.
83 registrar_.Add( 84 registrar_.Add(
84 this, 85 this,
85 NotificationType::EXTENSION_WILL_SHOW_CONFIRM_DIALOG, 86 chrome::NOTIFICATION_EXTENSION_WILL_SHOW_CONFIRM_DIALOG,
86 NotificationService::AllSources()); 87 NotificationService::AllSources());
87 88
88 // Add the view. 89 // Add the view.
89 [cocoa_view_ setFrame:parent_bounds]; 90 [cocoa_view_ setFrame:parent_bounds];
90 [cocoa_view_ setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable]; 91 [cocoa_view_ setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
91 [parent_view addSubview:cocoa_view_ 92 [parent_view addSubview:cocoa_view_
92 positioned:NSWindowAbove 93 positioned:NSWindowAbove
93 relativeTo:nil]; 94 relativeTo:nil];
94 [cocoa_view_ layout]; 95 [cocoa_view_ layout];
95 } 96 }
96 97
97 ThemeInstallBubbleView::~ThemeInstallBubbleView() { 98 ThemeInstallBubbleView::~ThemeInstallBubbleView() {
98 // Need to delete self; the real work happens in Close(). 99 // Need to delete self; the real work happens in Close().
99 } 100 }
100 101
101 void ThemeInstallBubbleView::Close() { 102 void ThemeInstallBubbleView::Close() {
102 --num_loads_extant_; 103 --num_loads_extant_;
103 if (num_loads_extant_ < 1) { 104 if (num_loads_extant_ < 1) {
104 registrar_.RemoveAll(); 105 registrar_.RemoveAll();
105 if (cocoa_view_ && [cocoa_view_ superview]) { 106 if (cocoa_view_ && [cocoa_view_ superview]) {
106 [cocoa_view_ removeFromSuperview]; 107 [cocoa_view_ removeFromSuperview];
107 [cocoa_view_ release]; 108 [cocoa_view_ release];
108 } 109 }
109 view_ = NULL; 110 view_ = NULL;
110 delete this; 111 delete this;
111 // this is deleted; nothing more! 112 // this is deleted; nothing more!
112 } 113 }
113 } 114 }
114 115
115 void ThemeInstallBubbleView::Observe(NotificationType type, 116 void ThemeInstallBubbleView::Observe(int type,
116 const NotificationSource& source, 117 const NotificationSource& source,
117 const NotificationDetails& details) { 118 const NotificationDetails& details) {
118 Close(); 119 Close();
119 } 120 }
120 121
121 // static 122 // static
122 void ThemeInstallBubbleView::Show(NSWindow* window) { 123 void ThemeInstallBubbleView::Show(NSWindow* window) {
123 if (view_) 124 if (view_)
124 ++view_->num_loads_extant_; 125 ++view_->num_loads_extant_;
125 else 126 else
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 179
179 [[[NSColor blackColor] colorWithAlphaComponent:kBubbleAlpha] set]; 180 [[[NSColor blackColor] colorWithAlphaComponent:kBubbleAlpha] set];
180 [[NSBezierPath bezierPathWithRoundedRect:grayRect_ 181 [[NSBezierPath bezierPathWithRoundedRect:grayRect_
181 xRadius:kBubbleCornerRadius 182 xRadius:kBubbleCornerRadius
182 yRadius:kBubbleCornerRadius] fill]; 183 yRadius:kBubbleCornerRadius] fill];
183 184
184 [message_.get() drawInRect:textRect_]; 185 [message_.get() drawInRect:textRect_];
185 } 186 }
186 187
187 @end 188 @end
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/theme_install_bubble_view.h ('k') | chrome/browser/ui/cocoa/toolbar/toolbar_controller.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698