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; | |
sky
2017/02/22 17:34:10
I would early return here and on 282, then 285 bec
themblsha
2017/02/27 11:49:16
Ok, I thought my code would make it easier to be r
| |
281 else if (event->details().swipe_right()) | |
282 *command = IDC_FORWARD; | |
283 } | |
284 #endif // OS_MACOSX | |
285 return *command != 0; | |
286 } | |
287 | |
274 } // namespace | 288 } // namespace |
275 | 289 |
276 /////////////////////////////////////////////////////////////////////////////// | 290 /////////////////////////////////////////////////////////////////////////////// |
277 // Delegate implementation for BrowserViewLayout. Usually just forwards calls | 291 // Delegate implementation for BrowserViewLayout. Usually just forwards calls |
278 // into BrowserView. | 292 // into BrowserView. |
279 class BrowserViewLayoutDelegateImpl : public BrowserViewLayoutDelegate { | 293 class BrowserViewLayoutDelegateImpl : public BrowserViewLayoutDelegate { |
280 public: | 294 public: |
281 explicit BrowserViewLayoutDelegateImpl(BrowserView* browser_view) | 295 explicit BrowserViewLayoutDelegateImpl(BrowserView* browser_view) |
282 : browser_view_(browser_view) {} | 296 : browser_view_(browser_view) {} |
283 ~BrowserViewLayoutDelegateImpl() override {} | 297 ~BrowserViewLayoutDelegateImpl() override {} |
(...skipping 1647 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1931 if (!initialized_ || in_process_fullscreen_) | 1945 if (!initialized_ || in_process_fullscreen_) |
1932 return; | 1946 return; |
1933 | 1947 |
1934 views::View::Layout(); | 1948 views::View::Layout(); |
1935 | 1949 |
1936 // TODO(jamescook): Why was this in the middle of layout code? | 1950 // TODO(jamescook): Why was this in the middle of layout code? |
1937 toolbar_->location_bar()->omnibox_view()->SetFocusBehavior( | 1951 toolbar_->location_bar()->omnibox_view()->SetFocusBehavior( |
1938 IsToolbarVisible() ? FocusBehavior::ALWAYS : FocusBehavior::NEVER); | 1952 IsToolbarVisible() ? FocusBehavior::ALWAYS : FocusBehavior::NEVER); |
1939 } | 1953 } |
1940 | 1954 |
1955 void BrowserView::OnGestureEvent(ui::GestureEvent* event) { | |
1956 int command; | |
1957 if (GetGestureCommand(event, &command) && | |
1958 chrome::IsCommandEnabled(browser(), command)) { | |
1959 chrome::ExecuteCommandWithDisposition( | |
1960 browser(), command, ui::DispositionFromEventFlags(event->flags())); | |
1961 return; | |
1962 } | |
1963 | |
1964 ClientView::OnGestureEvent(event); | |
1965 } | |
1966 | |
1941 void BrowserView::ViewHierarchyChanged( | 1967 void BrowserView::ViewHierarchyChanged( |
1942 const ViewHierarchyChangedDetails& details) { | 1968 const ViewHierarchyChangedDetails& details) { |
1943 if (!initialized_ && details.is_add && details.child == this && GetWidget()) { | 1969 if (!initialized_ && details.is_add && details.child == this && GetWidget()) { |
1944 InitViews(); | 1970 InitViews(); |
1945 initialized_ = true; | 1971 initialized_ = true; |
1946 } | 1972 } |
1947 } | 1973 } |
1948 | 1974 |
1949 void BrowserView::ChildPreferredSizeChanged(View* child) { | 1975 void BrowserView::ChildPreferredSizeChanged(View* child) { |
1950 Layout(); | 1976 Layout(); |
(...skipping 686 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2637 } | 2663 } |
2638 | 2664 |
2639 extensions::ActiveTabPermissionGranter* | 2665 extensions::ActiveTabPermissionGranter* |
2640 BrowserView::GetActiveTabPermissionGranter() { | 2666 BrowserView::GetActiveTabPermissionGranter() { |
2641 content::WebContents* web_contents = GetActiveWebContents(); | 2667 content::WebContents* web_contents = GetActiveWebContents(); |
2642 if (!web_contents) | 2668 if (!web_contents) |
2643 return nullptr; | 2669 return nullptr; |
2644 return extensions::TabHelper::FromWebContents(web_contents) | 2670 return extensions::TabHelper::FromWebContents(web_contents) |
2645 ->active_tab_permission_granter(); | 2671 ->active_tab_permission_granter(); |
2646 } | 2672 } |
OLD | NEW |