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

Side by Side Diff: chrome/browser/cocoa/toolbar_controller.mm

Issue 481012: Mac: implement DnD of URLs onto Omnibox. (Closed)
Patch Set: Stuff. Created 11 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
« no previous file with comments | « chrome/browser/cocoa/toolbar_controller.h ('k') | chrome/browser/cocoa/url_drop_target.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/cocoa/toolbar_controller.h" 5 #import "chrome/browser/cocoa/toolbar_controller.h"
6 6
7 #include "app/l10n_util_mac.h" 7 #include "app/l10n_util_mac.h"
8 #include "base/mac_util.h" 8 #include "base/mac_util.h"
9 #include "base/nsimage_cache_mac.h" 9 #include "base/nsimage_cache_mac.h"
10 #include "base/sys_string_conversions.h" 10 #include "base/sys_string_conversions.h"
11 #include "base/gfx/rect.h" 11 #include "base/gfx/rect.h"
12 #include "chrome/app/chrome_dll_resource.h" 12 #include "chrome/app/chrome_dll_resource.h"
13 #include "chrome/browser/app_menu_model.h" 13 #include "chrome/browser/app_menu_model.h"
14 #include "chrome/browser/autocomplete/autocomplete_edit_view.h" 14 #include "chrome/browser/autocomplete/autocomplete_edit_view.h"
15 #include "chrome/browser/browser.h" 15 #include "chrome/browser/browser.h"
16 #include "chrome/browser/bubble_positioner.h" 16 #include "chrome/browser/bubble_positioner.h"
17 #import "chrome/browser/cocoa/autocomplete_text_field.h" 17 #import "chrome/browser/cocoa/autocomplete_text_field.h"
18 #import "chrome/browser/cocoa/autocomplete_text_field_editor.h" 18 #import "chrome/browser/cocoa/autocomplete_text_field_editor.h"
19 #import "chrome/browser/cocoa/back_forward_menu_controller.h" 19 #import "chrome/browser/cocoa/back_forward_menu_controller.h"
20 #import "chrome/browser/cocoa/background_gradient_view.h" 20 #import "chrome/browser/cocoa/background_gradient_view.h"
21 #import "chrome/browser/cocoa/encoding_menu_controller_delegate_mac.h" 21 #import "chrome/browser/cocoa/encoding_menu_controller_delegate_mac.h"
22 #import "chrome/browser/cocoa/extensions/browser_actions_controller.h" 22 #import "chrome/browser/cocoa/extensions/browser_actions_controller.h"
23 #import "chrome/browser/cocoa/gradient_button_cell.h" 23 #import "chrome/browser/cocoa/gradient_button_cell.h"
24 #import "chrome/browser/cocoa/location_bar_view_mac.h" 24 #import "chrome/browser/cocoa/location_bar_view_mac.h"
25 #import "chrome/browser/cocoa/menu_button.h" 25 #import "chrome/browser/cocoa/menu_button.h"
26 #import "chrome/browser/cocoa/menu_controller.h" 26 #import "chrome/browser/cocoa/menu_controller.h"
27 #import "chrome/browser/cocoa/toolbar_view.h" 27 #import "chrome/browser/cocoa/toolbar_view.h"
28 #include "chrome/browser/net/url_fixer_upper.h"
28 #include "chrome/browser/page_menu_model.h" 29 #include "chrome/browser/page_menu_model.h"
29 #include "chrome/browser/profile.h" 30 #include "chrome/browser/profile.h"
30 #include "chrome/browser/search_engines/template_url_model.h" 31 #include "chrome/browser/search_engines/template_url_model.h"
32 #include "chrome/browser/tab_contents/tab_contents.h"
31 #include "chrome/browser/toolbar_model.h" 33 #include "chrome/browser/toolbar_model.h"
32 #include "chrome/common/notification_details.h" 34 #include "chrome/common/notification_details.h"
33 #include "chrome/common/notification_observer.h" 35 #include "chrome/common/notification_observer.h"
34 #include "chrome/common/notification_type.h" 36 #include "chrome/common/notification_type.h"
35 #include "chrome/common/pref_names.h" 37 #include "chrome/common/pref_names.h"
36 #include "chrome/common/pref_service.h" 38 #include "chrome/common/pref_service.h"
37 #include "grit/generated_resources.h" 39 #include "grit/generated_resources.h"
38 40
39 namespace { 41 namespace {
40 42
(...skipping 632 matching lines...) Expand 10 before | Expand all | Expand 10 after
673 const CGFloat maxX = NSMaxX(locationFrame) + NSWidth([goButton_ frame]); 675 const CGFloat maxX = NSMaxX(locationFrame) + NSWidth([goButton_ frame]);
674 676
675 NSRect r = NSMakeRect(minX, NSMinY(locationFrame), maxX - minX, 677 NSRect r = NSMakeRect(minX, NSMinY(locationFrame), maxX - minX,
676 NSHeight(locationFrame)); 678 NSHeight(locationFrame));
677 gfx::Rect stack_bounds( 679 gfx::Rect stack_bounds(
678 NSRectToCGRect([[self view] convertRect:r toView:nil])); 680 NSRectToCGRect([[self view] convertRect:r toView:nil]));
679 // Inset the bounds to just inside the visible edges (see comment above). 681 // Inset the bounds to just inside the visible edges (see comment above).
680 stack_bounds.Inset(kLocationStackEdgeWidth, 0); 682 stack_bounds.Inset(kLocationStackEdgeWidth, 0);
681 return stack_bounds; 683 return stack_bounds;
682 } 684 }
685
686 // (URLDropTargetController protocol)
687 - (void)dropURLs:(NSArray*)urls inView:(NSView*)view at:(NSPoint)point {
688 // TODO(viettrungluu): This code is more or less copied from the code in
689 // |TabStripController|. I'll refactor this soon to make it common and expand
690 // its capabilities (e.g., allow text DnD).
691 if ([urls count] < 1) {
692 NOTREACHED();
693 return;
694 }
695
696 //TODO(viettrungluu): dropping multiple URLs?
697 if ([urls count] > 1)
698 NOTIMPLEMENTED();
699
700 // Get the first URL and fix it up.
701 GURL url(URLFixerUpper::FixupURL(
702 base::SysNSStringToUTF8([urls objectAtIndex:0]), std::string()));
703
704 browser_->GetSelectedTabContents()->OpenURL(url, GURL(), CURRENT_TAB,
705 PageTransition::TYPED);
706 }
707
708 // (URLDropTargetController protocol)
709 - (void)indicateDropURLsInView:(NSView*)view at:(NSPoint)point {
710 // Do nothing.
711 }
712
713 // (URLDropTargetController protocol)
714 - (void)hideDropURLsIndicatorInView:(NSView*)view {
715 // Do nothing.
716 }
717
683 @end 718 @end
OLDNEW
« no previous file with comments | « chrome/browser/cocoa/toolbar_controller.h ('k') | chrome/browser/cocoa/url_drop_target.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698