OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 #import "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h" | 5 #import "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #import "base/mac/mac_util.h" | 9 #import "base/mac/mac_util.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 52 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
53 #include "chrome/common/chrome_switches.h" | 53 #include "chrome/common/chrome_switches.h" |
54 #include "chrome/common/pref_names.h" | 54 #include "chrome/common/pref_names.h" |
55 #include "components/bookmarks/common/bookmark_pref_names.h" | 55 #include "components/bookmarks/common/bookmark_pref_names.h" |
56 #import "components/omnibox/browser/omnibox_popup_model.h" | 56 #import "components/omnibox/browser/omnibox_popup_model.h" |
57 #include "components/prefs/pref_service.h" | 57 #include "components/prefs/pref_service.h" |
58 #include "components/search_engines/template_url.h" | 58 #include "components/search_engines/template_url.h" |
59 #include "components/search_engines/template_url_service.h" | 59 #include "components/search_engines/template_url_service.h" |
60 #include "components/security_state/security_state_model.h" | 60 #include "components/security_state/security_state_model.h" |
61 #include "components/translate/core/browser/language_state.h" | 61 #include "components/translate/core/browser/language_state.h" |
62 #include "components/ui/zoom/zoom_controller.h" | 62 #include "components/zoom/zoom_controller.h" |
63 #include "components/ui/zoom/zoom_event_manager.h" | 63 #include "components/zoom/zoom_event_manager.h" |
64 #include "content/public/browser/web_contents.h" | 64 #include "content/public/browser/web_contents.h" |
65 #include "extensions/browser/extension_system.h" | 65 #include "extensions/browser/extension_system.h" |
66 #include "extensions/common/extension.h" | 66 #include "extensions/common/extension.h" |
67 #include "grit/components_scaled_resources.h" | 67 #include "grit/components_scaled_resources.h" |
68 #include "grit/theme_resources.h" | 68 #include "grit/theme_resources.h" |
69 #include "skia/ext/skia_utils_mac.h" | 69 #include "skia/ext/skia_utils_mac.h" |
70 #import "ui/base/cocoa/cocoa_base_utils.h" | 70 #import "ui/base/cocoa/cocoa_base_utils.h" |
71 #include "ui/base/l10n/l10n_util_mac.h" | 71 #include "ui/base/l10n/l10n_util_mac.h" |
72 #include "ui/base/material_design/material_design_controller.h" | 72 #include "ui/base/material_design/material_design_controller.h" |
73 #include "ui/gfx/color_palette.h" | 73 #include "ui/gfx/color_palette.h" |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 content_setting_decorations_.push_back( | 127 content_setting_decorations_.push_back( |
128 new ContentSettingDecoration(model, this, profile)); | 128 new ContentSettingDecoration(model, this, profile)); |
129 } | 129 } |
130 models.weak_clear(); | 130 models.weak_clear(); |
131 | 131 |
132 edit_bookmarks_enabled_.Init( | 132 edit_bookmarks_enabled_.Init( |
133 bookmarks::prefs::kEditBookmarksEnabled, profile->GetPrefs(), | 133 bookmarks::prefs::kEditBookmarksEnabled, profile->GetPrefs(), |
134 base::Bind(&LocationBarViewMac::OnEditBookmarksEnabledChanged, | 134 base::Bind(&LocationBarViewMac::OnEditBookmarksEnabledChanged, |
135 base::Unretained(this))); | 135 base::Unretained(this))); |
136 | 136 |
137 ui_zoom::ZoomEventManager::GetForBrowserContext(profile) | 137 zoom::ZoomEventManager::GetForBrowserContext(profile) |
138 ->AddZoomEventManagerObserver(this); | 138 ->AddZoomEventManagerObserver(this); |
139 | 139 |
140 [[field_ cell] setIsPopupMode: | 140 [[field_ cell] setIsPopupMode: |
141 !browser->SupportsWindowFeature(Browser::FEATURE_TABSTRIP)]; | 141 !browser->SupportsWindowFeature(Browser::FEATURE_TABSTRIP)]; |
142 | 142 |
143 // Sets images for the decorations, and performs a layout. This call ensures | 143 // Sets images for the decorations, and performs a layout. This call ensures |
144 // that this class is in a consistent state after initialization. | 144 // that this class is in a consistent state after initialization. |
145 OnChanged(); | 145 OnChanged(); |
146 } | 146 } |
147 | 147 |
148 LocationBarViewMac::~LocationBarViewMac() { | 148 LocationBarViewMac::~LocationBarViewMac() { |
149 // Disconnect from cell in case it outlives us. | 149 // Disconnect from cell in case it outlives us. |
150 [[field_ cell] clearDecorations]; | 150 [[field_ cell] clearDecorations]; |
151 | 151 |
152 ui_zoom::ZoomEventManager::GetForBrowserContext(profile()) | 152 zoom::ZoomEventManager::GetForBrowserContext(profile()) |
153 ->RemoveZoomEventManagerObserver(this); | 153 ->RemoveZoomEventManagerObserver(this); |
154 } | 154 } |
155 | 155 |
156 void LocationBarViewMac::ShowFirstRunBubble() { | 156 void LocationBarViewMac::ShowFirstRunBubble() { |
157 // We need the browser window to be shown before we can show the bubble, but | 157 // We need the browser window to be shown before we can show the bubble, but |
158 // we get called before that's happened. | 158 // we get called before that's happened. |
159 base::MessageLoop::current()->PostTask( | 159 base::MessageLoop::current()->PostTask( |
160 FROM_HERE, base::Bind(&LocationBarViewMac::ShowFirstRunBubbleInternal, | 160 FROM_HERE, base::Bind(&LocationBarViewMac::ShowFirstRunBubbleInternal, |
161 weak_ptr_factory_.GetWeakPtr())); | 161 weak_ptr_factory_.GetWeakPtr())); |
162 } | 162 } |
(...skipping 650 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
813 translate_decoration_->SetLit(language_state.IsPageTranslated(), | 813 translate_decoration_->SetLit(language_state.IsPageTranslated(), |
814 IsLocationBarDark()); | 814 IsLocationBarDark()); |
815 } | 815 } |
816 | 816 |
817 bool LocationBarViewMac::UpdateZoomDecoration(bool default_zoom_changed) { | 817 bool LocationBarViewMac::UpdateZoomDecoration(bool default_zoom_changed) { |
818 WebContents* web_contents = GetWebContents(); | 818 WebContents* web_contents = GetWebContents(); |
819 if (!web_contents) | 819 if (!web_contents) |
820 return false; | 820 return false; |
821 | 821 |
822 return zoom_decoration_->UpdateIfNecessary( | 822 return zoom_decoration_->UpdateIfNecessary( |
823 ui_zoom::ZoomController::FromWebContents(web_contents), | 823 zoom::ZoomController::FromWebContents(web_contents), default_zoom_changed, |
824 default_zoom_changed, IsLocationBarDark()); | 824 IsLocationBarDark()); |
825 } | 825 } |
826 | 826 |
827 void LocationBarViewMac::OnDefaultZoomLevelChanged() { | 827 void LocationBarViewMac::OnDefaultZoomLevelChanged() { |
828 if (UpdateZoomDecoration(/*default_zoom_changed=*/true)) | 828 if (UpdateZoomDecoration(/*default_zoom_changed=*/true)) |
829 OnDecorationsChanged(); | 829 OnDecorationsChanged(); |
830 } | 830 } |
OLD | NEW |