Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(16)

Side by Side Diff: chrome/browser/ui/cocoa/translate/translate_bubble_controller.mm

Issue 2542173002: [Mac] Omnibox icons active states (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/translate/translate_bubble_controller.h" 5 #import "chrome/browser/ui/cocoa/translate/translate_bubble_controller.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/mac/foundation_util.h" 9 #include "base/mac/foundation_util.h"
10 #include "base/mac/scoped_nsobject.h" 10 #include "base/mac/scoped_nsobject.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/metrics/histogram_macros.h" 12 #include "base/metrics/histogram_macros.h"
13 #include "base/strings/sys_string_conversions.h" 13 #include "base/strings/sys_string_conversions.h"
14 #include "chrome/browser/ui/chrome_pages.h" 14 #include "chrome/browser/ui/chrome_pages.h"
15 #import "chrome/browser/ui/cocoa/browser_window_controller.h" 15 #import "chrome/browser/ui/cocoa/browser_window_controller.h"
16 #import "chrome/browser/ui/cocoa/bubble_combobox.h" 16 #import "chrome/browser/ui/cocoa/bubble_combobox.h"
17 #include "chrome/browser/ui/cocoa/chrome_style.h" 17 #include "chrome/browser/ui/cocoa/chrome_style.h"
18 #import "chrome/browser/ui/cocoa/hover_close_button.h" 18 #import "chrome/browser/ui/cocoa/hover_close_button.h"
19 #import "chrome/browser/ui/cocoa/info_bubble_view.h" 19 #import "chrome/browser/ui/cocoa/info_bubble_view.h"
20 #import "chrome/browser/ui/cocoa/info_bubble_window.h" 20 #import "chrome/browser/ui/cocoa/info_bubble_window.h"
21 #import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h" 21 #import "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h"
22 #import "chrome/browser/ui/cocoa/location_bar/translate_decoration.h"
22 #include "chrome/browser/ui/translate/language_combobox_model.h" 23 #include "chrome/browser/ui/translate/language_combobox_model.h"
23 #include "chrome/browser/ui/translate/translate_bubble_model.h" 24 #include "chrome/browser/ui/translate/translate_bubble_model.h"
24 #include "chrome/browser/ui/translate/translate_bubble_view_state_transition.h" 25 #include "chrome/browser/ui/translate/translate_bubble_view_state_transition.h"
25 #include "chrome/common/url_constants.h" 26 #include "chrome/common/url_constants.h"
26 #include "chrome/grit/generated_resources.h" 27 #include "chrome/grit/generated_resources.h"
27 #include "components/strings/grit/components_strings.h" 28 #include "components/strings/grit/components_strings.h"
28 #include "components/translate/core/browser/translate_ui_delegate.h" 29 #include "components/translate/core/browser/translate_ui_delegate.h"
29 #include "content/public/browser/browser_context.h" 30 #include "content/public/browser/browser_context.h"
30 #include "content/public/common/referrer.h" 31 #include "content/public/common/referrer.h"
31 #include "skia/ext/skia_utils_mac.h" 32 #include "skia/ext/skia_utils_mac.h"
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 NSView* view = [views_ objectForKey:key]; 205 NSView* view = [views_ objectForKey:key];
205 DCHECK(view); 206 DCHECK(view);
206 return view; 207 return view;
207 } 208 }
208 209
209 - (const TranslateBubbleModel*)model { 210 - (const TranslateBubbleModel*)model {
210 return model_.get(); 211 return model_.get();
211 } 212 }
212 213
213 - (void)showWindow:(id)sender { 214 - (void)showWindow:(id)sender {
214 BrowserWindowController* controller = [[self parentWindow] windowController]; 215 LocationBarViewMac* locationBar =
215 NSPoint anchorPoint = [[controller toolbarController] translateBubblePoint]; 216 [[[self parentWindow] windowController] locationBarBridge];
216 anchorPoint = 217 if (locationBar) {
217 ui::ConvertPointFromWindowToScreen([self parentWindow], anchorPoint); 218 NSPoint anchorPoint =
218 [self setAnchorPoint:anchorPoint]; 219 locationBar->GetBubblePointForDecoration([self decorationForBubble]);
220 anchorPoint =
221 ui::ConvertPointFromWindowToScreen([self parentWindow], anchorPoint);
222 [self setAnchorPoint:anchorPoint];
223 }
219 [super showWindow:sender]; 224 [super showWindow:sender];
220 } 225 }
221 226
227 - (LocationBarDecoration*)decorationForBubble {
228 LocationBarViewMac* locationBar =
229 [[[self parentWindow] windowController] locationBarBridge];
230 return locationBar ? locationBar->translate_decoration() : nullptr;
231 }
232
222 - (void)switchView:(TranslateBubbleModel::ViewState)viewState { 233 - (void)switchView:(TranslateBubbleModel::ViewState)viewState {
223 if (model_->GetViewState() == viewState) 234 if (model_->GetViewState() == viewState)
224 return; 235 return;
225 236
226 model_->SetViewState(viewState); 237 model_->SetViewState(viewState);
227 [self performLayout]; 238 [self performLayout];
228 } 239 }
229 240
230 - (void)switchToErrorView:(translate::TranslateErrors::Type)errorType { 241 - (void)switchToErrorView:(translate::TranslateErrors::Type)errorType {
231 [self switchView:TranslateBubbleModel::VIEW_STATE_ERROR]; 242 [self switchView:TranslateBubbleModel::VIEW_STATE_ERROR];
(...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after
879 // source or target language on the before translate view. 890 // source or target language on the before translate view.
880 - (BOOL)textView:(NSTextView*)aTextView 891 - (BOOL)textView:(NSTextView*)aTextView
881 clickedOnLink:(id)link 892 clickedOnLink:(id)link
882 atIndex:(NSUInteger)charIndex { 893 atIndex:(NSUInteger)charIndex {
883 translate::ReportUiAction(translate::ADVANCED_LINK_CLICKED); 894 translate::ReportUiAction(translate::ADVANCED_LINK_CLICKED);
884 [self switchView:TranslateBubbleModel::VIEW_STATE_ADVANCED]; 895 [self switchView:TranslateBubbleModel::VIEW_STATE_ADVANCED];
885 return YES; 896 return YES;
886 } 897 }
887 898
888 @end 899 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698