OLD | NEW |
1 // Copyright (c) 2011 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 #if defined(TOOLKIT_USES_GTK) | 7 #if defined(TOOLKIT_USES_GTK) |
8 #include <gtk/gtk.h> | 8 #include <gtk/gtk.h> |
9 #endif | 9 #endif |
10 | 10 |
11 #include <algorithm> | 11 #include <algorithm> |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 ev_bubble_view_(NULL), | 130 ev_bubble_view_(NULL), |
131 location_entry_view_(NULL), | 131 location_entry_view_(NULL), |
132 selected_keyword_view_(NULL), | 132 selected_keyword_view_(NULL), |
133 #if defined(OS_WIN) || defined(USE_AURA) | 133 #if defined(OS_WIN) || defined(USE_AURA) |
134 suggested_text_view_(NULL), | 134 suggested_text_view_(NULL), |
135 #endif | 135 #endif |
136 keyword_hint_view_(NULL), | 136 keyword_hint_view_(NULL), |
137 star_view_(NULL), | 137 star_view_(NULL), |
138 mode_(mode), | 138 mode_(mode), |
139 show_focus_rect_(false), | 139 show_focus_rect_(false), |
140 bubble_type_(FirstRun::MINIMAL_BUBBLE), | |
141 template_url_service_(NULL), | 140 template_url_service_(NULL), |
142 animation_offset_(0) { | 141 animation_offset_(0) { |
143 set_id(VIEW_ID_LOCATION_BAR); | 142 set_id(VIEW_ID_LOCATION_BAR); |
144 | 143 |
145 if (mode_ == NORMAL) { | 144 if (mode_ == NORMAL) { |
146 painter_.reset( | 145 painter_.reset( |
147 views::Painter::CreateImagePainter( | 146 views::Painter::CreateImagePainter( |
148 *ResourceBundle::GetSharedInstance().GetImageNamed( | 147 *ResourceBundle::GetSharedInstance().GetImageNamed( |
149 IDR_LOCATION_BAR_BORDER).ToSkBitmap(), | 148 IDR_LOCATION_BAR_BORDER).ToSkBitmap(), |
150 gfx::Insets(kBorderRoundCornerHeight, kBorderRoundCornerWidth, | 149 gfx::Insets(kBorderRoundCornerHeight, kBorderRoundCornerWidth, |
(...skipping 846 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
997 UINT flags = event.native_event().wParam; | 996 UINT flags = event.native_event().wParam; |
998 gfx::Point screen_point(event.location()); | 997 gfx::Point screen_point(event.location()); |
999 ConvertPointToScreen(this, &screen_point); | 998 ConvertPointToScreen(this, &screen_point); |
1000 if (views::Widget::IsPureViews()) | 999 if (views::Widget::IsPureViews()) |
1001 NOTIMPLEMENTED(); | 1000 NOTIMPLEMENTED(); |
1002 else | 1001 else |
1003 GetOmniboxViewWin()->HandleExternalMsg(msg, flags, screen_point.ToPOINT()); | 1002 GetOmniboxViewWin()->HandleExternalMsg(msg, flags, screen_point.ToPOINT()); |
1004 } | 1003 } |
1005 #endif | 1004 #endif |
1006 | 1005 |
1007 void LocationBarView::ShowFirstRunBubbleInternal( | 1006 void LocationBarView::ShowFirstRunBubbleInternal() { |
1008 FirstRun::BubbleType bubble_type) { | |
1009 #if !defined(OS_CHROMEOS) | 1007 #if !defined(OS_CHROMEOS) |
1010 // First run bubble doesn't make sense for Chrome OS. | 1008 // First run bubble doesn't make sense for Chrome OS. |
1011 FirstRunBubble::ShowBubble(browser_->profile(), | 1009 FirstRunBubble::ShowBubble(browser_->profile(), location_icon_view_); |
1012 location_icon_view_, | |
1013 views::BubbleBorder::TOP_LEFT, | |
1014 bubble_type); | |
1015 #endif | 1010 #endif |
1016 } | 1011 } |
1017 | 1012 |
1018 std::string LocationBarView::GetClassName() const { | 1013 std::string LocationBarView::GetClassName() const { |
1019 return kViewClassName; | 1014 return kViewClassName; |
1020 } | 1015 } |
1021 | 1016 |
1022 bool LocationBarView::SkipDefaultKeyEventProcessing( | 1017 bool LocationBarView::SkipDefaultKeyEventProcessing( |
1023 const views::KeyEvent& event) { | 1018 const views::KeyEvent& event) { |
1024 #if defined(OS_WIN) | 1019 #if defined(OS_WIN) |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1098 | 1093 |
1099 bool LocationBarView::CanStartDragForView(View* sender, | 1094 bool LocationBarView::CanStartDragForView(View* sender, |
1100 const gfx::Point& press_pt, | 1095 const gfx::Point& press_pt, |
1101 const gfx::Point& p) { | 1096 const gfx::Point& p) { |
1102 return true; | 1097 return true; |
1103 } | 1098 } |
1104 | 1099 |
1105 //////////////////////////////////////////////////////////////////////////////// | 1100 //////////////////////////////////////////////////////////////////////////////// |
1106 // LocationBarView, LocationBar implementation: | 1101 // LocationBarView, LocationBar implementation: |
1107 | 1102 |
1108 void LocationBarView::ShowFirstRunBubble(FirstRun::BubbleType bubble_type) { | 1103 void LocationBarView::ShowFirstRunBubble() { |
1109 // Wait until search engines have loaded to show the first run bubble. | 1104 // Wait until search engines have loaded to show the first run bubble. |
1110 TemplateURLService* url_service = | 1105 TemplateURLService* url_service = |
1111 TemplateURLServiceFactory::GetForProfile(browser_->profile()); | 1106 TemplateURLServiceFactory::GetForProfile(browser_->profile()); |
1112 if (!url_service->loaded()) { | 1107 if (!url_service->loaded()) { |
1113 bubble_type_ = bubble_type; | |
1114 template_url_service_ = url_service; | 1108 template_url_service_ = url_service; |
1115 template_url_service_->AddObserver(this); | 1109 template_url_service_->AddObserver(this); |
1116 template_url_service_->Load(); | 1110 template_url_service_->Load(); |
1117 return; | 1111 return; |
1118 } | 1112 } |
1119 ShowFirstRunBubbleInternal(bubble_type); | 1113 ShowFirstRunBubbleInternal(); |
1120 } | 1114 } |
1121 | 1115 |
1122 void LocationBarView::SetSuggestedText(const string16& text, | 1116 void LocationBarView::SetSuggestedText(const string16& text, |
1123 InstantCompleteBehavior behavior) { | 1117 InstantCompleteBehavior behavior) { |
1124 location_entry_->model()->SetSuggestedText(text, behavior); | 1118 location_entry_->model()->SetSuggestedText(text, behavior); |
1125 } | 1119 } |
1126 | 1120 |
1127 string16 LocationBarView::GetInputString() const { | 1121 string16 LocationBarView::GetInputString() const { |
1128 return location_input_; | 1122 return location_input_; |
1129 } | 1123 } |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1223 | 1217 |
1224 NOTREACHED(); | 1218 NOTREACHED(); |
1225 } | 1219 } |
1226 | 1220 |
1227 void LocationBarView::OnTemplateURLServiceChanged() { | 1221 void LocationBarView::OnTemplateURLServiceChanged() { |
1228 template_url_service_->RemoveObserver(this); | 1222 template_url_service_->RemoveObserver(this); |
1229 template_url_service_ = NULL; | 1223 template_url_service_ = NULL; |
1230 // If the browser is no longer active, let's not show the info bubble, as this | 1224 // If the browser is no longer active, let's not show the info bubble, as this |
1231 // would make the browser the active window again. | 1225 // would make the browser the active window again. |
1232 if (location_entry_view_ && location_entry_view_->GetWidget()->IsActive()) | 1226 if (location_entry_view_ && location_entry_view_->GetWidget()->IsActive()) |
1233 ShowFirstRunBubble(bubble_type_); | 1227 ShowFirstRunBubble(); |
1234 } | 1228 } |
1235 | 1229 |
1236 void LocationBarView::Observe(int type, | 1230 void LocationBarView::Observe(int type, |
1237 const content::NotificationSource& source, | 1231 const content::NotificationSource& source, |
1238 const content::NotificationDetails& details) { | 1232 const content::NotificationDetails& details) { |
1239 if (type == chrome::NOTIFICATION_PREF_CHANGED) { | 1233 if (type == chrome::NOTIFICATION_PREF_CHANGED) { |
1240 std::string* name = content::Details<std::string>(details).ptr(); | 1234 std::string* name = content::Details<std::string>(details).ptr(); |
1241 if (*name == prefs::kEditBookmarksEnabled) | 1235 if (*name == prefs::kEditBookmarksEnabled) |
1242 Update(NULL); | 1236 Update(NULL); |
1243 } | 1237 } |
1244 } | 1238 } |
1245 | 1239 |
1246 #if defined(OS_WIN) || defined(USE_AURA) | 1240 #if defined(OS_WIN) || defined(USE_AURA) |
1247 bool LocationBarView::HasValidSuggestText() const { | 1241 bool LocationBarView::HasValidSuggestText() const { |
1248 return suggested_text_view_ && !suggested_text_view_->size().IsEmpty() && | 1242 return suggested_text_view_ && !suggested_text_view_->size().IsEmpty() && |
1249 !suggested_text_view_->GetText().empty(); | 1243 !suggested_text_view_->GetText().empty(); |
1250 } | 1244 } |
1251 | 1245 |
1252 #if !defined(USE_AURA) | 1246 #if !defined(USE_AURA) |
1253 OmniboxViewWin* LocationBarView::GetOmniboxViewWin() { | 1247 OmniboxViewWin* LocationBarView::GetOmniboxViewWin() { |
1254 CHECK(!views::Widget::IsPureViews()); | 1248 CHECK(!views::Widget::IsPureViews()); |
1255 return static_cast<OmniboxViewWin*>(location_entry_.get()); | 1249 return static_cast<OmniboxViewWin*>(location_entry_.get()); |
1256 } | 1250 } |
1257 #endif | 1251 #endif |
1258 #endif | 1252 #endif |
OLD | NEW |