1// Copyright (c) 2012 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include <map>
6
7#import <Cocoa/Cocoa.h>
8
9#include "base/memory/scoped_ptr.h"
10#import "chrome/browser/ui/cocoa/base_bubble_controller.h"
11#include "content/public/common/media_stream_request.h"
12
13class ContentSettingBubbleModel;
14class ContentSettingBubbleWebContentsObserverBridge;
15class ContentSettingMediaMenuModel;
16@class InfoBubbleView;
17
18namespace content {
19class WebContents;
20}
21
22namespace content_setting_bubble {
23// For every "show popup" button, remember the index of the popup tab contents
24// it should open when clicked.
25typedef std::map<NSButton*, int> PopupLinks;
26
27// For every media menu button, remember the components assosiated with the
28// menu button.
29struct MediaMenuParts {
30  MediaMenuParts(content::MediaStreamType type, NSTextField* label);
31  ~MediaMenuParts();
32
33  content::MediaStreamType type;
34  NSTextField* label;  // Weak.
35  scoped_ptr<ContentSettingMediaMenuModel> model;
36
37 private:
38  DISALLOW_COPY_AND_ASSIGN(MediaMenuParts);
39};
40typedef std::map<NSPopUpButton*, MediaMenuParts*> MediaMenuPartsMap;
41}  // namespace content_setting_bubble
42
43// Manages a "content blocked" bubble.
44@interface ContentSettingBubbleController : BaseBubbleController {
45 @private
46  IBOutlet NSTextField* titleLabel_;
47  IBOutlet NSMatrix* allowBlockRadioGroup_;
48
49  IBOutlet NSButton* manageButton_;
50  IBOutlet NSButton* doneButton_;
51  IBOutlet NSButton* loadButton_;
52
53  // The container for the bubble contents of the geolocation bubble.
54  IBOutlet NSView* contentsContainer_;
55
56  IBOutlet NSTextField* blockedResourcesField_;
57
58  scoped_ptr<ContentSettingBubbleModel> contentSettingBubbleModel_;
59  scoped_ptr<ContentSettingBubbleWebContentsObserverBridge> observerBridge_;
60  content_setting_bubble::PopupLinks popupLinks_;
61  content_setting_bubble::MediaMenuPartsMap mediaMenus_;
62}
63
64// Creates and shows a content blocked bubble. Takes ownership of
65// |contentSettingBubbleModel| but not of the other objects.
66+ (ContentSettingBubbleController*)
67    showForModel:(ContentSettingBubbleModel*)contentSettingBubbleModel
68     webContents:(content::WebContents*)webContents
69    parentWindow:(NSWindow*)parentWindow
70      anchoredAt:(NSPoint)anchoredAt;
71
72// Callback for the "don't block / continue blocking" radio group.
73- (IBAction)allowBlockToggled:(id)sender;
74
75// Callback for "close" button.
76- (IBAction)closeBubble:(id)sender;
77
78// Callback for "manage" button.
79- (IBAction)manageBlocking:(id)sender;
80
81// Callback for "info" link.
82- (IBAction)showMoreInfo:(id)sender;
83
84// Callback for "load" (plug-ins, mixed script) button.
85- (IBAction)load:(id)sender;
86
87// Callback for "Learn More" link.
88- (IBAction)learnMoreLinkClicked:(id)sender;
89
90// Callback for "media menu" button.
91- (IBAction)mediaMenuChanged:(id)sender;
92
93@end
94
95@interface ContentSettingBubbleController (TestingAPI)
96
97// Returns the weak reference to the |mediaMenus_|.
98- (content_setting_bubble::MediaMenuPartsMap*)mediaMenus;
99
100@end
101