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/extension_service.h" | 18 #include "chrome/browser/extensions/extension_service.h" |
18 #include "chrome/browser/extensions/extension_system.h" | 19 #include "chrome/browser/extensions/extension_system.h" |
19 #include "chrome/browser/extensions/location_bar_controller.h" | 20 #include "chrome/browser/extensions/location_bar_controller.h" |
20 #include "chrome/browser/extensions/script_bubble_controller.h" | 21 #include "chrome/browser/extensions/script_bubble_controller.h" |
21 #include "chrome/browser/extensions/tab_helper.h" | 22 #include "chrome/browser/extensions/tab_helper.h" |
22 #include "chrome/browser/favicon/favicon_tab_helper.h" | 23 #include "chrome/browser/favicon/favicon_tab_helper.h" |
23 #include "chrome/browser/prefs/pref_service.h" | 24 #include "chrome/browser/prefs/pref_service.h" |
24 #include "chrome/browser/profiles/profile.h" | 25 #include "chrome/browser/profiles/profile.h" |
25 #include "chrome/browser/search_engines/template_url.h" | 26 #include "chrome/browser/search_engines/template_url.h" |
26 #include "chrome/browser/search_engines/template_url_service.h" | 27 #include "chrome/browser/search_engines/template_url_service.h" |
27 #include "chrome/browser/search_engines/template_url_service_factory.h" | 28 #include "chrome/browser/search_engines/template_url_service_factory.h" |
28 #include "chrome/browser/ui/browser.h" | 29 #include "chrome/browser/ui/browser.h" |
29 #include "chrome/browser/ui/browser_finder.h" | 30 #include "chrome/browser/ui/browser_finder.h" |
31 #include "chrome/browser/ui/browser_instant_controller.h" | |
30 #include "chrome/browser/ui/browser_tabstrip.h" | 32 #include "chrome/browser/ui/browser_tabstrip.h" |
31 #include "chrome/browser/ui/omnibox/location_bar_util.h" | 33 #include "chrome/browser/ui/omnibox/location_bar_util.h" |
32 #include "chrome/browser/ui/omnibox/omnibox_popup_model.h" | 34 #include "chrome/browser/ui/omnibox/omnibox_popup_model.h" |
33 #include "chrome/browser/ui/tab_contents/tab_contents.h" | 35 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
34 #include "chrome/browser/ui/view_ids.h" | 36 #include "chrome/browser/ui/view_ids.h" |
35 #include "chrome/browser/ui/views/bookmarks/bookmark_prompt_view.h" | 37 #include "chrome/browser/ui/views/bookmarks/bookmark_prompt_view.h" |
36 #include "chrome/browser/ui/views/browser_dialogs.h" | 38 #include "chrome/browser/ui/views/browser_dialogs.h" |
37 #include "chrome/browser/ui/views/extensions/extension_popup.h" | 39 #include "chrome/browser/ui/views/extensions/extension_popup.h" |
38 #include "chrome/browser/ui/views/location_bar/action_box_button_view.h" | 40 #include "chrome/browser/ui/views/location_bar/action_box_button_view.h" |
39 #include "chrome/browser/ui/views/location_bar/content_setting_image_view.h" | 41 #include "chrome/browser/ui/views/location_bar/content_setting_image_view.h" |
(...skipping 1359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1399 int LocationBarView::GetDragOperationsForView(views::View* sender, | 1401 int LocationBarView::GetDragOperationsForView(views::View* sender, |
1400 const gfx::Point& p) { | 1402 const gfx::Point& p) { |
1401 DCHECK((sender == location_icon_view_) || (sender == ev_bubble_view_)); | 1403 DCHECK((sender == location_icon_view_) || (sender == ev_bubble_view_)); |
1402 WebContents* web_contents = delegate_->GetWebContents(); | 1404 WebContents* web_contents = delegate_->GetWebContents(); |
1403 return (web_contents && web_contents->GetURL().is_valid() && | 1405 return (web_contents && web_contents->GetURL().is_valid() && |
1404 !GetLocationEntry()->IsEditingOrEmpty()) ? | 1406 !GetLocationEntry()->IsEditingOrEmpty()) ? |
1405 (ui::DragDropTypes::DRAG_COPY | ui::DragDropTypes::DRAG_LINK) : | 1407 (ui::DragDropTypes::DRAG_COPY | ui::DragDropTypes::DRAG_LINK) : |
1406 ui::DragDropTypes::DRAG_NONE; | 1408 ui::DragDropTypes::DRAG_NONE; |
1407 } | 1409 } |
1408 | 1410 |
1411 void LocationBarView::OnBoundsChanged(const gfx::Rect& previous_bounds) { | |
sky
2012/12/12 03:46:55
Make position match that of header.
melevin
2012/12/12 19:32:43
Done.
| |
1412 if (browser_ && browser_->instant_controller()) { | |
sky
2012/12/12 03:46:55
Add a check for parent() here too.
melevin
2012/12/12 19:32:43
Done.
| |
1413 // Pass the side margins of the location bar to the Instant Controller. | |
1414 const gfx::Rect bounds = GetBoundsInScreen(); | |
1415 const gfx::Rect parent_bounds = parent()->GetBoundsInScreen(); | |
1416 int start = bounds.x(); | |
1417 int end = | |
1418 parent_bounds.x() + parent_bounds.width() - bounds.width() - start; | |
1419 if (base::i18n::IsRTL()) | |
1420 std::swap(start, end); | |
1421 browser_->instant_controller()->SetMarginSize(start, end); | |
1422 } | |
1423 } | |
1424 | |
1409 bool LocationBarView::CanStartDragForView(View* sender, | 1425 bool LocationBarView::CanStartDragForView(View* sender, |
1410 const gfx::Point& press_pt, | 1426 const gfx::Point& press_pt, |
1411 const gfx::Point& p) { | 1427 const gfx::Point& p) { |
1412 return true; | 1428 return true; |
1413 } | 1429 } |
1414 | 1430 |
1415 //////////////////////////////////////////////////////////////////////////////// | 1431 //////////////////////////////////////////////////////////////////////////////// |
1416 // LocationBarView, LocationBar implementation: | 1432 // LocationBarView, LocationBar implementation: |
1417 | 1433 |
1418 void LocationBarView::ShowFirstRunBubble() { | 1434 void LocationBarView::ShowFirstRunBubble() { |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1571 int LocationBarView::GetInternalHeight(bool use_preferred_size) { | 1587 int LocationBarView::GetInternalHeight(bool use_preferred_size) { |
1572 int total_height = | 1588 int total_height = |
1573 use_preferred_size ? GetPreferredSize().height() : height(); | 1589 use_preferred_size ? GetPreferredSize().height() : height(); |
1574 return std::max(total_height - (kVerticalEdgeThickness * 2), 0); | 1590 return std::max(total_height - (kVerticalEdgeThickness * 2), 0); |
1575 } | 1591 } |
1576 | 1592 |
1577 bool LocationBarView::HasValidSuggestText() const { | 1593 bool LocationBarView::HasValidSuggestText() const { |
1578 return suggested_text_view_ && !suggested_text_view_->size().IsEmpty() && | 1594 return suggested_text_view_ && !suggested_text_view_->size().IsEmpty() && |
1579 !suggested_text_view_->text().empty(); | 1595 !suggested_text_view_->text().empty(); |
1580 } | 1596 } |
OLD | NEW |