| OLD | NEW | 
|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be | 
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. | 
| 4 | 4 | 
| 5 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" | 5 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" | 
| 6 | 6 | 
| 7 #if defined(TOOLKIT_USES_GTK) | 7 #if defined(TOOLKIT_USES_GTK) | 
| 8 #include <gtk/gtk.h> | 8 #include <gtk/gtk.h> | 
| 9 #endif | 9 #endif | 
| 10 | 10 | 
| (...skipping 18 matching lines...) Expand all  Loading... | 
| 29 #include "chrome/browser/ui/views/browser_dialogs.h" | 29 #include "chrome/browser/ui/views/browser_dialogs.h" | 
| 30 #include "chrome/browser/ui/views/location_bar/content_setting_image_view.h" | 30 #include "chrome/browser/ui/views/location_bar/content_setting_image_view.h" | 
| 31 #include "chrome/browser/ui/views/location_bar/ev_bubble_view.h" | 31 #include "chrome/browser/ui/views/location_bar/ev_bubble_view.h" | 
| 32 #include "chrome/browser/ui/views/location_bar/keyword_hint_view.h" | 32 #include "chrome/browser/ui/views/location_bar/keyword_hint_view.h" | 
| 33 #include "chrome/browser/ui/views/location_bar/location_icon_view.h" | 33 #include "chrome/browser/ui/views/location_bar/location_icon_view.h" | 
| 34 #include "chrome/browser/ui/views/location_bar/page_action_image_view.h" | 34 #include "chrome/browser/ui/views/location_bar/page_action_image_view.h" | 
| 35 #include "chrome/browser/ui/views/location_bar/page_action_with_badge_view.h" | 35 #include "chrome/browser/ui/views/location_bar/page_action_with_badge_view.h" | 
| 36 #include "chrome/browser/ui/views/location_bar/selected_keyword_view.h" | 36 #include "chrome/browser/ui/views/location_bar/selected_keyword_view.h" | 
| 37 #include "chrome/browser/ui/views/location_bar/star_view.h" | 37 #include "chrome/browser/ui/views/location_bar/star_view.h" | 
| 38 #include "chrome/browser/ui/views/omnibox/omnibox_view_views.h" | 38 #include "chrome/browser/ui/views/omnibox/omnibox_view_views.h" | 
|  | 39 #include "chrome/common/chrome_notification_types.h" | 
| 39 #include "chrome/common/chrome_switches.h" | 40 #include "chrome/common/chrome_switches.h" | 
| 40 #include "chrome/common/pref_names.h" | 41 #include "chrome/common/pref_names.h" | 
| 41 #include "content/browser/renderer_host/render_widget_host_view.h" | 42 #include "content/browser/renderer_host/render_widget_host_view.h" | 
| 42 #include "content/common/notification_service.h" | 43 #include "content/common/notification_service.h" | 
| 43 #include "grit/generated_resources.h" | 44 #include "grit/generated_resources.h" | 
| 44 #include "grit/theme_resources.h" | 45 #include "grit/theme_resources.h" | 
| 45 #include "grit/theme_resources_standard.h" | 46 #include "grit/theme_resources_standard.h" | 
| 46 #include "ui/base/accessibility/accessible_view_state.h" | 47 #include "ui/base/accessibility/accessible_view_state.h" | 
| 47 #include "ui/base/dragdrop/drag_drop_types.h" | 48 #include "ui/base/dragdrop/drag_drop_types.h" | 
| 48 #include "ui/base/l10n/l10n_util.h" | 49 #include "ui/base/l10n/l10n_util.h" | 
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 312 | 313 | 
| 313   Layout(); | 314   Layout(); | 
| 314   SchedulePaint(); | 315   SchedulePaint(); | 
| 315 } | 316 } | 
| 316 | 317 | 
| 317 void LocationBarView::UpdatePageActions() { | 318 void LocationBarView::UpdatePageActions() { | 
| 318   size_t count_before = page_action_views_.size(); | 319   size_t count_before = page_action_views_.size(); | 
| 319   RefreshPageActionViews(); | 320   RefreshPageActionViews(); | 
| 320   if (page_action_views_.size() != count_before) { | 321   if (page_action_views_.size() != count_before) { | 
| 321     NotificationService::current()->Notify( | 322     NotificationService::current()->Notify( | 
| 322         NotificationType::EXTENSION_PAGE_ACTION_COUNT_CHANGED, | 323         chrome::NOTIFICATION_EXTENSION_PAGE_ACTION_COUNT_CHANGED, | 
| 323         Source<LocationBar>(this), | 324         Source<LocationBar>(this), | 
| 324         NotificationService::NoDetails()); | 325         NotificationService::NoDetails()); | 
| 325   } | 326   } | 
| 326 | 327 | 
| 327   Layout(); | 328   Layout(); | 
| 328   SchedulePaint(); | 329   SchedulePaint(); | 
| 329 } | 330 } | 
| 330 | 331 | 
| 331 void LocationBarView::InvalidatePageActions() { | 332 void LocationBarView::InvalidatePageActions() { | 
| 332   size_t count_before = page_action_views_.size(); | 333   size_t count_before = page_action_views_.size(); | 
| 333   DeletePageActionViews(); | 334   DeletePageActionViews(); | 
| 334   if (page_action_views_.size() != count_before) { | 335   if (page_action_views_.size() != count_before) { | 
| 335     NotificationService::current()->Notify( | 336     NotificationService::current()->Notify( | 
| 336         NotificationType::EXTENSION_PAGE_ACTION_COUNT_CHANGED, | 337         chrome::NOTIFICATION_EXTENSION_PAGE_ACTION_COUNT_CHANGED, | 
| 337         Source<LocationBar>(this), | 338         Source<LocationBar>(this), | 
| 338         NotificationService::NoDetails()); | 339         NotificationService::NoDetails()); | 
| 339   } | 340   } | 
| 340 } | 341 } | 
| 341 | 342 | 
| 342 void LocationBarView::OnFocus() { | 343 void LocationBarView::OnFocus() { | 
| 343   // Focus the location entry native view. | 344   // Focus the location entry native view. | 
| 344   location_entry_->SetFocus(); | 345   location_entry_->SetFocus(); | 
| 345   GetWidget()->NotifyAccessibilityEvent( | 346   GetWidget()->NotifyAccessibilityEvent( | 
| 346       this, ui::AccessibilityTypes::EVENT_FOCUS, true); | 347       this, ui::AccessibilityTypes::EVENT_FOCUS, true); | 
| (...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 977     for (PageActionViews::const_iterator i(page_action_views_.begin()); | 978     for (PageActionViews::const_iterator i(page_action_views_.begin()); | 
| 978          i != page_action_views_.end(); ++i) { | 979          i != page_action_views_.end(); ++i) { | 
| 979       (*i)->UpdateVisibility(model_->input_in_progress() ? NULL : contents, | 980       (*i)->UpdateVisibility(model_->input_in_progress() ? NULL : contents, | 
| 980                              url); | 981                              url); | 
| 981 | 982 | 
| 982       // Check if the visibility of the action changed and notify if it did. | 983       // Check if the visibility of the action changed and notify if it did. | 
| 983       ExtensionAction* action = (*i)->image_view()->page_action(); | 984       ExtensionAction* action = (*i)->image_view()->page_action(); | 
| 984       if (old_visibility.find(action) == old_visibility.end() || | 985       if (old_visibility.find(action) == old_visibility.end() || | 
| 985           old_visibility[action] != (*i)->IsVisible()) { | 986           old_visibility[action] != (*i)->IsVisible()) { | 
| 986         NotificationService::current()->Notify( | 987         NotificationService::current()->Notify( | 
| 987             NotificationType::EXTENSION_PAGE_ACTION_VISIBILITY_CHANGED, | 988             chrome::NOTIFICATION_EXTENSION_PAGE_ACTION_VISIBILITY_CHANGED, | 
| 988             Source<ExtensionAction>(action), | 989             Source<ExtensionAction>(action), | 
| 989             Details<TabContents>(contents)); | 990             Details<TabContents>(contents)); | 
| 990       } | 991       } | 
| 991     } | 992     } | 
| 992   } | 993   } | 
| 993 } | 994 } | 
| 994 | 995 | 
| 995 #if defined(OS_WIN) | 996 #if defined(OS_WIN) | 
| 996 void LocationBarView::OnMouseEvent(const views::MouseEvent& event, UINT msg) { | 997 void LocationBarView::OnMouseEvent(const views::MouseEvent& event, UINT msg) { | 
| 997   UINT flags = event.GetWindowsFlags(); | 998   UINT flags = event.GetWindowsFlags(); | 
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1232 | 1233 | 
| 1233 void LocationBarView::OnTemplateURLServiceChanged() { | 1234 void LocationBarView::OnTemplateURLServiceChanged() { | 
| 1234   template_url_service_->RemoveObserver(this); | 1235   template_url_service_->RemoveObserver(this); | 
| 1235   template_url_service_ = NULL; | 1236   template_url_service_ = NULL; | 
| 1236   // If the browser is no longer active, let's not show the info bubble, as this | 1237   // If the browser is no longer active, let's not show the info bubble, as this | 
| 1237   // would make the browser the active window again. | 1238   // would make the browser the active window again. | 
| 1238   if (location_entry_view_ && location_entry_view_->GetWidget()->IsActive()) | 1239   if (location_entry_view_ && location_entry_view_->GetWidget()->IsActive()) | 
| 1239     ShowFirstRunBubble(bubble_type_); | 1240     ShowFirstRunBubble(bubble_type_); | 
| 1240 } | 1241 } | 
| 1241 | 1242 | 
| 1242 void LocationBarView::Observe(NotificationType type, | 1243 void LocationBarView::Observe(int type, | 
| 1243                               const NotificationSource& source, | 1244                               const NotificationSource& source, | 
| 1244                               const NotificationDetails& details) { | 1245                               const NotificationDetails& details) { | 
| 1245   if (type.value == NotificationType::PREF_CHANGED) { | 1246   if (type == chrome::NOTIFICATION_PREF_CHANGED) { | 
| 1246     std::string* name = Details<std::string>(details).ptr(); | 1247     std::string* name = Details<std::string>(details).ptr(); | 
| 1247     if (*name == prefs::kEditBookmarksEnabled) | 1248     if (*name == prefs::kEditBookmarksEnabled) | 
| 1248       Update(NULL); | 1249       Update(NULL); | 
| 1249   } | 1250   } | 
| 1250 } | 1251 } | 
| 1251 | 1252 | 
| 1252 #if defined(OS_WIN) | 1253 #if defined(OS_WIN) | 
| 1253 bool LocationBarView::HasValidSuggestText() const { | 1254 bool LocationBarView::HasValidSuggestText() const { | 
| 1254   return suggested_text_view_ && !suggested_text_view_->size().IsEmpty() && | 1255   return suggested_text_view_ && !suggested_text_view_->size().IsEmpty() && | 
| 1255       !suggested_text_view_->GetText().empty(); | 1256       !suggested_text_view_->GetText().empty(); | 
| 1256 } | 1257 } | 
| 1257 | 1258 | 
| 1258 OmniboxViewWin* LocationBarView::GetOmniboxViewWin() { | 1259 OmniboxViewWin* LocationBarView::GetOmniboxViewWin() { | 
| 1259   CHECK(!views::Widget::IsPureViews()); | 1260   CHECK(!views::Widget::IsPureViews()); | 
| 1260   return static_cast<OmniboxViewWin*>(location_entry_.get()); | 1261   return static_cast<OmniboxViewWin*>(location_entry_.get()); | 
| 1261 } | 1262 } | 
| 1262 #endif | 1263 #endif | 
| OLD | NEW | 
|---|