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 1920 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1931 if (!initialized_ || in_process_fullscreen_) | 1931 if (!initialized_ || in_process_fullscreen_) |
1932 return; | 1932 return; |
1933 | 1933 |
1934 views::View::Layout(); | 1934 views::View::Layout(); |
1935 | 1935 |
1936 // TODO(jamescook): Why was this in the middle of layout code? | 1936 // TODO(jamescook): Why was this in the middle of layout code? |
1937 toolbar_->location_bar()->omnibox_view()->SetFocusBehavior( | 1937 toolbar_->location_bar()->omnibox_view()->SetFocusBehavior( |
1938 IsToolbarVisible() ? FocusBehavior::ALWAYS : FocusBehavior::NEVER); | 1938 IsToolbarVisible() ? FocusBehavior::ALWAYS : FocusBehavior::NEVER); |
1939 } | 1939 } |
1940 | 1940 |
1941 void BrowserView::OnGestureEvent(ui::GestureEvent* event) { | |
1942 #if defined(OS_MACOSX) | |
1943 auto get_gesture_command = [](ui::GestureEvent* event, | |
sky
2017/02/22 00:37:17
IMO using a closure for this is overkill. How abou
themblsha
2017/02/22 11:49:50
Ok. I thought that this lambda serves only a very
sky
2017/02/22 17:34:10
You can always use an anonymous namespace above th
themblsha
2017/02/27 11:49:16
Ah, there seems to be no restriction on where the
| |
1944 base::Optional<int>* command) { | |
1945 if (event->details().type() == ui::ET_GESTURE_SWIPE) { | |
1946 if (event->details().swipe_left()) | |
1947 *command = IDC_BACK; | |
1948 else if (event->details().swipe_right()) | |
1949 *command = IDC_FORWARD; | |
1950 } | |
1951 return command->has_value(); | |
1952 }; | |
1953 | |
1954 base::Optional<int> command; | |
sky
2017/02/22 00:37:17
Why bother with a base_optional instead of just th
themblsha
2017/02/22 11:49:50
I thought that it would provide a nice additional
sky
2017/02/22 17:34:10
Like I said, I don't think it really buys you much
| |
1955 if (get_gesture_command(event, &command) && | |
1956 chrome::IsCommandEnabled(browser(), *command)) { | |
1957 chrome::ExecuteCommandWithDisposition( | |
1958 browser(), *command, ui::DispositionFromEventFlags(event->flags())); | |
1959 return; | |
1960 } | |
1961 #endif // OS_MACOSX | |
1962 | |
1963 ClientView::OnGestureEvent(event); | |
1964 } | |
1965 | |
1941 void BrowserView::ViewHierarchyChanged( | 1966 void BrowserView::ViewHierarchyChanged( |
1942 const ViewHierarchyChangedDetails& details) { | 1967 const ViewHierarchyChangedDetails& details) { |
1943 if (!initialized_ && details.is_add && details.child == this && GetWidget()) { | 1968 if (!initialized_ && details.is_add && details.child == this && GetWidget()) { |
1944 InitViews(); | 1969 InitViews(); |
1945 initialized_ = true; | 1970 initialized_ = true; |
1946 } | 1971 } |
1947 } | 1972 } |
1948 | 1973 |
1949 void BrowserView::ChildPreferredSizeChanged(View* child) { | 1974 void BrowserView::ChildPreferredSizeChanged(View* child) { |
1950 Layout(); | 1975 Layout(); |
(...skipping 686 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2637 } | 2662 } |
2638 | 2663 |
2639 extensions::ActiveTabPermissionGranter* | 2664 extensions::ActiveTabPermissionGranter* |
2640 BrowserView::GetActiveTabPermissionGranter() { | 2665 BrowserView::GetActiveTabPermissionGranter() { |
2641 content::WebContents* web_contents = GetActiveWebContents(); | 2666 content::WebContents* web_contents = GetActiveWebContents(); |
2642 if (!web_contents) | 2667 if (!web_contents) |
2643 return nullptr; | 2668 return nullptr; |
2644 return extensions::TabHelper::FromWebContents(web_contents) | 2669 return extensions::TabHelper::FromWebContents(web_contents) |
2645 ->active_tab_permission_granter(); | 2670 ->active_tab_permission_granter(); |
2646 } | 2671 } |
OLD | NEW |