| Index: chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.mm
|
| diff --git a/chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.mm b/chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.mm
|
| index c86592fc7b16706dbaced10c54f3cac80f1af596..61134b79450a8c047feb3b2bb7b86dd7fa2d897c 100644
|
| --- a/chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.mm
|
| +++ b/chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.mm
|
| @@ -12,6 +12,7 @@
|
| #include "base/strings/string_util.h"
|
| #include "base/strings/sys_string_conversions.h"
|
| #include "base/strings/utf_string_conversions.h"
|
| +#include "chrome/app/chrome_command_ids.h"
|
| #import "chrome/browser/app_controller_mac.h"
|
| #include "chrome/browser/chrome_notification_types.h"
|
| #include "chrome/browser/command_updater.h"
|
| @@ -26,6 +27,7 @@
|
| #include "chrome/browser/search_engines/template_url.h"
|
| #include "chrome/browser/search_engines/template_url_service.h"
|
| #include "chrome/browser/search_engines/template_url_service_factory.h"
|
| +#include "chrome/browser/translate/translate_tab_helper.h"
|
| #include "chrome/browser/ui/browser_instant_controller.h"
|
| #include "chrome/browser/ui/browser_list.h"
|
| #import "chrome/browser/ui/cocoa/content_settings/content_setting_bubble_cocoa.h"
|
| @@ -43,6 +45,7 @@
|
| #import "chrome/browser/ui/cocoa/location_bar/search_button_decoration.h"
|
| #import "chrome/browser/ui/cocoa/location_bar/selected_keyword_decoration.h"
|
| #import "chrome/browser/ui/cocoa/location_bar/star_decoration.h"
|
| +#import "chrome/browser/ui/cocoa/location_bar/translate_decoration.h"
|
| #import "chrome/browser/ui/cocoa/location_bar/zoom_decoration.h"
|
| #import "chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.h"
|
| #include "chrome/browser/ui/content_settings/content_setting_bubble_model.h"
|
| @@ -54,6 +57,7 @@
|
| #include "chrome/browser/ui/zoom/zoom_controller.h"
|
| #include "chrome/common/chrome_switches.h"
|
| #include "chrome/common/pref_names.h"
|
| +#include "components/translate/core/browser/language_state.h"
|
| #include "content/public/browser/notification_service.h"
|
| #include "content/public/browser/web_contents.h"
|
| #include "extensions/common/extension.h"
|
| @@ -116,6 +120,7 @@ LocationBarViewMac::LocationBarViewMac(
|
| ev_bubble_decoration_(
|
| new EVBubbleDecoration(location_icon_decoration_.get())),
|
| star_decoration_(new StarDecoration(command_updater)),
|
| + translate_decoration_(new TranslateDecoration(command_updater)),
|
| zoom_decoration_(new ZoomDecoration(this)),
|
| keyword_hint_decoration_(new KeywordHintDecoration()),
|
| mic_search_decoration_(new MicSearchDecoration(command_updater)),
|
| @@ -316,6 +321,11 @@ void LocationBarViewMac::SetStarred(bool starred) {
|
| OnDecorationsChanged();
|
| }
|
|
|
| +void LocationBarViewMac::SetTranslateIconToggled(bool on) {
|
| + translate_decoration_->SetToggled(on);
|
| + OnDecorationsChanged();
|
| +}
|
| +
|
| void LocationBarViewMac::ZoomChangedForActiveTab(bool can_show_bubble) {
|
| UpdateZoomDecoration();
|
| OnDecorationsChanged();
|
| @@ -342,6 +352,14 @@ NSPoint LocationBarViewMac::GetBookmarkBubblePoint() const {
|
| return [field_ convertPoint:point toView:nil];
|
| }
|
|
|
| +NSPoint LocationBarViewMac::GetTranslateBubblePoint() const {
|
| + AutocompleteTextFieldCell* cell = [field_ cell];
|
| + const NSRect frame = [cell frameForDecoration:translate_decoration_.get()
|
| + inFrame:[field_ bounds]];
|
| + const NSPoint point = translate_decoration_->GetBubblePointInFrame(frame);
|
| + return [field_ convertPoint:point toView:nil];
|
| +}
|
| +
|
| NSPoint LocationBarViewMac::GetPageInfoBubblePoint() const {
|
| AutocompleteTextFieldCell* cell = [field_ cell];
|
| if (ev_bubble_decoration_->IsVisible()) {
|
| @@ -392,6 +410,7 @@ void LocationBarViewMac::Layout() {
|
| [cell addLeftDecoration:ev_bubble_decoration_.get()];
|
| [cell addRightDecoration:search_button_decoration_.get()];
|
| [cell addRightDecoration:star_decoration_.get()];
|
| + [cell addRightDecoration:translate_decoration_.get()];
|
| [cell addRightDecoration:zoom_decoration_.get()];
|
| [cell addRightDecoration:generated_credit_card_decoration_.get()];
|
|
|
| @@ -509,6 +528,7 @@ NSPoint LocationBarViewMac::GetPageActionBubblePoint(
|
|
|
| void LocationBarViewMac::Update(const WebContents* contents) {
|
| UpdateStarDecorationVisibility();
|
| + UpdateTranslateDecoration();
|
| UpdateZoomDecoration();
|
| RefreshPageActionDecorations();
|
| RefreshContentSettingsDecorations();
|
| @@ -727,6 +747,18 @@ void LocationBarViewMac::ShowFirstRunBubbleInternal() {
|
| profile:profile()];
|
| }
|
|
|
| +void LocationBarViewMac::UpdateTranslateDecoration() {
|
| + WebContents* web_contents = GetWebContents();
|
| + if (!web_contents)
|
| + return;
|
| + LanguageState& language_state = TranslateTabHelper::FromWebContents(
|
| + web_contents)->GetLanguageState();
|
| + bool enabled = language_state.translate_enabled();
|
| + command_updater()->UpdateCommandEnabled(IDC_TRANSLATE_PAGE, enabled);
|
| + translate_decoration_->SetVisible(enabled);
|
| + translate_decoration_->SetToggled(language_state.IsPageTranslated());
|
| +}
|
| +
|
| void LocationBarViewMac::UpdateZoomDecoration() {
|
| WebContents* web_contents = GetWebContents();
|
| if (!web_contents)
|
|
|