| 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/location_bar/location_bar_view.h" | 5 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <map> | 8 #include <map> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/i18n/rtl.h" | 11 #include "base/i18n/rtl.h" |
| 12 #include "base/prefs/pref_service.h" | 12 #include "base/prefs/pref_service.h" |
| 13 #include "base/stl_util.h" | 13 #include "base/stl_util.h" |
| 14 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
| 15 #include "chrome/app/chrome_command_ids.h" | 15 #include "chrome/app/chrome_command_ids.h" |
| 16 #include "chrome/browser/command_updater.h" | 16 #include "chrome/browser/command_updater.h" |
| 17 #include "chrome/browser/defaults.h" | 17 #include "chrome/browser/defaults.h" |
| 18 #include "chrome/browser/extensions/api/omnibox/omnibox_api.h" | 18 #include "chrome/browser/extensions/api/omnibox/omnibox_api.h" |
| 19 #include "chrome/browser/extensions/location_bar_controller.h" | 19 #include "chrome/browser/extensions/location_bar_controller.h" |
| 20 #include "chrome/browser/extensions/script_bubble_controller.h" | 20 #include "chrome/browser/extensions/script_bubble_controller.h" |
| 21 #include "chrome/browser/extensions/tab_helper.h" | 21 #include "chrome/browser/extensions/tab_helper.h" |
| 22 #include "chrome/browser/favicon/favicon_tab_helper.h" | 22 #include "chrome/browser/favicon/favicon_tab_helper.h" |
| 23 #include "chrome/browser/instant/instant_controller.h" |
| 23 #include "chrome/browser/profiles/profile.h" | 24 #include "chrome/browser/profiles/profile.h" |
| 24 #include "chrome/browser/search_engines/template_url.h" | 25 #include "chrome/browser/search_engines/template_url.h" |
| 25 #include "chrome/browser/search_engines/template_url_service.h" | 26 #include "chrome/browser/search_engines/template_url_service.h" |
| 26 #include "chrome/browser/search_engines/template_url_service_factory.h" | 27 #include "chrome/browser/search_engines/template_url_service_factory.h" |
| 27 #include "chrome/browser/ui/browser.h" | 28 #include "chrome/browser/ui/browser.h" |
| 28 #include "chrome/browser/ui/browser_finder.h" | 29 #include "chrome/browser/ui/browser_finder.h" |
| 29 #include "chrome/browser/ui/browser_instant_controller.h" | 30 #include "chrome/browser/ui/browser_instant_controller.h" |
| 30 #include "chrome/browser/ui/omnibox/alternate_nav_url_fetcher.h" | 31 #include "chrome/browser/ui/omnibox/alternate_nav_url_fetcher.h" |
| 31 #include "chrome/browser/ui/omnibox/location_bar_util.h" | 32 #include "chrome/browser/ui/omnibox/location_bar_util.h" |
| 32 #include "chrome/browser/ui/omnibox/omnibox_popup_model.h" | 33 #include "chrome/browser/ui/omnibox/omnibox_popup_model.h" |
| (...skipping 1195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1228 if (views::FocusManager::IsTabTraversalKeyEvent(event)) { | 1229 if (views::FocusManager::IsTabTraversalKeyEvent(event)) { |
| 1229 if (location_entry_->model()->popup_model()->IsOpen()) { | 1230 if (location_entry_->model()->popup_model()->IsOpen()) { |
| 1230 // Return true so that the edit sees the tab and moves the selection. | 1231 // Return true so that the edit sees the tab and moves the selection. |
| 1231 return true; | 1232 return true; |
| 1232 } | 1233 } |
| 1233 if (keyword_hint_view_->visible() && !event.IsShiftDown()) { | 1234 if (keyword_hint_view_->visible() && !event.IsShiftDown()) { |
| 1234 // Return true so the edit gets the tab event and enters keyword mode. | 1235 // Return true so the edit gets the tab event and enters keyword mode. |
| 1235 return true; | 1236 return true; |
| 1236 } | 1237 } |
| 1237 | 1238 |
| 1238 // Tab while showing Instant commits instant immediately. | 1239 // Tab while showing Instant commits Instant immediately. |
| 1239 // Return true so that focus traversal isn't attempted. The edit ends | 1240 // Return true so that focus traversal isn't attempted. The edit ends |
| 1240 // up doing nothing in this case. | 1241 // up doing nothing in this case. |
| 1241 if (location_entry_->model()->AcceptCurrentInstantPreview()) | 1242 if (location_entry_->model()->AcceptCurrentInstantPreview()) |
| 1242 return true; | 1243 return true; |
| 1243 } | 1244 } |
| 1244 | 1245 |
| 1245 #if defined(USE_AURA) | 1246 #if defined(USE_AURA) |
| 1246 NOTIMPLEMENTED(); | 1247 NOTIMPLEMENTED(); |
| 1247 return false; | 1248 return false; |
| 1248 #else | 1249 #else |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1267 location_entry_->GetSelectionBounds(&entry_start, &entry_end); | 1268 location_entry_->GetSelectionBounds(&entry_start, &entry_end); |
| 1268 state->selection_start = entry_start; | 1269 state->selection_start = entry_start; |
| 1269 state->selection_end = entry_end; | 1270 state->selection_end = entry_end; |
| 1270 } | 1271 } |
| 1271 | 1272 |
| 1272 bool LocationBarView::HasFocus() const { | 1273 bool LocationBarView::HasFocus() const { |
| 1273 return location_entry_->model()->has_focus(); | 1274 return location_entry_->model()->has_focus(); |
| 1274 } | 1275 } |
| 1275 | 1276 |
| 1276 void LocationBarView::OnBoundsChanged(const gfx::Rect& previous_bounds) { | 1277 void LocationBarView::OnBoundsChanged(const gfx::Rect& previous_bounds) { |
| 1277 if (browser_ && browser_->instant_controller() && parent()) { | 1278 if (browser_ && browser_->instant_controller() && parent()) |
| 1278 browser_->instant_controller()->SetOmniboxBounds(bounds()); | 1279 browser_->instant_controller()->instant()->SetOmniboxBounds(bounds()); |
| 1279 } | |
| 1280 } | 1280 } |
| 1281 | 1281 |
| 1282 void LocationBarView::WriteDragDataForView(views::View* sender, | 1282 void LocationBarView::WriteDragDataForView(views::View* sender, |
| 1283 const gfx::Point& press_pt, | 1283 const gfx::Point& press_pt, |
| 1284 OSExchangeData* data) { | 1284 OSExchangeData* data) { |
| 1285 DCHECK_NE(GetDragOperationsForView(sender, press_pt), | 1285 DCHECK_NE(GetDragOperationsForView(sender, press_pt), |
| 1286 ui::DragDropTypes::DRAG_NONE); | 1286 ui::DragDropTypes::DRAG_NONE); |
| 1287 | 1287 |
| 1288 WebContents* web_contents = GetWebContents(); | 1288 WebContents* web_contents = GetWebContents(); |
| 1289 FaviconTabHelper* favicon_tab_helper = | 1289 FaviconTabHelper* favicon_tab_helper = |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1321 TemplateURLServiceFactory::GetForProfile(profile_); | 1321 TemplateURLServiceFactory::GetForProfile(profile_); |
| 1322 if (!url_service->loaded()) { | 1322 if (!url_service->loaded()) { |
| 1323 template_url_service_ = url_service; | 1323 template_url_service_ = url_service; |
| 1324 template_url_service_->AddObserver(this); | 1324 template_url_service_->AddObserver(this); |
| 1325 template_url_service_->Load(); | 1325 template_url_service_->Load(); |
| 1326 return; | 1326 return; |
| 1327 } | 1327 } |
| 1328 ShowFirstRunBubbleInternal(); | 1328 ShowFirstRunBubbleInternal(); |
| 1329 } | 1329 } |
| 1330 | 1330 |
| 1331 void LocationBarView::SetInstantSuggestion( | |
| 1332 const InstantSuggestion& suggestion) { | |
| 1333 location_entry_->model()->SetInstantSuggestion(suggestion); | |
| 1334 } | |
| 1335 | |
| 1336 string16 LocationBarView::GetInputString() const { | 1331 string16 LocationBarView::GetInputString() const { |
| 1337 return location_input_; | 1332 return location_input_; |
| 1338 } | 1333 } |
| 1339 | 1334 |
| 1340 WindowOpenDisposition LocationBarView::GetWindowOpenDisposition() const { | 1335 WindowOpenDisposition LocationBarView::GetWindowOpenDisposition() const { |
| 1341 return disposition_; | 1336 return disposition_; |
| 1342 } | 1337 } |
| 1343 | 1338 |
| 1344 content::PageTransition LocationBarView::GetPageTransition() const { | 1339 content::PageTransition LocationBarView::GetPageTransition() const { |
| 1345 return transition_; | 1340 return transition_; |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1471 int LocationBarView::GetInternalHeight(bool use_preferred_size) { | 1466 int LocationBarView::GetInternalHeight(bool use_preferred_size) { |
| 1472 int total_height = | 1467 int total_height = |
| 1473 use_preferred_size ? GetPreferredSize().height() : height(); | 1468 use_preferred_size ? GetPreferredSize().height() : height(); |
| 1474 return std::max(total_height - (kVerticalEdgeThickness * 2), 0); | 1469 return std::max(total_height - (kVerticalEdgeThickness * 2), 0); |
| 1475 } | 1470 } |
| 1476 | 1471 |
| 1477 bool LocationBarView::HasValidSuggestText() const { | 1472 bool LocationBarView::HasValidSuggestText() const { |
| 1478 return suggested_text_view_ && !suggested_text_view_->size().IsEmpty() && | 1473 return suggested_text_view_ && !suggested_text_view_->size().IsEmpty() && |
| 1479 !suggested_text_view_->text().empty(); | 1474 !suggested_text_view_->text().empty(); |
| 1480 } | 1475 } |
| OLD | NEW |