| 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 #import "chrome/browser/ui/cocoa/location_bar/content_setting_decoration.h" | 5 #import "chrome/browser/ui/cocoa/location_bar/content_setting_decoration.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
| 10 #include "base/strings/sys_string_conversions.h" | 10 #include "base/strings/sys_string_conversions.h" |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 [animation_ stopAnimation]; | 221 [animation_ stopAnimation]; |
| 222 animation_.reset(nil); | 222 animation_.reset(nil); |
| 223 } | 223 } |
| 224 return decoration_changed; | 224 return decoration_changed; |
| 225 } | 225 } |
| 226 | 226 |
| 227 CGFloat ContentSettingDecoration::MeasureTextWidth() { | 227 CGFloat ContentSettingDecoration::MeasureTextWidth() { |
| 228 return [animated_text_ size].width; | 228 return [animated_text_ size].width; |
| 229 } | 229 } |
| 230 | 230 |
| 231 scoped_nsobject<NSAttributedString> | 231 base::scoped_nsobject<NSAttributedString> |
| 232 ContentSettingDecoration::CreateAnimatedText() { | 232 ContentSettingDecoration::CreateAnimatedText() { |
| 233 NSString* text = | 233 NSString* text = |
| 234 l10n_util::GetNSString( | 234 l10n_util::GetNSString( |
| 235 content_setting_image_model_->explanatory_string_id()); | 235 content_setting_image_model_->explanatory_string_id()); |
| 236 scoped_nsobject<NSMutableParagraphStyle> style( | 236 base::scoped_nsobject<NSMutableParagraphStyle> style( |
| 237 [[NSMutableParagraphStyle alloc] init]); | 237 [[NSMutableParagraphStyle alloc] init]); |
| 238 // Set line break mode to clip the text, otherwise drawInRect: won't draw a | 238 // Set line break mode to clip the text, otherwise drawInRect: won't draw a |
| 239 // word if it doesn't fit in the bounding box. | 239 // word if it doesn't fit in the bounding box. |
| 240 [style setLineBreakMode:NSLineBreakByClipping]; | 240 [style setLineBreakMode:NSLineBreakByClipping]; |
| 241 NSDictionary* attributes = @{ NSFontAttributeName : GetFont(), | 241 NSDictionary* attributes = @{ NSFontAttributeName : GetFont(), |
| 242 NSParagraphStyleAttributeName : style }; | 242 NSParagraphStyleAttributeName : style }; |
| 243 return scoped_nsobject<NSAttributedString>( | 243 return base::scoped_nsobject<NSAttributedString>( |
| 244 [[NSAttributedString alloc] initWithString:text attributes:attributes]); | 244 [[NSAttributedString alloc] initWithString:text attributes:attributes]); |
| 245 } | 245 } |
| 246 | 246 |
| 247 NSPoint ContentSettingDecoration::GetBubblePointInFrame(NSRect frame) { | 247 NSPoint ContentSettingDecoration::GetBubblePointInFrame(NSRect frame) { |
| 248 // Compute the frame as if there is no animation pill in the Omnibox. Place | 248 // Compute the frame as if there is no animation pill in the Omnibox. Place |
| 249 // the bubble where the icon would be without animation, so when the animation | 249 // the bubble where the icon would be without animation, so when the animation |
| 250 // ends, the bubble is pointing in the right place. | 250 // ends, the bubble is pointing in the right place. |
| 251 NSSize image_size = [GetImage() size]; | 251 NSSize image_size = [GetImage() size]; |
| 252 frame.origin.x += frame.size.width - image_size.width; | 252 frame.origin.x += frame.size.width - image_size.width; |
| 253 frame.size = image_size; | 253 frame.size = image_size; |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 371 } | 371 } |
| 372 | 372 |
| 373 void ContentSettingDecoration::AnimationTimerFired() { | 373 void ContentSettingDecoration::AnimationTimerFired() { |
| 374 owner_->Layout(); | 374 owner_->Layout(); |
| 375 // Even after the animation completes, the |animator_| object should be kept | 375 // Even after the animation completes, the |animator_| object should be kept |
| 376 // alive to prevent the animation from re-appearing if the page opens | 376 // alive to prevent the animation from re-appearing if the page opens |
| 377 // additional popups later. The animator will be cleared when the decoration | 377 // additional popups later. The animator will be cleared when the decoration |
| 378 // hides, indicating something has changed with the WebContents (probably | 378 // hides, indicating something has changed with the WebContents (probably |
| 379 // navigation). | 379 // navigation). |
| 380 } | 380 } |
| OLD | NEW |