OLD | NEW |
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 #include "chrome/browser/ui/views/frame/browser_view.h" | 5 #include "chrome/browser/ui/views/frame/browser_view.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <memory> | 10 #include <memory> |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 PaintBackgroundAttachedMode(canvas, view->GetThemeProvider(), | 264 PaintBackgroundAttachedMode(canvas, view->GetThemeProvider(), |
265 view->GetLocalBounds(), background_image_offset); | 265 view->GetLocalBounds(), background_image_offset); |
266 if (view->height() >= toolbar_overlap) { | 266 if (view->height() >= toolbar_overlap) { |
267 BrowserView::Paint1pxHorizontalLine( | 267 BrowserView::Paint1pxHorizontalLine( |
268 canvas, view->GetThemeProvider()->GetColor( | 268 canvas, view->GetThemeProvider()->GetColor( |
269 ThemeProperties::COLOR_TOOLBAR_BOTTOM_SEPARATOR), | 269 ThemeProperties::COLOR_TOOLBAR_BOTTOM_SEPARATOR), |
270 view->GetLocalBounds(), true); | 270 view->GetLocalBounds(), true); |
271 } | 271 } |
272 } | 272 } |
273 | 273 |
| 274 bool GetGestureCommand(ui::GestureEvent* event, int* command) { |
| 275 DCHECK(command); |
| 276 *command = 0; |
| 277 #if defined(OS_MACOSX) |
| 278 if (event->details().type() == ui::ET_GESTURE_SWIPE) { |
| 279 if (event->details().swipe_left()) { |
| 280 *command = IDC_BACK; |
| 281 return true; |
| 282 } else if (event->details().swipe_right()) { |
| 283 *command = IDC_FORWARD; |
| 284 return true; |
| 285 } |
| 286 } |
| 287 #endif // OS_MACOSX |
| 288 return false; |
| 289 } |
| 290 |
274 } // namespace | 291 } // namespace |
275 | 292 |
276 /////////////////////////////////////////////////////////////////////////////// | 293 /////////////////////////////////////////////////////////////////////////////// |
277 // Delegate implementation for BrowserViewLayout. Usually just forwards calls | 294 // Delegate implementation for BrowserViewLayout. Usually just forwards calls |
278 // into BrowserView. | 295 // into BrowserView. |
279 class BrowserViewLayoutDelegateImpl : public BrowserViewLayoutDelegate { | 296 class BrowserViewLayoutDelegateImpl : public BrowserViewLayoutDelegate { |
280 public: | 297 public: |
281 explicit BrowserViewLayoutDelegateImpl(BrowserView* browser_view) | 298 explicit BrowserViewLayoutDelegateImpl(BrowserView* browser_view) |
282 : browser_view_(browser_view) {} | 299 : browser_view_(browser_view) {} |
283 ~BrowserViewLayoutDelegateImpl() override {} | 300 ~BrowserViewLayoutDelegateImpl() override {} |
(...skipping 1647 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1931 if (!initialized_ || in_process_fullscreen_) | 1948 if (!initialized_ || in_process_fullscreen_) |
1932 return; | 1949 return; |
1933 | 1950 |
1934 views::View::Layout(); | 1951 views::View::Layout(); |
1935 | 1952 |
1936 // TODO(jamescook): Why was this in the middle of layout code? | 1953 // TODO(jamescook): Why was this in the middle of layout code? |
1937 toolbar_->location_bar()->omnibox_view()->SetFocusBehavior( | 1954 toolbar_->location_bar()->omnibox_view()->SetFocusBehavior( |
1938 IsToolbarVisible() ? FocusBehavior::ALWAYS : FocusBehavior::NEVER); | 1955 IsToolbarVisible() ? FocusBehavior::ALWAYS : FocusBehavior::NEVER); |
1939 } | 1956 } |
1940 | 1957 |
| 1958 void BrowserView::OnGestureEvent(ui::GestureEvent* event) { |
| 1959 int command; |
| 1960 if (GetGestureCommand(event, &command) && |
| 1961 chrome::IsCommandEnabled(browser(), command)) { |
| 1962 chrome::ExecuteCommandWithDisposition( |
| 1963 browser(), command, ui::DispositionFromEventFlags(event->flags())); |
| 1964 return; |
| 1965 } |
| 1966 |
| 1967 ClientView::OnGestureEvent(event); |
| 1968 } |
| 1969 |
1941 void BrowserView::ViewHierarchyChanged( | 1970 void BrowserView::ViewHierarchyChanged( |
1942 const ViewHierarchyChangedDetails& details) { | 1971 const ViewHierarchyChangedDetails& details) { |
1943 if (!initialized_ && details.is_add && details.child == this && GetWidget()) { | 1972 if (!initialized_ && details.is_add && details.child == this && GetWidget()) { |
1944 InitViews(); | 1973 InitViews(); |
1945 initialized_ = true; | 1974 initialized_ = true; |
1946 } | 1975 } |
1947 } | 1976 } |
1948 | 1977 |
1949 void BrowserView::ChildPreferredSizeChanged(View* child) { | 1978 void BrowserView::ChildPreferredSizeChanged(View* child) { |
1950 Layout(); | 1979 Layout(); |
(...skipping 686 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2637 } | 2666 } |
2638 | 2667 |
2639 extensions::ActiveTabPermissionGranter* | 2668 extensions::ActiveTabPermissionGranter* |
2640 BrowserView::GetActiveTabPermissionGranter() { | 2669 BrowserView::GetActiveTabPermissionGranter() { |
2641 content::WebContents* web_contents = GetActiveWebContents(); | 2670 content::WebContents* web_contents = GetActiveWebContents(); |
2642 if (!web_contents) | 2671 if (!web_contents) |
2643 return nullptr; | 2672 return nullptr; |
2644 return extensions::TabHelper::FromWebContents(web_contents) | 2673 return extensions::TabHelper::FromWebContents(web_contents) |
2645 ->active_tab_permission_granter(); | 2674 ->active_tab_permission_granter(); |
2646 } | 2675 } |
OLD | NEW |