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

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 "content/common/notification_service.h" 10 #include "content/common/notification_service.h"
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 DCHECK(window); 55 DCHECK(window);
56 56
57 NSView* parent_view = [window contentView]; 57 NSView* parent_view = [window contentView];
58 NSRect parent_bounds = [parent_view bounds]; 58 NSRect parent_bounds = [parent_view bounds];
59 if (parent_bounds.size.height < [cocoa_view_ preferredSize].height) 59 if (parent_bounds.size.height < [cocoa_view_ preferredSize].height)
60 Close(); 60 Close();
61 61
62 // Close when theme has been installed. 62 // Close when theme has been installed.
63 registrar_.Add( 63 registrar_.Add(
64 this, 64 this,
65 NotificationType::BROWSER_THEME_CHANGED, 65 chrome::NOTIFICATION_BROWSER_THEME_CHANGED,
66 NotificationService::AllSources()); 66 NotificationService::AllSources());
67 67
68 // Close when we are installing an extension, not a theme. 68 // Close when we are installing an extension, not a theme.
69 registrar_.Add( 69 registrar_.Add(
70 this, 70 this,
71 NotificationType::NO_THEME_DETECTED, 71 chrome::NO_THEME_DETECTED,
72 NotificationService::AllSources()); 72 NotificationService::AllSources());
73 registrar_.Add( 73 registrar_.Add(
74 this, 74 this,
75 NotificationType::EXTENSION_INSTALLED, 75 chrome::EXTENSION_INSTALLED,
76 NotificationService::AllSources()); 76 NotificationService::AllSources());
77 registrar_.Add( 77 registrar_.Add(
78 this, 78 this,
79 NotificationType::EXTENSION_INSTALL_ERROR, 79 chrome::EXTENSION_INSTALL_ERROR,
80 NotificationService::AllSources()); 80 NotificationService::AllSources());
81 81
82 // Don't let the bubble overlap the confirm dialog. 82 // Don't let the bubble overlap the confirm dialog.
83 registrar_.Add( 83 registrar_.Add(
84 this, 84 this,
85 NotificationType::EXTENSION_WILL_SHOW_CONFIRM_DIALOG, 85 chrome::EXTENSION_WILL_SHOW_CONFIRM_DIALOG,
86 NotificationService::AllSources()); 86 NotificationService::AllSources());
87 87
88 // Add the view. 88 // Add the view.
89 [cocoa_view_ setFrame:parent_bounds]; 89 [cocoa_view_ setFrame:parent_bounds];
90 [cocoa_view_ setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable]; 90 [cocoa_view_ setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
91 [parent_view addSubview:cocoa_view_ 91 [parent_view addSubview:cocoa_view_
92 positioned:NSWindowAbove 92 positioned:NSWindowAbove
93 relativeTo:nil]; 93 relativeTo:nil];
94 [cocoa_view_ layout]; 94 [cocoa_view_ layout];
95 } 95 }
96 96
97 ThemeInstallBubbleView::~ThemeInstallBubbleView() { 97 ThemeInstallBubbleView::~ThemeInstallBubbleView() {
98 // Need to delete self; the real work happens in Close(). 98 // Need to delete self; the real work happens in Close().
99 } 99 }
100 100
101 void ThemeInstallBubbleView::Close() { 101 void ThemeInstallBubbleView::Close() {
102 --num_loads_extant_; 102 --num_loads_extant_;
103 if (num_loads_extant_ < 1) { 103 if (num_loads_extant_ < 1) {
104 registrar_.RemoveAll(); 104 registrar_.RemoveAll();
105 if (cocoa_view_ && [cocoa_view_ superview]) { 105 if (cocoa_view_ && [cocoa_view_ superview]) {
106 [cocoa_view_ removeFromSuperview]; 106 [cocoa_view_ removeFromSuperview];
107 [cocoa_view_ release]; 107 [cocoa_view_ release];
108 } 108 }
109 view_ = NULL; 109 view_ = NULL;
110 delete this; 110 delete this;
111 // this is deleted; nothing more! 111 // this is deleted; nothing more!
112 } 112 }
113 } 113 }
114 114
115 void ThemeInstallBubbleView::Observe(NotificationType type, 115 void ThemeInstallBubbleView::Observe(int type,
116 const NotificationSource& source, 116 const NotificationSource& source,
117 const NotificationDetails& details) { 117 const NotificationDetails& details) {
118 Close(); 118 Close();
119 } 119 }
120 120
121 // static 121 // static
122 void ThemeInstallBubbleView::Show(NSWindow* window) { 122 void ThemeInstallBubbleView::Show(NSWindow* window) {
123 if (view_) 123 if (view_)
124 ++view_->num_loads_extant_; 124 ++view_->num_loads_extant_;
125 else 125 else
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 178
179 [[[NSColor blackColor] colorWithAlphaComponent:kBubbleAlpha] set]; 179 [[[NSColor blackColor] colorWithAlphaComponent:kBubbleAlpha] set];
180 [[NSBezierPath bezierPathWithRoundedRect:grayRect_ 180 [[NSBezierPath bezierPathWithRoundedRect:grayRect_
181 xRadius:kBubbleCornerRadius 181 xRadius:kBubbleCornerRadius
182 yRadius:kBubbleCornerRadius] fill]; 182 yRadius:kBubbleCornerRadius] fill];
183 183
184 [message_.get() drawInRect:textRect_]; 184 [message_.get() drawInRect:textRect_];
185 } 185 }
186 186
187 @end 187 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698