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

Side by Side Diff: chrome/browser/ui/cocoa/infobars/infobar_container_controller.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 #include "base/logging.h" 5 #include "base/logging.h"
6 #include "base/mac/mac_util.h" 6 #include "base/mac/mac_util.h"
7 #include "chrome/browser/tab_contents/confirm_infobar_delegate.h" 7 #include "chrome/browser/tab_contents/confirm_infobar_delegate.h"
8 #include "chrome/browser/tab_contents/infobar.h" 8 #include "chrome/browser/tab_contents/infobar.h"
9 #import "chrome/browser/ui/cocoa/animatable_view.h" 9 #import "chrome/browser/ui/cocoa/animatable_view.h"
10 #import "chrome/browser/ui/cocoa/infobars/infobar_container_controller.h" 10 #import "chrome/browser/ui/cocoa/infobars/infobar_container_controller.h"
11 #import "chrome/browser/ui/cocoa/infobars/infobar_controller.h" 11 #import "chrome/browser/ui/cocoa/infobars/infobar_controller.h"
12 #import "chrome/browser/ui/cocoa/view_id_util.h" 12 #import "chrome/browser/ui/cocoa/view_id_util.h"
13 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 13 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
14 #include "chrome/common/chrome_notification_types.h"
14 #include "content/common/notification_details.h" 15 #include "content/common/notification_details.h"
15 #include "content/common/notification_source.h" 16 #include "content/common/notification_source.h"
16 #include "skia/ext/skia_utils_mac.h" 17 #include "skia/ext/skia_utils_mac.h"
17 18
18 // C++ class that receives INFOBAR_ADDED and INFOBAR_REMOVED 19 // C++ class that receives INFOBAR_ADDED and INFOBAR_REMOVED
19 // notifications and proxies them back to |controller|. 20 // notifications and proxies them back to |controller|.
20 class InfoBarNotificationObserver : public NotificationObserver { 21 class InfoBarNotificationObserver : public NotificationObserver {
21 public: 22 public:
22 InfoBarNotificationObserver(InfoBarContainerController* controller) 23 InfoBarNotificationObserver(InfoBarContainerController* controller)
23 : controller_(controller) { 24 : controller_(controller) {
24 } 25 }
25 26
26 private: 27 private:
27 // NotificationObserver implementation 28 // NotificationObserver implementation
28 void Observe(NotificationType type, 29 void Observe(int type,
29 const NotificationSource& source, 30 const NotificationSource& source,
30 const NotificationDetails& details) { 31 const NotificationDetails& details) {
31 TabContentsWrapper* tab_contents = Source<TabContentsWrapper>(source).ptr(); 32 TabContentsWrapper* tab_contents = Source<TabContentsWrapper>(source).ptr();
32 switch (type.value) { 33 switch (type) {
33 case NotificationType::TAB_CONTENTS_INFOBAR_ADDED: 34 case chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED:
34 [controller_ addInfoBar:Details<InfoBarAddedDetails>(details)-> 35 [controller_ addInfoBar:Details<InfoBarAddedDetails>(details)->
35 CreateInfoBar(tab_contents) 36 CreateInfoBar(tab_contents)
36 animate:YES]; 37 animate:YES];
37 break; 38 break;
38 39
39 case NotificationType::TAB_CONTENTS_INFOBAR_REMOVED: { 40 case chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED: {
40 InfoBarRemovedDetails* removed_details = 41 InfoBarRemovedDetails* removed_details =
41 Details<InfoBarRemovedDetails>(details).ptr(); 42 Details<InfoBarRemovedDetails>(details).ptr();
42 [controller_ 43 [controller_
43 closeInfoBarsForDelegate:removed_details->first 44 closeInfoBarsForDelegate:removed_details->first
44 animate:(removed_details->second ? YES : NO)]; 45 animate:(removed_details->second ? YES : NO)];
45 break; 46 break;
46 } 47 }
47 48
48 case NotificationType::TAB_CONTENTS_INFOBAR_REPLACED: { 49 case chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REPLACED: {
49 InfoBarReplacedDetails* replaced_details = 50 InfoBarReplacedDetails* replaced_details =
50 Details<InfoBarReplacedDetails>(details).ptr(); 51 Details<InfoBarReplacedDetails>(details).ptr();
51 [controller_ closeInfoBarsForDelegate:replaced_details->first 52 [controller_ closeInfoBarsForDelegate:replaced_details->first
52 animate:NO]; 53 animate:NO];
53 [controller_ addInfoBar:replaced_details->second-> 54 [controller_ addInfoBar:replaced_details->second->
54 CreateInfoBar(tab_contents) 55 CreateInfoBar(tab_contents)
55 animate:NO]; 56 animate:NO];
56 break; 57 break;
57 } 58 }
58 59
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 currentTabContents_ = contents; 132 currentTabContents_ = contents;
132 if (currentTabContents_) { 133 if (currentTabContents_) {
133 for (size_t i = 0; i < currentTabContents_->infobar_count(); ++i) { 134 for (size_t i = 0; i < currentTabContents_->infobar_count(); ++i) {
134 InfoBar* infobar = currentTabContents_->GetInfoBarDelegateAt(i)-> 135 InfoBar* infobar = currentTabContents_->GetInfoBarDelegateAt(i)->
135 CreateInfoBar(currentTabContents_); 136 CreateInfoBar(currentTabContents_);
136 [self addInfoBar:infobar animate:NO]; 137 [self addInfoBar:infobar animate:NO];
137 } 138 }
138 139
139 Source<TabContentsWrapper> source(currentTabContents_); 140 Source<TabContentsWrapper> source(currentTabContents_);
140 registrar_.Add(infoBarObserver_.get(), 141 registrar_.Add(infoBarObserver_.get(),
141 NotificationType::TAB_CONTENTS_INFOBAR_ADDED, source); 142 chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED, source);
142 registrar_.Add(infoBarObserver_.get(), 143 registrar_.Add(infoBarObserver_.get(),
143 NotificationType::TAB_CONTENTS_INFOBAR_REMOVED, source); 144 chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED, source);
144 registrar_.Add(infoBarObserver_.get(), 145 registrar_.Add(infoBarObserver_.get(),
145 NotificationType::TAB_CONTENTS_INFOBAR_REPLACED, source); 146 chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REPLACED, source);
146 } 147 }
147 148
148 [self positionInfoBarsAndRedraw]; 149 [self positionInfoBarsAndRedraw];
149 } 150 }
150 151
151 - (void)tabDetachedWithContents:(TabContentsWrapper*)contents { 152 - (void)tabDetachedWithContents:(TabContentsWrapper*)contents {
152 if (currentTabContents_ == contents) 153 if (currentTabContents_ == contents)
153 [self changeTabContents:NULL]; 154 [self changeTabContents:NULL];
154 } 155 }
155 156
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 frame.size.width = NSWidth(containerBounds); 243 frame.size.width = NSWidth(containerBounds);
243 [view setFrame:frame]; 244 [view setFrame:frame];
244 245
245 minY += NSHeight(frame); 246 minY += NSHeight(frame);
246 } 247 }
247 248
248 [resizeDelegate_ resizeView:[self view] newHeight:[self desiredHeight]]; 249 [resizeDelegate_ resizeView:[self view] newHeight:[self desiredHeight]];
249 } 250 }
250 251
251 @end 252 @end
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/info_bubble_window.mm ('k') | chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698