| 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/web_intent_sheet_controller.h" | 5 #import "chrome/browser/ui/cocoa/web_intent_sheet_controller.h" |
| 6 | 6 |
| 7 #include "base/memory/scoped_nsobject.h" | 7 #include "base/memory/scoped_nsobject.h" |
| 8 #include "base/sys_string_conversions.h" | 8 #include "base/sys_string_conversions.h" |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "chrome/browser/ui/browser_list.h" | 10 #include "chrome/browser/ui/browser_list.h" |
| 11 #import "chrome/browser/ui/cocoa/event_utils.h" | 11 #import "chrome/browser/ui/cocoa/event_utils.h" |
| 12 #import "chrome/browser/ui/cocoa/hover_close_button.h" | 12 #import "chrome/browser/ui/cocoa/hover_close_button.h" |
| 13 #import "chrome/browser/ui/cocoa/hyperlink_button_cell.h" | 13 #import "chrome/browser/ui/cocoa/hyperlink_button_cell.h" |
| 14 #import "chrome/browser/ui/cocoa/info_bubble_view.h" | 14 #import "chrome/browser/ui/cocoa/info_bubble_view.h" |
| 15 #import "chrome/browser/ui/cocoa/info_bubble_window.h" | 15 #import "chrome/browser/ui/cocoa/info_bubble_window.h" |
| 16 #include "chrome/browser/ui/cocoa/web_intent_picker_cocoa.h" | 16 #include "chrome/browser/ui/cocoa/web_intent_picker_cocoa.h" |
| 17 #include "chrome/browser/ui/constrained_window.h" | 17 #include "chrome/browser/ui/constrained_window.h" |
| 18 #include "chrome/browser/ui/constrained_window_constants.h" |
| 18 #include "chrome/browser/ui/intents/web_intent_picker_delegate.h" | 19 #include "chrome/browser/ui/intents/web_intent_picker_delegate.h" |
| 19 #include "chrome/browser/ui/intents/web_intent_picker_model.h" | 20 #include "chrome/browser/ui/intents/web_intent_picker_model.h" |
| 20 #include "chrome/browser/ui/tab_contents/tab_contents.h" | 21 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
| 21 #import "chrome/browser/ui/cocoa/tabs/throbber_view.h" | 22 #import "chrome/browser/ui/cocoa/tabs/throbber_view.h" |
| 22 #include "content/public/browser/web_contents.h" | 23 #include "content/public/browser/web_contents.h" |
| 23 #include "content/public/browser/web_contents_view.h" | 24 #include "content/public/browser/web_contents_view.h" |
| 24 #include "grit/generated_resources.h" | 25 #include "grit/generated_resources.h" |
| 25 #include "grit/google_chrome_strings.h" | 26 #include "grit/google_chrome_strings.h" |
| 26 #include "grit/locale_settings.h" | 27 #include "grit/locale_settings.h" |
| 27 #include "grit/theme_resources.h" | 28 #include "grit/theme_resources.h" |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 @implementation HeaderView | 262 @implementation HeaderView |
| 262 - (id)init { | 263 - (id)init { |
| 263 NSRect contentFrame = NSMakeRect(0, 0, WebIntentPicker::kWindowMinWidth, 1); | 264 NSRect contentFrame = NSMakeRect(0, 0, WebIntentPicker::kWindowMinWidth, 1); |
| 264 if (self = [super initWithFrame:contentFrame]) { | 265 if (self = [super initWithFrame:contentFrame]) { |
| 265 NSRect frame = NSMakeRect(WebIntentPicker::kContentAreaBorder, 0, | 266 NSRect frame = NSMakeRect(WebIntentPicker::kContentAreaBorder, 0, |
| 266 kTextWidth, 1); | 267 kTextWidth, 1); |
| 267 | 268 |
| 268 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 269 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| 269 titleField_.reset([[NSTextField alloc] initWithFrame:frame]); | 270 titleField_.reset([[NSTextField alloc] initWithFrame:frame]); |
| 270 ConfigureTextFieldAsLabel(titleField_); | 271 ConfigureTextFieldAsLabel(titleField_); |
| 271 gfx::Font titleFont = rb.GetFont(ConstrainedWindow::kTitleFontStyle); | 272 gfx::Font titleFont = rb.GetFont( |
| 273 ConstrainedWindowConstants::kTitleFontStyle); |
| 272 titleFont = titleFont.DeriveFont(0, gfx::Font::BOLD); | 274 titleFont = titleFont.DeriveFont(0, gfx::Font::BOLD); |
| 273 [titleField_ setFont:titleFont.GetNativeFont()]; | 275 [titleField_ setFont:titleFont.GetNativeFont()]; |
| 274 | 276 |
| 275 frame = NSMakeRect(WebIntentPicker::kContentAreaBorder, 0, | 277 frame = NSMakeRect(WebIntentPicker::kContentAreaBorder, 0, |
| 276 kTextWidth, 1); | 278 kTextWidth, 1); |
| 277 subtitleField_.reset([[NSTextField alloc] initWithFrame:frame]); | 279 subtitleField_.reset([[NSTextField alloc] initWithFrame:frame]); |
| 278 ConfigureTextFieldAsLabel(subtitleField_); | 280 ConfigureTextFieldAsLabel(subtitleField_); |
| 279 gfx::Font textFont = rb.GetFont(ConstrainedWindow::kTextFontStyle); | 281 gfx::Font textFont = rb.GetFont(ConstrainedWindowConstants::kTextFontStyle); |
| 280 [subtitleField_ setFont:textFont.GetNativeFont()]; | 282 [subtitleField_ setFont:textFont.GetNativeFont()]; |
| 281 | 283 |
| 282 frame = NSMakeRect(0, 0, WebIntentPicker::kWindowMinWidth, 1.0); | 284 frame = NSMakeRect(0, 0, WebIntentPicker::kWindowMinWidth, 1.0); |
| 283 spacer_.reset([[NSBox alloc] initWithFrame:frame]); | 285 spacer_.reset([[NSBox alloc] initWithFrame:frame]); |
| 284 [spacer_ setBoxType:NSBoxSeparator]; | 286 [spacer_ setBoxType:NSBoxSeparator]; |
| 285 [spacer_ setBorderColor:[NSColor blackColor]]; | 287 [spacer_ setBorderColor:[NSColor blackColor]]; |
| 286 [spacer_ setAlphaValue:0.2]; | 288 [spacer_ setAlphaValue:0.2]; |
| 287 | 289 |
| 288 NSArray* subviews = @[titleField_, subtitleField_, spacer_]; | 290 NSArray* subviews = @[titleField_, subtitleField_, spacer_]; |
| 289 [self setSubviews:subviews]; | 291 [self setSubviews:subviews]; |
| (...skipping 755 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1045 } | 1047 } |
| 1046 | 1048 |
| 1047 - (NSView*)createEmptyView { | 1049 - (NSView*)createEmptyView { |
| 1048 NSRect titleFrame = NSMakeRect(WebIntentPicker::kContentAreaBorder, | 1050 NSRect titleFrame = NSMakeRect(WebIntentPicker::kContentAreaBorder, |
| 1049 WebIntentPicker::kContentAreaBorder, | 1051 WebIntentPicker::kContentAreaBorder, |
| 1050 kTextWidth, 1); | 1052 kTextWidth, 1); |
| 1051 scoped_nsobject<NSTextField> title( | 1053 scoped_nsobject<NSTextField> title( |
| 1052 [[NSTextField alloc] initWithFrame:titleFrame]); | 1054 [[NSTextField alloc] initWithFrame:titleFrame]); |
| 1053 ConfigureTextFieldAsLabel(title); | 1055 ConfigureTextFieldAsLabel(title); |
| 1054 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 1056 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| 1055 gfx::Font titleFont = rb.GetFont(ConstrainedWindow::kTitleFontStyle); | 1057 gfx::Font titleFont = rb.GetFont(ConstrainedWindowConstants::kTitleFontStyle); |
| 1056 titleFont = titleFont.DeriveFont(0, gfx::Font::BOLD); | 1058 titleFont = titleFont.DeriveFont(0, gfx::Font::BOLD); |
| 1057 [title setFont:titleFont.GetNativeFont()]; | 1059 [title setFont:titleFont.GetNativeFont()]; |
| 1058 [title setStringValue: | 1060 [title setStringValue: |
| 1059 l10n_util::GetNSStringWithFixup(IDS_INTENT_PICKER_NO_SERVICES_TITLE)]; | 1061 l10n_util::GetNSStringWithFixup(IDS_INTENT_PICKER_NO_SERVICES_TITLE)]; |
| 1060 titleFrame.size.height += | 1062 titleFrame.size.height += |
| 1061 [GTMUILocalizerAndLayoutTweaker sizeToFitFixedWidthTextField:title]; | 1063 [GTMUILocalizerAndLayoutTweaker sizeToFitFixedWidthTextField:title]; |
| 1062 | 1064 |
| 1063 NSRect bodyFrame = titleFrame; | 1065 NSRect bodyFrame = titleFrame; |
| 1064 bodyFrame.origin.y += | 1066 bodyFrame.origin.y += |
| 1065 NSHeight(titleFrame) + WebIntentPicker::kContentAreaBorder; | 1067 NSHeight(titleFrame) + WebIntentPicker::kContentAreaBorder; |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1146 | 1148 |
| 1147 - (void)setActionString:(NSString*)actionString { | 1149 - (void)setActionString:(NSString*)actionString { |
| 1148 NSRect textFrame; | 1150 NSRect textFrame; |
| 1149 if (!actionTextField_.get()) { | 1151 if (!actionTextField_.get()) { |
| 1150 textFrame = NSMakeRect(WebIntentPicker::kContentAreaBorder, 0, | 1152 textFrame = NSMakeRect(WebIntentPicker::kContentAreaBorder, 0, |
| 1151 kTextWidth, 1); | 1153 kTextWidth, 1); |
| 1152 | 1154 |
| 1153 actionTextField_.reset([[NSTextField alloc] initWithFrame:textFrame]); | 1155 actionTextField_.reset([[NSTextField alloc] initWithFrame:textFrame]); |
| 1154 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 1156 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| 1155 ConfigureTextFieldAsLabel(actionTextField_); | 1157 ConfigureTextFieldAsLabel(actionTextField_); |
| 1156 gfx::Font titleFont = rb.GetFont(ConstrainedWindow::kTitleFontStyle); | 1158 gfx::Font titleFont = rb.GetFont( |
| 1159 ConstrainedWindowConstants::kTitleFontStyle); |
| 1157 titleFont = titleFont.DeriveFont(0, gfx::Font::BOLD); | 1160 titleFont = titleFont.DeriveFont(0, gfx::Font::BOLD); |
| 1158 [actionTextField_ setFont:titleFont.GetNativeFont()]; | 1161 [actionTextField_ setFont:titleFont.GetNativeFont()]; |
| 1159 } else { | 1162 } else { |
| 1160 textFrame = [actionTextField_ frame]; | 1163 textFrame = [actionTextField_ frame]; |
| 1161 } | 1164 } |
| 1162 | 1165 |
| 1163 [actionTextField_ setStringValue:actionString]; | 1166 [actionTextField_ setStringValue:actionString]; |
| 1164 textFrame.size.height += | 1167 textFrame.size.height += |
| 1165 [GTMUILocalizerAndLayoutTweaker sizeToFitFixedWidthTextField: | 1168 [GTMUILocalizerAndLayoutTweaker sizeToFitFixedWidthTextField: |
| 1166 actionTextField_]; | 1169 actionTextField_]; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1180 - (void)stopThrobber { | 1183 - (void)stopThrobber { |
| 1181 [closeButton_ setEnabled:YES]; | 1184 [closeButton_ setEnabled:YES]; |
| 1182 [intentView_ stopThrobber]; | 1185 [intentView_ stopThrobber]; |
| 1183 } | 1186 } |
| 1184 | 1187 |
| 1185 - (void)closeSheet { | 1188 - (void)closeSheet { |
| 1186 [NSApp endSheet:[self window]]; | 1189 [NSApp endSheet:[self window]]; |
| 1187 } | 1190 } |
| 1188 | 1191 |
| 1189 @end // WebIntentPickerSheetController | 1192 @end // WebIntentPickerSheetController |
| OLD | NEW |