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/tabs/tab_strip_controller.h" | 5 #import "chrome/browser/ui/cocoa/tabs/tab_strip_controller.h" |
6 | 6 |
7 #import <QuartzCore/QuartzCore.h> | 7 #import <QuartzCore/QuartzCore.h> |
8 | 8 |
9 #include <cmath> | 9 #include <cmath> |
10 #include <limits> | 10 #include <limits> |
(...skipping 2108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2119 } | 2119 } |
2120 | 2120 |
2121 //TODO(viettrungluu): dropping multiple URLs. | 2121 //TODO(viettrungluu): dropping multiple URLs. |
2122 if ([urls count] > 1) | 2122 if ([urls count] > 1) |
2123 NOTIMPLEMENTED(); | 2123 NOTIMPLEMENTED(); |
2124 | 2124 |
2125 // Get the first URL and fix it up. | 2125 // Get the first URL and fix it up. |
2126 GURL url(GURL(url_formatter::FixupURL( | 2126 GURL url(GURL(url_formatter::FixupURL( |
2127 base::SysNSStringToUTF8([urls objectAtIndex:0]), std::string()))); | 2127 base::SysNSStringToUTF8([urls objectAtIndex:0]), std::string()))); |
2128 | 2128 |
| 2129 // If the URL isn't valid, don't bother. |
| 2130 if (!url.is_valid()) |
| 2131 return; |
| 2132 |
2129 [self openURL:&url inView:view at:point]; | 2133 [self openURL:&url inView:view at:point]; |
2130 } | 2134 } |
2131 | 2135 |
2132 // (URLDropTargetController protocol) | 2136 // (URLDropTargetController protocol) |
2133 - (void)dropText:(NSString*)text inView:(NSView*)view at:(NSPoint)point { | 2137 - (void)dropText:(NSString*)text inView:(NSView*)view at:(NSPoint)point { |
2134 DCHECK_EQ(view, tabStripView_.get()); | 2138 DCHECK_EQ(view, tabStripView_.get()); |
2135 | 2139 |
2136 // If the input is plain text, classify the input and make the URL. | 2140 // If the input is plain text, classify the input and make the URL. |
2137 AutocompleteMatch match; | 2141 AutocompleteMatch match; |
2138 AutocompleteClassifierFactory::GetForProfile(browser_->profile())->Classify( | 2142 AutocompleteClassifierFactory::GetForProfile(browser_->profile())->Classify( |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2323 forButtonState:image_button_cell::kHoverStateBackground]; | 2327 forButtonState:image_button_cell::kHoverStateBackground]; |
2324 } else { | 2328 } else { |
2325 [[newTabButton_ cell] setImage:nil | 2329 [[newTabButton_ cell] setImage:nil |
2326 forButtonState:image_button_cell::kDefaultStateBackground]; | 2330 forButtonState:image_button_cell::kDefaultStateBackground]; |
2327 [[newTabButton_ cell] setImage:nil | 2331 [[newTabButton_ cell] setImage:nil |
2328 forButtonState:image_button_cell::kHoverStateBackground]; | 2332 forButtonState:image_button_cell::kHoverStateBackground]; |
2329 } | 2333 } |
2330 } | 2334 } |
2331 | 2335 |
2332 @end | 2336 @end |
OLD | NEW |