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

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

Issue 2262913002: fix TranslateBubble toggle off by omnibar icon Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix comment Created 4 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
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 #include <utility> 9 #include <utility>
10 10
(...skipping 1591 matching lines...) Expand 10 before | Expand all | Expand 10 after
1602 } 1602 }
1603 if (step != translate::TRANSLATE_STEP_TRANSLATE_ERROR) { 1603 if (step != translate::TRANSLATE_STEP_TRANSLATE_ERROR) {
1604 TranslateBubbleModel::ViewState viewState = 1604 TranslateBubbleModel::ViewState viewState =
1605 TranslateBubbleModelImpl::TranslateStepToViewState(step); 1605 TranslateBubbleModelImpl::TranslateStepToViewState(step);
1606 [translateBubbleController_ switchView:viewState]; 1606 [translateBubbleController_ switchView:viewState];
1607 } else { 1607 } else {
1608 [translateBubbleController_ switchToErrorView:errorType]; 1608 [translateBubbleController_ switchToErrorView:errorType];
1609 } 1609 }
1610 return; 1610 return;
1611 } 1611 }
1612 if ((base::Time::Now() - translateBubbleClosedTime_).InMilliseconds() < 10) {
1613 // The TranslateBubble was just cloed within 10 ms. Do not open it.
1614 // It was closed by focus lost when user click on the icon to toggle it off.
1615 return;
1616 }
1612 1617
1613 std::string sourceLanguage; 1618 std::string sourceLanguage;
1614 std::string targetLanguage; 1619 std::string targetLanguage;
1615 ChromeTranslateClient::GetTranslateLanguages( 1620 ChromeTranslateClient::GetTranslateLanguages(
1616 contents, &sourceLanguage, &targetLanguage); 1621 contents, &sourceLanguage, &targetLanguage);
1617 1622
1618 std::unique_ptr<translate::TranslateUIDelegate> uiDelegate( 1623 std::unique_ptr<translate::TranslateUIDelegate> uiDelegate(
1619 new translate::TranslateUIDelegate( 1624 new translate::TranslateUIDelegate(
1620 ChromeTranslateClient::GetManagerFromWebContents(contents) 1625 ChromeTranslateClient::GetManagerFromWebContents(contents)
1621 ->GetWeakPtr(), 1626 ->GetWeakPtr(),
(...skipping 21 matching lines...) Expand all
1643 1648
1644 // Nil out the weak translate bubble controller reference. 1649 // Nil out the weak translate bubble controller reference.
1645 - (void)translateBubbleWindowWillClose:(NSNotification*)notification { 1650 - (void)translateBubbleWindowWillClose:(NSNotification*)notification {
1646 DCHECK_EQ([notification object], [translateBubbleController_ window]); 1651 DCHECK_EQ([notification object], [translateBubbleController_ window]);
1647 1652
1648 NSNotificationCenter* center = [NSNotificationCenter defaultCenter]; 1653 NSNotificationCenter* center = [NSNotificationCenter defaultCenter];
1649 [center removeObserver:self 1654 [center removeObserver:self
1650 name:NSWindowWillCloseNotification 1655 name:NSWindowWillCloseNotification
1651 object:[translateBubbleController_ window]]; 1656 object:[translateBubbleController_ window]];
1652 translateBubbleController_ = nil; 1657 translateBubbleController_ = nil;
1658 translateBubbleClosedTime_ = base::Time::Now();
1653 } 1659 }
1654 1660
1655 // If the browser is in incognito mode or has multi-profiles, install the image 1661 // If the browser is in incognito mode or has multi-profiles, install the image
1656 // view to decorate the window at the upper right. Use the same base y 1662 // view to decorate the window at the upper right. Use the same base y
1657 // coordinate as the tab strip. 1663 // coordinate as the tab strip.
1658 - (void)installAvatar { 1664 - (void)installAvatar {
1659 // Install the image into the badge view. Hide it for now; positioning and 1665 // Install the image into the badge view. Hide it for now; positioning and
1660 // sizing will be done by the layout code. The AvatarIcon will choose which 1666 // sizing will be done by the layout code. The AvatarIcon will choose which
1661 // image to display based on the browser. The AvatarButton will display 1667 // image to display based on the browser. The AvatarButton will display
1662 // the browser profile's name unless the browser is incognito. 1668 // the browser profile's name unless the browser is incognito.
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after
2050 2056
2051 - (NSRect)savedRegularWindowFrame { 2057 - (NSRect)savedRegularWindowFrame {
2052 return savedRegularWindowFrame_; 2058 return savedRegularWindowFrame_;
2053 } 2059 }
2054 2060
2055 - (BOOL)isFullscreenTransitionInProgress { 2061 - (BOOL)isFullscreenTransitionInProgress {
2056 return enteringAppKitFullscreen_ || exitingAppKitFullscreen_; 2062 return enteringAppKitFullscreen_ || exitingAppKitFullscreen_;
2057 } 2063 }
2058 2064
2059 @end // @implementation BrowserWindowController(WindowType) 2065 @end // @implementation BrowserWindowController(WindowType)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698