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/i18n/rtl.h" | 10 #include "base/i18n/rtl.h" |
11 #include "base/prefs/pref_service.h" | 11 #include "base/prefs/pref_service.h" |
12 #include "base/stl_util.h" | 12 #include "base/stl_util.h" |
13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
14 #include "chrome/app/chrome_command_ids.h" | 14 #include "chrome/app/chrome_command_ids.h" |
15 #include "chrome/browser/chrome_notification_types.h" | |
16 #include "chrome/browser/command_updater.h" | 15 #include "chrome/browser/command_updater.h" |
17 #include "chrome/browser/defaults.h" | 16 #include "chrome/browser/defaults.h" |
18 #include "chrome/browser/extensions/api/omnibox/omnibox_api.h" | 17 #include "chrome/browser/extensions/api/omnibox/omnibox_api.h" |
19 #include "chrome/browser/extensions/extension_action.h" | 18 #include "chrome/browser/extensions/extension_action.h" |
20 #include "chrome/browser/extensions/extension_util.h" | 19 #include "chrome/browser/extensions/extension_util.h" |
21 #include "chrome/browser/extensions/location_bar_controller.h" | 20 #include "chrome/browser/extensions/location_bar_controller.h" |
22 #include "chrome/browser/extensions/tab_helper.h" | 21 #include "chrome/browser/extensions/tab_helper.h" |
23 #include "chrome/browser/favicon/favicon_tab_helper.h" | 22 #include "chrome/browser/favicon/favicon_tab_helper.h" |
24 #include "chrome/browser/profiles/profile.h" | 23 #include "chrome/browser/profiles/profile.h" |
25 #include "chrome/browser/search/instant_service.h" | 24 #include "chrome/browser/search/instant_service.h" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 #include "chrome/browser/ui/views/location_bar/zoom_view.h" | 56 #include "chrome/browser/ui/views/location_bar/zoom_view.h" |
58 #include "chrome/browser/ui/views/passwords/manage_passwords_bubble_view.h" | 57 #include "chrome/browser/ui/views/passwords/manage_passwords_bubble_view.h" |
59 #include "chrome/browser/ui/views/passwords/manage_passwords_icon_view.h" | 58 #include "chrome/browser/ui/views/passwords/manage_passwords_icon_view.h" |
60 #include "chrome/browser/ui/views/translate/translate_bubble_view.h" | 59 #include "chrome/browser/ui/views/translate/translate_bubble_view.h" |
61 #include "chrome/browser/ui/zoom/zoom_controller.h" | 60 #include "chrome/browser/ui/zoom/zoom_controller.h" |
62 #include "chrome/common/pref_names.h" | 61 #include "chrome/common/pref_names.h" |
63 #include "chrome/grit/generated_resources.h" | 62 #include "chrome/grit/generated_resources.h" |
64 #include "components/search_engines/template_url.h" | 63 #include "components/search_engines/template_url.h" |
65 #include "components/search_engines/template_url_service.h" | 64 #include "components/search_engines/template_url_service.h" |
66 #include "components/translate/core/browser/language_state.h" | 65 #include "components/translate/core/browser/language_state.h" |
67 #include "content/public/browser/notification_service.h" | |
68 #include "content/public/browser/render_widget_host_view.h" | 66 #include "content/public/browser/render_widget_host_view.h" |
69 #include "content/public/browser/web_contents.h" | 67 #include "content/public/browser/web_contents.h" |
70 #include "extensions/browser/extension_registry.h" | 68 #include "extensions/browser/extension_registry.h" |
71 #include "extensions/common/feature_switch.h" | 69 #include "extensions/common/feature_switch.h" |
72 #include "extensions/common/permissions/permissions_data.h" | 70 #include "extensions/common/permissions/permissions_data.h" |
73 #include "grit/component_scaled_resources.h" | 71 #include "grit/component_scaled_resources.h" |
74 #include "grit/theme_resources.h" | 72 #include "grit/theme_resources.h" |
75 #include "ui/accessibility/ax_view_state.h" | 73 #include "ui/accessibility/ax_view_state.h" |
76 #include "ui/base/dragdrop/drag_drop_types.h" | 74 #include "ui/base/dragdrop/drag_drop_types.h" |
77 #include "ui/base/l10n/l10n_util.h" | 75 #include "ui/base/l10n/l10n_util.h" |
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
396 AddChildView(search_button_); | 394 AddChildView(search_button_); |
397 | 395 |
398 show_url_animation_.reset(new gfx::SlideAnimation(this)); | 396 show_url_animation_.reset(new gfx::SlideAnimation(this)); |
399 show_url_animation_->SetTweenType(kShowTweenType); | 397 show_url_animation_->SetTweenType(kShowTweenType); |
400 show_url_animation_->SetSlideDuration(200); | 398 show_url_animation_->SetSlideDuration(200); |
401 | 399 |
402 hide_url_animation_.reset(new gfx::SlideAnimation(this)); | 400 hide_url_animation_.reset(new gfx::SlideAnimation(this)); |
403 hide_url_animation_->SetTweenType(kHideTweenType); | 401 hide_url_animation_->SetTweenType(kHideTweenType); |
404 hide_url_animation_->SetSlideDuration(175); | 402 hide_url_animation_->SetSlideDuration(175); |
405 | 403 |
406 content::Source<Profile> profile_source = content::Source<Profile>(profile()); | |
407 registrar_.Add(this, | |
408 extensions::NOTIFICATION_EXTENSION_LOADED_DEPRECATED, | |
409 profile_source); | |
410 registrar_.Add(this, | |
411 extensions::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED, | |
412 profile_source); | |
413 | |
414 // Initialize the location entry. We do this to avoid a black flash which is | 404 // Initialize the location entry. We do this to avoid a black flash which is |
415 // visible when the location entry has just been initialized. | 405 // visible when the location entry has just been initialized. |
416 Update(NULL); | 406 Update(NULL); |
417 } | 407 } |
418 | 408 |
419 bool LocationBarView::IsInitialized() const { | 409 bool LocationBarView::IsInitialized() const { |
420 return omnibox_view_ != NULL; | 410 return omnibox_view_ != NULL; |
421 } | 411 } |
422 | 412 |
423 SkColor LocationBarView::GetColor(ToolbarModel::SecurityLevel security_level, | 413 SkColor LocationBarView::GetColor(ToolbarModel::SecurityLevel security_level, |
(...skipping 1262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1686 void LocationBarView::OnTemplateURLServiceChanged() { | 1676 void LocationBarView::OnTemplateURLServiceChanged() { |
1687 template_url_service_->RemoveObserver(this); | 1677 template_url_service_->RemoveObserver(this); |
1688 template_url_service_ = NULL; | 1678 template_url_service_ = NULL; |
1689 // If the browser is no longer active, let's not show the info bubble, as this | 1679 // If the browser is no longer active, let's not show the info bubble, as this |
1690 // would make the browser the active window again. | 1680 // would make the browser the active window again. |
1691 if (omnibox_view_ && omnibox_view_->GetWidget()->IsActive()) | 1681 if (omnibox_view_ && omnibox_view_->GetWidget()->IsActive()) |
1692 ShowFirstRunBubble(); | 1682 ShowFirstRunBubble(); |
1693 } | 1683 } |
1694 | 1684 |
1695 //////////////////////////////////////////////////////////////////////////////// | 1685 //////////////////////////////////////////////////////////////////////////////// |
1696 // LocationBarView, private content::NotificationObserver implementation: | |
1697 | |
1698 void LocationBarView::Observe(int type, | |
1699 const content::NotificationSource& source, | |
1700 const content::NotificationDetails& details) { | |
1701 switch (type) { | |
1702 case extensions::NOTIFICATION_EXTENSION_LOADED_DEPRECATED: | |
1703 case extensions::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED: | |
1704 Update(NULL); | |
1705 break; | |
1706 | |
1707 default: | |
1708 NOTREACHED() << "Unexpected notification."; | |
1709 } | |
1710 } | |
1711 | |
1712 //////////////////////////////////////////////////////////////////////////////// | |
1713 // LocationBarView, private SearchModelObserver implementation: | 1686 // LocationBarView, private SearchModelObserver implementation: |
1714 | 1687 |
1715 void LocationBarView::ModelChanged(const SearchModel::State& old_state, | 1688 void LocationBarView::ModelChanged(const SearchModel::State& old_state, |
1716 const SearchModel::State& new_state) { | 1689 const SearchModel::State& new_state) { |
1717 const bool visible = !GetToolbarModel()->input_in_progress() && | 1690 const bool visible = !GetToolbarModel()->input_in_progress() && |
1718 new_state.voice_search_supported; | 1691 new_state.voice_search_supported; |
1719 if (mic_search_view_->visible() != visible) { | 1692 if (mic_search_view_->visible() != visible) { |
1720 mic_search_view_->SetVisible(visible); | 1693 mic_search_view_->SetVisible(visible); |
1721 Layout(); | 1694 Layout(); |
1722 } | 1695 } |
1723 } | 1696 } |
OLD | NEW |