| 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 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <map> | 8 #include <map> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 #include "chrome/browser/search_engines/template_url_service.h" | 25 #include "chrome/browser/search_engines/template_url_service.h" |
| 26 #include "chrome/browser/search_engines/template_url_service_factory.h" | 26 #include "chrome/browser/search_engines/template_url_service_factory.h" |
| 27 #include "chrome/browser/ui/browser.h" | 27 #include "chrome/browser/ui/browser.h" |
| 28 #include "chrome/browser/ui/browser_finder.h" | 28 #include "chrome/browser/ui/browser_finder.h" |
| 29 #include "chrome/browser/ui/browser_tabstrip.h" | 29 #include "chrome/browser/ui/browser_tabstrip.h" |
| 30 #include "chrome/browser/ui/omnibox/location_bar_util.h" | 30 #include "chrome/browser/ui/omnibox/location_bar_util.h" |
| 31 #include "chrome/browser/ui/omnibox/omnibox_popup_model.h" | 31 #include "chrome/browser/ui/omnibox/omnibox_popup_model.h" |
| 32 #include "chrome/browser/ui/search/search.h" | 32 #include "chrome/browser/ui/search/search.h" |
| 33 #include "chrome/browser/ui/search/search_model.h" | 33 #include "chrome/browser/ui/search/search_model.h" |
| 34 #include "chrome/browser/ui/search/search_types.h" | 34 #include "chrome/browser/ui/search/search_types.h" |
| 35 #include "chrome/browser/ui/tab_contents/tab_contents.h" | |
| 36 #include "chrome/browser/ui/view_ids.h" | 35 #include "chrome/browser/ui/view_ids.h" |
| 37 #include "chrome/browser/ui/views/bookmarks/bookmark_prompt_view.h" | 36 #include "chrome/browser/ui/views/bookmarks/bookmark_prompt_view.h" |
| 38 #include "chrome/browser/ui/views/browser_dialogs.h" | 37 #include "chrome/browser/ui/views/browser_dialogs.h" |
| 39 #include "chrome/browser/ui/views/extensions/extension_popup.h" | 38 #include "chrome/browser/ui/views/extensions/extension_popup.h" |
| 40 #include "chrome/browser/ui/views/location_bar/action_box_button_view.h" | 39 #include "chrome/browser/ui/views/location_bar/action_box_button_view.h" |
| 41 #include "chrome/browser/ui/views/location_bar/content_setting_image_view.h" | 40 #include "chrome/browser/ui/views/location_bar/content_setting_image_view.h" |
| 42 #include "chrome/browser/ui/views/location_bar/ev_bubble_view.h" | 41 #include "chrome/browser/ui/views/location_bar/ev_bubble_view.h" |
| 43 #include "chrome/browser/ui/views/location_bar/keyword_hint_view.h" | 42 #include "chrome/browser/ui/views/location_bar/keyword_hint_view.h" |
| 44 #include "chrome/browser/ui/views/location_bar/location_icon_view.h" | 43 #include "chrome/browser/ui/views/location_bar/location_icon_view.h" |
| 45 #include "chrome/browser/ui/views/location_bar/open_pdf_in_reader_view.h" | 44 #include "chrome/browser/ui/views/location_bar/open_pdf_in_reader_view.h" |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 #if defined(USE_AURA) | 93 #if defined(USE_AURA) |
| 95 #include "ui/compositor/layer.h" | 94 #include "ui/compositor/layer.h" |
| 96 #include "ui/compositor/scoped_layer_animation_settings.h" | 95 #include "ui/compositor/scoped_layer_animation_settings.h" |
| 97 #endif | 96 #endif |
| 98 | 97 |
| 99 using content::WebContents; | 98 using content::WebContents; |
| 100 using views::View; | 99 using views::View; |
| 101 | 100 |
| 102 namespace { | 101 namespace { |
| 103 | 102 |
| 104 WebContents* GetWebContentsFromDelegate(LocationBarView::Delegate* delegate) { | |
| 105 const TabContents* tab_contents = delegate->GetTabContents(); | |
| 106 return tab_contents ? tab_contents->web_contents() : NULL; | |
| 107 } | |
| 108 | |
| 109 Browser* GetBrowserFromDelegate(LocationBarView::Delegate* delegate) { | 103 Browser* GetBrowserFromDelegate(LocationBarView::Delegate* delegate) { |
| 110 WebContents* contents = GetWebContentsFromDelegate(delegate); | 104 WebContents* contents = delegate->GetWebContents(); |
| 111 return browser::FindBrowserWithWebContents(contents); | 105 return browser::FindBrowserWithWebContents(contents); |
| 112 } | 106 } |
| 113 | 107 |
| 114 // Height of the location bar's round corner region. | 108 // Height of the location bar's round corner region. |
| 115 const int kBorderRoundCornerHeight = 5; | 109 const int kBorderRoundCornerHeight = 5; |
| 116 // Width of location bar's round corner region. | 110 // Width of location bar's round corner region. |
| 117 const int kBorderRoundCornerWidth = 4; | 111 const int kBorderRoundCornerWidth = 4; |
| 118 // Radius of the round corners inside the location bar. | 112 // Radius of the round corners inside the location bar. |
| 119 const int kBorderCornerRadius = 2; | 113 const int kBorderCornerRadius = 2; |
| 120 | 114 |
| (...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 446 StopFadeAnimation(); | 440 StopFadeAnimation(); |
| 447 } | 441 } |
| 448 #endif | 442 #endif |
| 449 } | 443 } |
| 450 | 444 |
| 451 void LocationBarView::Update(const WebContents* tab_for_state_restoring) { | 445 void LocationBarView::Update(const WebContents* tab_for_state_restoring) { |
| 452 RefreshContentSettingViews(); | 446 RefreshContentSettingViews(); |
| 453 ZoomBubbleView::CloseBubble(); | 447 ZoomBubbleView::CloseBubble(); |
| 454 RefreshZoomView(); | 448 RefreshZoomView(); |
| 455 RefreshPageActionViews(); | 449 RefreshPageActionViews(); |
| 456 web_intents_button_view_->Update(GetTabContents()); | 450 web_intents_button_view_->Update(GetWebContents()); |
| 457 open_pdf_in_reader_view_->Update( | 451 open_pdf_in_reader_view_->Update( |
| 458 model_->GetInputInProgress() ? NULL : GetTabContents()); | 452 model_->GetInputInProgress() ? NULL : GetWebContents()); |
| 459 | 453 |
| 460 bool star_enabled = star_view_ && !model_->GetInputInProgress() && | 454 bool star_enabled = star_view_ && !model_->GetInputInProgress() && |
| 461 edit_bookmarks_enabled_.GetValue(); | 455 edit_bookmarks_enabled_.GetValue(); |
| 462 | 456 |
| 463 command_updater_->UpdateCommandEnabled(IDC_BOOKMARK_PAGE, star_enabled); | 457 command_updater_->UpdateCommandEnabled(IDC_BOOKMARK_PAGE, star_enabled); |
| 464 command_updater_->UpdateCommandEnabled(IDC_BOOKMARK_PAGE_FROM_STAR, | 458 command_updater_->UpdateCommandEnabled(IDC_BOOKMARK_PAGE_FROM_STAR, |
| 465 star_enabled); | 459 star_enabled); |
| 466 if (star_view_ && !extensions::FeatureSwitch::action_box()->IsEnabled()) | 460 if (star_view_ && !extensions::FeatureSwitch::action_box()->IsEnabled()) |
| 467 star_view_->SetVisible(star_enabled); | 461 star_view_->SetVisible(star_enabled); |
| 468 | 462 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 499 DeletePageActionViews(); | 493 DeletePageActionViews(); |
| 500 if (page_action_views_.size() != count_before) { | 494 if (page_action_views_.size() != count_before) { |
| 501 content::NotificationService::current()->Notify( | 495 content::NotificationService::current()->Notify( |
| 502 chrome::NOTIFICATION_EXTENSION_PAGE_ACTION_COUNT_CHANGED, | 496 chrome::NOTIFICATION_EXTENSION_PAGE_ACTION_COUNT_CHANGED, |
| 503 content::Source<LocationBar>(this), | 497 content::Source<LocationBar>(this), |
| 504 content::NotificationService::NoDetails()); | 498 content::NotificationService::NoDetails()); |
| 505 } | 499 } |
| 506 } | 500 } |
| 507 | 501 |
| 508 void LocationBarView::UpdateWebIntentsButton() { | 502 void LocationBarView::UpdateWebIntentsButton() { |
| 509 web_intents_button_view_->Update(GetTabContents()); | 503 web_intents_button_view_->Update(GetWebContents()); |
| 510 | 504 |
| 511 Layout(); | 505 Layout(); |
| 512 SchedulePaint(); | 506 SchedulePaint(); |
| 513 } | 507 } |
| 514 | 508 |
| 515 void LocationBarView::UpdateOpenPDFInReaderPrompt() { | 509 void LocationBarView::UpdateOpenPDFInReaderPrompt() { |
| 516 open_pdf_in_reader_view_->Update( | 510 open_pdf_in_reader_view_->Update( |
| 517 model_->GetInputInProgress() ? NULL : GetTabContents()); | 511 model_->GetInputInProgress() ? NULL : GetWebContents()); |
| 518 Layout(); | 512 Layout(); |
| 519 SchedulePaint(); | 513 SchedulePaint(); |
| 520 } | 514 } |
| 521 | 515 |
| 522 void LocationBarView::OnFocus() { | 516 void LocationBarView::OnFocus() { |
| 523 // Focus the view widget first which implements accessibility for | 517 // Focus the view widget first which implements accessibility for |
| 524 // Chrome OS. It is noop on Win. This should be removed once | 518 // Chrome OS. It is noop on Win. This should be removed once |
| 525 // Chrome OS migrates to aura, which uses Views' textfield that receives | 519 // Chrome OS migrates to aura, which uses Views' textfield that receives |
| 526 // focus. See crbug.com/106428. | 520 // focus. See crbug.com/106428. |
| 527 GetWidget()->NotifyAccessibilityEvent( | 521 GetWidget()->NotifyAccessibilityEvent( |
| 528 this, ui::AccessibilityTypes::EVENT_FOCUS, false); | 522 this, ui::AccessibilityTypes::EVENT_FOCUS, false); |
| 529 | 523 |
| 530 // Then focus the native location view which implements accessibility for | 524 // Then focus the native location view which implements accessibility for |
| 531 // Windows. | 525 // Windows. |
| 532 location_entry_->SetFocus(); | 526 location_entry_->SetFocus(); |
| 533 } | 527 } |
| 534 | 528 |
| 535 void LocationBarView::SetPreviewEnabledPageAction(ExtensionAction* page_action, | 529 void LocationBarView::SetPreviewEnabledPageAction(ExtensionAction* page_action, |
| 536 bool preview_enabled) { | 530 bool preview_enabled) { |
| 537 if (mode_ != NORMAL) | 531 if (mode_ != NORMAL) |
| 538 return; | 532 return; |
| 539 | 533 |
| 540 DCHECK(page_action); | 534 DCHECK(page_action); |
| 541 WebContents* contents = GetWebContentsFromDelegate(delegate_); | 535 WebContents* contents = delegate_->GetWebContents(); |
| 542 | 536 |
| 543 RefreshPageActionViews(); | 537 RefreshPageActionViews(); |
| 544 PageActionWithBadgeView* page_action_view = | 538 PageActionWithBadgeView* page_action_view = |
| 545 static_cast<PageActionWithBadgeView*>(GetPageActionView(page_action)); | 539 static_cast<PageActionWithBadgeView*>(GetPageActionView(page_action)); |
| 546 DCHECK(page_action_view); | 540 DCHECK(page_action_view); |
| 547 if (!page_action_view) | 541 if (!page_action_view) |
| 548 return; | 542 return; |
| 549 | 543 |
| 550 page_action_view->image_view()->set_preview_enabled(preview_enabled); | 544 page_action_view->image_view()->set_preview_enabled(preview_enabled); |
| 551 page_action_view->UpdateVisibility(contents, model_->GetURL()); | 545 page_action_view->UpdateVisibility(contents, model_->GetURL()); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 584 } | 578 } |
| 585 } | 579 } |
| 586 | 580 |
| 587 void LocationBarView::ZoomChangedForActiveTab(bool can_show_bubble) { | 581 void LocationBarView::ZoomChangedForActiveTab(bool can_show_bubble) { |
| 588 DCHECK(zoom_view_); | 582 DCHECK(zoom_view_); |
| 589 RefreshZoomView(); | 583 RefreshZoomView(); |
| 590 | 584 |
| 591 Layout(); | 585 Layout(); |
| 592 SchedulePaint(); | 586 SchedulePaint(); |
| 593 | 587 |
| 594 if (can_show_bubble && zoom_view_->visible()) { | 588 if (can_show_bubble && zoom_view_->visible()) |
| 595 ZoomBubbleView::ShowBubble( | 589 ZoomBubbleView::ShowBubble(zoom_view_, delegate_->GetWebContents(), true); |
| 596 zoom_view_, GetWebContentsFromDelegate(delegate_), true); | |
| 597 } | |
| 598 } | 590 } |
| 599 | 591 |
| 600 void LocationBarView::RefreshZoomView() { | 592 void LocationBarView::RefreshZoomView() { |
| 601 DCHECK(zoom_view_); | 593 DCHECK(zoom_view_); |
| 602 TabContents* tab_contents = GetTabContents(); | 594 WebContents* web_contents = GetWebContents(); |
| 603 if (!tab_contents) | 595 if (!web_contents) |
| 604 return; | 596 return; |
| 605 | 597 |
| 606 ZoomController* zoom_controller = | 598 ZoomController* zoom_controller = |
| 607 ZoomController::FromWebContents(tab_contents->web_contents()); | 599 ZoomController::FromWebContents(web_contents); |
| 608 zoom_view_->Update(zoom_controller); | 600 zoom_view_->Update(zoom_controller); |
| 609 } | 601 } |
| 610 | 602 |
| 611 void LocationBarView::ShowChromeToMobileBubble() { | 603 void LocationBarView::ShowChromeToMobileBubble() { |
| 612 chrome::ShowChromeToMobileBubbleView(action_box_button_view_, | 604 chrome::ShowChromeToMobileBubbleView(action_box_button_view_, |
| 613 GetBrowserFromDelegate(delegate_)); | 605 GetBrowserFromDelegate(delegate_)); |
| 614 } | 606 } |
| 615 | 607 |
| 616 gfx::Point LocationBarView::GetLocationEntryOrigin() const { | 608 gfx::Point LocationBarView::GetLocationEntryOrigin() const { |
| 617 gfx::Point origin(location_entry_view_->bounds().origin()); | 609 gfx::Point origin(location_entry_view_->bounds().origin()); |
| (...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1135 views::FocusManager* focus_manager = GetFocusManager(); | 1127 views::FocusManager* focus_manager = GetFocusManager(); |
| 1136 if (!focus_manager) { | 1128 if (!focus_manager) { |
| 1137 NOTREACHED(); | 1129 NOTREACHED(); |
| 1138 return; | 1130 return; |
| 1139 } | 1131 } |
| 1140 focus_manager->SetFocusedView(this); | 1132 focus_manager->SetFocusedView(this); |
| 1141 } | 1133 } |
| 1142 | 1134 |
| 1143 gfx::Image LocationBarView::GetFavicon() const { | 1135 gfx::Image LocationBarView::GetFavicon() const { |
| 1144 return FaviconTabHelper::FromWebContents( | 1136 return FaviconTabHelper::FromWebContents( |
| 1145 delegate_->GetTabContents()->web_contents())->GetFavicon(); | 1137 delegate_->GetWebContents())->GetFavicon(); |
| 1146 } | 1138 } |
| 1147 | 1139 |
| 1148 string16 LocationBarView::GetTitle() const { | 1140 string16 LocationBarView::GetTitle() const { |
| 1149 return GetWebContentsFromDelegate(delegate_)->GetTitle(); | 1141 return delegate_->GetWebContents()->GetTitle(); |
| 1150 } | 1142 } |
| 1151 | 1143 |
| 1152 InstantController* LocationBarView::GetInstant() { | 1144 InstantController* LocationBarView::GetInstant() { |
| 1153 return delegate_->GetInstant(); | 1145 return delegate_->GetInstant(); |
| 1154 } | 1146 } |
| 1155 | 1147 |
| 1156 TabContents* LocationBarView::GetTabContents() const { | 1148 WebContents* LocationBarView::GetWebContents() const { |
| 1157 return delegate_->GetTabContents(); | 1149 return delegate_->GetWebContents(); |
| 1158 } | 1150 } |
| 1159 | 1151 |
| 1160 int LocationBarView::AvailableWidth(int location_bar_width) { | 1152 int LocationBarView::AvailableWidth(int location_bar_width) { |
| 1161 return location_bar_width - location_entry_->TextWidth(); | 1153 return location_bar_width - location_entry_->TextWidth(); |
| 1162 } | 1154 } |
| 1163 | 1155 |
| 1164 void LocationBarView::LayoutView(views::View* view, | 1156 void LocationBarView::LayoutView(views::View* view, |
| 1165 int padding, | 1157 int padding, |
| 1166 int available_width, | 1158 int available_width, |
| 1167 bool leading, | 1159 bool leading, |
| 1168 gfx::Rect* bounds) { | 1160 gfx::Rect* bounds) { |
| 1169 DCHECK(view && bounds); | 1161 DCHECK(view && bounds); |
| 1170 gfx::Size view_size = view->GetPreferredSize(); | 1162 gfx::Size view_size = view->GetPreferredSize(); |
| 1171 if ((view_size.width() + padding) > available_width) | 1163 if ((view_size.width() + padding) > available_width) |
| 1172 view_size = view->GetMinimumSize(); | 1164 view_size = view->GetMinimumSize(); |
| 1173 int desired_width = view_size.width() + padding; | 1165 int desired_width = view_size.width() + padding; |
| 1174 view->SetVisible(desired_width < bounds->width()); | 1166 view->SetVisible(desired_width < bounds->width()); |
| 1175 if (view->visible()) { | 1167 if (view->visible()) { |
| 1176 view->SetBounds( | 1168 view->SetBounds( |
| 1177 leading ? bounds->x() : (bounds->right() - view_size.width()), | 1169 leading ? bounds->x() : (bounds->right() - view_size.width()), |
| 1178 view->y(), view_size.width(), view->height()); | 1170 view->y(), view_size.width(), view->height()); |
| 1179 bounds->set_width(bounds->width() - desired_width); | 1171 bounds->set_width(bounds->width() - desired_width); |
| 1180 } | 1172 } |
| 1181 } | 1173 } |
| 1182 | 1174 |
| 1183 void LocationBarView::RefreshContentSettingViews() { | 1175 void LocationBarView::RefreshContentSettingViews() { |
| 1184 for (ContentSettingViews::const_iterator i(content_setting_views_.begin()); | 1176 for (ContentSettingViews::const_iterator i(content_setting_views_.begin()); |
| 1185 i != content_setting_views_.end(); ++i) { | 1177 i != content_setting_views_.end(); ++i) { |
| 1186 (*i)->Update(model_->GetInputInProgress() ? NULL : GetTabContents()); | 1178 (*i)->Update(model_->GetInputInProgress() ? NULL : GetWebContents()); |
| 1187 } | 1179 } |
| 1188 } | 1180 } |
| 1189 | 1181 |
| 1190 void LocationBarView::DeletePageActionViews() { | 1182 void LocationBarView::DeletePageActionViews() { |
| 1191 for (PageActionViews::const_iterator i(page_action_views_.begin()); | 1183 for (PageActionViews::const_iterator i(page_action_views_.begin()); |
| 1192 i != page_action_views_.end(); ++i) | 1184 i != page_action_views_.end(); ++i) |
| 1193 RemoveChildView(*i); | 1185 RemoveChildView(*i); |
| 1194 STLDeleteElements(&page_action_views_); | 1186 STLDeleteElements(&page_action_views_); |
| 1195 } | 1187 } |
| 1196 | 1188 |
| 1197 void LocationBarView::RefreshPageActionViews() { | 1189 void LocationBarView::RefreshPageActionViews() { |
| 1198 if (mode_ != NORMAL) | 1190 if (mode_ != NORMAL) |
| 1199 return; | 1191 return; |
| 1200 | 1192 |
| 1201 // Remember the previous visibility of the page actions so that we can | 1193 // Remember the previous visibility of the page actions so that we can |
| 1202 // notify when this changes. | 1194 // notify when this changes. |
| 1203 std::map<ExtensionAction*, bool> old_visibility; | 1195 std::map<ExtensionAction*, bool> old_visibility; |
| 1204 for (PageActionViews::const_iterator i(page_action_views_.begin()); | 1196 for (PageActionViews::const_iterator i(page_action_views_.begin()); |
| 1205 i != page_action_views_.end(); ++i) { | 1197 i != page_action_views_.end(); ++i) { |
| 1206 old_visibility[(*i)->image_view()->page_action()] = (*i)->visible(); | 1198 old_visibility[(*i)->image_view()->page_action()] = (*i)->visible(); |
| 1207 } | 1199 } |
| 1208 | 1200 |
| 1209 std::vector<ExtensionAction*> new_page_actions; | 1201 std::vector<ExtensionAction*> new_page_actions; |
| 1210 | 1202 |
| 1211 WebContents* contents = GetWebContentsFromDelegate(delegate_); | 1203 WebContents* contents = delegate_->GetWebContents(); |
| 1212 if (contents) { | 1204 if (contents) { |
| 1213 extensions::TabHelper* extensions_tab_helper = | 1205 extensions::TabHelper* extensions_tab_helper = |
| 1214 extensions::TabHelper::FromWebContents(contents); | 1206 extensions::TabHelper::FromWebContents(contents); |
| 1215 extensions::LocationBarController* controller = | 1207 extensions::LocationBarController* controller = |
| 1216 extensions_tab_helper->location_bar_controller(); | 1208 extensions_tab_helper->location_bar_controller(); |
| 1217 new_page_actions = controller->GetCurrentActions(); | 1209 new_page_actions = controller->GetCurrentActions(); |
| 1218 } | 1210 } |
| 1219 | 1211 |
| 1220 // On startup we sometimes haven't loaded any extensions. This makes sure | 1212 // On startup we sometimes haven't loaded any extensions. This makes sure |
| 1221 // we catch up when the extensions (and any page actions) load. | 1213 // we catch up when the extensions (and any page actions) load. |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1277 | 1269 |
| 1278 void LocationBarView::ShowFirstRunBubbleInternal() { | 1270 void LocationBarView::ShowFirstRunBubbleInternal() { |
| 1279 #if !defined(OS_CHROMEOS) | 1271 #if !defined(OS_CHROMEOS) |
| 1280 // First run bubble doesn't make sense for Chrome OS. | 1272 // First run bubble doesn't make sense for Chrome OS. |
| 1281 Browser* browser = GetBrowserFromDelegate(delegate_); | 1273 Browser* browser = GetBrowserFromDelegate(delegate_); |
| 1282 FirstRunBubble::ShowBubble(browser, location_icon_view_); | 1274 FirstRunBubble::ShowBubble(browser, location_icon_view_); |
| 1283 #endif | 1275 #endif |
| 1284 } | 1276 } |
| 1285 | 1277 |
| 1286 void LocationBarView::PaintPageActionBackgrounds(gfx::Canvas* canvas) { | 1278 void LocationBarView::PaintPageActionBackgrounds(gfx::Canvas* canvas) { |
| 1287 TabContents* tab_contents = GetTabContents(); | 1279 WebContents* web_contents = GetWebContents(); |
| 1288 // tab_contents may be NULL while the browser is shutting down. | 1280 // web_contents may be NULL while the browser is shutting down. |
| 1289 if (tab_contents == NULL) | 1281 if (!web_contents) |
| 1290 return; | 1282 return; |
| 1291 | 1283 |
| 1292 const int32 tab_id = SessionID::IdForTab(tab_contents->web_contents()); | 1284 const int32 tab_id = SessionID::IdForTab(web_contents); |
| 1293 const ToolbarModel::SecurityLevel security_level = model_->GetSecurityLevel(); | 1285 const ToolbarModel::SecurityLevel security_level = model_->GetSecurityLevel(); |
| 1294 const SkColor text_color = GetColor(security_level, TEXT); | 1286 const SkColor text_color = GetColor(security_level, TEXT); |
| 1295 const SkColor background_color = GetColor(security_level, BACKGROUND); | 1287 const SkColor background_color = GetColor(security_level, BACKGROUND); |
| 1296 | 1288 |
| 1297 for (PageActionViews::const_iterator | 1289 for (PageActionViews::const_iterator |
| 1298 page_action_view = page_action_views_.begin(); | 1290 page_action_view = page_action_views_.begin(); |
| 1299 page_action_view != page_action_views_.end(); | 1291 page_action_view != page_action_views_.end(); |
| 1300 ++page_action_view) { | 1292 ++page_action_view) { |
| 1301 gfx::Rect bounds = (*page_action_view)->bounds(); | 1293 gfx::Rect bounds = (*page_action_view)->bounds(); |
| 1302 int horizontal_padding = GetItemPadding() - | 1294 int horizontal_padding = GetItemPadding() - |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1368 bool LocationBarView::HasFocus() const { | 1360 bool LocationBarView::HasFocus() const { |
| 1369 return location_entry_->model()->has_focus(); | 1361 return location_entry_->model()->has_focus(); |
| 1370 } | 1362 } |
| 1371 | 1363 |
| 1372 void LocationBarView::WriteDragDataForView(views::View* sender, | 1364 void LocationBarView::WriteDragDataForView(views::View* sender, |
| 1373 const gfx::Point& press_pt, | 1365 const gfx::Point& press_pt, |
| 1374 OSExchangeData* data) { | 1366 OSExchangeData* data) { |
| 1375 DCHECK_NE(GetDragOperationsForView(sender, press_pt), | 1367 DCHECK_NE(GetDragOperationsForView(sender, press_pt), |
| 1376 ui::DragDropTypes::DRAG_NONE); | 1368 ui::DragDropTypes::DRAG_NONE); |
| 1377 | 1369 |
| 1378 WebContents* web_contents = GetTabContents()->web_contents(); | 1370 WebContents* web_contents = GetWebContents(); |
| 1379 FaviconTabHelper* favicon_tab_helper = | 1371 FaviconTabHelper* favicon_tab_helper = |
| 1380 FaviconTabHelper::FromWebContents(web_contents); | 1372 FaviconTabHelper::FromWebContents(web_contents); |
| 1381 gfx::ImageSkia favicon = favicon_tab_helper->GetFavicon().AsImageSkia(); | 1373 gfx::ImageSkia favicon = favicon_tab_helper->GetFavicon().AsImageSkia(); |
| 1382 button_drag_utils::SetURLAndDragImage(web_contents->GetURL(), | 1374 button_drag_utils::SetURLAndDragImage(web_contents->GetURL(), |
| 1383 web_contents->GetTitle(), | 1375 web_contents->GetTitle(), |
| 1384 favicon, | 1376 favicon, |
| 1385 data, | 1377 data, |
| 1386 sender->GetWidget()); | 1378 sender->GetWidget()); |
| 1387 } | 1379 } |
| 1388 | 1380 |
| 1389 int LocationBarView::GetDragOperationsForView(views::View* sender, | 1381 int LocationBarView::GetDragOperationsForView(views::View* sender, |
| 1390 const gfx::Point& p) { | 1382 const gfx::Point& p) { |
| 1391 DCHECK((sender == location_icon_view_) || (sender == ev_bubble_view_)); | 1383 DCHECK((sender == location_icon_view_) || (sender == ev_bubble_view_)); |
| 1392 WebContents* web_contents = GetWebContentsFromDelegate(delegate_); | 1384 WebContents* web_contents = delegate_->GetWebContents(); |
| 1393 return (web_contents && web_contents->GetURL().is_valid() && | 1385 return (web_contents && web_contents->GetURL().is_valid() && |
| 1394 !GetLocationEntry()->IsEditingOrEmpty()) ? | 1386 !GetLocationEntry()->IsEditingOrEmpty()) ? |
| 1395 (ui::DragDropTypes::DRAG_COPY | ui::DragDropTypes::DRAG_LINK) : | 1387 (ui::DragDropTypes::DRAG_COPY | ui::DragDropTypes::DRAG_LINK) : |
| 1396 ui::DragDropTypes::DRAG_NONE; | 1388 ui::DragDropTypes::DRAG_NONE; |
| 1397 } | 1389 } |
| 1398 | 1390 |
| 1399 bool LocationBarView::CanStartDragForView(View* sender, | 1391 bool LocationBarView::CanStartDragForView(View* sender, |
| 1400 const gfx::Point& press_pt, | 1392 const gfx::Point& press_pt, |
| 1401 const gfx::Point& p) { | 1393 const gfx::Point& p) { |
| 1402 return true; | 1394 return true; |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1541 ShowFirstRunBubble(); | 1533 ShowFirstRunBubble(); |
| 1542 } | 1534 } |
| 1543 | 1535 |
| 1544 void LocationBarView::Observe(int type, | 1536 void LocationBarView::Observe(int type, |
| 1545 const content::NotificationSource& source, | 1537 const content::NotificationSource& source, |
| 1546 const content::NotificationDetails& details) { | 1538 const content::NotificationDetails& details) { |
| 1547 switch (type) { | 1539 switch (type) { |
| 1548 case chrome::NOTIFICATION_EXTENSION_LOCATION_BAR_UPDATED: { | 1540 case chrome::NOTIFICATION_EXTENSION_LOCATION_BAR_UPDATED: { |
| 1549 // Only update if the updated action box was for the active tab contents. | 1541 // Only update if the updated action box was for the active tab contents. |
| 1550 WebContents* target_tab = content::Details<WebContents>(details).ptr(); | 1542 WebContents* target_tab = content::Details<WebContents>(details).ptr(); |
| 1551 if (target_tab == GetTabContents()->web_contents()) | 1543 if (target_tab == GetWebContents()) |
| 1552 UpdatePageActions(); | 1544 UpdatePageActions(); |
| 1553 break; | 1545 break; |
| 1554 } | 1546 } |
| 1555 | 1547 |
| 1556 default: | 1548 default: |
| 1557 NOTREACHED() << "Unexpected notification."; | 1549 NOTREACHED() << "Unexpected notification."; |
| 1558 } | 1550 } |
| 1559 } | 1551 } |
| 1560 | 1552 |
| 1561 void LocationBarView::OnPreferenceChanged(PrefServiceBase* service, | 1553 void LocationBarView::OnPreferenceChanged(PrefServiceBase* service, |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1607 } | 1599 } |
| 1608 | 1600 |
| 1609 void LocationBarView::CleanupFadeAnimation() { | 1601 void LocationBarView::CleanupFadeAnimation() { |
| 1610 // Since we're no longer animating we don't need our layer. | 1602 // Since we're no longer animating we don't need our layer. |
| 1611 SetPaintToLayer(false); | 1603 SetPaintToLayer(false); |
| 1612 // Bubble labels don't need a transparent background anymore. | 1604 // Bubble labels don't need a transparent background anymore. |
| 1613 ev_bubble_view_->SetLabelBackgroundColor(SK_ColorWHITE); | 1605 ev_bubble_view_->SetLabelBackgroundColor(SK_ColorWHITE); |
| 1614 selected_keyword_view_->SetLabelBackgroundColor(SK_ColorWHITE); | 1606 selected_keyword_view_->SetLabelBackgroundColor(SK_ColorWHITE); |
| 1615 } | 1607 } |
| 1616 #endif // USE_AURA | 1608 #endif // USE_AURA |
| OLD | NEW |