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

Side by Side Diff: chrome/browser/ui/cocoa/bookmarks/bookmark_bubble_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 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bubble_controller.h" 5 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bubble_controller.h"
6 6
7 #include "base/mac/mac_util.h" 7 #include "base/mac/mac_util.h"
8 #include "base/sys_string_conversions.h" 8 #include "base/sys_string_conversions.h"
9 #include "base/utf_string_conversions.h" // TODO(viettrungluu): remove 9 #include "base/utf_string_conversions.h" // TODO(viettrungluu): remove
10 #include "chrome/browser/bookmarks/bookmark_model.h" 10 #include "chrome/browser/bookmarks/bookmark_model.h"
11 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_button.h" 11 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_button.h"
12 #import "chrome/browser/ui/cocoa/browser_window_controller.h" 12 #import "chrome/browser/ui/cocoa/browser_window_controller.h"
13 #import "chrome/browser/ui/cocoa/info_bubble_view.h" 13 #import "chrome/browser/ui/cocoa/info_bubble_view.h"
14 #include "content/browser/user_metrics.h" 14 #include "content/browser/user_metrics.h"
15 #include "content/common/notification_observer.h" 15 #include "content/common/notification_observer.h"
16 #include "content/common/notification_registrar.h" 16 #include "content/common/notification_registrar.h"
17 #include "content/common/notification_service.h" 17 #include "content/common/notification_service.h"
18 #include "grit/generated_resources.h" 18 #include "grit/generated_resources.h"
19 #include "ui/base/l10n/l10n_util_mac.h" 19 #include "ui/base/l10n/l10n_util_mac.h"
20 20
21 21
22 // Simple class to watch for tab creation/destruction and close the bubble. 22 // Simple class to watch for tab creation/destruction and close the bubble.
23 // Bridge between Chrome-style notifications and ObjC-style notifications. 23 // Bridge between Chrome-style notifications and ObjC-style notifications.
24 class BookmarkBubbleNotificationBridge : public NotificationObserver { 24 class BookmarkBubbleNotificationBridge : public NotificationObserver {
25 public: 25 public:
26 BookmarkBubbleNotificationBridge(BookmarkBubbleController* controller, 26 BookmarkBubbleNotificationBridge(BookmarkBubbleController* controller,
27 SEL selector); 27 SEL selector);
28 virtual ~BookmarkBubbleNotificationBridge() {} 28 virtual ~BookmarkBubbleNotificationBridge() {}
29 void Observe(NotificationType type, 29 void Observe(int type,
30 const NotificationSource& source, 30 const NotificationSource& source,
31 const NotificationDetails& details); 31 const NotificationDetails& details);
32 private: 32 private:
33 NotificationRegistrar registrar_; 33 NotificationRegistrar registrar_;
34 BookmarkBubbleController* controller_; // weak; owns us. 34 BookmarkBubbleController* controller_; // weak; owns us.
35 SEL selector_; // SEL sent to controller_ on notification. 35 SEL selector_; // SEL sent to controller_ on notification.
36 }; 36 };
37 37
38 BookmarkBubbleNotificationBridge::BookmarkBubbleNotificationBridge( 38 BookmarkBubbleNotificationBridge::BookmarkBubbleNotificationBridge(
39 BookmarkBubbleController* controller, SEL selector) 39 BookmarkBubbleController* controller, SEL selector)
40 : controller_(controller), selector_(selector) { 40 : controller_(controller), selector_(selector) {
41 // registrar_ will automatically RemoveAll() when destroyed so we 41 // registrar_ will automatically RemoveAll() when destroyed so we
42 // don't need to do so explicitly. 42 // don't need to do so explicitly.
43 registrar_.Add(this, NotificationType::TAB_CONTENTS_CONNECTED, 43 registrar_.Add(this, content::NOTIFICATION_TAB_CONTENTS_CONNECTED,
44 NotificationService::AllSources()); 44 NotificationService::AllSources());
45 registrar_.Add(this, NotificationType::TAB_CLOSED, 45 registrar_.Add(this, content::NOTIFICATION_TAB_CLOSED,
46 NotificationService::AllSources()); 46 NotificationService::AllSources());
47 } 47 }
48 48
49 // At this time all notifications instigate the same behavior (go 49 // At this time all notifications instigate the same behavior (go
50 // away) so we don't bother checking which notification came in. 50 // away) so we don't bother checking which notification came in.
51 void BookmarkBubbleNotificationBridge::Observe( 51 void BookmarkBubbleNotificationBridge::Observe(
52 NotificationType type, 52 int type,
53 const NotificationSource& source, 53 const NotificationSource& source,
54 const NotificationDetails& details) { 54 const NotificationDetails& details) {
55 [controller_ performSelector:selector_ withObject:controller_]; 55 [controller_ performSelector:selector_ withObject:controller_];
56 } 56 }
57 57
58 58
59 // An object to represent the ChooseAnotherFolder item in the pop up. 59 // An object to represent the ChooseAnotherFolder item in the pop up.
60 @interface ChooseAnotherFolder : NSObject 60 @interface ChooseAnotherFolder : NSObject
61 @end 61 @end
62 62
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 NSInteger idx = [menu indexOfItemWithRepresentedObject:parentValue]; 414 NSInteger idx = [menu indexOfItemWithRepresentedObject:parentValue];
415 DCHECK(idx != -1); 415 DCHECK(idx != -1);
416 [folderPopUpButton_ selectItemAtIndex:idx]; 416 [folderPopUpButton_ selectItemAtIndex:idx];
417 } 417 }
418 418
419 - (NSPopUpButton*)folderPopUpButton { 419 - (NSPopUpButton*)folderPopUpButton {
420 return folderPopUpButton_; 420 return folderPopUpButton_;
421 } 421 }
422 422
423 @end // implementation BookmarkBubbleController(ExposedForUnitTesting) 423 @end // implementation BookmarkBubbleController(ExposedForUnitTesting)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698