| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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_root_view.h" | 5 #include "chrome/browser/ui/views/frame/browser_root_view.h" |
| 6 | 6 |
| 7 #include "chrome/browser/autocomplete/autocomplete_classifier.h" | 7 #include "chrome/browser/autocomplete/autocomplete_classifier.h" |
| 8 #include "chrome/browser/autocomplete/autocomplete_classifier_factory.h" | 8 #include "chrome/browser/autocomplete/autocomplete_classifier_factory.h" |
| 9 #include "chrome/browser/autocomplete/autocomplete_input.h" | 9 #include "chrome/browser/autocomplete/autocomplete_input.h" |
| 10 #include "chrome/browser/autocomplete/autocomplete_match.h" | 10 #include "chrome/browser/autocomplete/autocomplete_match.h" |
| 11 #include "chrome/browser/defaults.h" | 11 #include "chrome/browser/defaults.h" |
| 12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
| 13 #include "chrome/browser/ui/browser_commands.h" | 13 #include "chrome/browser/ui/browser_commands.h" |
| 14 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 14 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 15 #include "chrome/browser/ui/views/frame/browser_frame.h" | 15 #include "chrome/browser/ui/views/frame/browser_frame.h" |
| 16 #include "chrome/browser/ui/views/frame/browser_view.h" | 16 #include "chrome/browser/ui/views/frame/browser_view.h" |
| 17 #include "chrome/browser/ui/views/tabs/tab_strip.h" | 17 #include "chrome/browser/ui/views/tabs/tab_strip.h" |
| 18 #include "chrome/browser/ui/views/touch_uma/touch_uma.h" | 18 #include "chrome/browser/ui/views/touch_uma/touch_uma.h" |
| 19 #include "ui/base/dragdrop/drag_drop_types.h" | 19 #include "ui/base/dragdrop/drag_drop_types.h" |
| 20 #include "ui/base/dragdrop/os_exchange_data.h" | 20 #include "ui/base/dragdrop/os_exchange_data.h" |
| 21 #include "ui/base/hit_test.h" |
| 21 | 22 |
| 22 // static | 23 // static |
| 23 const char BrowserRootView::kViewClassName[] = | 24 const char BrowserRootView::kViewClassName[] = |
| 24 "browser/ui/views/frame/BrowserRootView"; | 25 "browser/ui/views/frame/BrowserRootView"; |
| 25 | 26 |
| 26 BrowserRootView::BrowserRootView(BrowserView* browser_view, | 27 BrowserRootView::BrowserRootView(BrowserView* browser_view, |
| 27 views::Widget* widget) | 28 views::Widget* widget) |
| 28 : views::internal::RootView(widget), | 29 : views::internal::RootView(widget), |
| 29 browser_view_(browser_view), | 30 browser_view_(browser_view), |
| 30 forwarding_to_tab_strip_(false) { } | 31 forwarding_to_tab_strip_(false) { } |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 | 118 |
| 118 const char* BrowserRootView::GetClassName() const { | 119 const char* BrowserRootView::GetClassName() const { |
| 119 return kViewClassName; | 120 return kViewClassName; |
| 120 } | 121 } |
| 121 | 122 |
| 122 bool BrowserRootView::OnMouseWheel(const ui::MouseWheelEvent& event) { | 123 bool BrowserRootView::OnMouseWheel(const ui::MouseWheelEvent& event) { |
| 123 if (browser_defaults::kScrollEventChangesTab) { | 124 if (browser_defaults::kScrollEventChangesTab) { |
| 124 // Switch to the left/right tab if the wheel-scroll happens over the | 125 // Switch to the left/right tab if the wheel-scroll happens over the |
| 125 // tabstrip, or the empty space beside the tabstrip. | 126 // tabstrip, or the empty space beside the tabstrip. |
| 126 views::View* hit_view = GetEventHandlerForPoint(event.location()); | 127 views::View* hit_view = GetEventHandlerForPoint(event.location()); |
| 127 views::NonClientView* non_client = GetWidget()->non_client_view(); | 128 int hittest = |
| 129 GetWidget()->non_client_view()->NonClientHitTest(event.location()); |
| 128 if (tabstrip()->Contains(hit_view) || | 130 if (tabstrip()->Contains(hit_view) || |
| 129 hit_view == non_client->frame_view()) { | 131 hittest == HTCAPTION || |
| 132 hittest == HTTOP) { |
| 130 int scroll_offset = abs(event.y_offset()) > abs(event.x_offset()) ? | 133 int scroll_offset = abs(event.y_offset()) > abs(event.x_offset()) ? |
| 131 event.y_offset() : -event.x_offset(); | 134 event.y_offset() : -event.x_offset(); |
| 132 Browser* browser = browser_view_->browser(); | 135 Browser* browser = browser_view_->browser(); |
| 133 TabStripModel* model = browser->tab_strip_model(); | 136 TabStripModel* model = browser->tab_strip_model(); |
| 134 // Switch to the next tab only if not at the end of the tab-strip. | 137 // Switch to the next tab only if not at the end of the tab-strip. |
| 135 if (scroll_offset < 0 && model->active_index() + 1 < model->count()) { | 138 if (scroll_offset < 0 && model->active_index() + 1 < model->count()) { |
| 136 chrome::SelectNextTab(browser); | 139 chrome::SelectNextTab(browser); |
| 137 return true; | 140 return true; |
| 138 } | 141 } |
| 139 | 142 |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 AutocompleteClassifierFactory::GetForProfile( | 200 AutocompleteClassifierFactory::GetForProfile( |
| 198 browser_view_->browser()->profile())->Classify( | 201 browser_view_->browser()->profile())->Classify( |
| 199 text, false, false, AutocompleteInput::INVALID_SPEC, &match, NULL); | 202 text, false, false, AutocompleteInput::INVALID_SPEC, &match, NULL); |
| 200 if (!match.destination_url.is_valid()) | 203 if (!match.destination_url.is_valid()) |
| 201 return false; | 204 return false; |
| 202 | 205 |
| 203 if (url) | 206 if (url) |
| 204 *url = match.destination_url; | 207 *url = match.destination_url; |
| 205 return true; | 208 return true; |
| 206 } | 209 } |
| OLD | NEW |