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

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

Issue 10833056: Add a menu to the Action Box Button. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Final changes! Created 8 years, 4 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 | Annotate | Revision Log
OLDNEW
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/location_bar/location_bar_view_mac.h" 5 #import "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "base/stl_util.h" 9 #include "base/stl_util.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 field_(field), 91 field_(field),
92 disposition_(CURRENT_TAB), 92 disposition_(CURRENT_TAB),
93 location_icon_decoration_(new LocationIconDecoration(this)), 93 location_icon_decoration_(new LocationIconDecoration(this)),
94 selected_keyword_decoration_( 94 selected_keyword_decoration_(
95 new SelectedKeywordDecoration(OmniboxViewMac::GetFieldFont())), 95 new SelectedKeywordDecoration(OmniboxViewMac::GetFieldFont())),
96 ev_bubble_decoration_( 96 ev_bubble_decoration_(
97 new EVBubbleDecoration(location_icon_decoration_.get(), 97 new EVBubbleDecoration(location_icon_decoration_.get(),
98 OmniboxViewMac::GetFieldFont())), 98 OmniboxViewMac::GetFieldFont())),
99 plus_decoration_(NULL), 99 plus_decoration_(NULL),
100 star_decoration_(new StarDecoration(command_updater)), 100 star_decoration_(new StarDecoration(command_updater)),
101 chrome_to_mobile_decoration_(nil), 101 chrome_to_mobile_decoration_(NULL),
102 keyword_hint_decoration_( 102 keyword_hint_decoration_(
103 new KeywordHintDecoration(OmniboxViewMac::GetFieldFont())), 103 new KeywordHintDecoration(OmniboxViewMac::GetFieldFont())),
104 profile_(profile), 104 profile_(profile),
105 browser_(browser), 105 browser_(browser),
106 toolbar_model_(toolbar_model), 106 toolbar_model_(toolbar_model),
107 transition_(content::PageTransitionFromInt( 107 transition_(content::PageTransitionFromInt(
108 content::PAGE_TRANSITION_TYPED | 108 content::PAGE_TRANSITION_TYPED |
109 content::PAGE_TRANSITION_FROM_ADDRESS_BAR)), 109 content::PAGE_TRANSITION_FROM_ADDRESS_BAR)),
110 weak_ptr_factory_(this) { 110 weak_ptr_factory_(this) {
111 // Disable Chrome To Mobile for off-the-record and non-synced profiles, 111 // Disable Chrome To Mobile for off-the-record and non-synced profiles,
112 // or if the feature is disabled by a command line flag or chrome://flags. 112 // or if the feature is disabled by a command line flag or chrome://flags.
113 if (!profile_->IsOffTheRecord() && profile_->IsSyncAccessible() && 113 if (!profile_->IsOffTheRecord() && profile_->IsSyncAccessible() &&
114 ChromeToMobileService::IsChromeToMobileEnabled()) { 114 ChromeToMobileService::IsChromeToMobileEnabled()) {
115 command_updater_->AddCommandObserver(IDC_CHROME_TO_MOBILE_PAGE, this); 115 command_updater_->AddCommandObserver(IDC_CHROME_TO_MOBILE_PAGE, this);
116 chrome_to_mobile_decoration_.reset( 116 chrome_to_mobile_decoration_.reset(
117 new ChromeToMobileDecoration(profile, command_updater)); 117 new ChromeToMobileDecoration(profile, command_updater));
118 ChromeToMobileServiceFactory::GetForProfile(profile)-> 118 ChromeToMobileServiceFactory::GetForProfile(profile)->
119 RequestMobileListUpdate(); 119 RequestMobileListUpdate();
120 } 120 }
121 121
122 if (extensions::switch_utils::IsActionBoxEnabled()) { 122 if (extensions::switch_utils::IsActionBoxEnabled()) {
123 plus_decoration_.reset(new PlusDecoration(command_updater)); 123 plus_decoration_.reset(new PlusDecoration(this, command_updater, browser_));
124 } 124 }
125 125
126 for (size_t i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) { 126 for (size_t i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) {
127 DCHECK_EQ(i, content_setting_decorations_.size()); 127 DCHECK_EQ(i, content_setting_decorations_.size());
128 ContentSettingsType type = static_cast<ContentSettingsType>(i); 128 ContentSettingsType type = static_cast<ContentSettingsType>(i);
129 content_setting_decorations_.push_back( 129 content_setting_decorations_.push_back(
130 new ContentSettingDecoration(type, this, profile_)); 130 new ContentSettingDecoration(type, this, profile_));
131 } 131 }
132 132
133 registrar_.Add(this, 133 registrar_.Add(this,
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
493 const NSPoint point = star_decoration_->GetBubblePointInFrame(frame); 493 const NSPoint point = star_decoration_->GetBubblePointInFrame(frame);
494 return [field_ convertPoint:point toView:nil]; 494 return [field_ convertPoint:point toView:nil];
495 } 495 }
496 496
497 NSPoint LocationBarViewMac::GetChromeToMobileBubblePoint() const { 497 NSPoint LocationBarViewMac::GetChromeToMobileBubblePoint() const {
498 AutocompleteTextFieldCell* cell = [field_ cell]; 498 AutocompleteTextFieldCell* cell = [field_ cell];
499 const NSRect frame = 499 const NSRect frame =
500 [cell frameForDecoration:chrome_to_mobile_decoration_.get() 500 [cell frameForDecoration:chrome_to_mobile_decoration_.get()
501 inFrame:[field_ bounds]]; 501 inFrame:[field_ bounds]];
502 const NSPoint point = 502 const NSPoint point =
503 chrome_to_mobile_decoration_->GetBubblePointInFrame(frame); 503 chrome_to_mobile_decoration_->GetBubblePointInFrame(frame);
504 return [field_ convertPoint:point toView:nil]; 504 return [field_ convertPoint:point toView:nil];
505 } 505 }
506 506
507 NSPoint LocationBarViewMac::GetPageInfoBubblePoint() const { 507 NSPoint LocationBarViewMac::GetPageInfoBubblePoint() const {
508 AutocompleteTextFieldCell* cell = [field_ cell]; 508 AutocompleteTextFieldCell* cell = [field_ cell];
509 if (ev_bubble_decoration_->IsVisible()) { 509 if (ev_bubble_decoration_->IsVisible()) {
510 const NSRect frame = [cell frameForDecoration:ev_bubble_decoration_.get() 510 const NSRect frame = [cell frameForDecoration:ev_bubble_decoration_.get()
511 inFrame:[field_ bounds]]; 511 inFrame:[field_ bounds]];
512 const NSPoint point = ev_bubble_decoration_->GetBubblePointInFrame(frame); 512 const NSPoint point = ev_bubble_decoration_->GetBubblePointInFrame(frame);
513 return [field_ convertPoint:point toView:nil]; 513 return [field_ convertPoint:point toView:nil];
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
726 void LocationBarViewMac::UpdateChromeToMobileEnabled() { 726 void LocationBarViewMac::UpdateChromeToMobileEnabled() {
727 if (!chrome_to_mobile_decoration_.get()) 727 if (!chrome_to_mobile_decoration_.get())
728 return; 728 return;
729 729
730 DCHECK(ChromeToMobileService::IsChromeToMobileEnabled()); 730 DCHECK(ChromeToMobileService::IsChromeToMobileEnabled());
731 bool enabled = [field_ isEditable] && !toolbar_model_->input_in_progress() && 731 bool enabled = [field_ isEditable] && !toolbar_model_->input_in_progress() &&
732 ChromeToMobileServiceFactory::GetForProfile(profile_)->HasMobiles(); 732 ChromeToMobileServiceFactory::GetForProfile(profile_)->HasMobiles();
733 chrome_to_mobile_decoration_->SetVisible(enabled); 733 chrome_to_mobile_decoration_->SetVisible(enabled);
734 command_updater_->UpdateCommandEnabled(IDC_CHROME_TO_MOBILE_PAGE, enabled); 734 command_updater_->UpdateCommandEnabled(IDC_CHROME_TO_MOBILE_PAGE, enabled);
735 } 735 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698