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

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

Issue 190063006: Infobar Componentization Proof of Concept (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: minor fixes Created 6 years, 9 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
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/infobars/infobar_container_controller.h" 5 #import "chrome/browser/ui/cocoa/infobars/infobar_container_controller.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/mac/mac_util.h" 8 #include "base/mac/mac_util.h"
9 #include "chrome/browser/infobars/confirm_infobar_delegate.h" 9 #include "chrome/browser/infobars/confirm_infobar_delegate.h"
10 #include "chrome/browser/infobars/infobar.h" 10 #include "chrome/browser/infobars/infobar.h"
11 #include "chrome/browser/infobars/infobar_container.h" 11 #include "chrome/browser/infobars/infobar_container.h"
12 #include "chrome/browser/infobars/infobar_manager.h"
12 #include "chrome/browser/infobars/infobar_service.h" 13 #include "chrome/browser/infobars/infobar_service.h"
13 #import "chrome/browser/ui/cocoa/browser_window_controller.h" 14 #import "chrome/browser/ui/cocoa/browser_window_controller.h"
14 #import "chrome/browser/ui/cocoa/infobars/infobar_cocoa.h" 15 #import "chrome/browser/ui/cocoa/infobars/infobar_cocoa.h"
15 #import "chrome/browser/ui/cocoa/infobars/infobar_container_cocoa.h" 16 #import "chrome/browser/ui/cocoa/infobars/infobar_container_cocoa.h"
16 #import "chrome/browser/ui/cocoa/infobars/infobar_controller.h" 17 #import "chrome/browser/ui/cocoa/infobars/infobar_controller.h"
17 #import "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h" 18 #import "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h"
18 #import "chrome/browser/ui/cocoa/view_id_util.h" 19 #import "chrome/browser/ui/cocoa/view_id_util.h"
19 20
20 @interface InfoBarContainerController () 21 @interface InfoBarContainerController ()
21 // Removes |controller| from the list of controllers in this container and 22 // Removes |controller| from the list of controllers in this container and
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 } 62 }
62 63
63 - (CGFloat)infobarArrowX { 64 - (CGFloat)infobarArrowX {
64 LocationBarViewMac* locationBar = 65 LocationBarViewMac* locationBar =
65 [[self browserWindowController] locationBarBridge]; 66 [[self browserWindowController] locationBarBridge];
66 return locationBar->GetPageInfoBubblePoint().x; 67 return locationBar->GetPageInfoBubblePoint().x;
67 } 68 }
68 69
69 - (void)changeWebContents:(content::WebContents*)contents { 70 - (void)changeWebContents:(content::WebContents*)contents {
70 currentWebContents_ = contents; 71 currentWebContents_ = contents;
72 InfoBarManager* infobar_manager = NULL;
71 if (contents) { 73 if (contents) {
72 containerCocoa_->ChangeInfoBarService( 74 InfoBarService* infobar_service = InfoBarService::FromWebContents(contents);
73 InfoBarService::FromWebContents(contents)); 75 if (infobar_service)
74 } else { 76 infobar_manager = &infobar_service->infobar_manager();
75 containerCocoa_->ChangeInfoBarService(NULL);
76 } 77 }
78 containerCocoa_->ChangeInfoBarManager(infobar_manager);
77 } 79 }
78 80
79 - (void)tabDetachedWithContents:(content::WebContents*)contents { 81 - (void)tabDetachedWithContents:(content::WebContents*)contents {
80 if (currentWebContents_ == contents) 82 if (currentWebContents_ == contents)
81 [self changeWebContents:NULL]; 83 [self changeWebContents:NULL];
82 } 84 }
83 85
84 - (CGFloat)overlappingTipHeight { 86 - (CGFloat)overlappingTipHeight {
85 return containerCocoa_->GetVerticalOverlap(NULL); 87 return containerCocoa_->GetVerticalOverlap(NULL);
86 } 88 }
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 159
158 // This code can be executed while InfoBarController is still on the stack, so 160 // This code can be executed while InfoBarController is still on the stack, so
159 // we retain and autorelease the controller to prevent it from being 161 // we retain and autorelease the controller to prevent it from being
160 // dealloc'ed too early. 162 // dealloc'ed too early.
161 [[controller retain] autorelease]; 163 [[controller retain] autorelease];
162 [[controller view] removeFromSuperview]; 164 [[controller view] removeFromSuperview];
163 [infobarControllers_ removeObject:controller]; 165 [infobarControllers_ removeObject:controller];
164 } 166 }
165 167
166 @end 168 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698