| OLD | NEW |
| 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 #include "chrome/browser/ui/views/compact_nav/compact_location_bar_view_host.h" | 5 #include "chrome/browser/ui/views/compact_nav/compact_location_bar_view_host.h" |
| 6 | 6 |
| 7 #if defined(TOOLKIT_USES_GTK) | 7 #if defined(TOOLKIT_USES_GTK) |
| 8 #include <gtk/gtk.h> | 8 #include <gtk/gtk.h> |
| 9 #endif | 9 #endif |
| 10 | 10 |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 bool observing_; | 83 bool observing_; |
| 84 | 84 |
| 85 DISALLOW_COPY_AND_ASSIGN(MouseObserver); | 85 DISALLOW_COPY_AND_ASSIGN(MouseObserver); |
| 86 }; | 86 }; |
| 87 | 87 |
| 88 MouseObserver::MouseObserver(CompactLocationBarViewHost* host, | 88 MouseObserver::MouseObserver(CompactLocationBarViewHost* host, |
| 89 BrowserView* view) | 89 BrowserView* view) |
| 90 : host_(host), | 90 : host_(host), |
| 91 browser_view_(view), | 91 browser_view_(view), |
| 92 observing_(false) { | 92 observing_(false) { |
| 93 DCHECK(host_); |
| 94 DCHECK(browser_view_); |
| 95 DCHECK(browser_view_->GetWidget()); |
| 93 top_level_window_ = browser_view_->GetWidget()->GetNativeView(); | 96 top_level_window_ = browser_view_->GetWidget()->GetNativeView(); |
| 94 } | 97 } |
| 95 | 98 |
| 96 MouseObserver::~MouseObserver() { | 99 MouseObserver::~MouseObserver() { |
| 97 StopObserving(MessageLoopForUI::current()); | 100 StopObserving(MessageLoopForUI::current()); |
| 98 } | 101 } |
| 99 | 102 |
| 100 #if defined(OS_WIN) | 103 #if defined(OS_WIN) |
| 101 void MouseObserver::WillProcessMessage(const MSG& native_event) {} | 104 void MouseObserver::WillProcessMessage(const MSG& native_event) {} |
| 102 void MouseObserver::DidProcessMessage(const MSG& native_event) { | 105 void MouseObserver::DidProcessMessage(const MSG& native_event) { |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 #endif | 159 #endif |
| 157 } | 160 } |
| 158 | 161 |
| 159 bool MouseObserver::HitContentArea(int x, int y) { | 162 bool MouseObserver::HitContentArea(int x, int y) { |
| 160 gfx::Point p(x, y); | 163 gfx::Point p(x, y); |
| 161 // First, exclude the location bar as it's shown on top of | 164 // First, exclude the location bar as it's shown on top of |
| 162 // content area. | 165 // content area. |
| 163 if (HitOnScreen(host_->view(), p)) { | 166 if (HitOnScreen(host_->view(), p)) { |
| 164 return false; | 167 return false; |
| 165 } | 168 } |
| 166 // Treat the bookmark as a content area when it in detached mode. | 169 // Treat the bookmark as a content area when it in detached mode. We must |
| 167 if (browser_view_->GetBookmarkBarView()->IsDetached() && | 170 // check the view itself as it can be NULL for example in popup windows. |
| 171 if (browser_view_->GetBookmarkBarView() && |
| 172 browser_view_->GetBookmarkBarView()->IsDetached() && |
| 168 browser_view_->IsBookmarkBarVisible() && | 173 browser_view_->IsBookmarkBarVisible() && |
| 169 HitOnScreen(browser_view_->GetBookmarkBarView(), p)) { | 174 HitOnScreen(browser_view_->GetBookmarkBarView(), p)) { |
| 170 return true; | 175 return true; |
| 171 } | 176 } |
| 172 if (HitOnScreen(browser_view_->GetContentsView(), p)) { | 177 if (HitOnScreen(browser_view_->GetContentsView(), p)) { |
| 173 return true; | 178 return true; |
| 174 } | 179 } |
| 175 return false; | 180 return false; |
| 176 } | 181 } |
| 177 | 182 |
| (...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 508 bool CompactLocationBarViewHost::IsCurrentTabIndex(int index) { | 513 bool CompactLocationBarViewHost::IsCurrentTabIndex(int index) { |
| 509 return current_tab_model_index_ == index; | 514 return current_tab_model_index_ == index; |
| 510 } | 515 } |
| 511 | 516 |
| 512 bool CompactLocationBarViewHost::IsCurrentTab(TabContents* contents) { | 517 bool CompactLocationBarViewHost::IsCurrentTab(TabContents* contents) { |
| 513 TabStripModel* tab_strip_model = browser_view()->browser()->tabstrip_model(); | 518 TabStripModel* tab_strip_model = browser_view()->browser()->tabstrip_model(); |
| 514 return tab_strip_model->ContainsIndex(current_tab_model_index_) && | 519 return tab_strip_model->ContainsIndex(current_tab_model_index_) && |
| 515 tab_strip_model->GetTabContentsAt(current_tab_model_index_)-> | 520 tab_strip_model->GetTabContentsAt(current_tab_model_index_)-> |
| 516 tab_contents() == contents; | 521 tab_contents() == contents; |
| 517 } | 522 } |
| OLD | NEW |