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

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

Issue 1567023: [Mac] Location icon in omnibox as drag source. (Closed)
Patch Set: more nits Created 10 years, 8 months 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/location_bar_view_mac.h ('k') | no next file » | 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/location_bar_view_mac.h" 5 #import "chrome/browser/cocoa/location_bar_view_mac.h"
6 6
7 #include "app/l10n_util_mac.h" 7 #include "app/l10n_util_mac.h"
8 #include "app/resource_bundle.h" 8 #include "app/resource_bundle.h"
9 #include "base/i18n/rtl.h" 9 #include "base/i18n/rtl.h"
10 #include "base/nsimage_cache_mac.h" 10 #include "base/nsimage_cache_mac.h"
(...skipping 23 matching lines...) Expand all
34 #include "chrome/browser/tab_contents/navigation_entry.h" 34 #include "chrome/browser/tab_contents/navigation_entry.h"
35 #include "chrome/browser/tab_contents/tab_contents.h" 35 #include "chrome/browser/tab_contents/tab_contents.h"
36 #include "chrome/common/extensions/extension.h" 36 #include "chrome/common/extensions/extension.h"
37 #include "chrome/common/extensions/extension_action.h" 37 #include "chrome/common/extensions/extension_action.h"
38 #include "chrome/common/notification_service.h" 38 #include "chrome/common/notification_service.h"
39 #include "chrome/common/pref_names.h" 39 #include "chrome/common/pref_names.h"
40 #include "net/base/net_util.h" 40 #include "net/base/net_util.h"
41 #include "grit/generated_resources.h" 41 #include "grit/generated_resources.h"
42 #include "grit/theme_resources.h" 42 #include "grit/theme_resources.h"
43 #include "skia/ext/skia_utils_mac.h" 43 #include "skia/ext/skia_utils_mac.h"
44 #import "third_party/mozilla/include/NSPasteboard+Utils.h"
44 45
45 46
46 // TODO(shess): This code is mostly copied from the gtk 47 // TODO(shess): This code is mostly copied from the gtk
47 // implementation. Make sure it's all appropriate and flesh it out. 48 // implementation. Make sure it's all appropriate and flesh it out.
48 49
49 namespace { 50 namespace {
50 51
51 // Returns the short name for a keyword. 52 // Returns the short name for a keyword.
52 // TODO(shess): Copied from views/location_bar_view.cc. Try to share 53 // TODO(shess): Copied from views/location_bar_view.cc. Try to share
53 // it. 54 // it.
(...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after
593 // LocationIconView ------------------------------------------------------------ 594 // LocationIconView ------------------------------------------------------------
594 595
595 LocationBarViewMac::LocationIconView::LocationIconView( 596 LocationBarViewMac::LocationIconView::LocationIconView(
596 LocationBarViewMac* owner) 597 LocationBarViewMac* owner)
597 : owner_(owner) { 598 : owner_(owner) {
598 } 599 }
599 600
600 LocationBarViewMac::LocationIconView::~LocationIconView() {} 601 LocationBarViewMac::LocationIconView::~LocationIconView() {}
601 602
602 void LocationBarViewMac::LocationIconView::OnMousePressed(NSRect bounds) { 603 void LocationBarViewMac::LocationIconView::OnMousePressed(NSRect bounds) {
604 // TODO(shess): Only allow click if page-info makes sense.
605 // http://codereview.chromium.org/1594012
603 TabContents* tab = owner_->GetTabContents(); 606 TabContents* tab = owner_->GetTabContents();
604 NavigationEntry* nav_entry = tab->controller().GetActiveEntry(); 607 NavigationEntry* nav_entry = tab->controller().GetActiveEntry();
605 if (!nav_entry) { 608 if (!nav_entry) {
606 NOTREACHED(); 609 NOTREACHED();
607 return; 610 return;
608 } 611 }
609 tab->ShowPageInfo(nav_entry->url(), nav_entry->ssl(), true); 612 tab->ShowPageInfo(nav_entry->url(), nav_entry->ssl(), true);
610 } 613 }
611 614
615 bool LocationBarViewMac::LocationIconView::IsDraggable() {
616 // TODO(shess): Only allow drag if there's an URL to drag.
617 // http://codereview.chromium.org/1594012
618 return true;
619 }
620
621 NSPasteboard* LocationBarViewMac::LocationIconView::GetDragPasteboard() {
622 TabContents* tab = owner_->GetTabContents();
623 DCHECK(tab);
viettrungluu 2010/04/08 17:23:18 This seems redundant, since it'll crash on the nex
624
625 NSString* url = base::SysUTF8ToNSString(tab->GetURL().spec());
626 NSString* title = base::SysUTF16ToNSString(tab->GetTitle());
627
628 NSPasteboard* pboard = [NSPasteboard pasteboardWithName:NSDragPboard];
629 [pboard declareURLPasteboardWithAdditionalTypes:[NSArray array]
630 owner:nil];
631 [pboard setDataForURL:url title:title];
632 return pboard;
633 }
634
612 // StarIconView----------------------------------------------------------------- 635 // StarIconView-----------------------------------------------------------------
613 636
614 LocationBarViewMac::StarIconView::StarIconView(CommandUpdater* command_updater) 637 LocationBarViewMac::StarIconView::StarIconView(CommandUpdater* command_updater)
615 : command_updater_(command_updater) { 638 : command_updater_(command_updater) {
616 SetVisible(true); 639 SetVisible(true);
617 SetStarred(false); 640 SetStarred(false);
618 } 641 }
619 642
620 void LocationBarViewMac::StarIconView::SetStarred(bool starred) { 643 void LocationBarViewMac::StarIconView::SetStarred(bool starred) {
621 if (starred) { 644 if (starred) {
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
968 ++result; 991 ++result;
969 } 992 }
970 return result; 993 return result;
971 } 994 }
972 995
973 void LocationBarViewMac::PageActionViewList::OnMousePressed(NSRect iconFrame, 996 void LocationBarViewMac::PageActionViewList::OnMousePressed(NSRect iconFrame,
974 size_t index) { 997 size_t index) {
975 ViewAt(index)->OnMousePressed(iconFrame); 998 ViewAt(index)->OnMousePressed(iconFrame);
976 } 999 }
977 1000
OLDNEW
« no previous file with comments | « chrome/browser/cocoa/location_bar_view_mac.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698