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

Side by Side Diff: chrome/browser/ui/cocoa/browser_window_controller.mm

Issue 1130603005: [PermissionBubble] Remove bubble from previous manager. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Managers can be NULL at shutdown - account for that. Created 5 years, 7 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
« no previous file with comments | « chrome/browser/ui/cocoa/browser_window_controller.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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/browser_window_controller.h" 5 #import "chrome/browser/ui/cocoa/browser_window_controller.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 #include <numeric> 8 #include <numeric>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 NSRect frame = [[self window] frame]; 388 NSRect frame = [[self window] frame];
389 frame.size.height += convertedSize.height; 389 frame.size.height += convertedSize.height;
390 frame.origin.y -= convertedSize.height; 390 frame.origin.y -= convertedSize.height;
391 [[self window] setFrame:frame display:NO]; 391 [[self window] setFrame:frame display:NO];
392 } 392 }
393 } 393 }
394 394
395 // Create the bridge for the status bubble. 395 // Create the bridge for the status bubble.
396 statusBubble_ = new StatusBubbleMac([self window], self); 396 statusBubble_ = new StatusBubbleMac([self window], self);
397 397
398 // Create the permissions bubble.
399 permissionBubbleCocoa_.reset(new PermissionBubbleCocoa([self window]));
400
401 // Register for application hide/unhide notifications. 398 // Register for application hide/unhide notifications.
402 [[NSNotificationCenter defaultCenter] 399 [[NSNotificationCenter defaultCenter]
403 addObserver:self 400 addObserver:self
404 selector:@selector(applicationDidHide:) 401 selector:@selector(applicationDidHide:)
405 name:NSApplicationDidHideNotification 402 name:NSApplicationDidHideNotification
406 object:nil]; 403 object:nil];
407 [[NSNotificationCenter defaultCenter] 404 [[NSNotificationCenter defaultCenter]
408 addObserver:self 405 addObserver:self
409 selector:@selector(applicationDidUnhide:) 406 selector:@selector(applicationDidUnhide:)
410 name:NSApplicationDidUnhideNotification 407 name:NSApplicationDidUnhideNotification
(...skipping 851 matching lines...) Expand 10 before | Expand all | Expand 10 after
1262 } 1259 }
1263 1260
1264 - (void)setStarredState:(BOOL)isStarred { 1261 - (void)setStarredState:(BOOL)isStarred {
1265 [toolbarController_ setStarredState:isStarred]; 1262 [toolbarController_ setStarredState:isStarred];
1266 } 1263 }
1267 1264
1268 - (void)setCurrentPageIsTranslated:(BOOL)on { 1265 - (void)setCurrentPageIsTranslated:(BOOL)on {
1269 [toolbarController_ setTranslateIconLit:on]; 1266 [toolbarController_ setTranslateIconLit:on];
1270 } 1267 }
1271 1268
1269 - (void)onActiveTabChanged:(content::WebContents*)oldContents
rohitrao (ping after 24h) 2015/05/15 18:38:02 How is this different from onActivateTabWithConten
groby-ooo-7-16 2015/05/15 19:06:58 onActivateTabWithContents is called at a very spec
1270 to:(content::WebContents*)newContents {
1271 // No need to remove previous bubble. It will close itself.
1272 PermissionBubbleManager* manager(nullptr);
1273 if (oldContents) {
1274 manager = PermissionBubbleManager::FromWebContents(oldContents);
1275 if (manager)
1276 manager->SetView(nullptr);
1277 }
1278
1279 if (newContents) {
1280 if (!permissionBubbleCocoa_.get()) {
1281 permissionBubbleCocoa_.reset(new PermissionBubbleCocoa([self window]));
1282 }
1283 manager = PermissionBubbleManager::FromWebContents(newContents);
1284 if (manager)
1285 manager->SetView(permissionBubbleCocoa_.get());
1286 }
1287 }
1288
1272 - (void)zoomChangedForActiveTab:(BOOL)canShowBubble { 1289 - (void)zoomChangedForActiveTab:(BOOL)canShowBubble {
1273 [toolbarController_ zoomChangedForActiveTab:canShowBubble]; 1290 [toolbarController_ zoomChangedForActiveTab:canShowBubble];
1274 } 1291 }
1275 1292
1276 // Return the rect, in WebKit coordinates (flipped), of the window's grow box 1293 // Return the rect, in WebKit coordinates (flipped), of the window's grow box
1277 // in the coordinate system of the content area of the currently selected tab. 1294 // in the coordinate system of the content area of the currently selected tab.
1278 // |windowGrowBox| needs to be in the window's coordinate system. 1295 // |windowGrowBox| needs to be in the window's coordinate system.
1279 - (NSRect)selectedTabGrowBoxRect { 1296 - (NSRect)selectedTabGrowBoxRect {
1280 NSWindow* window = [self window]; 1297 NSWindow* window = [self window];
1281 if (![window respondsToSelector:@selector(_growBoxRect)]) 1298 if (![window respondsToSelector:@selector(_growBoxRect)])
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after
1644 windowShim_->UpdateTitleBar(); 1661 windowShim_->UpdateTitleBar();
1645 1662
1646 // Update the bookmark bar. 1663 // Update the bookmark bar.
1647 // TODO(viettrungluu): perhaps update to not terminate running animations (if 1664 // TODO(viettrungluu): perhaps update to not terminate running animations (if
1648 // applicable)? 1665 // applicable)?
1649 windowShim_->BookmarkBarStateChanged( 1666 windowShim_->BookmarkBarStateChanged(
1650 BookmarkBar::DONT_ANIMATE_STATE_CHANGE); 1667 BookmarkBar::DONT_ANIMATE_STATE_CHANGE);
1651 1668
1652 [infoBarContainerController_ changeWebContents:contents]; 1669 [infoBarContainerController_ changeWebContents:contents];
1653 1670
1654 // No need to remove previous bubble. It will close itself.
1655 // TODO(leng): The PermissionBubbleManager for the previous contents should
1656 // have SetView(NULL) called. Fix this when the previous contents are
1657 // available here or move to BrowserWindowCocoa::OnActiveTabChanged().
1658 // crbug.com/340720
1659 PermissionBubbleManager::FromWebContents(contents)->SetView(
1660 permissionBubbleCocoa_.get());
1661
1662 // Must do this after bookmark and infobar updates to avoid 1671 // Must do this after bookmark and infobar updates to avoid
1663 // unnecesary resize in contents. 1672 // unnecesary resize in contents.
1664 [devToolsController_ updateDevToolsForWebContents:contents 1673 [devToolsController_ updateDevToolsForWebContents:contents
1665 withProfile:browser_->profile()]; 1674 withProfile:browser_->profile()];
1666 } 1675 }
1667 1676
1668 - (void)onTabChanged:(TabStripModelObserver::TabChangeType)change 1677 - (void)onTabChanged:(TabStripModelObserver::TabChangeType)change
1669 withContents:(WebContents*)contents { 1678 withContents:(WebContents*)contents {
1670 // Update titles if this is the currently selected tab and if it isn't just 1679 // Update titles if this is the currently selected tab and if it isn't just
1671 // the loading state which changed. 1680 // the loading state which changed.
(...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after
2222 2231
2223 - (BOOL)supportsBookmarkBar { 2232 - (BOOL)supportsBookmarkBar {
2224 return [self supportsWindowFeature:Browser::FEATURE_BOOKMARKBAR]; 2233 return [self supportsWindowFeature:Browser::FEATURE_BOOKMARKBAR];
2225 } 2234 }
2226 2235
2227 - (BOOL)isTabbedWindow { 2236 - (BOOL)isTabbedWindow {
2228 return browser_->is_type_tabbed(); 2237 return browser_->is_type_tabbed();
2229 } 2238 }
2230 2239
2231 @end // @implementation BrowserWindowController(WindowType) 2240 @end // @implementation BrowserWindowController(WindowType)
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/browser_window_controller.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698