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

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

Powered by Google App Engine
This is Rietveld 408576698