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

Side by Side Diff: chrome/browser/ui/cocoa/infobars/extension_infobar_controller.mm

Issue 10830353: Introduce InfoBarTabService API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Respond to review comments, merge to LKGR Created 8 years, 4 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) 2012 The Chromium Authors. All rights reserved. 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 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/infobars/extension_infobar_controller.h" 5 #import "chrome/browser/ui/cocoa/infobars/extension_infobar_controller.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 8
9 #include "chrome/browser/api/infobars/infobar_tab_service.h"
9 #include "chrome/browser/extensions/extension_host.h" 10 #include "chrome/browser/extensions/extension_host.h"
10 #include "chrome/browser/extensions/extension_infobar_delegate.h" 11 #include "chrome/browser/extensions/extension_infobar_delegate.h"
11 #include "chrome/browser/extensions/image_loading_tracker.h" 12 #include "chrome/browser/extensions/image_loading_tracker.h"
12 #include "chrome/browser/infobars/infobar_tab_helper.h"
13 #include "chrome/browser/ui/browser_finder.h" 13 #include "chrome/browser/ui/browser_finder.h"
14 #import "chrome/browser/ui/cocoa/animatable_view.h" 14 #import "chrome/browser/ui/cocoa/animatable_view.h"
15 #import "chrome/browser/ui/cocoa/extensions/extension_action_context_menu.h" 15 #import "chrome/browser/ui/cocoa/extensions/extension_action_context_menu.h"
16 #include "chrome/browser/ui/cocoa/infobars/infobar.h" 16 #include "chrome/browser/ui/cocoa/infobars/infobar.h"
17 #import "chrome/browser/ui/cocoa/menu_button.h" 17 #import "chrome/browser/ui/cocoa/menu_button.h"
18 #include "chrome/browser/ui/tab_contents/tab_contents.h" 18 #include "chrome/browser/ui/tab_contents/tab_contents.h"
19 #include "chrome/common/extensions/extension.h" 19 #include "chrome/common/extensions/extension.h"
20 #include "chrome/common/extensions/extension_constants.h" 20 #include "chrome/common/extensions/extension_constants.h"
21 #include "chrome/common/extensions/extension_icon_set.h" 21 #include "chrome/common/extensions/extension_icon_set.h"
22 #include "chrome/common/extensions/extension_resource.h" 22 #include "chrome/common/extensions/extension_resource.h"
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 // Loads the extensions's icon on the file thread. 133 // Loads the extensions's icon on the file thread.
134 ImageLoadingTracker tracker_; 134 ImageLoadingTracker tracker_;
135 135
136 DISALLOW_COPY_AND_ASSIGN(InfobarBridge); 136 DISALLOW_COPY_AND_ASSIGN(InfobarBridge);
137 }; 137 };
138 138
139 139
140 @implementation ExtensionInfoBarController 140 @implementation ExtensionInfoBarController
141 141
142 - (id)initWithDelegate:(InfoBarDelegate*)delegate 142 - (id)initWithDelegate:(InfoBarDelegate*)delegate
143 owner:(InfoBarTabHelper*)owner 143 owner:(InfoBarTabService*)owner
144 window:(NSWindow*)window { 144 window:(NSWindow*)window {
145 if ((self = [super initWithDelegate:delegate owner:owner])) { 145 if ((self = [super initWithDelegate:delegate owner:owner])) {
146 window_ = window; 146 window_ = window;
147 dropdownButton_.reset([[MenuButton alloc] init]); 147 dropdownButton_.reset([[MenuButton alloc] init]);
148 [dropdownButton_ setOpenMenuOnClick:YES]; 148 [dropdownButton_ setOpenMenuOnClick:YES];
149 149
150 extensions::ExtensionHost* extensionHost = 150 extensions::ExtensionHost* extensionHost =
151 delegate_->AsExtensionInfoBarDelegate()->extension_host(); 151 delegate_->AsExtensionInfoBarDelegate()->extension_host();
152 Browser* browser = 152 Browser* browser =
153 browser::FindBrowserWithWebContents(owner->web_contents()); 153 browser::FindBrowserWithWebContents(owner->GetWebContents());
154 contextMenu_.reset([[ExtensionActionContextMenu alloc] 154 contextMenu_.reset([[ExtensionActionContextMenu alloc]
155 initWithExtension:extensionHost->extension() 155 initWithExtension:extensionHost->extension()
156 browser:browser 156 browser:browser
157 extensionAction:NULL]); 157 extensionAction:NULL]);
158 // See menu_button.h for documentation on why this is needed. 158 // See menu_button.h for documentation on why this is needed.
159 NSMenuItem* dummyItem = 159 NSMenuItem* dummyItem =
160 [[[NSMenuItem alloc] initWithTitle:@"" 160 [[[NSMenuItem alloc] initWithTitle:@""
161 action:nil 161 action:nil
162 keyEquivalent:@""] autorelease]; 162 keyEquivalent:@""] autorelease];
163 [contextMenu_ insertItem:dummyItem atIndex:0]; 163 [contextMenu_ insertItem:dummyItem atIndex:0];
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 [extensionView_ setFrameSize:extensionViewSize]; 265 [extensionView_ setFrameSize:extensionViewSize];
266 [extensionView_ setPostsFrameChangedNotifications:YES]; 266 [extensionView_ setPostsFrameChangedNotifications:YES];
267 } 267 }
268 268
269 - (void)setButtonImage:(NSImage*)image { 269 - (void)setButtonImage:(NSImage*)image {
270 [dropdownButton_ setImage:image]; 270 [dropdownButton_ setImage:image];
271 } 271 }
272 272
273 @end 273 @end
274 274
275 InfoBar* ExtensionInfoBarDelegate::CreateInfoBar(InfoBarTabHelper* owner) { 275 InfoBar* ExtensionInfoBarDelegate::CreateInfoBar(InfoBarTabService* owner) {
276 NSWindow* window = 276 NSWindow* window =
277 [(NSView*)owner->web_contents()->GetContentNativeView() window]; 277 [(NSView*)owner->GetWebContents()->GetContentNativeView() window];
278 ExtensionInfoBarController* controller = 278 ExtensionInfoBarController* controller =
279 [[ExtensionInfoBarController alloc] initWithDelegate:this 279 [[ExtensionInfoBarController alloc] initWithDelegate:this
280 owner:owner 280 owner:owner
281 window:window]; 281 window:window];
282 return new InfoBar(controller, this); 282 return new InfoBar(controller, this);
283 } 283 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698