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

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: Revert to the patch set 1 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 side-by-side diff with in-line comments
Download patch
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 69e51c3c192e9fca16e2cfa622d8de452ad735cc..ab66c7569f67f37fcd5be57b81030a56132d7428 100644
--- a/chrome/browser/ui/cocoa/browser_window_controller.mm
+++ b/chrome/browser/ui/cocoa/browser_window_controller.mm
@@ -85,6 +85,9 @@
#include "chrome/grit/locale_settings.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"
@@ -186,6 +189,41 @@
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_(nullptr) {
+ DCHECK(controller_);
+ omnibox_popup_model_ = [controller_ locationBarBridge]
Robert Sesek 2016/08/04 17:13:41 You could move this to the initializer list and re
Sungmann Cho 2016/08/04 17:42:27 Done.
+ ->GetOmniboxView()->model()->popup_model();
+ DCHECK(omnibox_popup_model_);
+ omnibox_popup_model_->AddObserver(this);
+ }
+
+ ~OmniboxPopupModelObserverBridge() {
+ omnibox_popup_model_->RemoveObserver(this);
+ }
+
+ void OnOmniboxPopupShownOrHidden() override {
+ InfoBarContainerController* infobar_container_controller =
+ [controller_ infoBarContainerController];
+ int max_top_arrow_height = 0;
+ if (!omnibox_popup_model_->IsOpen()) {
+ max_top_arrow_height =
+ [infobar_container_controller defaultMaxTopArrowHeight];
+ }
+ [infobar_container_controller setMaxTopArrowHeight:max_top_arrow_height];
+ }
+
+ private:
+ BrowserWindowController* controller_;
+ OmniboxPopupModel* omnibox_popup_model_;
+};
Robert Sesek 2016/08/04 17:13:41 DISALLOW_COPY_AND_ASSIGN
Sungmann Cho 2016/08/04 17:42:26 Done.
+
void SetUpBrowserWindowCommandHandler(NSWindow* window) {
// Make the window handle browser window commands.
[base::mac::ObjCCastStrict<ChromeEventProcessingWindow>(window)
@@ -401,6 +439,9 @@ new ExtensionKeybindingRegistryCocoa(browser_->profile(),
extensions::ExtensionKeybindingRegistry::ALL_EXTENSIONS,
windowShim_.get()));
+ omnibox_popup_model_observer_bridge_.reset(
+ new OmniboxPopupModelObserverBridge(self));
+
PrefService* prefs = browser_->profile()->GetPrefs();
shouldShowFullscreenToolbar_ =
prefs->GetBoolean(prefs::kShowFullscreenToolbar);

Powered by Google App Engine
This is Rietveld 408576698