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 #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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 IDR_LOCATION_BAR_SELECTED_KEYWORD_BACKGROUND_R, | 108 IDR_LOCATION_BAR_SELECTED_KEYWORD_BACKGROUND_R, |
109 }; | 109 }; |
110 | 110 |
111 // Height of the location bar's round corner region. | 111 // Height of the location bar's round corner region. |
112 static const int kBorderRoundCornerHeight = 6; | 112 static const int kBorderRoundCornerHeight = 6; |
113 // Width of location bar's round corner region. | 113 // Width of location bar's round corner region. |
114 static const int kBorderRoundCornerWidth = 5; | 114 static const int kBorderRoundCornerWidth = 5; |
115 | 115 |
116 // LocationBarView ----------------------------------------------------------- | 116 // LocationBarView ----------------------------------------------------------- |
117 | 117 |
118 LocationBarView::LocationBarView(Browser* browser, | 118 LocationBarView::LocationBarView(Profile* profile, |
| 119 CommandUpdater* command_updater, |
119 ToolbarModel* model, | 120 ToolbarModel* model, |
120 Delegate* delegate, | 121 Delegate* delegate, |
121 Mode mode) | 122 Mode mode) |
122 : browser_(browser), | 123 : profile_(profile), |
| 124 command_updater_(command_updater), |
123 model_(model), | 125 model_(model), |
124 delegate_(delegate), | 126 delegate_(delegate), |
125 disposition_(CURRENT_TAB), | 127 disposition_(CURRENT_TAB), |
126 transition_(content::PageTransitionFromInt( | 128 transition_(content::PageTransitionFromInt( |
127 content::PAGE_TRANSITION_TYPED | | 129 content::PAGE_TRANSITION_TYPED | |
128 content::PAGE_TRANSITION_FROM_ADDRESS_BAR)), | 130 content::PAGE_TRANSITION_FROM_ADDRESS_BAR)), |
129 location_icon_view_(NULL), | 131 location_icon_view_(NULL), |
130 ev_bubble_view_(NULL), | 132 ev_bubble_view_(NULL), |
131 location_entry_view_(NULL), | 133 location_entry_view_(NULL), |
132 selected_keyword_view_(NULL), | 134 selected_keyword_view_(NULL), |
(...skipping 12 matching lines...) Expand all Loading... |
145 painter_.reset( | 147 painter_.reset( |
146 views::Painter::CreateImagePainter( | 148 views::Painter::CreateImagePainter( |
147 *ResourceBundle::GetSharedInstance().GetImageNamed( | 149 *ResourceBundle::GetSharedInstance().GetImageNamed( |
148 IDR_LOCATION_BAR_BORDER).ToSkBitmap(), | 150 IDR_LOCATION_BAR_BORDER).ToSkBitmap(), |
149 gfx::Insets(kBorderRoundCornerHeight, kBorderRoundCornerWidth, | 151 gfx::Insets(kBorderRoundCornerHeight, kBorderRoundCornerWidth, |
150 kBorderRoundCornerHeight, kBorderRoundCornerWidth), | 152 kBorderRoundCornerHeight, kBorderRoundCornerWidth), |
151 true)); | 153 true)); |
152 } | 154 } |
153 | 155 |
154 edit_bookmarks_enabled_.Init(prefs::kEditBookmarksEnabled, | 156 edit_bookmarks_enabled_.Init(prefs::kEditBookmarksEnabled, |
155 browser_->profile()->GetPrefs(), this); | 157 profile_->GetPrefs(), this); |
156 } | 158 } |
157 | 159 |
158 LocationBarView::~LocationBarView() { | 160 LocationBarView::~LocationBarView() { |
159 if (template_url_service_) | 161 if (template_url_service_) |
160 template_url_service_->RemoveObserver(this); | 162 template_url_service_->RemoveObserver(this); |
161 } | 163 } |
162 | 164 |
163 void LocationBarView::Init() { | 165 void LocationBarView::Init() { |
164 if (mode_ == POPUP) { | 166 if (mode_ == POPUP) { |
165 font_ = ResourceBundle::GetSharedInstance().GetFont( | 167 font_ = ResourceBundle::GetSharedInstance().GetFont( |
(...skipping 17 matching lines...) Expand all Loading... |
183 | 185 |
184 ev_bubble_view_ = | 186 ev_bubble_view_ = |
185 new EVBubbleView(kEVBubbleBackgroundImages, IDR_OMNIBOX_HTTPS_VALID, | 187 new EVBubbleView(kEVBubbleBackgroundImages, IDR_OMNIBOX_HTTPS_VALID, |
186 GetColor(ToolbarModel::EV_SECURE, SECURITY_TEXT), this); | 188 GetColor(ToolbarModel::EV_SECURE, SECURITY_TEXT), this); |
187 AddChildView(ev_bubble_view_); | 189 AddChildView(ev_bubble_view_); |
188 ev_bubble_view_->SetVisible(false); | 190 ev_bubble_view_->SetVisible(false); |
189 ev_bubble_view_->set_drag_controller(this); | 191 ev_bubble_view_->set_drag_controller(this); |
190 | 192 |
191 // URL edit field. | 193 // URL edit field. |
192 // View container for URL edit field. | 194 // View container for URL edit field. |
193 Profile* profile = browser_->profile(); | |
194 location_entry_.reset(OmniboxView::CreateOmniboxView( | 195 location_entry_.reset(OmniboxView::CreateOmniboxView( |
195 this, | 196 this, |
196 model_, | 197 model_, |
197 profile, | 198 profile_, |
198 browser_->command_updater(), | 199 command_updater_, |
199 mode_ == POPUP, | 200 mode_ == POPUP, |
200 this)); | 201 this)); |
201 SetLocationEntryFocusable(true); | 202 SetLocationEntryFocusable(true); |
202 | 203 |
203 location_entry_view_ = location_entry_->AddToView(this); | 204 location_entry_view_ = location_entry_->AddToView(this); |
204 location_entry_view_->set_id(VIEW_ID_AUTOCOMPLETE); | 205 location_entry_view_->set_id(VIEW_ID_AUTOCOMPLETE); |
205 | 206 |
206 selected_keyword_view_ = new SelectedKeywordView( | 207 selected_keyword_view_ = new SelectedKeywordView( |
207 kSelectedKeywordBackgroundImages, IDR_KEYWORD_SEARCH_MAGNIFIER, | 208 kSelectedKeywordBackgroundImages, IDR_KEYWORD_SEARCH_MAGNIFIER, |
208 GetColor(ToolbarModel::NONE, TEXT), profile); | 209 GetColor(ToolbarModel::NONE, TEXT), profile_); |
209 AddChildView(selected_keyword_view_); | 210 AddChildView(selected_keyword_view_); |
210 selected_keyword_view_->SetFont(font_); | 211 selected_keyword_view_->SetFont(font_); |
211 selected_keyword_view_->SetVisible(false); | 212 selected_keyword_view_->SetVisible(false); |
212 | 213 |
213 keyword_hint_view_ = new KeywordHintView(profile); | 214 keyword_hint_view_ = new KeywordHintView(profile_); |
214 AddChildView(keyword_hint_view_); | 215 AddChildView(keyword_hint_view_); |
215 keyword_hint_view_->SetVisible(false); | 216 keyword_hint_view_->SetVisible(false); |
216 keyword_hint_view_->SetFont(font_); | 217 keyword_hint_view_->SetFont(font_); |
217 | 218 |
218 for (int i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) { | 219 for (int i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) { |
219 ContentSettingImageView* content_blocked_view = | 220 ContentSettingImageView* content_blocked_view = |
220 new ContentSettingImageView(static_cast<ContentSettingsType>(i), this); | 221 new ContentSettingImageView(static_cast<ContentSettingsType>(i), this); |
221 content_setting_views_.push_back(content_blocked_view); | 222 content_setting_views_.push_back(content_blocked_view); |
222 AddChildView(content_blocked_view); | 223 AddChildView(content_blocked_view); |
223 content_blocked_view->SetVisible(false); | 224 content_blocked_view->SetVisible(false); |
224 } | 225 } |
225 | 226 |
226 // The star is not visible in popups and in the app launcher. | 227 // The star is not visible in popups and in the app launcher. |
227 if (browser_defaults::bookmarks_enabled && (mode_ == NORMAL)) { | 228 if (browser_defaults::bookmarks_enabled && (mode_ == NORMAL)) { |
228 star_view_ = new StarView(browser_->command_updater()); | 229 star_view_ = new StarView(command_updater_); |
229 AddChildView(star_view_); | 230 AddChildView(star_view_); |
230 star_view_->SetVisible(true); | 231 star_view_->SetVisible(true); |
231 } | 232 } |
232 | 233 |
233 // Initialize the location entry. We do this to avoid a black flash which is | 234 // Initialize the location entry. We do this to avoid a black flash which is |
234 // visible when the location entry has just been initialized. | 235 // visible when the location entry has just been initialized. |
235 Update(NULL); | 236 Update(NULL); |
236 | 237 |
237 OnChanged(); | 238 OnChanged(); |
238 } | 239 } |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 FocusLocation(select_all); | 296 FocusLocation(select_all); |
296 } | 297 } |
297 | 298 |
298 void LocationBarView::SetAnimationOffset(int offset) { | 299 void LocationBarView::SetAnimationOffset(int offset) { |
299 animation_offset_ = offset; | 300 animation_offset_ = offset; |
300 } | 301 } |
301 | 302 |
302 void LocationBarView::Update(const WebContents* tab_for_state_restoring) { | 303 void LocationBarView::Update(const WebContents* tab_for_state_restoring) { |
303 bool star_enabled = star_view_ && !model_->input_in_progress() && | 304 bool star_enabled = star_view_ && !model_->input_in_progress() && |
304 edit_bookmarks_enabled_.GetValue(); | 305 edit_bookmarks_enabled_.GetValue(); |
305 browser_->command_updater()->UpdateCommandEnabled( | 306 command_updater_->UpdateCommandEnabled( |
306 IDC_BOOKMARK_PAGE, star_enabled); | 307 IDC_BOOKMARK_PAGE, star_enabled); |
307 if (star_view_) | 308 if (star_view_) |
308 star_view_->SetVisible(star_enabled); | 309 star_view_->SetVisible(star_enabled); |
309 RefreshContentSettingViews(); | 310 RefreshContentSettingViews(); |
310 RefreshPageActionViews(); | 311 RefreshPageActionViews(); |
311 // Don't Update in app launcher mode so that the location entry does not show | 312 // Don't Update in app launcher mode so that the location entry does not show |
312 // a URL or security background. | 313 // a URL or security background. |
313 if (mode_ != APP_LAUNCHER) | 314 if (mode_ != APP_LAUNCHER) |
314 location_entry_->Update(tab_for_state_restoring); | 315 location_entry_->Update(tab_for_state_restoring); |
315 OnChanged(); | 316 OnChanged(); |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
391 } | 392 } |
392 return NULL; | 393 return NULL; |
393 } | 394 } |
394 | 395 |
395 void LocationBarView::SetStarToggled(bool on) { | 396 void LocationBarView::SetStarToggled(bool on) { |
396 if (star_view_) | 397 if (star_view_) |
397 star_view_->SetToggled(on); | 398 star_view_->SetToggled(on); |
398 } | 399 } |
399 | 400 |
400 void LocationBarView::ShowStarBubble(const GURL& url, bool newly_bookmarked) { | 401 void LocationBarView::ShowStarBubble(const GURL& url, bool newly_bookmarked) { |
401 browser::ShowBookmarkBubbleView(star_view_, browser_->profile(), url, | 402 browser::ShowBookmarkBubbleView(star_view_, profile_, url, |
402 newly_bookmarked); | 403 newly_bookmarked); |
403 } | 404 } |
404 | 405 |
405 gfx::Point LocationBarView::GetLocationEntryOrigin() const { | 406 gfx::Point LocationBarView::GetLocationEntryOrigin() const { |
406 gfx::Point origin(location_entry_view_->bounds().origin()); | 407 gfx::Point origin(location_entry_view_->bounds().origin()); |
407 // If the UI layout is RTL, the coordinate system is not transformed and | 408 // If the UI layout is RTL, the coordinate system is not transformed and |
408 // therefore we need to adjust the X coordinate so that bubble appears on the | 409 // therefore we need to adjust the X coordinate so that bubble appears on the |
409 // right hand side of the location bar. | 410 // right hand side of the location bar. |
410 if (base::i18n::IsRTL()) | 411 if (base::i18n::IsRTL()) |
411 origin.set_x(width() - origin.x()); | 412 origin.set_x(width() - origin.x()); |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
557 if (max_edit_width < 0) | 558 if (max_edit_width < 0) |
558 return; | 559 return; |
559 const int available_width = AvailableWidth(max_edit_width); | 560 const int available_width = AvailableWidth(max_edit_width); |
560 | 561 |
561 const bool show_keyword_hint = !keyword.empty() && is_keyword_hint; | 562 const bool show_keyword_hint = !keyword.empty() && is_keyword_hint; |
562 selected_keyword_view_->SetVisible(show_selected_keyword); | 563 selected_keyword_view_->SetVisible(show_selected_keyword); |
563 keyword_hint_view_->SetVisible(show_keyword_hint); | 564 keyword_hint_view_->SetVisible(show_keyword_hint); |
564 if (show_selected_keyword) { | 565 if (show_selected_keyword) { |
565 if (selected_keyword_view_->keyword() != keyword) { | 566 if (selected_keyword_view_->keyword() != keyword) { |
566 selected_keyword_view_->SetKeyword(keyword); | 567 selected_keyword_view_->SetKeyword(keyword); |
567 Profile* profile = browser_->profile(); | |
568 const TemplateURL* template_url = | 568 const TemplateURL* template_url = |
569 TemplateURLServiceFactory::GetForProfile(profile)-> | 569 TemplateURLServiceFactory::GetForProfile(profile_)-> |
570 GetTemplateURLForKeyword(keyword); | 570 GetTemplateURLForKeyword(keyword); |
571 if (template_url && template_url->IsExtensionKeyword()) { | 571 if (template_url && template_url->IsExtensionKeyword()) { |
572 const SkBitmap& bitmap = profile->GetExtensionService()->GetOmniboxIcon( | 572 const SkBitmap& bitmap = |
573 template_url->GetExtensionId()); | 573 profile_->GetExtensionService()->GetOmniboxIcon( |
| 574 template_url->GetExtensionId()); |
574 selected_keyword_view_->SetImage(bitmap); | 575 selected_keyword_view_->SetImage(bitmap); |
575 selected_keyword_view_->set_is_extension_icon(true); | 576 selected_keyword_view_->set_is_extension_icon(true); |
576 } else { | 577 } else { |
577 selected_keyword_view_->SetImage(*ResourceBundle::GetSharedInstance(). | 578 selected_keyword_view_->SetImage(*ResourceBundle::GetSharedInstance(). |
578 GetBitmapNamed(IDR_OMNIBOX_SEARCH)); | 579 GetBitmapNamed(IDR_OMNIBOX_SEARCH)); |
579 selected_keyword_view_->set_is_extension_icon(false); | 580 selected_keyword_view_->set_is_extension_icon(false); |
580 } | 581 } |
581 } | 582 } |
582 } else if (show_keyword_hint) { | 583 } else if (show_keyword_hint) { |
583 if (keyword_hint_view_->keyword() != keyword) | 584 if (keyword_hint_view_->keyword() != keyword) |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
811 content::PageTransition transition, | 812 content::PageTransition transition, |
812 const GURL& alternate_nav_url) { | 813 const GURL& alternate_nav_url) { |
813 // WARNING: don't add an early return here. The calls after the if must | 814 // WARNING: don't add an early return here. The calls after the if must |
814 // happen. | 815 // happen. |
815 if (url.is_valid()) { | 816 if (url.is_valid()) { |
816 location_input_ = UTF8ToUTF16(url.spec()); | 817 location_input_ = UTF8ToUTF16(url.spec()); |
817 disposition_ = disposition; | 818 disposition_ = disposition; |
818 transition_ = content::PageTransitionFromInt( | 819 transition_ = content::PageTransitionFromInt( |
819 transition | content::PAGE_TRANSITION_FROM_ADDRESS_BAR); | 820 transition | content::PAGE_TRANSITION_FROM_ADDRESS_BAR); |
820 | 821 |
821 if (browser_->command_updater()) { | 822 if (command_updater_) { |
822 if (!alternate_nav_url.is_valid()) { | 823 if (!alternate_nav_url.is_valid()) { |
823 browser_->command_updater()->ExecuteCommand(IDC_OPEN_CURRENT_URL); | 824 command_updater_->ExecuteCommand(IDC_OPEN_CURRENT_URL); |
824 } else { | 825 } else { |
825 AlternateNavURLFetcher* fetcher = | 826 AlternateNavURLFetcher* fetcher = |
826 new AlternateNavURLFetcher(alternate_nav_url); | 827 new AlternateNavURLFetcher(alternate_nav_url); |
827 // The AlternateNavURLFetcher will listen for the pending navigation | 828 // The AlternateNavURLFetcher will listen for the pending navigation |
828 // notification that will be issued as a result of the "open URL." It | 829 // notification that will be issued as a result of the "open URL." It |
829 // will automatically install itself into that navigation controller. | 830 // will automatically install itself into that navigation controller. |
830 browser_->command_updater()->ExecuteCommand(IDC_OPEN_CURRENT_URL); | 831 command_updater_->ExecuteCommand(IDC_OPEN_CURRENT_URL); |
831 if (fetcher->state() == AlternateNavURLFetcher::NOT_STARTED) { | 832 if (fetcher->state() == AlternateNavURLFetcher::NOT_STARTED) { |
832 // I'm not sure this should be reachable, but I'm not also sure enough | 833 // I'm not sure this should be reachable, but I'm not also sure enough |
833 // that it shouldn't to stick in a NOTREACHED(). In any case, this is | 834 // that it shouldn't to stick in a NOTREACHED(). In any case, this is |
834 // harmless. | 835 // harmless. |
835 delete fetcher; | 836 delete fetcher; |
836 } else { | 837 } else { |
837 // The navigation controller will delete the fetcher. | 838 // The navigation controller will delete the fetcher. |
838 } | 839 } |
839 } | 840 } |
840 } | 841 } |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
927 for (PageActionViews::const_iterator i(page_action_views_.begin()); | 928 for (PageActionViews::const_iterator i(page_action_views_.begin()); |
928 i != page_action_views_.end(); ++i) | 929 i != page_action_views_.end(); ++i) |
929 RemoveChildView(*i); | 930 RemoveChildView(*i); |
930 STLDeleteElements(&page_action_views_); | 931 STLDeleteElements(&page_action_views_); |
931 } | 932 } |
932 | 933 |
933 void LocationBarView::RefreshPageActionViews() { | 934 void LocationBarView::RefreshPageActionViews() { |
934 if (mode_ != NORMAL) | 935 if (mode_ != NORMAL) |
935 return; | 936 return; |
936 | 937 |
937 ExtensionService* service = browser_->profile()->GetExtensionService(); | 938 ExtensionService* service = profile_->GetExtensionService(); |
938 if (!service) | 939 if (!service) |
939 return; | 940 return; |
940 | 941 |
941 std::map<ExtensionAction*, bool> old_visibility; | 942 std::map<ExtensionAction*, bool> old_visibility; |
942 for (PageActionViews::const_iterator i(page_action_views_.begin()); | 943 for (PageActionViews::const_iterator i(page_action_views_.begin()); |
943 i != page_action_views_.end(); ++i) | 944 i != page_action_views_.end(); ++i) |
944 old_visibility[(*i)->image_view()->page_action()] = (*i)->visible(); | 945 old_visibility[(*i)->image_view()->page_action()] = (*i)->visible(); |
945 | 946 |
946 // Remember the previous visibility of the page actions so that we can | 947 // Remember the previous visibility of the page actions so that we can |
947 // notify when this changes. | 948 // notify when this changes. |
948 std::vector<ExtensionAction*> page_actions; | 949 std::vector<ExtensionAction*> page_actions; |
949 for (ExtensionSet::const_iterator it = service->extensions()->begin(); | 950 for (ExtensionSet::const_iterator it = service->extensions()->begin(); |
950 it != service->extensions()->end(); ++it) { | 951 it != service->extensions()->end(); ++it) { |
951 if ((*it)->page_action()) | 952 if ((*it)->page_action()) |
952 page_actions.push_back((*it)->page_action()); | 953 page_actions.push_back((*it)->page_action()); |
953 } | 954 } |
954 | 955 |
955 // On startup we sometimes haven't loaded any extensions. This makes sure | 956 // On startup we sometimes haven't loaded any extensions. This makes sure |
956 // we catch up when the extensions (and any page actions) load. | 957 // we catch up when the extensions (and any page actions) load. |
957 if (page_actions.size() != page_action_views_.size()) { | 958 if (page_actions.size() != page_action_views_.size()) { |
958 DeletePageActionViews(); // Delete the old views (if any). | 959 DeletePageActionViews(); // Delete the old views (if any). |
959 | 960 |
960 page_action_views_.resize(page_actions.size()); | 961 page_action_views_.resize(page_actions.size()); |
961 | 962 |
962 // Add the page actions in reverse order, so that the child views are | 963 // Add the page actions in reverse order, so that the child views are |
963 // inserted in left-to-right order for accessibility. | 964 // inserted in left-to-right order for accessibility. |
964 for (int i = page_actions.size() - 1; i >= 0; --i) { | 965 for (int i = page_actions.size() - 1; i >= 0; --i) { |
965 page_action_views_[i] = new PageActionWithBadgeView( | 966 page_action_views_[i] = new PageActionWithBadgeView( |
966 new PageActionImageView(this, page_actions[i])); | 967 delegate_->CreatePageActionImageView(this, page_actions[i])); |
967 page_action_views_[i]->SetVisible(false); | 968 page_action_views_[i]->SetVisible(false); |
968 AddChildViewAt(page_action_views_[i], GetIndexOf(star_view_)); | 969 AddChildViewAt(page_action_views_[i], GetIndexOf(star_view_)); |
969 } | 970 } |
970 } | 971 } |
971 | 972 |
972 WebContents* contents = GetWebContentsFromDelegate(delegate_); | 973 WebContents* contents = GetWebContentsFromDelegate(delegate_); |
973 if (!page_action_views_.empty() && contents) { | 974 if (!page_action_views_.empty() && contents) { |
974 GURL url = GURL(model_->GetText()); | 975 GURL url = GURL(model_->GetText()); |
975 | 976 |
976 for (PageActionViews::const_iterator i(page_action_views_.begin()); | 977 for (PageActionViews::const_iterator i(page_action_views_.begin()); |
(...skipping 22 matching lines...) Expand all Loading... |
999 if (views::Widget::IsPureViews()) | 1000 if (views::Widget::IsPureViews()) |
1000 NOTIMPLEMENTED(); | 1001 NOTIMPLEMENTED(); |
1001 else | 1002 else |
1002 GetOmniboxViewWin()->HandleExternalMsg(msg, flags, screen_point.ToPOINT()); | 1003 GetOmniboxViewWin()->HandleExternalMsg(msg, flags, screen_point.ToPOINT()); |
1003 } | 1004 } |
1004 #endif | 1005 #endif |
1005 | 1006 |
1006 void LocationBarView::ShowFirstRunBubbleInternal() { | 1007 void LocationBarView::ShowFirstRunBubbleInternal() { |
1007 #if !defined(OS_CHROMEOS) | 1008 #if !defined(OS_CHROMEOS) |
1008 // First run bubble doesn't make sense for Chrome OS. | 1009 // First run bubble doesn't make sense for Chrome OS. |
1009 FirstRunBubble::ShowBubble(browser_->profile(), location_icon_view_); | 1010 FirstRunBubble::ShowBubble(profile_, location_icon_view_); |
1010 #endif | 1011 #endif |
1011 } | 1012 } |
1012 | 1013 |
1013 std::string LocationBarView::GetClassName() const { | 1014 std::string LocationBarView::GetClassName() const { |
1014 return kViewClassName; | 1015 return kViewClassName; |
1015 } | 1016 } |
1016 | 1017 |
1017 bool LocationBarView::SkipDefaultKeyEventProcessing( | 1018 bool LocationBarView::SkipDefaultKeyEventProcessing( |
1018 const views::KeyEvent& event) { | 1019 const views::KeyEvent& event) { |
1019 #if defined(OS_WIN) | 1020 #if defined(OS_WIN) |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1089 const gfx::Point& p) { | 1090 const gfx::Point& p) { |
1090 return true; | 1091 return true; |
1091 } | 1092 } |
1092 | 1093 |
1093 //////////////////////////////////////////////////////////////////////////////// | 1094 //////////////////////////////////////////////////////////////////////////////// |
1094 // LocationBarView, LocationBar implementation: | 1095 // LocationBarView, LocationBar implementation: |
1095 | 1096 |
1096 void LocationBarView::ShowFirstRunBubble() { | 1097 void LocationBarView::ShowFirstRunBubble() { |
1097 // Wait until search engines have loaded to show the first run bubble. | 1098 // Wait until search engines have loaded to show the first run bubble. |
1098 TemplateURLService* url_service = | 1099 TemplateURLService* url_service = |
1099 TemplateURLServiceFactory::GetForProfile(browser_->profile()); | 1100 TemplateURLServiceFactory::GetForProfile(profile_); |
1100 if (!url_service->loaded()) { | 1101 if (!url_service->loaded()) { |
1101 template_url_service_ = url_service; | 1102 template_url_service_ = url_service; |
1102 template_url_service_->AddObserver(this); | 1103 template_url_service_->AddObserver(this); |
1103 template_url_service_->Load(); | 1104 template_url_service_->Load(); |
1104 return; | 1105 return; |
1105 } | 1106 } |
1106 ShowFirstRunBubbleInternal(); | 1107 ShowFirstRunBubbleInternal(); |
1107 } | 1108 } |
1108 | 1109 |
1109 void LocationBarView::SetSuggestedText(const string16& text, | 1110 void LocationBarView::SetSuggestedText(const string16& text, |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1236 !suggested_text_view_->GetText().empty(); | 1237 !suggested_text_view_->GetText().empty(); |
1237 } | 1238 } |
1238 | 1239 |
1239 #if !defined(USE_AURA) | 1240 #if !defined(USE_AURA) |
1240 OmniboxViewWin* LocationBarView::GetOmniboxViewWin() { | 1241 OmniboxViewWin* LocationBarView::GetOmniboxViewWin() { |
1241 CHECK(!views::Widget::IsPureViews()); | 1242 CHECK(!views::Widget::IsPureViews()); |
1242 return static_cast<OmniboxViewWin*>(location_entry_.get()); | 1243 return static_cast<OmniboxViewWin*>(location_entry_.get()); |
1243 } | 1244 } |
1244 #endif | 1245 #endif |
1245 #endif | 1246 #endif |
OLD | NEW |