| 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/stl_util.h" | 12 #include "base/stl_util.h" |
| 12 #include "base/utf_string_conversions.h" | 13 #include "base/utf_string_conversions.h" |
| 13 #include "chrome/app/chrome_command_ids.h" | 14 #include "chrome/app/chrome_command_ids.h" |
| 14 #include "chrome/browser/alternate_nav_url_fetcher.h" | 15 #include "chrome/browser/alternate_nav_url_fetcher.h" |
| 15 #include "chrome/browser/command_updater.h" | 16 #include "chrome/browser/command_updater.h" |
| 16 #include "chrome/browser/defaults.h" | 17 #include "chrome/browser/defaults.h" |
| 17 #include "chrome/browser/extensions/api/omnibox/omnibox_api.h" | 18 #include "chrome/browser/extensions/api/omnibox/omnibox_api.h" |
| 18 #include "chrome/browser/extensions/location_bar_controller.h" | 19 #include "chrome/browser/extensions/location_bar_controller.h" |
| 19 #include "chrome/browser/extensions/script_bubble_controller.h" | 20 #include "chrome/browser/extensions/script_bubble_controller.h" |
| 20 #include "chrome/browser/extensions/tab_helper.h" | 21 #include "chrome/browser/extensions/tab_helper.h" |
| 21 #include "chrome/browser/favicon/favicon_tab_helper.h" | 22 #include "chrome/browser/favicon/favicon_tab_helper.h" |
| 22 #include "chrome/browser/prefs/pref_service.h" | 23 #include "chrome/browser/prefs/pref_service.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" |
| 30 #include "chrome/browser/ui/browser_instant_controller.h" |
| 29 #include "chrome/browser/ui/browser_tabstrip.h" | 31 #include "chrome/browser/ui/browser_tabstrip.h" |
| 30 #include "chrome/browser/ui/omnibox/location_bar_util.h" | 32 #include "chrome/browser/ui/omnibox/location_bar_util.h" |
| 31 #include "chrome/browser/ui/omnibox/omnibox_popup_model.h" | 33 #include "chrome/browser/ui/omnibox/omnibox_popup_model.h" |
| 32 #include "chrome/browser/ui/view_ids.h" | 34 #include "chrome/browser/ui/view_ids.h" |
| 33 #include "chrome/browser/ui/views/bookmarks/bookmark_prompt_view.h" | 35 #include "chrome/browser/ui/views/bookmarks/bookmark_prompt_view.h" |
| 34 #include "chrome/browser/ui/views/browser_dialogs.h" | 36 #include "chrome/browser/ui/views/browser_dialogs.h" |
| 35 #include "chrome/browser/ui/views/extensions/extension_popup.h" | 37 #include "chrome/browser/ui/views/extensions/extension_popup.h" |
| 36 #include "chrome/browser/ui/views/location_bar/action_box_button_view.h" | 38 #include "chrome/browser/ui/views/location_bar/action_box_button_view.h" |
| 37 #include "chrome/browser/ui/views/location_bar/content_setting_image_view.h" | 39 #include "chrome/browser/ui/views/location_bar/content_setting_image_view.h" |
| 38 #include "chrome/browser/ui/views/location_bar/ev_bubble_view.h" | 40 #include "chrome/browser/ui/views/location_bar/ev_bubble_view.h" |
| (...skipping 1322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1361 string16::size_type entry_end; | 1363 string16::size_type entry_end; |
| 1362 location_entry_->GetSelectionBounds(&entry_start, &entry_end); | 1364 location_entry_->GetSelectionBounds(&entry_start, &entry_end); |
| 1363 state->selection_start = entry_start; | 1365 state->selection_start = entry_start; |
| 1364 state->selection_end = entry_end; | 1366 state->selection_end = entry_end; |
| 1365 } | 1367 } |
| 1366 | 1368 |
| 1367 bool LocationBarView::HasFocus() const { | 1369 bool LocationBarView::HasFocus() const { |
| 1368 return location_entry_->model()->has_focus(); | 1370 return location_entry_->model()->has_focus(); |
| 1369 } | 1371 } |
| 1370 | 1372 |
| 1373 void LocationBarView::OnBoundsChanged(const gfx::Rect& previous_bounds) { |
| 1374 if (browser_ && browser_->instant_controller() && parent()) { |
| 1375 // Pass the side margins of the location bar to the Instant Controller. |
| 1376 const gfx::Rect bounds = GetBoundsInScreen(); |
| 1377 const gfx::Rect parent_bounds = parent()->GetBoundsInScreen(); |
| 1378 int start = bounds.x() - parent_bounds.x(); |
| 1379 int end = parent_bounds.right() - bounds.right(); |
| 1380 if (base::i18n::IsRTL()) |
| 1381 std::swap(start, end); |
| 1382 browser_->instant_controller()->SetMarginSize(start, end); |
| 1383 } |
| 1384 } |
| 1385 |
| 1371 void LocationBarView::WriteDragDataForView(views::View* sender, | 1386 void LocationBarView::WriteDragDataForView(views::View* sender, |
| 1372 const gfx::Point& press_pt, | 1387 const gfx::Point& press_pt, |
| 1373 OSExchangeData* data) { | 1388 OSExchangeData* data) { |
| 1374 DCHECK_NE(GetDragOperationsForView(sender, press_pt), | 1389 DCHECK_NE(GetDragOperationsForView(sender, press_pt), |
| 1375 ui::DragDropTypes::DRAG_NONE); | 1390 ui::DragDropTypes::DRAG_NONE); |
| 1376 | 1391 |
| 1377 WebContents* web_contents = GetWebContents(); | 1392 WebContents* web_contents = GetWebContents(); |
| 1378 FaviconTabHelper* favicon_tab_helper = | 1393 FaviconTabHelper* favicon_tab_helper = |
| 1379 FaviconTabHelper::FromWebContents(web_contents); | 1394 FaviconTabHelper::FromWebContents(web_contents); |
| 1380 gfx::ImageSkia favicon = favicon_tab_helper->GetFavicon().AsImageSkia(); | 1395 gfx::ImageSkia favicon = favicon_tab_helper->GetFavicon().AsImageSkia(); |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1560 int LocationBarView::GetInternalHeight(bool use_preferred_size) { | 1575 int LocationBarView::GetInternalHeight(bool use_preferred_size) { |
| 1561 int total_height = | 1576 int total_height = |
| 1562 use_preferred_size ? GetPreferredSize().height() : height(); | 1577 use_preferred_size ? GetPreferredSize().height() : height(); |
| 1563 return std::max(total_height - (kVerticalEdgeThickness * 2), 0); | 1578 return std::max(total_height - (kVerticalEdgeThickness * 2), 0); |
| 1564 } | 1579 } |
| 1565 | 1580 |
| 1566 bool LocationBarView::HasValidSuggestText() const { | 1581 bool LocationBarView::HasValidSuggestText() const { |
| 1567 return suggested_text_view_ && !suggested_text_view_->size().IsEmpty() && | 1582 return suggested_text_view_ && !suggested_text_view_->size().IsEmpty() && |
| 1568 !suggested_text_view_->text().empty(); | 1583 !suggested_text_view_->text().empty(); |
| 1569 } | 1584 } |
| OLD | NEW |