From 008643e4943099407bec289e1bdf5e0da8cd78f4 Mon Sep 17 00:00:00 2001 From: "karen@chromium.org" Date: Mon, 25 Jun 2012 19:59:59 +0000 Subject: Revert 143683 - Merge 143042 - [WebIntents, OSX] Show inline disposition service header if appropriate. R=thakis@chromium.org BUG=125591, 127358 TEST=none Review URL: https://chromiumcodereview.appspot.com/10575011 TBR=groby@chromium.org Review URL: https://chromiumcodereview.appspot.com/10633031 TBR=groby@chromium.org Review URL: https://chromiumcodereview.appspot.com/10657028 git-svn-id: svn://svn.chromium.org/chrome/branches/1180/src@143988 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/browser/ui/cocoa/web_intent_picker_cocoa.h | 1 - chrome/browser/ui/cocoa/web_intent_picker_cocoa.mm | 16 +---- .../browser/ui/cocoa/web_intent_sheet_controller.h | 4 -- .../ui/cocoa/web_intent_sheet_controller.mm | 70 +--------------------- 4 files changed, 4 insertions(+), 87 deletions(-) diff --git a/chrome/browser/ui/cocoa/web_intent_picker_cocoa.h b/chrome/browser/ui/cocoa/web_intent_picker_cocoa.h index 099e732..89b34ea 100644 --- a/chrome/browser/ui/cocoa/web_intent_picker_cocoa.h +++ b/chrome/browser/ui/cocoa/web_intent_picker_cocoa.h @@ -41,7 +41,6 @@ class WebIntentPickerCocoa : public WebIntentPicker, void OnExtensionInstallRequested(const std::string& extension_id); void OnExtensionLinkClicked(const std::string& extension_id); void OnSuggestionsLinkClicked(); - void OnChooseAnotherService(); // WebIntentPicker implementation. virtual void Close() OVERRIDE; diff --git a/chrome/browser/ui/cocoa/web_intent_picker_cocoa.mm b/chrome/browser/ui/cocoa/web_intent_picker_cocoa.mm index 1a8cdc4..f6141f1 100644 --- a/chrome/browser/ui/cocoa/web_intent_picker_cocoa.mm +++ b/chrome/browser/ui/cocoa/web_intent_picker_cocoa.mm @@ -156,10 +156,6 @@ void WebIntentPickerCocoa::OnExtensionIconChanged( void WebIntentPickerCocoa::OnInlineDisposition(WebIntentPickerModel* model, const GURL& url) { - const WebIntentPickerModel::InstalledService* service = - model->GetInstalledServiceWithURL(model->inline_disposition_url()); - DCHECK(service); - content::WebContents* web_contents = content::WebContents::Create( tab_contents_->profile(), tab_util::GetSiteInstanceForNewTab(tab_contents_->profile(), url), @@ -178,8 +174,7 @@ void WebIntentPickerCocoa::OnInlineDisposition(WebIntentPickerModel* model, content::Referrer(), content::PAGE_TRANSITION_START_PAGE, std::string()); - [sheet_controller_ setInlineDispositionTitle: - base::SysUTF16ToNSString(service->title)]; + [sheet_controller_ setInlineDispositionTabContents: inline_disposition_tab_contents_.get()]; PerformLayout(); @@ -234,12 +229,3 @@ void WebIntentPickerCocoa::OnSuggestionsLinkClicked() { DCHECK(delegate_); delegate_->OnSuggestionsLinkClicked(); } - -void WebIntentPickerCocoa::OnChooseAnotherService() { - DCHECK(delegate_); - delegate_->OnChooseAnotherService(); - inline_disposition_tab_contents_.reset(); - inline_disposition_delegate_.reset(); - [sheet_controller_ setInlineDispositionTabContents:NULL]; - PerformLayout(); -} diff --git a/chrome/browser/ui/cocoa/web_intent_sheet_controller.h b/chrome/browser/ui/cocoa/web_intent_sheet_controller.h index 36607e2..fb121d5 100644 --- a/chrome/browser/ui/cocoa/web_intent_sheet_controller.h +++ b/chrome/browser/ui/cocoa/web_intent_sheet_controller.h @@ -35,7 +35,6 @@ class WebIntentPickerModel; scoped_nsobject closeButton_; scoped_nsobject intentButtons_; scoped_nsobject flipView_; - scoped_nsobject inlineDispositionTitleField_; } - (IBAction)installExtension:(id)sender; @@ -54,9 +53,6 @@ class WebIntentPickerModel; // "Which service should be used for sharing?". - (void)setActionString:(NSString*)actionString; -// Sets the service title for inline disposition. -- (void)setInlineDispositionTitle:(NSString*)title; - // Stop displaying throbber. Called when extension isntallation is complete. - (void)stopThrobber; diff --git a/chrome/browser/ui/cocoa/web_intent_sheet_controller.mm b/chrome/browser/ui/cocoa/web_intent_sheet_controller.mm index fa75634..eaa85a6 100644 --- a/chrome/browser/ui/cocoa/web_intent_sheet_controller.mm +++ b/chrome/browser/ui/cocoa/web_intent_sheet_controller.mm @@ -27,7 +27,6 @@ #include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util_mac.h" #include "ui/base/resource/resource_bundle.h" -#include "ui/base/text/text_elider.h" #include "ui/gfx/image/image.h" using content::OpenURLParams; @@ -39,9 +38,6 @@ namespace { // determined by the content. const CGFloat kWindowWidth = 400; -// The maximum width in view units of a suggested extension's title link. -const int kTitleLinkMaxWidth = 130; - // The width of a service button, in view coordinates. const CGFloat kServiceButtonWidth = 300; @@ -472,9 +468,6 @@ NSButton* CreateHyperlinkButton(NSString* title, const NSRect& frame) { model_ = picker->model(); intentButtons_.reset([[NSMutableArray alloc] init]); - inlineDispositionTitleField_.reset([[NSTextField alloc] init]); - ConfigureTextFieldAsLabel(inlineDispositionTitleField_); - flipView_.reset([[WebIntentsContentView alloc] init]); [flipView_ setAutoresizingMask:NSViewMinYMargin]; [[[self window] contentView] setSubviews: @@ -493,11 +486,6 @@ NSButton* CreateHyperlinkButton(NSString* title, const NSRect& frame) { [self closeSheet]; } -- (void)chooseAnotherService:(id)sender { - if (picker_) - picker_->OnChooseAnotherService(); -} - // Handle keyDown events, specifically ESC. - (void)keyDown:(NSEvent*)event { // Check for escape key. @@ -521,17 +509,16 @@ NSButton* CreateHyperlinkButton(NSString* title, const NSRect& frame) { - (void)setInlineDispositionFrameSize:(NSSize)inlineContentSize { DCHECK(contents_); - NSView* webContentView = contents_->web_contents()->GetNativeView(); - // Compute container size to fit all elements, including padding. NSSize containerSize = inlineContentSize; - containerSize.height += [webContentView frame].origin.y + kFramePadding; - containerSize.width += 2 * kFramePadding; + containerSize.height += 2 * kFramePadding; + containerSize.width += 2 * kFramePadding + kFramePadding + kCloseButtonSize; // Ensure minimum container width. containerSize.width = std::max(kWindowWidth, containerSize.width); // Resize web contents. + NSView* webContentView = contents_->web_contents()->GetNativeView(); [webContentView setFrameSize:inlineContentSize]; // Position close button. @@ -684,44 +671,6 @@ NSButton* CreateHyperlinkButton(NSString* title, const NSRect& frame) { return NSHeight(frame); } -- (CGFloat)addAnotherServiceLinkToSubviews:(NSMutableArray*)subviews - atOffset:(CGFloat)offset { - - NSRect textFrame = NSMakeRect(kFramePadding, offset, kTextWidth, 1); - [inlineDispositionTitleField_ setFrame:textFrame]; - [subviews addObject:inlineDispositionTitleField_]; - [GTMUILocalizerAndLayoutTweaker sizeToFitView:inlineDispositionTitleField_]; - textFrame = [inlineDispositionTitleField_ frame]; - - if (model_->GetSuggestedExtensionCount()) { - NSRect frame = NSMakeRect( - NSMaxX(textFrame) + kFramePadding, offset, - kTitleLinkMaxWidth, 1); - NSString* string = l10n_util::GetNSStringWithFixup( - IDS_INTENT_PICKER_USE_ALTERNATE_SERVICE); - scoped_nsobject button(CreateHyperlinkButton(string, frame)); - [[button cell] setControlSize:NSRegularControlSize]; - [button setTarget:self]; - [button setAction:@selector(chooseAnotherService:)]; - [subviews addObject:button]; - - // Call size-to-fit to fixup for the localized string. - [GTMUILocalizerAndLayoutTweaker sizeToFitView:button]; - - // And finally, make sure the link and the title are horizontally centered. - frame = [button frame]; - CGFloat height = std::max(NSHeight(textFrame), NSHeight(frame)); - frame.origin.y += (height - NSHeight(frame)) / 2.0; - frame.size.height = height; - textFrame.origin.y += (height - NSHeight(textFrame)) / 2.0; - textFrame.size.height = height; - [button setFrame:frame]; - [inlineDispositionTitleField_ setFrame:textFrame]; - } - - return NSHeight(textFrame); -} - // Add a single button for a specific service - (CGFloat)addServiceButton:(NSString*)title withImage:(NSImage*)image @@ -767,9 +716,6 @@ NSButton* CreateHyperlinkButton(NSString* title, const NSRect& frame) { NSMutableArray* subviews = [NSMutableArray array]; if (contents_) { - offset += [self addAnotherServiceLinkToSubviews:subviews - atOffset:offset]; - offset += kFramePadding; offset += [self addInlineHtmlToSubviews:subviews atOffset:offset]; [self addCloseButtonToSubviews:subviews]; } else { @@ -833,16 +779,6 @@ NSButton* CreateHyperlinkButton(NSString* title, const NSRect& frame) { [actionTextField_ setFrame: textFrame]; } -- (void)setInlineDispositionTitle:(NSString*)title { - NSFont* nsfont = [inlineDispositionTitleField_ font]; - gfx::Font font( - base::SysNSStringToUTF8([nsfont fontName]), [nsfont pointSize]); - NSString* elidedTitle = base::SysUTF16ToNSString(ui::ElideText( - base::SysNSStringToUTF16(title), - font, kTitleLinkMaxWidth, ui::ELIDE_AT_END)); - [inlineDispositionTitleField_ setStringValue:elidedTitle]; -} - - (void)stopThrobber { [closeButton_ setEnabled:YES]; [self setIntentButtonsEnabled:YES]; -- cgit v1.1