| 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( |
| 166 ResourceBundle::BaseFont); | 168 ResourceBundle::BaseFont); |
| 167 } else { | 169 } else { |
| 168 // Use a larger version of the system font. | 170 // Use a larger version of the system font. |
| 169 font_ = ResourceBundle::GetSharedInstance().GetFont( | 171 font_ = ResourceBundle::GetSharedInstance().GetFont( |
| 170 ResourceBundle::MediumFont); | 172 ResourceBundle::MediumFont); |
| 171 } | 173 } |
| 172 | 174 |
| 173 // If this makes the font too big, try to make it smaller so it will fit. | 175 // If this makes the font too big, try to make it smaller so it will fit. |
| 174 const int height = | 176 const int height = |
| 175 std::max(GetPreferredSize().height() - (kVerticalEdgeThickness * 2), 0); | 177 std::max(GetPreferredSize().height() - (kVerticalEdgeThickness * 2), 0); |
| 176 while ((font_.GetHeight() > height) && (font_.GetFontSize() > 1)) | 178 while ((font_.GetHeight() > height) && (font_.GetFontSize() > 1)) |
| 177 font_ = font_.DeriveFont(-1); | 179 font_ = font_.DeriveFont(-1); |
| 178 | 180 |
| 179 location_icon_view_ = new LocationIconView(this); | 181 location_icon_view_ = new LocationIconView( |
| 182 this, delegate_->GetBrowserShowPageInfo()); |
| 180 AddChildView(location_icon_view_); | 183 AddChildView(location_icon_view_); |
| 181 location_icon_view_->SetVisible(true); | 184 location_icon_view_->SetVisible(true); |
| 182 location_icon_view_->set_drag_controller(this); | 185 location_icon_view_->set_drag_controller(this); |
| 183 | 186 |
| 184 ev_bubble_view_ = | 187 ev_bubble_view_ = |
| 185 new EVBubbleView(kEVBubbleBackgroundImages, IDR_OMNIBOX_HTTPS_VALID, | 188 new EVBubbleView(kEVBubbleBackgroundImages, IDR_OMNIBOX_HTTPS_VALID, |
| 186 GetColor(ToolbarModel::EV_SECURE, SECURITY_TEXT), this); | 189 GetColor(ToolbarModel::EV_SECURE, SECURITY_TEXT), this, |
| 190 delegate_->GetBrowserShowPageInfo()); |
| 187 AddChildView(ev_bubble_view_); | 191 AddChildView(ev_bubble_view_); |
| 188 ev_bubble_view_->SetVisible(false); | 192 ev_bubble_view_->SetVisible(false); |
| 189 ev_bubble_view_->set_drag_controller(this); | 193 ev_bubble_view_->set_drag_controller(this); |
| 190 | 194 |
| 191 // URL edit field. | 195 // URL edit field. |
| 192 // View container for URL edit field. | 196 // View container for URL edit field. |
| 193 Profile* profile = browser_->profile(); | |
| 194 location_entry_.reset(OmniboxView::CreateOmniboxView( | 197 location_entry_.reset(OmniboxView::CreateOmniboxView( |
| 195 this, | 198 this, |
| 196 model_, | 199 model_, |
| 197 profile, | 200 profile_, |
| 198 browser_->command_updater(), | 201 command_updater_, |
| 199 mode_ == POPUP, | 202 mode_ == POPUP, |
| 200 this)); | 203 this)); |
| 201 SetLocationEntryFocusable(true); | 204 SetLocationEntryFocusable(true); |
| 202 | 205 |
| 203 location_entry_view_ = location_entry_->AddToView(this); | 206 location_entry_view_ = location_entry_->AddToView(this); |
| 204 location_entry_view_->set_id(VIEW_ID_AUTOCOMPLETE); | 207 location_entry_view_->set_id(VIEW_ID_AUTOCOMPLETE); |
| 205 | 208 |
| 206 selected_keyword_view_ = new SelectedKeywordView( | 209 selected_keyword_view_ = new SelectedKeywordView( |
| 207 kSelectedKeywordBackgroundImages, IDR_KEYWORD_SEARCH_MAGNIFIER, | 210 kSelectedKeywordBackgroundImages, IDR_KEYWORD_SEARCH_MAGNIFIER, |
| 208 GetColor(ToolbarModel::NONE, TEXT), profile); | 211 GetColor(ToolbarModel::NONE, TEXT), profile_); |
| 209 AddChildView(selected_keyword_view_); | 212 AddChildView(selected_keyword_view_); |
| 210 selected_keyword_view_->SetFont(font_); | 213 selected_keyword_view_->SetFont(font_); |
| 211 selected_keyword_view_->SetVisible(false); | 214 selected_keyword_view_->SetVisible(false); |
| 212 | 215 |
| 213 keyword_hint_view_ = new KeywordHintView(profile); | 216 keyword_hint_view_ = new KeywordHintView(profile_); |
| 214 AddChildView(keyword_hint_view_); | 217 AddChildView(keyword_hint_view_); |
| 215 keyword_hint_view_->SetVisible(false); | 218 keyword_hint_view_->SetVisible(false); |
| 216 keyword_hint_view_->SetFont(font_); | 219 keyword_hint_view_->SetFont(font_); |
| 217 | 220 |
| 218 for (int i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) { | 221 for (int i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) { |
| 219 ContentSettingImageView* content_blocked_view = | 222 ContentSettingImageView* content_blocked_view = |
| 220 new ContentSettingImageView(static_cast<ContentSettingsType>(i), this); | 223 new ContentSettingImageView( |
| 224 static_cast<ContentSettingsType>(i), |
| 225 this, |
| 226 delegate_->GetBrowserShowContentRelated()); |
| 221 content_setting_views_.push_back(content_blocked_view); | 227 content_setting_views_.push_back(content_blocked_view); |
| 222 AddChildView(content_blocked_view); | 228 AddChildView(content_blocked_view); |
| 223 content_blocked_view->SetVisible(false); | 229 content_blocked_view->SetVisible(false); |
| 224 } | 230 } |
| 225 | 231 |
| 226 // The star is not visible in popups and in the app launcher. | 232 // The star is not visible in popups and in the app launcher. |
| 227 if (browser_defaults::bookmarks_enabled && (mode_ == NORMAL)) { | 233 if (browser_defaults::bookmarks_enabled && (mode_ == NORMAL)) { |
| 228 star_view_ = new StarView(browser_->command_updater()); | 234 star_view_ = new StarView(command_updater_); |
| 229 AddChildView(star_view_); | 235 AddChildView(star_view_); |
| 230 star_view_->SetVisible(true); | 236 star_view_->SetVisible(true); |
| 231 } | 237 } |
| 232 | 238 |
| 233 // Initialize the location entry. We do this to avoid a black flash which is | 239 // Initialize the location entry. We do this to avoid a black flash which is |
| 234 // visible when the location entry has just been initialized. | 240 // visible when the location entry has just been initialized. |
| 235 Update(NULL); | 241 Update(NULL); |
| 236 | 242 |
| 237 OnChanged(); | 243 OnChanged(); |
| 238 } | 244 } |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 FocusLocation(select_all); | 301 FocusLocation(select_all); |
| 296 } | 302 } |
| 297 | 303 |
| 298 void LocationBarView::SetAnimationOffset(int offset) { | 304 void LocationBarView::SetAnimationOffset(int offset) { |
| 299 animation_offset_ = offset; | 305 animation_offset_ = offset; |
| 300 } | 306 } |
| 301 | 307 |
| 302 void LocationBarView::Update(const WebContents* tab_for_state_restoring) { | 308 void LocationBarView::Update(const WebContents* tab_for_state_restoring) { |
| 303 bool star_enabled = star_view_ && !model_->input_in_progress() && | 309 bool star_enabled = star_view_ && !model_->input_in_progress() && |
| 304 edit_bookmarks_enabled_.GetValue(); | 310 edit_bookmarks_enabled_.GetValue(); |
| 305 browser_->command_updater()->UpdateCommandEnabled( | 311 command_updater_->UpdateCommandEnabled( |
| 306 IDC_BOOKMARK_PAGE, star_enabled); | 312 IDC_BOOKMARK_PAGE, star_enabled); |
| 307 if (star_view_) | 313 if (star_view_) |
| 308 star_view_->SetVisible(star_enabled); | 314 star_view_->SetVisible(star_enabled); |
| 309 RefreshContentSettingViews(); | 315 RefreshContentSettingViews(); |
| 310 RefreshPageActionViews(); | 316 RefreshPageActionViews(); |
| 311 // Don't Update in app launcher mode so that the location entry does not show | 317 // Don't Update in app launcher mode so that the location entry does not show |
| 312 // a URL or security background. | 318 // a URL or security background. |
| 313 if (mode_ != APP_LAUNCHER) | 319 if (mode_ != APP_LAUNCHER) |
| 314 location_entry_->Update(tab_for_state_restoring); | 320 location_entry_->Update(tab_for_state_restoring); |
| 315 OnChanged(); | 321 OnChanged(); |
| 316 } | 322 } |
| 317 | 323 |
| 324 views::Widget* LocationBarView::CreateViewsBubble( |
| 325 views::BubbleDelegateView* bubble_delegate) { |
| 326 return delegate_->CreateViewsBubble(bubble_delegate); |
| 327 } |
| 328 |
| 318 void LocationBarView::UpdateContentSettingsIcons() { | 329 void LocationBarView::UpdateContentSettingsIcons() { |
| 319 RefreshContentSettingViews(); | 330 RefreshContentSettingViews(); |
| 320 | 331 |
| 321 Layout(); | 332 Layout(); |
| 322 SchedulePaint(); | 333 SchedulePaint(); |
| 323 } | 334 } |
| 324 | 335 |
| 325 void LocationBarView::UpdatePageActions() { | 336 void LocationBarView::UpdatePageActions() { |
| 326 size_t count_before = page_action_views_.size(); | 337 size_t count_before = page_action_views_.size(); |
| 327 RefreshPageActionViews(); | 338 RefreshPageActionViews(); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 391 } | 402 } |
| 392 return NULL; | 403 return NULL; |
| 393 } | 404 } |
| 394 | 405 |
| 395 void LocationBarView::SetStarToggled(bool on) { | 406 void LocationBarView::SetStarToggled(bool on) { |
| 396 if (star_view_) | 407 if (star_view_) |
| 397 star_view_->SetToggled(on); | 408 star_view_->SetToggled(on); |
| 398 } | 409 } |
| 399 | 410 |
| 400 void LocationBarView::ShowStarBubble(const GURL& url, bool newly_bookmarked) { | 411 void LocationBarView::ShowStarBubble(const GURL& url, bool newly_bookmarked) { |
| 401 browser::ShowBookmarkBubbleView(star_view_, browser_->profile(), url, | 412 browser::ShowBookmarkBubbleView(star_view_, profile_, url, |
| 402 newly_bookmarked); | 413 newly_bookmarked); |
| 403 } | 414 } |
| 404 | 415 |
| 405 gfx::Point LocationBarView::GetLocationEntryOrigin() const { | 416 gfx::Point LocationBarView::GetLocationEntryOrigin() const { |
| 406 gfx::Point origin(location_entry_view_->bounds().origin()); | 417 gfx::Point origin(location_entry_view_->bounds().origin()); |
| 407 // If the UI layout is RTL, the coordinate system is not transformed and | 418 // 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 | 419 // therefore we need to adjust the X coordinate so that bubble appears on the |
| 409 // right hand side of the location bar. | 420 // right hand side of the location bar. |
| 410 if (base::i18n::IsRTL()) | 421 if (base::i18n::IsRTL()) |
| 411 origin.set_x(width() - origin.x()); | 422 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) | 568 if (max_edit_width < 0) |
| 558 return; | 569 return; |
| 559 const int available_width = AvailableWidth(max_edit_width); | 570 const int available_width = AvailableWidth(max_edit_width); |
| 560 | 571 |
| 561 const bool show_keyword_hint = !keyword.empty() && is_keyword_hint; | 572 const bool show_keyword_hint = !keyword.empty() && is_keyword_hint; |
| 562 selected_keyword_view_->SetVisible(show_selected_keyword); | 573 selected_keyword_view_->SetVisible(show_selected_keyword); |
| 563 keyword_hint_view_->SetVisible(show_keyword_hint); | 574 keyword_hint_view_->SetVisible(show_keyword_hint); |
| 564 if (show_selected_keyword) { | 575 if (show_selected_keyword) { |
| 565 if (selected_keyword_view_->keyword() != keyword) { | 576 if (selected_keyword_view_->keyword() != keyword) { |
| 566 selected_keyword_view_->SetKeyword(keyword); | 577 selected_keyword_view_->SetKeyword(keyword); |
| 567 Profile* profile = browser_->profile(); | |
| 568 const TemplateURL* template_url = | 578 const TemplateURL* template_url = |
| 569 TemplateURLServiceFactory::GetForProfile(profile)-> | 579 TemplateURLServiceFactory::GetForProfile(profile_)-> |
| 570 GetTemplateURLForKeyword(keyword); | 580 GetTemplateURLForKeyword(keyword); |
| 571 if (template_url && template_url->IsExtensionKeyword()) { | 581 if (template_url && template_url->IsExtensionKeyword()) { |
| 572 const SkBitmap& bitmap = profile->GetExtensionService()->GetOmniboxIcon( | 582 const SkBitmap& bitmap = |
| 573 template_url->GetExtensionId()); | 583 profile_->GetExtensionService()->GetOmniboxIcon( |
| 584 template_url->GetExtensionId()); |
| 574 selected_keyword_view_->SetImage(bitmap); | 585 selected_keyword_view_->SetImage(bitmap); |
| 575 selected_keyword_view_->set_is_extension_icon(true); | 586 selected_keyword_view_->set_is_extension_icon(true); |
| 576 } else { | 587 } else { |
| 577 selected_keyword_view_->SetImage(*ResourceBundle::GetSharedInstance(). | 588 selected_keyword_view_->SetImage(*ResourceBundle::GetSharedInstance(). |
| 578 GetBitmapNamed(IDR_OMNIBOX_SEARCH)); | 589 GetBitmapNamed(IDR_OMNIBOX_SEARCH)); |
| 579 selected_keyword_view_->set_is_extension_icon(false); | 590 selected_keyword_view_->set_is_extension_icon(false); |
| 580 } | 591 } |
| 581 } | 592 } |
| 582 } else if (show_keyword_hint) { | 593 } else if (show_keyword_hint) { |
| 583 if (keyword_hint_view_->keyword() != keyword) | 594 if (keyword_hint_view_->keyword() != keyword) |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 811 content::PageTransition transition, | 822 content::PageTransition transition, |
| 812 const GURL& alternate_nav_url) { | 823 const GURL& alternate_nav_url) { |
| 813 // WARNING: don't add an early return here. The calls after the if must | 824 // WARNING: don't add an early return here. The calls after the if must |
| 814 // happen. | 825 // happen. |
| 815 if (url.is_valid()) { | 826 if (url.is_valid()) { |
| 816 location_input_ = UTF8ToUTF16(url.spec()); | 827 location_input_ = UTF8ToUTF16(url.spec()); |
| 817 disposition_ = disposition; | 828 disposition_ = disposition; |
| 818 transition_ = content::PageTransitionFromInt( | 829 transition_ = content::PageTransitionFromInt( |
| 819 transition | content::PAGE_TRANSITION_FROM_ADDRESS_BAR); | 830 transition | content::PAGE_TRANSITION_FROM_ADDRESS_BAR); |
| 820 | 831 |
| 821 if (browser_->command_updater()) { | 832 if (command_updater_) { |
| 822 if (!alternate_nav_url.is_valid()) { | 833 if (!alternate_nav_url.is_valid()) { |
| 823 browser_->command_updater()->ExecuteCommand(IDC_OPEN_CURRENT_URL); | 834 command_updater_->ExecuteCommand(IDC_OPEN_CURRENT_URL); |
| 824 } else { | 835 } else { |
| 825 AlternateNavURLFetcher* fetcher = | 836 AlternateNavURLFetcher* fetcher = |
| 826 new AlternateNavURLFetcher(alternate_nav_url); | 837 new AlternateNavURLFetcher(alternate_nav_url); |
| 827 // The AlternateNavURLFetcher will listen for the pending navigation | 838 // The AlternateNavURLFetcher will listen for the pending navigation |
| 828 // notification that will be issued as a result of the "open URL." It | 839 // notification that will be issued as a result of the "open URL." It |
| 829 // will automatically install itself into that navigation controller. | 840 // will automatically install itself into that navigation controller. |
| 830 browser_->command_updater()->ExecuteCommand(IDC_OPEN_CURRENT_URL); | 841 command_updater_->ExecuteCommand(IDC_OPEN_CURRENT_URL); |
| 831 if (fetcher->state() == AlternateNavURLFetcher::NOT_STARTED) { | 842 if (fetcher->state() == AlternateNavURLFetcher::NOT_STARTED) { |
| 832 // I'm not sure this should be reachable, but I'm not also sure enough | 843 // 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 | 844 // that it shouldn't to stick in a NOTREACHED(). In any case, this is |
| 834 // harmless. | 845 // harmless. |
| 835 delete fetcher; | 846 delete fetcher; |
| 836 } else { | 847 } else { |
| 837 // The navigation controller will delete the fetcher. | 848 // The navigation controller will delete the fetcher. |
| 838 } | 849 } |
| 839 } | 850 } |
| 840 } | 851 } |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 927 for (PageActionViews::const_iterator i(page_action_views_.begin()); | 938 for (PageActionViews::const_iterator i(page_action_views_.begin()); |
| 928 i != page_action_views_.end(); ++i) | 939 i != page_action_views_.end(); ++i) |
| 929 RemoveChildView(*i); | 940 RemoveChildView(*i); |
| 930 STLDeleteElements(&page_action_views_); | 941 STLDeleteElements(&page_action_views_); |
| 931 } | 942 } |
| 932 | 943 |
| 933 void LocationBarView::RefreshPageActionViews() { | 944 void LocationBarView::RefreshPageActionViews() { |
| 934 if (mode_ != NORMAL) | 945 if (mode_ != NORMAL) |
| 935 return; | 946 return; |
| 936 | 947 |
| 937 ExtensionService* service = browser_->profile()->GetExtensionService(); | 948 ExtensionService* service = profile_->GetExtensionService(); |
| 938 if (!service) | 949 if (!service) |
| 939 return; | 950 return; |
| 940 | 951 |
| 941 std::map<ExtensionAction*, bool> old_visibility; | 952 std::map<ExtensionAction*, bool> old_visibility; |
| 942 for (PageActionViews::const_iterator i(page_action_views_.begin()); | 953 for (PageActionViews::const_iterator i(page_action_views_.begin()); |
| 943 i != page_action_views_.end(); ++i) | 954 i != page_action_views_.end(); ++i) |
| 944 old_visibility[(*i)->image_view()->page_action()] = (*i)->visible(); | 955 old_visibility[(*i)->image_view()->page_action()] = (*i)->visible(); |
| 945 | 956 |
| 946 // Remember the previous visibility of the page actions so that we can | 957 // Remember the previous visibility of the page actions so that we can |
| 947 // notify when this changes. | 958 // notify when this changes. |
| 948 std::vector<ExtensionAction*> page_actions; | 959 std::vector<ExtensionAction*> page_actions; |
| 949 for (ExtensionSet::const_iterator it = service->extensions()->begin(); | 960 for (ExtensionSet::const_iterator it = service->extensions()->begin(); |
| 950 it != service->extensions()->end(); ++it) { | 961 it != service->extensions()->end(); ++it) { |
| 951 if ((*it)->page_action()) | 962 if ((*it)->page_action()) |
| 952 page_actions.push_back((*it)->page_action()); | 963 page_actions.push_back((*it)->page_action()); |
| 953 } | 964 } |
| 954 | 965 |
| 955 // On startup we sometimes haven't loaded any extensions. This makes sure | 966 // On startup we sometimes haven't loaded any extensions. This makes sure |
| 956 // we catch up when the extensions (and any page actions) load. | 967 // we catch up when the extensions (and any page actions) load. |
| 957 if (page_actions.size() != page_action_views_.size()) { | 968 if (page_actions.size() != page_action_views_.size()) { |
| 958 DeletePageActionViews(); // Delete the old views (if any). | 969 DeletePageActionViews(); // Delete the old views (if any). |
| 959 | 970 |
| 960 page_action_views_.resize(page_actions.size()); | 971 page_action_views_.resize(page_actions.size()); |
| 961 | 972 |
| 962 // Add the page actions in reverse order, so that the child views are | 973 // Add the page actions in reverse order, so that the child views are |
| 963 // inserted in left-to-right order for accessibility. | 974 // inserted in left-to-right order for accessibility. |
| 964 for (int i = page_actions.size() - 1; i >= 0; --i) { | 975 for (int i = page_actions.size() - 1; i >= 0; --i) { |
| 965 page_action_views_[i] = new PageActionWithBadgeView( | 976 page_action_views_[i] = new PageActionWithBadgeView( |
| 966 new PageActionImageView(this, page_actions[i])); | 977 delegate_->CreatePageActionImageView(this, page_actions[i])); |
| 967 page_action_views_[i]->SetVisible(false); | 978 page_action_views_[i]->SetVisible(false); |
| 968 AddChildViewAt(page_action_views_[i], GetIndexOf(star_view_)); | 979 AddChildViewAt(page_action_views_[i], GetIndexOf(star_view_)); |
| 969 } | 980 } |
| 970 } | 981 } |
| 971 | 982 |
| 972 WebContents* contents = GetWebContentsFromDelegate(delegate_); | 983 WebContents* contents = GetWebContentsFromDelegate(delegate_); |
| 973 if (!page_action_views_.empty() && contents) { | 984 if (!page_action_views_.empty() && contents) { |
| 974 GURL url = GURL(model_->GetText()); | 985 GURL url = GURL(model_->GetText()); |
| 975 | 986 |
| 976 for (PageActionViews::const_iterator i(page_action_views_.begin()); | 987 for (PageActionViews::const_iterator i(page_action_views_.begin()); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 999 if (views::Widget::IsPureViews()) | 1010 if (views::Widget::IsPureViews()) |
| 1000 NOTIMPLEMENTED(); | 1011 NOTIMPLEMENTED(); |
| 1001 else | 1012 else |
| 1002 GetOmniboxViewWin()->HandleExternalMsg(msg, flags, screen_point.ToPOINT()); | 1013 GetOmniboxViewWin()->HandleExternalMsg(msg, flags, screen_point.ToPOINT()); |
| 1003 } | 1014 } |
| 1004 #endif | 1015 #endif |
| 1005 | 1016 |
| 1006 void LocationBarView::ShowFirstRunBubbleInternal() { | 1017 void LocationBarView::ShowFirstRunBubbleInternal() { |
| 1007 #if !defined(OS_CHROMEOS) | 1018 #if !defined(OS_CHROMEOS) |
| 1008 // First run bubble doesn't make sense for Chrome OS. | 1019 // First run bubble doesn't make sense for Chrome OS. |
| 1009 FirstRunBubble::ShowBubble(browser_->profile(), location_icon_view_); | 1020 FirstRunBubble::ShowBubble(profile_, location_icon_view_); |
| 1010 #endif | 1021 #endif |
| 1011 } | 1022 } |
| 1012 | 1023 |
| 1013 std::string LocationBarView::GetClassName() const { | 1024 std::string LocationBarView::GetClassName() const { |
| 1014 return kViewClassName; | 1025 return kViewClassName; |
| 1015 } | 1026 } |
| 1016 | 1027 |
| 1017 bool LocationBarView::SkipDefaultKeyEventProcessing( | 1028 bool LocationBarView::SkipDefaultKeyEventProcessing( |
| 1018 const views::KeyEvent& event) { | 1029 const views::KeyEvent& event) { |
| 1019 #if defined(OS_WIN) | 1030 #if defined(OS_WIN) |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1089 const gfx::Point& p) { | 1100 const gfx::Point& p) { |
| 1090 return true; | 1101 return true; |
| 1091 } | 1102 } |
| 1092 | 1103 |
| 1093 //////////////////////////////////////////////////////////////////////////////// | 1104 //////////////////////////////////////////////////////////////////////////////// |
| 1094 // LocationBarView, LocationBar implementation: | 1105 // LocationBarView, LocationBar implementation: |
| 1095 | 1106 |
| 1096 void LocationBarView::ShowFirstRunBubble() { | 1107 void LocationBarView::ShowFirstRunBubble() { |
| 1097 // Wait until search engines have loaded to show the first run bubble. | 1108 // Wait until search engines have loaded to show the first run bubble. |
| 1098 TemplateURLService* url_service = | 1109 TemplateURLService* url_service = |
| 1099 TemplateURLServiceFactory::GetForProfile(browser_->profile()); | 1110 TemplateURLServiceFactory::GetForProfile(profile_); |
| 1100 if (!url_service->loaded()) { | 1111 if (!url_service->loaded()) { |
| 1101 template_url_service_ = url_service; | 1112 template_url_service_ = url_service; |
| 1102 template_url_service_->AddObserver(this); | 1113 template_url_service_->AddObserver(this); |
| 1103 template_url_service_->Load(); | 1114 template_url_service_->Load(); |
| 1104 return; | 1115 return; |
| 1105 } | 1116 } |
| 1106 ShowFirstRunBubbleInternal(); | 1117 ShowFirstRunBubbleInternal(); |
| 1107 } | 1118 } |
| 1108 | 1119 |
| 1109 void LocationBarView::SetSuggestedText(const string16& text, | 1120 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(); | 1247 !suggested_text_view_->GetText().empty(); |
| 1237 } | 1248 } |
| 1238 | 1249 |
| 1239 #if !defined(USE_AURA) | 1250 #if !defined(USE_AURA) |
| 1240 OmniboxViewWin* LocationBarView::GetOmniboxViewWin() { | 1251 OmniboxViewWin* LocationBarView::GetOmniboxViewWin() { |
| 1241 CHECK(!views::Widget::IsPureViews()); | 1252 CHECK(!views::Widget::IsPureViews()); |
| 1242 return static_cast<OmniboxViewWin*>(location_entry_.get()); | 1253 return static_cast<OmniboxViewWin*>(location_entry_.get()); |
| 1243 } | 1254 } |
| 1244 #endif | 1255 #endif |
| 1245 #endif | 1256 #endif |
| OLD | NEW |