| 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" | |
| 11 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
| 12 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
| 13 #include "chrome/app/chrome_command_ids.h" | 12 #include "chrome/app/chrome_command_ids.h" |
| 14 #include "chrome/browser/alternate_nav_url_fetcher.h" | 13 #include "chrome/browser/alternate_nav_url_fetcher.h" |
| 15 #include "chrome/browser/autocomplete/autocomplete_popup_model.h" | 14 #include "chrome/browser/autocomplete/autocomplete_popup_model.h" |
| 16 #include "chrome/browser/chrome_to_mobile_service.h" | 15 #include "chrome/browser/chrome_to_mobile_service.h" |
| 17 #include "chrome/browser/chrome_to_mobile_service_factory.h" | 16 #include "chrome/browser/chrome_to_mobile_service_factory.h" |
| 18 #include "chrome/browser/defaults.h" | 17 #include "chrome/browser/defaults.h" |
| 19 #include "chrome/browser/extensions/extension_browser_event_router.h" | 18 #include "chrome/browser/extensions/extension_browser_event_router.h" |
| 20 #include "chrome/browser/extensions/extension_service.h" | 19 #include "chrome/browser/extensions/extension_service.h" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 #include "content/public/browser/web_contents.h" | 53 #include "content/public/browser/web_contents.h" |
| 55 #include "grit/generated_resources.h" | 54 #include "grit/generated_resources.h" |
| 56 #include "grit/theme_resources.h" | 55 #include "grit/theme_resources.h" |
| 57 #include "grit/theme_resources_standard.h" | 56 #include "grit/theme_resources_standard.h" |
| 58 #include "ui/base/accessibility/accessible_view_state.h" | 57 #include "ui/base/accessibility/accessible_view_state.h" |
| 59 #include "ui/base/dragdrop/drag_drop_types.h" | 58 #include "ui/base/dragdrop/drag_drop_types.h" |
| 60 #include "ui/base/l10n/l10n_util.h" | 59 #include "ui/base/l10n/l10n_util.h" |
| 61 #include "ui/base/layout.h" | 60 #include "ui/base/layout.h" |
| 62 #include "ui/base/resource/resource_bundle.h" | 61 #include "ui/base/resource/resource_bundle.h" |
| 63 #include "ui/base/theme_provider.h" | 62 #include "ui/base/theme_provider.h" |
| 64 #include "ui/base/ui_base_switches.h" | |
| 65 #include "ui/gfx/canvas.h" | 63 #include "ui/gfx/canvas.h" |
| 66 #include "ui/gfx/color_utils.h" | 64 #include "ui/gfx/color_utils.h" |
| 67 #include "ui/gfx/image/image.h" | 65 #include "ui/gfx/image/image.h" |
| 68 #include "ui/gfx/skia_util.h" | 66 #include "ui/gfx/skia_util.h" |
| 69 #include "ui/views/border.h" | 67 #include "ui/views/border.h" |
| 70 #include "ui/views/button_drag_utils.h" | 68 #include "ui/views/button_drag_utils.h" |
| 71 #include "ui/views/controls/label.h" | 69 #include "ui/views/controls/label.h" |
| 72 | 70 |
| 73 #if defined(OS_WIN) && !defined(USE_AURA) | 71 #if defined(OS_WIN) && !defined(USE_AURA) |
| 74 #include "chrome/browser/ui/views/omnibox/omnibox_view_win.h" | 72 #include "chrome/browser/ui/views/omnibox/omnibox_view_win.h" |
| 75 #endif | 73 #endif |
| 76 | 74 |
| 77 #if !defined(OS_CHROMEOS) | 75 #if !defined(OS_CHROMEOS) |
| 78 #include "chrome/browser/ui/views/first_run_bubble.h" | 76 #include "chrome/browser/ui/views/first_run_bubble.h" |
| 79 #endif | 77 #endif |
| 80 | 78 |
| 81 using content::WebContents; | 79 using content::WebContents; |
| 82 using views::View; | 80 using views::View; |
| 83 | 81 |
| 84 namespace { | 82 namespace { |
| 85 | 83 |
| 86 WebContents* GetWebContentsFromDelegate(LocationBarView::Delegate* delegate) { | 84 WebContents* GetWebContentsFromDelegate(LocationBarView::Delegate* delegate) { |
| 87 const TabContents* tab_contents = delegate->GetTabContents(); | 85 const TabContents* tab_contents = delegate->GetTabContents(); |
| 88 return tab_contents ? tab_contents->web_contents() : NULL; | 86 return tab_contents ? tab_contents->web_contents() : NULL; |
| 89 } | 87 } |
| 90 | 88 |
| 91 bool UseOmniboxViews() { | |
| 92 #if defined(OS_WIN) && !defined(USE_AURA) | |
| 93 static bool kUseOmniboxViews = CommandLine::ForCurrentProcess()-> | |
| 94 HasSwitch(switches::kEnableViewsTextfield); | |
| 95 return kUseOmniboxViews; | |
| 96 #endif | |
| 97 return true; | |
| 98 } | |
| 99 | |
| 100 // Return |view| as an OmniboxViewViews, or NULL if it is of a different type. | |
| 101 OmniboxViewViews* GetOmniboxViewViews(OmniboxView* view) { | |
| 102 return UseOmniboxViews() ? static_cast<OmniboxViewViews*>(view) : NULL; | |
| 103 } | |
| 104 | |
| 105 #if defined(OS_WIN) && !defined(USE_AURA) | |
| 106 // Return |view| as an OmniboxViewWin, or NULL if it is of a different type. | |
| 107 OmniboxViewWin* GetOmniboxViewWin(OmniboxView* view) { | |
| 108 return UseOmniboxViews() ? NULL : static_cast<OmniboxViewWin*>(view); | |
| 109 } | |
| 110 #endif | |
| 111 | |
| 112 // Height of the location bar's round corner region. | 89 // Height of the location bar's round corner region. |
| 113 const int kBorderRoundCornerHeight = 5; | 90 const int kBorderRoundCornerHeight = 5; |
| 114 // Width of location bar's round corner region. | 91 // Width of location bar's round corner region. |
| 115 const int kBorderRoundCornerWidth = 4; | 92 const int kBorderRoundCornerWidth = 4; |
| 116 // Radius of the round corners inside the location bar. | 93 // Radius of the round corners inside the location bar. |
| 117 const int kBorderCornerRadius = 2; | 94 const int kBorderCornerRadius = 2; |
| 118 | 95 |
| 119 const int kDesktopItemPadding = 3; | 96 const int kDesktopItemPadding = 3; |
| 120 const int kDesktopEdgeItemPadding = kDesktopItemPadding; | 97 const int kDesktopEdgeItemPadding = kDesktopItemPadding; |
| 121 | 98 |
| (...skipping 1245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1367 int LocationBarView::GetInternalHeight(bool use_preferred_size) { | 1344 int LocationBarView::GetInternalHeight(bool use_preferred_size) { |
| 1368 int total_height = | 1345 int total_height = |
| 1369 use_preferred_size ? GetPreferredSize().height() : height(); | 1346 use_preferred_size ? GetPreferredSize().height() : height(); |
| 1370 return std::max(total_height - (kVerticalEdgeThickness * 2), 0); | 1347 return std::max(total_height - (kVerticalEdgeThickness * 2), 0); |
| 1371 } | 1348 } |
| 1372 | 1349 |
| 1373 bool LocationBarView::HasValidSuggestText() const { | 1350 bool LocationBarView::HasValidSuggestText() const { |
| 1374 return suggested_text_view_ && !suggested_text_view_->size().IsEmpty() && | 1351 return suggested_text_view_ && !suggested_text_view_->size().IsEmpty() && |
| 1375 !suggested_text_view_->text().empty(); | 1352 !suggested_text_view_->text().empty(); |
| 1376 } | 1353 } |
| OLD | NEW |