OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 }; | 95 }; |
96 | 96 |
97 static const int kNormalModeBackgroundImages[] = { | 97 static const int kNormalModeBackgroundImages[] = { |
98 IDR_LOCATIONBG_L, | 98 IDR_LOCATIONBG_L, |
99 IDR_LOCATIONBG_C, | 99 IDR_LOCATIONBG_C, |
100 IDR_LOCATIONBG_R, | 100 IDR_LOCATIONBG_R, |
101 }; | 101 }; |
102 | 102 |
103 // LocationBarView ----------------------------------------------------------- | 103 // LocationBarView ----------------------------------------------------------- |
104 | 104 |
105 LocationBarView::LocationBarView(Profile* profile, | 105 LocationBarView::LocationBarView(Browser* browser, |
106 Browser* browser, | |
107 ToolbarModel* model, | 106 ToolbarModel* model, |
108 Delegate* delegate, | 107 Delegate* delegate, |
109 Mode mode) | 108 Mode mode) |
110 : profile_(profile), | 109 : browser_(browser), |
111 browser_(browser), | |
112 model_(model), | 110 model_(model), |
113 delegate_(delegate), | 111 delegate_(delegate), |
114 disposition_(CURRENT_TAB), | 112 disposition_(CURRENT_TAB), |
115 transition_(PageTransition::LINK), | 113 transition_(PageTransition::LINK), |
116 location_icon_view_(NULL), | 114 location_icon_view_(NULL), |
117 ev_bubble_view_(NULL), | 115 ev_bubble_view_(NULL), |
118 location_entry_view_(NULL), | 116 location_entry_view_(NULL), |
119 selected_keyword_view_(NULL), | 117 selected_keyword_view_(NULL), |
120 #if defined(OS_WIN) | 118 #if defined(OS_WIN) |
121 suggested_text_view_(NULL), | 119 suggested_text_view_(NULL), |
122 #endif | 120 #endif |
123 keyword_hint_view_(NULL), | 121 keyword_hint_view_(NULL), |
124 star_view_(NULL), | 122 star_view_(NULL), |
125 mode_(mode), | 123 mode_(mode), |
126 show_focus_rect_(false), | 124 show_focus_rect_(false), |
127 bubble_type_(FirstRun::MINIMAL_BUBBLE), | 125 bubble_type_(FirstRun::MINIMAL_BUBBLE), |
128 template_url_service_(NULL), | 126 template_url_service_(NULL), |
129 animation_offset_(0) { | 127 animation_offset_(0) { |
130 DCHECK(profile_); | |
131 set_id(VIEW_ID_LOCATION_BAR); | 128 set_id(VIEW_ID_LOCATION_BAR); |
132 set_focusable(true); | 129 set_focusable(true); |
133 | 130 |
134 if (mode_ == NORMAL) | 131 if (mode_ == NORMAL) |
135 painter_.reset(new views::HorizontalPainter(kNormalModeBackgroundImages)); | 132 painter_.reset(new views::HorizontalPainter(kNormalModeBackgroundImages)); |
136 | 133 |
137 edit_bookmarks_enabled_.Init(prefs::kEditBookmarksEnabled, | 134 edit_bookmarks_enabled_.Init(prefs::kEditBookmarksEnabled, |
138 profile_->GetPrefs(), this); | 135 browser_->profile()->GetPrefs(), this); |
139 } | 136 } |
140 | 137 |
141 LocationBarView::~LocationBarView() { | 138 LocationBarView::~LocationBarView() { |
142 if (template_url_service_) | 139 if (template_url_service_) |
143 template_url_service_->RemoveObserver(this); | 140 template_url_service_->RemoveObserver(this); |
144 } | 141 } |
145 | 142 |
146 void LocationBarView::Init() { | 143 void LocationBarView::Init() { |
147 if (mode_ == POPUP) { | 144 if (mode_ == POPUP) { |
148 font_ = ResourceBundle::GetSharedInstance().GetFont( | 145 font_ = ResourceBundle::GetSharedInstance().GetFont( |
(...skipping 17 matching lines...) Expand all Loading... |
166 | 163 |
167 ev_bubble_view_ = | 164 ev_bubble_view_ = |
168 new EVBubbleView(kEVBubbleBackgroundImages, IDR_OMNIBOX_HTTPS_VALID, | 165 new EVBubbleView(kEVBubbleBackgroundImages, IDR_OMNIBOX_HTTPS_VALID, |
169 GetColor(ToolbarModel::EV_SECURE, SECURITY_TEXT), this); | 166 GetColor(ToolbarModel::EV_SECURE, SECURITY_TEXT), this); |
170 AddChildView(ev_bubble_view_); | 167 AddChildView(ev_bubble_view_); |
171 ev_bubble_view_->SetVisible(false); | 168 ev_bubble_view_->SetVisible(false); |
172 ev_bubble_view_->set_drag_controller(this); | 169 ev_bubble_view_->set_drag_controller(this); |
173 | 170 |
174 // URL edit field. | 171 // URL edit field. |
175 // View container for URL edit field. | 172 // View container for URL edit field. |
| 173 Profile* profile = browser_->profile(); |
176 #if defined(OS_WIN) | 174 #if defined(OS_WIN) |
177 if (views::Widget::IsPureViews()) { | 175 if (views::Widget::IsPureViews()) { |
178 OmniboxViewViews* omnibox_view = | 176 OmniboxViewViews* omnibox_view = new OmniboxViewViews(this, model_, profile, |
179 new OmniboxViewViews(this, model_, profile_, | 177 browser_->command_updater(), mode_ == POPUP, this); |
180 browser_->command_updater(), mode_ == POPUP, this); | |
181 omnibox_view->Init(); | 178 omnibox_view->Init(); |
182 location_entry_.reset(omnibox_view); | 179 location_entry_.reset(omnibox_view); |
183 } else { | 180 } else { |
184 location_entry_.reset(new OmniboxViewWin(font_, this, model_, this, | 181 location_entry_.reset(new OmniboxViewWin(font_, this, model_, this, |
185 GetWidget()->GetNativeView(), profile_, browser_->command_updater(), | 182 GetWidget()->GetNativeView(), browser_->command_updater(), |
186 mode_ == POPUP, this)); | 183 mode_ == POPUP, this)); |
187 } | 184 } |
188 #else | 185 #else |
189 location_entry_.reset(OmniboxViewGtk::Create(this, model_, profile_, | 186 location_entry_.reset(OmniboxViewGtk::Create(this, model_, profile, |
190 browser_->command_updater(), mode_ == POPUP, this)); | 187 browser_->command_updater(), mode_ == POPUP, this)); |
191 #endif | 188 #endif |
192 | 189 |
193 location_entry_view_ = location_entry_->AddToView(this); | 190 location_entry_view_ = location_entry_->AddToView(this); |
194 location_entry_view_->set_id(VIEW_ID_AUTOCOMPLETE); | 191 location_entry_view_->set_id(VIEW_ID_AUTOCOMPLETE); |
195 | 192 |
196 selected_keyword_view_ = new SelectedKeywordView( | 193 selected_keyword_view_ = new SelectedKeywordView( |
197 kSelectedKeywordBackgroundImages, IDR_KEYWORD_SEARCH_MAGNIFIER, | 194 kSelectedKeywordBackgroundImages, IDR_KEYWORD_SEARCH_MAGNIFIER, |
198 GetColor(ToolbarModel::NONE, TEXT), profile_), | 195 GetColor(ToolbarModel::NONE, TEXT), profile); |
199 AddChildView(selected_keyword_view_); | 196 AddChildView(selected_keyword_view_); |
200 selected_keyword_view_->SetFont(font_); | 197 selected_keyword_view_->SetFont(font_); |
201 selected_keyword_view_->SetVisible(false); | 198 selected_keyword_view_->SetVisible(false); |
202 | 199 |
203 SkColor dimmed_text = GetColor(ToolbarModel::NONE, DEEMPHASIZED_TEXT); | 200 SkColor dimmed_text = GetColor(ToolbarModel::NONE, DEEMPHASIZED_TEXT); |
204 | 201 |
205 keyword_hint_view_ = new KeywordHintView(profile_); | 202 keyword_hint_view_ = new KeywordHintView(profile); |
206 AddChildView(keyword_hint_view_); | 203 AddChildView(keyword_hint_view_); |
207 keyword_hint_view_->SetVisible(false); | 204 keyword_hint_view_->SetVisible(false); |
208 keyword_hint_view_->SetFont(font_); | 205 keyword_hint_view_->SetFont(font_); |
209 keyword_hint_view_->SetColor(dimmed_text); | 206 keyword_hint_view_->SetColor(dimmed_text); |
210 | 207 |
211 for (int i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) { | 208 for (int i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) { |
212 ContentSettingImageView* content_blocked_view = new ContentSettingImageView( | 209 ContentSettingImageView* content_blocked_view = |
213 static_cast<ContentSettingsType>(i), this, profile_); | 210 new ContentSettingImageView(static_cast<ContentSettingsType>(i), this); |
214 content_setting_views_.push_back(content_blocked_view); | 211 content_setting_views_.push_back(content_blocked_view); |
215 AddChildView(content_blocked_view); | 212 AddChildView(content_blocked_view); |
216 content_blocked_view->SetVisible(false); | 213 content_blocked_view->SetVisible(false); |
217 } | 214 } |
218 | 215 |
219 // The star is not visible in popups and in the app launcher. | 216 // The star is not visible in popups and in the app launcher. |
220 if (browser_defaults::bookmarks_enabled && (mode_ == NORMAL)) { | 217 if (browser_defaults::bookmarks_enabled && (mode_ == NORMAL)) { |
221 star_view_ = new StarView(browser_->command_updater()); | 218 star_view_ = new StarView(browser_->command_updater()); |
222 AddChildView(star_view_); | 219 AddChildView(star_view_); |
223 star_view_->SetVisible(true); | 220 star_view_->SetVisible(true); |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
340 } | 337 } |
341 } | 338 } |
342 | 339 |
343 void LocationBarView::OnFocus() { | 340 void LocationBarView::OnFocus() { |
344 // Focus the location entry native view. | 341 // Focus the location entry native view. |
345 location_entry_->SetFocus(); | 342 location_entry_->SetFocus(); |
346 GetWidget()->NotifyAccessibilityEvent( | 343 GetWidget()->NotifyAccessibilityEvent( |
347 this, ui::AccessibilityTypes::EVENT_FOCUS, true); | 344 this, ui::AccessibilityTypes::EVENT_FOCUS, true); |
348 } | 345 } |
349 | 346 |
350 void LocationBarView::SetProfile(Profile* profile) { | |
351 DCHECK(profile); | |
352 if (profile_ != profile) { | |
353 profile_ = profile; | |
354 location_entry_->model()->SetProfile(profile); | |
355 selected_keyword_view_->set_profile(profile); | |
356 keyword_hint_view_->set_profile(profile); | |
357 for (ContentSettingViews::const_iterator i(content_setting_views_.begin()); | |
358 i != content_setting_views_.end(); ++i) | |
359 (*i)->set_profile(profile); | |
360 } | |
361 } | |
362 | |
363 void LocationBarView::SetPreviewEnabledPageAction(ExtensionAction* page_action, | 347 void LocationBarView::SetPreviewEnabledPageAction(ExtensionAction* page_action, |
364 bool preview_enabled) { | 348 bool preview_enabled) { |
365 if (mode_ != NORMAL) | 349 if (mode_ != NORMAL) |
366 return; | 350 return; |
367 | 351 |
368 DCHECK(page_action); | 352 DCHECK(page_action); |
369 TabContents* contents = GetTabContentsFromDelegate(delegate_); | 353 TabContents* contents = GetTabContentsFromDelegate(delegate_); |
370 | 354 |
371 RefreshPageActionViews(); | 355 RefreshPageActionViews(); |
372 PageActionWithBadgeView* page_action_view = | 356 PageActionWithBadgeView* page_action_view = |
(...skipping 26 matching lines...) Expand all Loading... |
399 } | 383 } |
400 | 384 |
401 void LocationBarView::ShowStarBubble(const GURL& url, bool newly_bookmarked) { | 385 void LocationBarView::ShowStarBubble(const GURL& url, bool newly_bookmarked) { |
402 gfx::Rect screen_bounds(star_view_->GetImageBounds()); | 386 gfx::Rect screen_bounds(star_view_->GetImageBounds()); |
403 // Compensate for some built-in padding in the Star image. | 387 // Compensate for some built-in padding in the Star image. |
404 screen_bounds.Inset(1, 1, 1, 2); | 388 screen_bounds.Inset(1, 1, 1, 2); |
405 gfx::Point origin(screen_bounds.origin()); | 389 gfx::Point origin(screen_bounds.origin()); |
406 views::View::ConvertPointToScreen(star_view_, &origin); | 390 views::View::ConvertPointToScreen(star_view_, &origin); |
407 screen_bounds.set_origin(origin); | 391 screen_bounds.set_origin(origin); |
408 browser::ShowBookmarkBubbleView(GetWidget(), screen_bounds, star_view_, | 392 browser::ShowBookmarkBubbleView(GetWidget(), screen_bounds, star_view_, |
409 profile_, url, newly_bookmarked); | 393 browser_->profile(), url, newly_bookmarked); |
410 } | 394 } |
411 | 395 |
412 gfx::Point LocationBarView::GetLocationEntryOrigin() const { | 396 gfx::Point LocationBarView::GetLocationEntryOrigin() const { |
413 gfx::Point origin(location_entry_view_->bounds().origin()); | 397 gfx::Point origin(location_entry_view_->bounds().origin()); |
414 // If the UI layout is RTL, the coordinate system is not transformed and | 398 // If the UI layout is RTL, the coordinate system is not transformed and |
415 // therefore we need to adjust the X coordinate so that bubble appears on the | 399 // therefore we need to adjust the X coordinate so that bubble appears on the |
416 // right hand side of the location bar. | 400 // right hand side of the location bar. |
417 if (base::i18n::IsRTL()) | 401 if (base::i18n::IsRTL()) |
418 origin.set_x(width() - origin.x()); | 402 origin.set_x(width() - origin.x()); |
419 views::View::ConvertPointToScreen(this, &origin); | 403 views::View::ConvertPointToScreen(this, &origin); |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
565 if (max_edit_width < 0) | 549 if (max_edit_width < 0) |
566 return; | 550 return; |
567 const int available_width = AvailableWidth(max_edit_width); | 551 const int available_width = AvailableWidth(max_edit_width); |
568 | 552 |
569 const bool show_keyword_hint = !keyword.empty() && is_keyword_hint; | 553 const bool show_keyword_hint = !keyword.empty() && is_keyword_hint; |
570 selected_keyword_view_->SetVisible(show_selected_keyword); | 554 selected_keyword_view_->SetVisible(show_selected_keyword); |
571 keyword_hint_view_->SetVisible(show_keyword_hint); | 555 keyword_hint_view_->SetVisible(show_keyword_hint); |
572 if (show_selected_keyword) { | 556 if (show_selected_keyword) { |
573 if (selected_keyword_view_->keyword() != keyword) { | 557 if (selected_keyword_view_->keyword() != keyword) { |
574 selected_keyword_view_->SetKeyword(keyword); | 558 selected_keyword_view_->SetKeyword(keyword); |
| 559 Profile* profile = browser_->profile(); |
575 const TemplateURL* template_url = | 560 const TemplateURL* template_url = |
576 TemplateURLServiceFactory::GetForProfile(profile_)-> | 561 TemplateURLServiceFactory::GetForProfile(profile)-> |
577 GetTemplateURLForKeyword(keyword); | 562 GetTemplateURLForKeyword(keyword); |
578 if (template_url && template_url->IsExtensionKeyword()) { | 563 if (template_url && template_url->IsExtensionKeyword()) { |
579 const SkBitmap& bitmap = profile_->GetExtensionService()-> | 564 const SkBitmap& bitmap = profile->GetExtensionService()->GetOmniboxIcon( |
580 GetOmniboxIcon(template_url->GetExtensionId()); | 565 template_url->GetExtensionId()); |
581 selected_keyword_view_->SetImage(bitmap); | 566 selected_keyword_view_->SetImage(bitmap); |
582 selected_keyword_view_->set_is_extension_icon(true); | 567 selected_keyword_view_->set_is_extension_icon(true); |
583 } else { | 568 } else { |
584 selected_keyword_view_->SetImage(*ResourceBundle::GetSharedInstance(). | 569 selected_keyword_view_->SetImage(*ResourceBundle::GetSharedInstance(). |
585 GetBitmapNamed(IDR_OMNIBOX_SEARCH)); | 570 GetBitmapNamed(IDR_OMNIBOX_SEARCH)); |
586 selected_keyword_view_->set_is_extension_icon(false); | 571 selected_keyword_view_->set_is_extension_icon(false); |
587 } | 572 } |
588 } | 573 } |
589 } else if (show_keyword_hint) { | 574 } else if (show_keyword_hint) { |
590 if (keyword_hint_view_->keyword() != keyword) | 575 if (keyword_hint_view_->keyword() != keyword) |
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
930 for (PageActionViews::const_iterator i(page_action_views_.begin()); | 915 for (PageActionViews::const_iterator i(page_action_views_.begin()); |
931 i != page_action_views_.end(); ++i) | 916 i != page_action_views_.end(); ++i) |
932 RemoveChildView(*i); | 917 RemoveChildView(*i); |
933 STLDeleteElements(&page_action_views_); | 918 STLDeleteElements(&page_action_views_); |
934 } | 919 } |
935 | 920 |
936 void LocationBarView::RefreshPageActionViews() { | 921 void LocationBarView::RefreshPageActionViews() { |
937 if (mode_ != NORMAL) | 922 if (mode_ != NORMAL) |
938 return; | 923 return; |
939 | 924 |
940 ExtensionService* service = profile_->GetExtensionService(); | 925 ExtensionService* service = browser_->profile()->GetExtensionService(); |
941 if (!service) | 926 if (!service) |
942 return; | 927 return; |
943 | 928 |
944 std::map<ExtensionAction*, bool> old_visibility; | 929 std::map<ExtensionAction*, bool> old_visibility; |
945 for (PageActionViews::const_iterator i(page_action_views_.begin()); | 930 for (PageActionViews::const_iterator i(page_action_views_.begin()); |
946 i != page_action_views_.end(); ++i) | 931 i != page_action_views_.end(); ++i) |
947 old_visibility[(*i)->image_view()->page_action()] = (*i)->IsVisible(); | 932 old_visibility[(*i)->image_view()->page_action()] = (*i)->IsVisible(); |
948 | 933 |
949 // Remember the previous visibility of the page actions so that we can | 934 // Remember the previous visibility of the page actions so that we can |
950 // notify when this changes. | 935 // notify when this changes. |
951 std::vector<ExtensionAction*> page_actions; | 936 std::vector<ExtensionAction*> page_actions; |
952 for (size_t i = 0; i < service->extensions()->size(); ++i) { | 937 for (size_t i = 0; i < service->extensions()->size(); ++i) { |
953 if (service->extensions()->at(i)->page_action()) | 938 if (service->extensions()->at(i)->page_action()) |
954 page_actions.push_back(service->extensions()->at(i)->page_action()); | 939 page_actions.push_back(service->extensions()->at(i)->page_action()); |
955 } | 940 } |
956 | 941 |
957 // On startup we sometimes haven't loaded any extensions. This makes sure | 942 // On startup we sometimes haven't loaded any extensions. This makes sure |
958 // we catch up when the extensions (and any page actions) load. | 943 // we catch up when the extensions (and any page actions) load. |
959 if (page_actions.size() != page_action_views_.size()) { | 944 if (page_actions.size() != page_action_views_.size()) { |
960 DeletePageActionViews(); // Delete the old views (if any). | 945 DeletePageActionViews(); // Delete the old views (if any). |
961 | 946 |
962 page_action_views_.resize(page_actions.size()); | 947 page_action_views_.resize(page_actions.size()); |
963 | 948 |
964 // Add the page actions in reverse order, so that the child views are | 949 // Add the page actions in reverse order, so that the child views are |
965 // inserted in left-to-right order for accessibility. | 950 // inserted in left-to-right order for accessibility. |
966 for (int i = page_actions.size() - 1; i >= 0; --i) { | 951 for (int i = page_actions.size() - 1; i >= 0; --i) { |
967 page_action_views_[i] = new PageActionWithBadgeView( | 952 page_action_views_[i] = new PageActionWithBadgeView( |
968 new PageActionImageView(this, profile_, page_actions[i])); | 953 new PageActionImageView(this, page_actions[i])); |
969 page_action_views_[i]->SetVisible(false); | 954 page_action_views_[i]->SetVisible(false); |
970 AddChildViewAt(page_action_views_[i], GetIndexOf(star_view_)); | 955 AddChildViewAt(page_action_views_[i], GetIndexOf(star_view_)); |
971 } | 956 } |
972 } | 957 } |
973 | 958 |
974 TabContents* contents = GetTabContentsFromDelegate(delegate_); | 959 TabContents* contents = GetTabContentsFromDelegate(delegate_); |
975 if (!page_action_views_.empty() && contents) { | 960 if (!page_action_views_.empty() && contents) { |
976 GURL url = GURL(WideToUTF8(model_->GetText())); | 961 GURL url = GURL(WideToUTF8(model_->GetText())); |
977 | 962 |
978 for (PageActionViews::const_iterator i(page_action_views_.begin()); | 963 for (PageActionViews::const_iterator i(page_action_views_.begin()); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1014 IDR_OMNIBOX_HTTP)->width() + kItemPadding; | 999 IDR_OMNIBOX_HTTP)->width() + kItemPadding; |
1015 const int kYOffset = -(kVerticalEdgeThickness + 2); | 1000 const int kYOffset = -(kVerticalEdgeThickness + 2); |
1016 gfx::Point origin(location_entry_view_->bounds().x() + kXOffset, | 1001 gfx::Point origin(location_entry_view_->bounds().x() + kXOffset, |
1017 y() + height() + kYOffset); | 1002 y() + height() + kYOffset); |
1018 // If the UI layout is RTL, the coordinate system is not transformed and | 1003 // If the UI layout is RTL, the coordinate system is not transformed and |
1019 // therefore we need to adjust the X coordinate so that bubble appears on the | 1004 // therefore we need to adjust the X coordinate so that bubble appears on the |
1020 // right hand side of the location bar. | 1005 // right hand side of the location bar. |
1021 if (base::i18n::IsRTL()) | 1006 if (base::i18n::IsRTL()) |
1022 origin.set_x(width() - origin.x()); | 1007 origin.set_x(width() - origin.x()); |
1023 views::View::ConvertPointToScreen(this, &origin); | 1008 views::View::ConvertPointToScreen(this, &origin); |
1024 FirstRunBubble::Show(profile_, GetWidget(), gfx::Rect(origin, gfx::Size()), | 1009 FirstRunBubble::Show(browser_->profile(), GetWidget(), |
1025 BubbleBorder::TOP_LEFT, bubble_type); | 1010 gfx::Rect(origin, gfx::Size()), BubbleBorder::TOP_LEFT, bubble_type); |
1026 #endif | 1011 #endif |
1027 } | 1012 } |
1028 | 1013 |
1029 std::string LocationBarView::GetClassName() const { | 1014 std::string LocationBarView::GetClassName() const { |
1030 return kViewClassName; | 1015 return kViewClassName; |
1031 } | 1016 } |
1032 | 1017 |
1033 bool LocationBarView::SkipDefaultKeyEventProcessing( | 1018 bool LocationBarView::SkipDefaultKeyEventProcessing( |
1034 const views::KeyEvent& event) { | 1019 const views::KeyEvent& event) { |
1035 #if defined(OS_WIN) | 1020 #if defined(OS_WIN) |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1108 const gfx::Point& p) { | 1093 const gfx::Point& p) { |
1109 return true; | 1094 return true; |
1110 } | 1095 } |
1111 | 1096 |
1112 //////////////////////////////////////////////////////////////////////////////// | 1097 //////////////////////////////////////////////////////////////////////////////// |
1113 // LocationBarView, LocationBar implementation: | 1098 // LocationBarView, LocationBar implementation: |
1114 | 1099 |
1115 void LocationBarView::ShowFirstRunBubble(FirstRun::BubbleType bubble_type) { | 1100 void LocationBarView::ShowFirstRunBubble(FirstRun::BubbleType bubble_type) { |
1116 // Wait until search engines have loaded to show the first run bubble. | 1101 // Wait until search engines have loaded to show the first run bubble. |
1117 TemplateURLService* url_service = | 1102 TemplateURLService* url_service = |
1118 TemplateURLServiceFactory::GetForProfile(profile_); | 1103 TemplateURLServiceFactory::GetForProfile(browser_->profile()); |
1119 if (!url_service->loaded()) { | 1104 if (!url_service->loaded()) { |
1120 bubble_type_ = bubble_type; | 1105 bubble_type_ = bubble_type; |
1121 template_url_service_ = url_service; | 1106 template_url_service_ = url_service; |
1122 template_url_service_->AddObserver(this); | 1107 template_url_service_->AddObserver(this); |
1123 template_url_service_->Load(); | 1108 template_url_service_->Load(); |
1124 return; | 1109 return; |
1125 } | 1110 } |
1126 ShowFirstRunBubbleInternal(bubble_type); | 1111 ShowFirstRunBubbleInternal(bubble_type); |
1127 } | 1112 } |
1128 | 1113 |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1254 bool LocationBarView::HasValidSuggestText() const { | 1239 bool LocationBarView::HasValidSuggestText() const { |
1255 return suggested_text_view_ && !suggested_text_view_->size().IsEmpty() && | 1240 return suggested_text_view_ && !suggested_text_view_->size().IsEmpty() && |
1256 !suggested_text_view_->GetText().empty(); | 1241 !suggested_text_view_->GetText().empty(); |
1257 } | 1242 } |
1258 | 1243 |
1259 OmniboxViewWin* LocationBarView::GetOmniboxViewWin() { | 1244 OmniboxViewWin* LocationBarView::GetOmniboxViewWin() { |
1260 CHECK(!views::Widget::IsPureViews()); | 1245 CHECK(!views::Widget::IsPureViews()); |
1261 return static_cast<OmniboxViewWin*>(location_entry_.get()); | 1246 return static_cast<OmniboxViewWin*>(location_entry_.get()); |
1262 } | 1247 } |
1263 #endif | 1248 #endif |
OLD | NEW |