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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 }; | 132 }; |
133 | 133 |
134 static const int kSelectedKeywordBackgroundImages[] = { | 134 static const int kSelectedKeywordBackgroundImages[] = { |
135 IDR_LOCATION_BAR_SELECTED_KEYWORD_BACKGROUND_L, | 135 IDR_LOCATION_BAR_SELECTED_KEYWORD_BACKGROUND_L, |
136 IDR_LOCATION_BAR_SELECTED_KEYWORD_BACKGROUND_C, | 136 IDR_LOCATION_BAR_SELECTED_KEYWORD_BACKGROUND_C, |
137 IDR_LOCATION_BAR_SELECTED_KEYWORD_BACKGROUND_R, | 137 IDR_LOCATION_BAR_SELECTED_KEYWORD_BACKGROUND_R, |
138 }; | 138 }; |
139 | 139 |
140 // LocationBarView ----------------------------------------------------------- | 140 // LocationBarView ----------------------------------------------------------- |
141 | 141 |
142 LocationBarView::LocationBarView(Profile* profile, | 142 LocationBarView::LocationBarView(Browser* browser, |
143 CommandUpdater* command_updater, | |
144 ToolbarModel* model, | 143 ToolbarModel* model, |
145 Delegate* delegate, | 144 Delegate* delegate, |
146 Mode mode) | 145 Mode mode) |
147 : profile_(profile), | 146 : browser_(browser), |
148 command_updater_(command_updater), | |
149 model_(model), | 147 model_(model), |
150 delegate_(delegate), | 148 delegate_(delegate), |
151 disposition_(CURRENT_TAB), | 149 disposition_(CURRENT_TAB), |
152 transition_(content::PageTransitionFromInt( | 150 transition_(content::PageTransitionFromInt( |
153 content::PAGE_TRANSITION_TYPED | | 151 content::PAGE_TRANSITION_TYPED | |
154 content::PAGE_TRANSITION_FROM_ADDRESS_BAR)), | 152 content::PAGE_TRANSITION_FROM_ADDRESS_BAR)), |
155 location_icon_view_(NULL), | 153 location_icon_view_(NULL), |
156 ev_bubble_view_(NULL), | 154 ev_bubble_view_(NULL), |
157 location_entry_view_(NULL), | 155 location_entry_view_(NULL), |
158 selected_keyword_view_(NULL), | 156 selected_keyword_view_(NULL), |
(...skipping 13 matching lines...) Expand all Loading... |
172 painter_.reset( | 170 painter_.reset( |
173 views::Painter::CreateImagePainter( | 171 views::Painter::CreateImagePainter( |
174 *ResourceBundle::GetSharedInstance().GetImageNamed( | 172 *ResourceBundle::GetSharedInstance().GetImageNamed( |
175 IDR_LOCATION_BAR_BORDER).ToSkBitmap(), | 173 IDR_LOCATION_BAR_BORDER).ToSkBitmap(), |
176 gfx::Insets(kBorderRoundCornerHeight, kBorderRoundCornerWidth, | 174 gfx::Insets(kBorderRoundCornerHeight, kBorderRoundCornerWidth, |
177 kBorderRoundCornerHeight, kBorderRoundCornerWidth), | 175 kBorderRoundCornerHeight, kBorderRoundCornerWidth), |
178 true)); | 176 true)); |
179 } | 177 } |
180 | 178 |
181 edit_bookmarks_enabled_.Init(prefs::kEditBookmarksEnabled, | 179 edit_bookmarks_enabled_.Init(prefs::kEditBookmarksEnabled, |
182 profile_->GetPrefs(), this); | 180 browser_->profile()->GetPrefs(), this); |
183 } | 181 } |
184 | 182 |
185 LocationBarView::~LocationBarView() { | 183 LocationBarView::~LocationBarView() { |
186 if (template_url_service_) | 184 if (template_url_service_) |
187 template_url_service_->RemoveObserver(this); | 185 template_url_service_->RemoveObserver(this); |
188 } | 186 } |
189 | 187 |
190 void LocationBarView::Init() { | 188 void LocationBarView::Init() { |
191 if (mode_ == POPUP) { | 189 if (mode_ == POPUP) { |
192 font_ = ResourceBundle::GetSharedInstance().GetFont( | 190 font_ = ResourceBundle::GetSharedInstance().GetFont( |
(...skipping 17 matching lines...) Expand all Loading... |
210 | 208 |
211 ev_bubble_view_ = | 209 ev_bubble_view_ = |
212 new EVBubbleView(kEVBubbleBackgroundImages, IDR_OMNIBOX_HTTPS_VALID, | 210 new EVBubbleView(kEVBubbleBackgroundImages, IDR_OMNIBOX_HTTPS_VALID, |
213 GetColor(ToolbarModel::EV_SECURE, SECURITY_TEXT), this); | 211 GetColor(ToolbarModel::EV_SECURE, SECURITY_TEXT), this); |
214 AddChildView(ev_bubble_view_); | 212 AddChildView(ev_bubble_view_); |
215 ev_bubble_view_->SetVisible(false); | 213 ev_bubble_view_->SetVisible(false); |
216 ev_bubble_view_->set_drag_controller(this); | 214 ev_bubble_view_->set_drag_controller(this); |
217 | 215 |
218 // URL edit field. | 216 // URL edit field. |
219 // View container for URL edit field. | 217 // View container for URL edit field. |
| 218 Profile* profile = browser_->profile(); |
220 location_entry_.reset(OmniboxView::CreateOmniboxView( | 219 location_entry_.reset(OmniboxView::CreateOmniboxView( |
221 this, | 220 this, |
222 model_, | 221 model_, |
223 profile_, | 222 profile, |
224 command_updater_, | 223 browser_->command_updater(), |
225 mode_ == POPUP, | 224 mode_ == POPUP, |
226 this)); | 225 this)); |
227 SetLocationEntryFocusable(true); | 226 SetLocationEntryFocusable(true); |
228 | 227 |
229 location_entry_view_ = location_entry_->AddToView(this); | 228 location_entry_view_ = location_entry_->AddToView(this); |
230 location_entry_view_->set_id(VIEW_ID_AUTOCOMPLETE); | 229 location_entry_view_->set_id(VIEW_ID_AUTOCOMPLETE); |
231 | 230 |
232 selected_keyword_view_ = new SelectedKeywordView( | 231 selected_keyword_view_ = new SelectedKeywordView( |
233 kSelectedKeywordBackgroundImages, IDR_KEYWORD_SEARCH_MAGNIFIER, | 232 kSelectedKeywordBackgroundImages, IDR_KEYWORD_SEARCH_MAGNIFIER, |
234 GetColor(ToolbarModel::NONE, TEXT), profile_); | 233 GetColor(ToolbarModel::NONE, TEXT), profile); |
235 AddChildView(selected_keyword_view_); | 234 AddChildView(selected_keyword_view_); |
236 selected_keyword_view_->SetFont(font_); | 235 selected_keyword_view_->SetFont(font_); |
237 selected_keyword_view_->SetVisible(false); | 236 selected_keyword_view_->SetVisible(false); |
238 | 237 |
239 keyword_hint_view_ = new KeywordHintView(profile_); | 238 keyword_hint_view_ = new KeywordHintView(profile); |
240 AddChildView(keyword_hint_view_); | 239 AddChildView(keyword_hint_view_); |
241 keyword_hint_view_->SetVisible(false); | 240 keyword_hint_view_->SetVisible(false); |
242 keyword_hint_view_->SetFont(font_); | 241 keyword_hint_view_->SetFont(font_); |
243 | 242 |
244 for (int i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) { | 243 for (int i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) { |
245 ContentSettingImageView* content_blocked_view = | 244 ContentSettingImageView* content_blocked_view = |
246 new ContentSettingImageView(static_cast<ContentSettingsType>(i), this); | 245 new ContentSettingImageView(static_cast<ContentSettingsType>(i), this); |
247 content_setting_views_.push_back(content_blocked_view); | 246 content_setting_views_.push_back(content_blocked_view); |
248 AddChildView(content_blocked_view); | 247 AddChildView(content_blocked_view); |
249 content_blocked_view->SetVisible(false); | 248 content_blocked_view->SetVisible(false); |
250 } | 249 } |
251 | 250 |
252 // Hide the star and Chrome To Mobile icons in popups and in the app launcher. | 251 // Hide the star and Chrome To Mobile icons in popups and in the app launcher. |
253 if (browser_defaults::bookmarks_enabled && (mode_ == NORMAL)) { | 252 if (browser_defaults::bookmarks_enabled && (mode_ == NORMAL)) { |
254 star_view_ = new StarView(command_updater_); | 253 star_view_ = new StarView(browser_->command_updater()); |
255 AddChildView(star_view_); | 254 AddChildView(star_view_); |
256 star_view_->SetVisible(true); | 255 star_view_->SetVisible(true); |
257 | 256 |
258 // Also disable Chrome To Mobile for off-the-record and non-synced profiles. | 257 // Also disable Chrome To Mobile for off-the-record and non-synced profiles. |
259 if (!profile_->IsOffTheRecord() && profile_->IsSyncAccessible()) { | 258 Profile* profile = browser_->profile(); |
| 259 if (!profile->IsOffTheRecord() && profile->IsSyncAccessible()) { |
260 chrome_to_mobile_view_ = | 260 chrome_to_mobile_view_ = |
261 new ChromeToMobileView(this, command_updater_); | 261 new ChromeToMobileView(this, browser_->command_updater()); |
262 AddChildView(chrome_to_mobile_view_); | 262 AddChildView(chrome_to_mobile_view_); |
263 ChromeToMobileService* service = | 263 ChromeToMobileService* service = |
264 ChromeToMobileServiceFactory::GetForProfile(profile_); | 264 ChromeToMobileServiceFactory::GetForProfile(browser_->profile()); |
265 service->RequestMobileListUpdate(); | 265 service->RequestMobileListUpdate(); |
266 chrome_to_mobile_view_->SetVisible(!service->mobiles().empty()); | 266 chrome_to_mobile_view_->SetVisible(!service->mobiles().empty()); |
267 } | 267 } |
268 } | 268 } |
269 | 269 |
270 // Initialize the location entry. We do this to avoid a black flash which is | 270 // Initialize the location entry. We do this to avoid a black flash which is |
271 // visible when the location entry has just been initialized. | 271 // visible when the location entry has just been initialized. |
272 Update(NULL); | 272 Update(NULL); |
273 | 273 |
274 OnChanged(); | 274 OnChanged(); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
332 FocusLocation(select_all); | 332 FocusLocation(select_all); |
333 } | 333 } |
334 | 334 |
335 void LocationBarView::SetAnimationOffset(int offset) { | 335 void LocationBarView::SetAnimationOffset(int offset) { |
336 animation_offset_ = offset; | 336 animation_offset_ = offset; |
337 } | 337 } |
338 | 338 |
339 void LocationBarView::Update(const WebContents* tab_for_state_restoring) { | 339 void LocationBarView::Update(const WebContents* tab_for_state_restoring) { |
340 bool star_enabled = star_view_ && !model_->input_in_progress() && | 340 bool star_enabled = star_view_ && !model_->input_in_progress() && |
341 edit_bookmarks_enabled_.GetValue(); | 341 edit_bookmarks_enabled_.GetValue(); |
342 command_updater_->UpdateCommandEnabled(IDC_BOOKMARK_PAGE, star_enabled); | 342 CommandUpdater* command_updater = browser_->command_updater(); |
| 343 command_updater->UpdateCommandEnabled(IDC_BOOKMARK_PAGE, star_enabled); |
343 if (star_view_) | 344 if (star_view_) |
344 star_view_->SetVisible(star_enabled); | 345 star_view_->SetVisible(star_enabled); |
345 | 346 |
| 347 Profile* profile = browser_->profile(); |
346 bool chrome_to_mobile_enabled = chrome_to_mobile_view_ && | 348 bool chrome_to_mobile_enabled = chrome_to_mobile_view_ && |
347 !model_->input_in_progress() && profile_->IsSyncAccessible() && | 349 !model_->input_in_progress() && profile->IsSyncAccessible() && |
348 !ChromeToMobileServiceFactory::GetForProfile(profile_)->mobiles().empty(); | 350 !ChromeToMobileServiceFactory::GetForProfile(profile)->mobiles().empty(); |
349 command_updater_->UpdateCommandEnabled(IDC_CHROME_TO_MOBILE_PAGE, | 351 command_updater->UpdateCommandEnabled(IDC_CHROME_TO_MOBILE_PAGE, |
350 chrome_to_mobile_enabled); | 352 chrome_to_mobile_enabled); |
351 | 353 |
352 RefreshContentSettingViews(); | 354 RefreshContentSettingViews(); |
353 RefreshPageActionViews(); | 355 RefreshPageActionViews(); |
354 // Don't Update in app launcher mode so that the location entry does not show | 356 // Don't Update in app launcher mode so that the location entry does not show |
355 // a URL or security background. | 357 // a URL or security background. |
356 if (mode_ != APP_LAUNCHER) | 358 if (mode_ != APP_LAUNCHER) |
357 location_entry_->Update(tab_for_state_restoring); | 359 location_entry_->Update(tab_for_state_restoring); |
358 OnChanged(); | 360 OnChanged(); |
359 } | 361 } |
360 | 362 |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
434 } | 436 } |
435 return NULL; | 437 return NULL; |
436 } | 438 } |
437 | 439 |
438 void LocationBarView::SetStarToggled(bool on) { | 440 void LocationBarView::SetStarToggled(bool on) { |
439 if (star_view_) | 441 if (star_view_) |
440 star_view_->SetToggled(on); | 442 star_view_->SetToggled(on); |
441 } | 443 } |
442 | 444 |
443 void LocationBarView::ShowStarBubble(const GURL& url, bool newly_bookmarked) { | 445 void LocationBarView::ShowStarBubble(const GURL& url, bool newly_bookmarked) { |
444 browser::ShowBookmarkBubbleView(star_view_, profile_, url, | 446 browser::ShowBookmarkBubbleView(star_view_, browser_->profile(), url, |
445 newly_bookmarked); | 447 newly_bookmarked); |
446 } | 448 } |
447 | 449 |
448 void LocationBarView::ShowChromeToMobileBubble() { | 450 void LocationBarView::ShowChromeToMobileBubble() { |
449 ChromeToMobileServiceFactory::GetForProfile(profile_)-> | 451 ChromeToMobileServiceFactory::GetForProfile(browser_->profile())-> |
450 RequestMobileListUpdate(); | 452 RequestMobileListUpdate(); |
451 browser::ShowChromeToMobileBubbleView(chrome_to_mobile_view_, | 453 browser::ShowChromeToMobileBubbleView(chrome_to_mobile_view_, |
452 profile_); | 454 browser_->profile()); |
453 } | 455 } |
454 | 456 |
455 gfx::Point LocationBarView::GetLocationEntryOrigin() const { | 457 gfx::Point LocationBarView::GetLocationEntryOrigin() const { |
456 gfx::Point origin(location_entry_view_->bounds().origin()); | 458 gfx::Point origin(location_entry_view_->bounds().origin()); |
457 // If the UI layout is RTL, the coordinate system is not transformed and | 459 // If the UI layout is RTL, the coordinate system is not transformed and |
458 // therefore we need to adjust the X coordinate so that bubble appears on the | 460 // therefore we need to adjust the X coordinate so that bubble appears on the |
459 // right hand side of the location bar. | 461 // right hand side of the location bar. |
460 if (base::i18n::IsRTL()) | 462 if (base::i18n::IsRTL()) |
461 origin.set_x(width() - origin.x()); | 463 origin.set_x(width() - origin.x()); |
462 views::View::ConvertPointToScreen(this, &origin); | 464 views::View::ConvertPointToScreen(this, &origin); |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
610 if (max_edit_width < 0) | 612 if (max_edit_width < 0) |
611 return; | 613 return; |
612 const int available_width = AvailableWidth(max_edit_width); | 614 const int available_width = AvailableWidth(max_edit_width); |
613 | 615 |
614 const bool show_keyword_hint = !keyword.empty() && is_keyword_hint; | 616 const bool show_keyword_hint = !keyword.empty() && is_keyword_hint; |
615 selected_keyword_view_->SetVisible(show_selected_keyword); | 617 selected_keyword_view_->SetVisible(show_selected_keyword); |
616 keyword_hint_view_->SetVisible(show_keyword_hint); | 618 keyword_hint_view_->SetVisible(show_keyword_hint); |
617 if (show_selected_keyword) { | 619 if (show_selected_keyword) { |
618 if (selected_keyword_view_->keyword() != keyword) { | 620 if (selected_keyword_view_->keyword() != keyword) { |
619 selected_keyword_view_->SetKeyword(keyword); | 621 selected_keyword_view_->SetKeyword(keyword); |
| 622 Profile* profile = browser_->profile(); |
620 const TemplateURL* template_url = | 623 const TemplateURL* template_url = |
621 TemplateURLServiceFactory::GetForProfile(profile_)-> | 624 TemplateURLServiceFactory::GetForProfile(profile)-> |
622 GetTemplateURLForKeyword(keyword); | 625 GetTemplateURLForKeyword(keyword); |
623 if (template_url && template_url->IsExtensionKeyword()) { | 626 if (template_url && template_url->IsExtensionKeyword()) { |
624 const SkBitmap& bitmap = | 627 const SkBitmap& bitmap = profile->GetExtensionService()->GetOmniboxIcon( |
625 profile_->GetExtensionService()->GetOmniboxIcon( | 628 template_url->GetExtensionId()); |
626 template_url->GetExtensionId()); | |
627 selected_keyword_view_->SetImage(bitmap); | 629 selected_keyword_view_->SetImage(bitmap); |
628 selected_keyword_view_->set_is_extension_icon(true); | 630 selected_keyword_view_->set_is_extension_icon(true); |
629 } else { | 631 } else { |
630 selected_keyword_view_->SetImage(*ResourceBundle::GetSharedInstance(). | 632 selected_keyword_view_->SetImage(*ResourceBundle::GetSharedInstance(). |
631 GetBitmapNamed(IDR_OMNIBOX_SEARCH)); | 633 GetBitmapNamed(IDR_OMNIBOX_SEARCH)); |
632 selected_keyword_view_->set_is_extension_icon(false); | 634 selected_keyword_view_->set_is_extension_icon(false); |
633 } | 635 } |
634 } | 636 } |
635 } else if (show_keyword_hint) { | 637 } else if (show_keyword_hint) { |
636 if (keyword_hint_view_->keyword() != keyword) | 638 if (keyword_hint_view_->keyword() != keyword) |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
877 content::PageTransition transition, | 879 content::PageTransition transition, |
878 const GURL& alternate_nav_url) { | 880 const GURL& alternate_nav_url) { |
879 // WARNING: don't add an early return here. The calls after the if must | 881 // WARNING: don't add an early return here. The calls after the if must |
880 // happen. | 882 // happen. |
881 if (url.is_valid()) { | 883 if (url.is_valid()) { |
882 location_input_ = UTF8ToUTF16(url.spec()); | 884 location_input_ = UTF8ToUTF16(url.spec()); |
883 disposition_ = disposition; | 885 disposition_ = disposition; |
884 transition_ = content::PageTransitionFromInt( | 886 transition_ = content::PageTransitionFromInt( |
885 transition | content::PAGE_TRANSITION_FROM_ADDRESS_BAR); | 887 transition | content::PAGE_TRANSITION_FROM_ADDRESS_BAR); |
886 | 888 |
887 if (command_updater_) { | 889 if (browser_->command_updater()) { |
888 if (!alternate_nav_url.is_valid()) { | 890 if (!alternate_nav_url.is_valid()) { |
889 command_updater_->ExecuteCommand(IDC_OPEN_CURRENT_URL); | 891 browser_->command_updater()->ExecuteCommand(IDC_OPEN_CURRENT_URL); |
890 } else { | 892 } else { |
891 AlternateNavURLFetcher* fetcher = | 893 AlternateNavURLFetcher* fetcher = |
892 new AlternateNavURLFetcher(alternate_nav_url); | 894 new AlternateNavURLFetcher(alternate_nav_url); |
893 // The AlternateNavURLFetcher will listen for the pending navigation | 895 // The AlternateNavURLFetcher will listen for the pending navigation |
894 // notification that will be issued as a result of the "open URL." It | 896 // notification that will be issued as a result of the "open URL." It |
895 // will automatically install itself into that navigation controller. | 897 // will automatically install itself into that navigation controller. |
896 command_updater_->ExecuteCommand(IDC_OPEN_CURRENT_URL); | 898 browser_->command_updater()->ExecuteCommand(IDC_OPEN_CURRENT_URL); |
897 if (fetcher->state() == AlternateNavURLFetcher::NOT_STARTED) { | 899 if (fetcher->state() == AlternateNavURLFetcher::NOT_STARTED) { |
898 // I'm not sure this should be reachable, but I'm not also sure enough | 900 // I'm not sure this should be reachable, but I'm not also sure enough |
899 // that it shouldn't to stick in a NOTREACHED(). In any case, this is | 901 // that it shouldn't to stick in a NOTREACHED(). In any case, this is |
900 // harmless. | 902 // harmless. |
901 delete fetcher; | 903 delete fetcher; |
902 } else { | 904 } else { |
903 // The navigation controller will delete the fetcher. | 905 // The navigation controller will delete the fetcher. |
904 } | 906 } |
905 } | 907 } |
906 } | 908 } |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
993 for (PageActionViews::const_iterator i(page_action_views_.begin()); | 995 for (PageActionViews::const_iterator i(page_action_views_.begin()); |
994 i != page_action_views_.end(); ++i) | 996 i != page_action_views_.end(); ++i) |
995 RemoveChildView(*i); | 997 RemoveChildView(*i); |
996 STLDeleteElements(&page_action_views_); | 998 STLDeleteElements(&page_action_views_); |
997 } | 999 } |
998 | 1000 |
999 void LocationBarView::RefreshPageActionViews() { | 1001 void LocationBarView::RefreshPageActionViews() { |
1000 if (mode_ != NORMAL) | 1002 if (mode_ != NORMAL) |
1001 return; | 1003 return; |
1002 | 1004 |
1003 ExtensionService* service = profile_->GetExtensionService(); | 1005 ExtensionService* service = browser_->profile()->GetExtensionService(); |
1004 if (!service) | 1006 if (!service) |
1005 return; | 1007 return; |
1006 | 1008 |
1007 std::map<ExtensionAction*, bool> old_visibility; | 1009 std::map<ExtensionAction*, bool> old_visibility; |
1008 for (PageActionViews::const_iterator i(page_action_views_.begin()); | 1010 for (PageActionViews::const_iterator i(page_action_views_.begin()); |
1009 i != page_action_views_.end(); ++i) | 1011 i != page_action_views_.end(); ++i) |
1010 old_visibility[(*i)->image_view()->page_action()] = (*i)->visible(); | 1012 old_visibility[(*i)->image_view()->page_action()] = (*i)->visible(); |
1011 | 1013 |
1012 // Remember the previous visibility of the page actions so that we can | 1014 // Remember the previous visibility of the page actions so that we can |
1013 // notify when this changes. | 1015 // notify when this changes. |
(...skipping 10 matching lines...) Expand all Loading... |
1024 DeletePageActionViews(); // Delete the old views (if any). | 1026 DeletePageActionViews(); // Delete the old views (if any). |
1025 | 1027 |
1026 page_action_views_.resize(page_actions.size()); | 1028 page_action_views_.resize(page_actions.size()); |
1027 View* view = chrome_to_mobile_view_ ? chrome_to_mobile_view_ : | 1029 View* view = chrome_to_mobile_view_ ? chrome_to_mobile_view_ : |
1028 static_cast<View*>(star_view_); | 1030 static_cast<View*>(star_view_); |
1029 | 1031 |
1030 // Add the page actions in reverse order, so that the child views are | 1032 // Add the page actions in reverse order, so that the child views are |
1031 // inserted in left-to-right order for accessibility. | 1033 // inserted in left-to-right order for accessibility. |
1032 for (int i = page_actions.size() - 1; i >= 0; --i) { | 1034 for (int i = page_actions.size() - 1; i >= 0; --i) { |
1033 page_action_views_[i] = new PageActionWithBadgeView( | 1035 page_action_views_[i] = new PageActionWithBadgeView( |
1034 delegate_->CreatePageActionImageView(this, page_actions[i])); | 1036 new PageActionImageView(this, page_actions[i])); |
1035 page_action_views_[i]->SetVisible(false); | 1037 page_action_views_[i]->SetVisible(false); |
1036 AddChildViewAt(page_action_views_[i], GetIndexOf(view)); | 1038 AddChildViewAt(page_action_views_[i], GetIndexOf(view)); |
1037 } | 1039 } |
1038 } | 1040 } |
1039 | 1041 |
1040 WebContents* contents = GetWebContentsFromDelegate(delegate_); | 1042 WebContents* contents = GetWebContentsFromDelegate(delegate_); |
1041 if (!page_action_views_.empty() && contents) { | 1043 if (!page_action_views_.empty() && contents) { |
1042 GURL url = GURL(model_->GetText()); | 1044 GURL url = GURL(model_->GetText()); |
1043 | 1045 |
1044 for (PageActionViews::const_iterator i(page_action_views_.begin()); | 1046 for (PageActionViews::const_iterator i(page_action_views_.begin()); |
(...skipping 22 matching lines...) Expand all Loading... |
1067 if (views::Widget::IsPureViews()) | 1069 if (views::Widget::IsPureViews()) |
1068 NOTIMPLEMENTED(); | 1070 NOTIMPLEMENTED(); |
1069 else | 1071 else |
1070 GetOmniboxViewWin()->HandleExternalMsg(msg, flags, screen_point.ToPOINT()); | 1072 GetOmniboxViewWin()->HandleExternalMsg(msg, flags, screen_point.ToPOINT()); |
1071 } | 1073 } |
1072 #endif | 1074 #endif |
1073 | 1075 |
1074 void LocationBarView::ShowFirstRunBubbleInternal() { | 1076 void LocationBarView::ShowFirstRunBubbleInternal() { |
1075 #if !defined(OS_CHROMEOS) | 1077 #if !defined(OS_CHROMEOS) |
1076 // First run bubble doesn't make sense for Chrome OS. | 1078 // First run bubble doesn't make sense for Chrome OS. |
1077 FirstRunBubble::ShowBubble(profile_, location_icon_view_); | 1079 FirstRunBubble::ShowBubble(browser_->profile(), location_icon_view_); |
1078 #endif | 1080 #endif |
1079 } | 1081 } |
1080 | 1082 |
1081 std::string LocationBarView::GetClassName() const { | 1083 std::string LocationBarView::GetClassName() const { |
1082 return kViewClassName; | 1084 return kViewClassName; |
1083 } | 1085 } |
1084 | 1086 |
1085 bool LocationBarView::SkipDefaultKeyEventProcessing( | 1087 bool LocationBarView::SkipDefaultKeyEventProcessing( |
1086 const views::KeyEvent& event) { | 1088 const views::KeyEvent& event) { |
1087 #if defined(OS_WIN) | 1089 #if defined(OS_WIN) |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1157 const gfx::Point& p) { | 1159 const gfx::Point& p) { |
1158 return true; | 1160 return true; |
1159 } | 1161 } |
1160 | 1162 |
1161 //////////////////////////////////////////////////////////////////////////////// | 1163 //////////////////////////////////////////////////////////////////////////////// |
1162 // LocationBarView, LocationBar implementation: | 1164 // LocationBarView, LocationBar implementation: |
1163 | 1165 |
1164 void LocationBarView::ShowFirstRunBubble() { | 1166 void LocationBarView::ShowFirstRunBubble() { |
1165 // Wait until search engines have loaded to show the first run bubble. | 1167 // Wait until search engines have loaded to show the first run bubble. |
1166 TemplateURLService* url_service = | 1168 TemplateURLService* url_service = |
1167 TemplateURLServiceFactory::GetForProfile(profile_); | 1169 TemplateURLServiceFactory::GetForProfile(browser_->profile()); |
1168 if (!url_service->loaded()) { | 1170 if (!url_service->loaded()) { |
1169 template_url_service_ = url_service; | 1171 template_url_service_ = url_service; |
1170 template_url_service_->AddObserver(this); | 1172 template_url_service_->AddObserver(this); |
1171 template_url_service_->Load(); | 1173 template_url_service_->Load(); |
1172 return; | 1174 return; |
1173 } | 1175 } |
1174 ShowFirstRunBubbleInternal(); | 1176 ShowFirstRunBubbleInternal(); |
1175 } | 1177 } |
1176 | 1178 |
1177 void LocationBarView::SetSuggestedText(const string16& text, | 1179 void LocationBarView::SetSuggestedText(const string16& text, |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1304 !suggested_text_view_->GetText().empty(); | 1306 !suggested_text_view_->GetText().empty(); |
1305 } | 1307 } |
1306 | 1308 |
1307 #if !defined(USE_AURA) | 1309 #if !defined(USE_AURA) |
1308 OmniboxViewWin* LocationBarView::GetOmniboxViewWin() { | 1310 OmniboxViewWin* LocationBarView::GetOmniboxViewWin() { |
1309 CHECK(!views::Widget::IsPureViews()); | 1311 CHECK(!views::Widget::IsPureViews()); |
1310 return static_cast<OmniboxViewWin*>(location_entry_.get()); | 1312 return static_cast<OmniboxViewWin*>(location_entry_.get()); |
1311 } | 1313 } |
1312 #endif | 1314 #endif |
1313 #endif | 1315 #endif |
OLD | NEW |