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

Side by Side Diff: chrome/browser/ui/views/compact_nav/compact_location_bar_view_host.cc

Issue 7834048: Preliminary work to allow Chrome to build with USE_AURA (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 3 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 | Annotate | Revision Log
OLDNEW
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 29 matching lines...) Expand all
40 // TODO(stevet): Share this with CompactLocationBarView. This is the actual 40 // TODO(stevet): Share this with CompactLocationBarView. This is the actual
41 // height, without the overlap added. 41 // height, without the overlap added.
42 const int kCompactNavbarSpacerHeight = 4; 42 const int kCompactNavbarSpacerHeight = 4;
43 const int kBookmarkBarLocationBarOverlap = 2; 43 const int kBookmarkBarLocationBarOverlap = 2;
44 const int kSpacerLocationbarOverlap = 1; 44 const int kSpacerLocationbarOverlap = 1;
45 45
46 } // namespace 46 } // namespace
47 47
48 // An mouse event observer to detect a mouse click on 48 // An mouse event observer to detect a mouse click on
49 // BrowserView's content area and hide the location bar. 49 // BrowserView's content area and hide the location bar.
50 class MouseObserver : public MessageLoopForUI::Observer { 50 class MouseObserver
51 #if !defined(USE_AURA)
52 : public MessageLoopForUI::Observer
53 #endif
54 {
51 public: 55 public:
52 MouseObserver(CompactLocationBarViewHost* host, BrowserView* view); 56 MouseObserver(CompactLocationBarViewHost* host, BrowserView* view);
53 ~MouseObserver(); 57 ~MouseObserver();
54 58
55 // MessageLoopForUI::Observer overrides. 59 // MessageLoopForUI::Observer overrides.
60 #if !defined(USE_AURA)
56 #if defined(OS_WIN) 61 #if defined(OS_WIN)
57 virtual void WillProcessMessage(const MSG& native_event) OVERRIDE; 62 virtual void WillProcessMessage(const MSG& native_event) OVERRIDE;
58 virtual void DidProcessMessage(const MSG& native_event) OVERRIDE; 63 virtual void DidProcessMessage(const MSG& native_event) OVERRIDE;
59 #elif defined(OS_LINUX) 64 #elif defined(OS_LINUX)
60 virtual void WillProcessEvent(GdkEvent* native_event) OVERRIDE; 65 virtual void WillProcessEvent(GdkEvent* native_event) OVERRIDE;
61 virtual void DidProcessEvent(GdkEvent* native_event) OVERRIDE; 66 virtual void DidProcessEvent(GdkEvent* native_event) OVERRIDE;
62 #endif 67 #endif
68 #endif
63 69
64 void Observe(MessageLoopForUI* loop); 70 void Observe(MessageLoopForUI* loop);
65 void StopObserving(MessageLoopForUI* loop); 71 void StopObserving(MessageLoopForUI* loop);
66 72
67 private: 73 private:
68 // TODO(mad): would be nice to have this on the views::Event class. 74 // TODO(mad): would be nice to have this on the views::Event class.
69 bool IsMouseEvent(const views::NativeEvent& native_event); 75 bool IsMouseEvent(const views::NativeEvent& native_event);
70 76
71 bool IsSameTopLevelWindow(views::NativeEvent native_event); 77 bool IsSameTopLevelWindow(views::NativeEvent native_event);
72 78
(...skipping 20 matching lines...) Expand all
93 DCHECK(host_); 99 DCHECK(host_);
94 DCHECK(browser_view_); 100 DCHECK(browser_view_);
95 DCHECK(browser_view_->GetWidget()); 101 DCHECK(browser_view_->GetWidget());
96 top_level_window_ = browser_view_->GetWidget()->GetNativeView(); 102 top_level_window_ = browser_view_->GetWidget()->GetNativeView();
97 } 103 }
98 104
99 MouseObserver::~MouseObserver() { 105 MouseObserver::~MouseObserver() {
100 StopObserving(MessageLoopForUI::current()); 106 StopObserving(MessageLoopForUI::current());
101 } 107 }
102 108
109 #if !defined(USE_AURA)
103 #if defined(OS_WIN) 110 #if defined(OS_WIN)
104 void MouseObserver::WillProcessMessage(const MSG& native_event) {} 111 void MouseObserver::WillProcessMessage(const MSG& native_event) {}
105 void MouseObserver::DidProcessMessage(const MSG& native_event) { 112 void MouseObserver::DidProcessMessage(const MSG& native_event) {
106 #elif defined(OS_LINUX) 113 #elif defined(OS_LINUX)
107 void MouseObserver::WillProcessEvent(GdkEvent* native_event) {} 114 void MouseObserver::WillProcessEvent(GdkEvent* native_event) {}
108 void MouseObserver::DidProcessEvent(GdkEvent* native_event) { 115 void MouseObserver::DidProcessEvent(GdkEvent* native_event) {
109 #endif 116 #endif
110 // Hide the location bar iff the mouse is pressed on the 117 // Hide the location bar iff the mouse is pressed on the
111 // BrowserView's content area. 118 // BrowserView's content area.
112 if (!IsMouseEvent(native_event)) 119 if (!IsMouseEvent(native_event))
113 return; 120 return;
114 views::MouseEvent event(native_event); 121 views::MouseEvent event(native_event);
115 if (event.type() == ui::ET_MOUSE_PRESSED && 122 if (event.type() == ui::ET_MOUSE_PRESSED &&
116 IsSameTopLevelWindow(native_event) && 123 IsSameTopLevelWindow(native_event) &&
117 HitContentArea(event.x(), event.y())) { 124 HitContentArea(event.x(), event.y())) {
118 host_->Hide(true); 125 host_->Hide(true);
119 } 126 }
120 } 127 }
128 #endif
121 129
122 void MouseObserver::Observe(MessageLoopForUI* loop) { 130 void MouseObserver::Observe(MessageLoopForUI* loop) {
131 #if !defined(USE_AURA)
123 if (!observing_) { 132 if (!observing_) {
124 loop->AddObserver(this); 133 loop->AddObserver(this);
125 observing_ = true; 134 observing_ = true;
126 } 135 }
136 #endif
127 } 137 }
128 138
129 void MouseObserver::StopObserving(MessageLoopForUI* loop) { 139 void MouseObserver::StopObserving(MessageLoopForUI* loop) {
140 #if !defined(USE_AURA)
130 if (observing_) { 141 if (observing_) {
131 loop->RemoveObserver(this); 142 loop->RemoveObserver(this);
132 observing_ = false; 143 observing_ = false;
133 } 144 }
145 #endif
134 } 146 }
135 147
136 bool MouseObserver::IsMouseEvent(const views::NativeEvent& native_event) { 148 bool MouseObserver::IsMouseEvent(const views::NativeEvent& native_event) {
137 #if defined(OS_WIN) 149 #if defined(OS_WIN)
138 return views::IsClientMouseEvent(native_event) || 150 return views::IsClientMouseEvent(native_event) ||
139 views::IsNonClientMouseEvent(native_event); 151 views::IsNonClientMouseEvent(native_event);
140 #elif defined(OS_LINUX) 152 #elif defined(OS_LINUX)
141 return native_event->type == GDK_MOTION_NOTIFY || 153 return native_event->type == GDK_MOTION_NOTIFY ||
142 native_event->type == GDK_BUTTON_PRESS || 154 native_event->type == GDK_BUTTON_PRESS ||
143 native_event->type == GDK_2BUTTON_PRESS || 155 native_event->type == GDK_2BUTTON_PRESS ||
144 native_event->type == GDK_3BUTTON_PRESS || 156 native_event->type == GDK_3BUTTON_PRESS ||
145 native_event->type == GDK_BUTTON_RELEASE; 157 native_event->type == GDK_BUTTON_RELEASE;
146 #endif 158 #endif
147 } 159 }
148 160
149 // TODO(mad): Would be nice to have a NativeEvent -> NativeWindow mapping. 161 // TODO(mad): Would be nice to have a NativeEvent -> NativeWindow mapping.
150 // Then, with a GetTopLevel receiving a NativeWindow, we could do this in a 162 // Then, with a GetTopLevel receiving a NativeWindow, we could do this in a
151 // platform independent way. 163 // platform independent way.
152 bool MouseObserver::IsSameTopLevelWindow(views::NativeEvent native_event) { 164 bool MouseObserver::IsSameTopLevelWindow(views::NativeEvent native_event) {
153 #if defined(OS_WIN) 165 #if defined(USE_AURA)
166 // TODO(beng):
167 NOTIMPLEMENTED();
168 return false;
169 #elif defined(OS_WIN)
154 return platform_util::GetTopLevel(native_event.hwnd) == top_level_window_; 170 return platform_util::GetTopLevel(native_event.hwnd) == top_level_window_;
155 #elif defined(OS_LINUX) 171 #elif defined(OS_LINUX)
156 return gdk_window_get_toplevel( 172 return gdk_window_get_toplevel(
157 reinterpret_cast<GdkEventAny*>(native_event)->window) == 173 reinterpret_cast<GdkEventAny*>(native_event)->window) ==
158 top_level_window_->window; 174 top_level_window_->window;
159 #endif 175 #endif
160 } 176 }
161 177
162 bool MouseObserver::HitContentArea(int x, int y) { 178 bool MouseObserver::HitContentArea(int x, int y) {
163 gfx::Point p(x, y); 179 gfx::Point p(x, y);
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
528 bool CompactLocationBarViewHost::IsCurrentTabIndex(int index) { 544 bool CompactLocationBarViewHost::IsCurrentTabIndex(int index) {
529 return current_tab_model_index_ == index; 545 return current_tab_model_index_ == index;
530 } 546 }
531 547
532 bool CompactLocationBarViewHost::IsCurrentTab(TabContents* contents) { 548 bool CompactLocationBarViewHost::IsCurrentTab(TabContents* contents) {
533 TabStripModel* tab_strip_model = browser_view()->browser()->tabstrip_model(); 549 TabStripModel* tab_strip_model = browser_view()->browser()->tabstrip_model();
534 return tab_strip_model->ContainsIndex(current_tab_model_index_) && 550 return tab_strip_model->ContainsIndex(current_tab_model_index_) &&
535 tab_strip_model->GetTabContentsAt(current_tab_model_index_)-> 551 tab_strip_model->GetTabContentsAt(current_tab_model_index_)->
536 tab_contents() == contents; 552 tab_contents() == contents;
537 } 553 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/collected_cookies_win.cc ('k') | chrome/browser/ui/views/constrained_window_views.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698