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

Unified Diff: chrome/browser/ui/cocoa/browser_window_controller.mm

Issue 2196203002: [Mac] The infobar's top arrow should be hidden while the omnibox popup is shown (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: The third approach Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/cocoa/browser_window_controller.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/cocoa/browser_window_controller.mm
diff --git a/chrome/browser/ui/cocoa/browser_window_controller.mm b/chrome/browser/ui/cocoa/browser_window_controller.mm
index 2fd4f20fa2362cd5b3c99df981d23eb4abb640b3..7a3e0a372f414baa5356140f6f75d34f68da8273 100644
--- a/chrome/browser/ui/cocoa/browser_window_controller.mm
+++ b/chrome/browser/ui/cocoa/browser_window_controller.mm
@@ -64,6 +64,7 @@
#import "chrome/browser/ui/cocoa/infobars/infobar_container_controller.h"
#include "chrome/browser/ui/cocoa/l10n_util.h"
#import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_editor.h"
+#import "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h"
#include "chrome/browser/ui/cocoa/permission_bubble/permission_bubble_cocoa.h"
#import "chrome/browser/ui/cocoa/profiles/avatar_base_controller.h"
#import "chrome/browser/ui/cocoa/profiles/avatar_button_controller.h"
@@ -87,6 +88,9 @@
#include "chrome/common/pref_names.h"
#include "components/bookmarks/browser/bookmark_model.h"
#include "components/bookmarks/managed/managed_bookmark_service.h"
+#include "components/omnibox/browser/omnibox_edit_model.h"
+#include "components/omnibox/browser/omnibox_popup_model.h"
+#include "components/omnibox/browser/omnibox_popup_model_observer.h"
#include "components/signin/core/common/profile_management_switches.h"
#include "components/translate/core/browser/translate_manager.h"
#include "components/translate/core/browser/translate_ui_delegate.h"
@@ -185,6 +189,44 @@
namespace {
+// This class shows or hides the top arrow of the infobar in accordance with the
+// visibility of the omnibox popup. It hides the top arrow when the omnibox
+// popup is shown, and vice versa.
+class OmniboxPopupModelObserverBridge final : public OmniboxPopupModelObserver {
+ public:
+ explicit OmniboxPopupModelObserverBridge(BrowserWindowController* controller)
+ : controller_(controller),
+ omnibox_popup_model_([controller_ locationBarBridge]
+ ->GetOmniboxView()
+ ->model()
+ ->popup_model()) {
+ DCHECK(omnibox_popup_model_);
+ omnibox_popup_model_->AddObserver(this);
Peter Kasting 2017/04/10 21:53:56 Nit: Prefer using a ScopedObserver to manual add/r
Sungmann Cho 2017/04/13 15:25:16 Done.
+ }
+
+ ~OmniboxPopupModelObserverBridge() {
+ omnibox_popup_model_->RemoveObserver(this);
+ }
+
+ void OnOmniboxPopupShownOrHidden() override {
+ int max_top_arrow_height = 0;
+ if (!omnibox_popup_model_->IsOpen()) {
+ base::scoped_nsobject<BrowserWindowLayout> layout(
+ [[BrowserWindowLayout alloc] init]);
+ [controller_ updateLayoutParameters:layout];
+ max_top_arrow_height = [layout computeLayout].infoBarMaxTopArrowHeight;
+ }
+ [[controller_ infoBarContainerController]
+ setMaxTopArrowHeight:max_top_arrow_height];
+ }
+
+ private:
+ BrowserWindowController* controller_;
+ OmniboxPopupModel* omnibox_popup_model_;
+
+ DISALLOW_COPY_AND_ASSIGN(OmniboxPopupModelObserverBridge);
+};
+
void SetUpBrowserWindowCommandHandler(NSWindow* window) {
// Make the window handle browser window commands.
[base::mac::ObjCCastStrict<ChromeEventProcessingWindow>(window)
@@ -389,6 +431,9 @@ new ExtensionKeybindingRegistryCocoa(browser_->profile(),
extensions::ExtensionKeybindingRegistry::ALL_EXTENSIONS,
windowShim_.get()));
+ omniboxPopupModelObserverBridge_.reset(
+ new OmniboxPopupModelObserverBridge(self));
Peter Kasting 2017/04/10 21:53:56 Is it safe to construct this in the constructor, o
Sungmann Cho 2017/04/13 15:25:16 I think |initWithBrowser:browser:| is the right pl
+
blockLayoutSubviews_ = NO;
// We are done initializing now.
« 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