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

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

Issue 540483002: Fix regression in showing bookmark star when an extension should override it (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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/command_line.h" 8 #include "base/command_line.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/prefs/pref_service.h" 10 #include "base/prefs/pref_service.h"
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 217
218 [field_ updateMouseTracking]; 218 [field_ updateMouseTracking];
219 [field_ setNeedsDisplay:YES]; 219 [field_ setNeedsDisplay:YES];
220 } 220 }
221 221
222 void LocationBarViewMac::InvalidatePageActions() { 222 void LocationBarViewMac::InvalidatePageActions() {
223 DeletePageActionDecorations(); 223 DeletePageActionDecorations();
224 Layout(); 224 Layout();
225 } 225 }
226 226
227 void LocationBarViewMac::UpdateBookmarkStarVisibility() {
228 star_decoration_->SetVisible(IsStarEnabled());
229 }
230
227 bool LocationBarViewMac::ShowPageActionPopup( 231 bool LocationBarViewMac::ShowPageActionPopup(
228 const extensions::Extension* extension, bool grant_active_tab) { 232 const extensions::Extension* extension, bool grant_active_tab) {
229 for (ScopedVector<PageActionDecoration>::iterator iter = 233 for (ScopedVector<PageActionDecoration>::iterator iter =
230 page_action_decorations_.begin(); 234 page_action_decorations_.begin();
231 iter != page_action_decorations_.end(); ++iter) { 235 iter != page_action_decorations_.end(); ++iter) {
232 if ((*iter)->page_action()->extension_id() == extension->id()) 236 if ((*iter)->page_action()->extension_id() == extension->id())
233 return (*iter)->ActivatePageAction(grant_active_tab); 237 return (*iter)->ActivatePageAction(grant_active_tab);
234 } 238 }
235 return false; 239 return false;
236 } 240 }
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 page_action_decorations_[index]->OnMousePressed(NSZeroRect, NSZeroPoint); 310 page_action_decorations_[index]->OnMousePressed(NSZeroRect, NSZeroPoint);
307 } 311 }
308 312
309 bool LocationBarViewMac::GetBookmarkStarVisibility() { 313 bool LocationBarViewMac::GetBookmarkStarVisibility() {
310 DCHECK(star_decoration_.get()); 314 DCHECK(star_decoration_.get());
311 return star_decoration_->IsVisible(); 315 return star_decoration_->IsVisible();
312 } 316 }
313 317
314 void LocationBarViewMac::SetEditable(bool editable) { 318 void LocationBarViewMac::SetEditable(bool editable) {
315 [field_ setEditable:editable ? YES : NO]; 319 [field_ setEditable:editable ? YES : NO];
316 UpdateStarDecorationVisibility(); 320 UpdateBookmarkStarVisibility();
317 UpdateZoomDecoration(); 321 UpdateZoomDecoration();
318 UpdatePageActions(); 322 UpdatePageActions();
319 Layout(); 323 Layout();
320 } 324 }
321 325
322 bool LocationBarViewMac::IsEditable() { 326 bool LocationBarViewMac::IsEditable() {
323 return [field_ isEditable] ? true : false; 327 return [field_ isEditable] ? true : false;
324 } 328 }
325 329
326 void LocationBarViewMac::SetStarred(bool starred) { 330 void LocationBarViewMac::SetStarred(bool starred) {
327 if (star_decoration_->starred() == starred) 331 if (star_decoration_->starred() == starred)
328 return; 332 return;
329 333
330 star_decoration_->SetStarred(starred); 334 star_decoration_->SetStarred(starred);
331 UpdateStarDecorationVisibility(); 335 UpdateBookmarkStarVisibility();
332 OnDecorationsChanged(); 336 OnDecorationsChanged();
333 } 337 }
334 338
335 void LocationBarViewMac::SetTranslateIconLit(bool on) { 339 void LocationBarViewMac::SetTranslateIconLit(bool on) {
336 translate_decoration_->SetLit(on); 340 translate_decoration_->SetLit(on);
337 OnDecorationsChanged(); 341 OnDecorationsChanged();
338 } 342 }
339 343
340 void LocationBarViewMac::ZoomChangedForActiveTab(bool can_show_bubble) { 344 void LocationBarViewMac::ZoomChangedForActiveTab(bool can_show_bubble) {
341 bool changed = UpdateZoomDecoration(); 345 bool changed = UpdateZoomDecoration();
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 NOTREACHED(); 525 NOTREACHED();
522 return NSZeroPoint; 526 return NSZeroPoint;
523 } 527 }
524 528
525 NSPoint bubble_point = decoration->GetBubblePointInFrame(frame); 529 NSPoint bubble_point = decoration->GetBubblePointInFrame(frame);
526 return [field_ convertPoint:bubble_point toView:nil]; 530 return [field_ convertPoint:bubble_point toView:nil];
527 } 531 }
528 532
529 void LocationBarViewMac::Update(const WebContents* contents) { 533 void LocationBarViewMac::Update(const WebContents* contents) {
530 UpdateManagePasswordsIconAndBubble(); 534 UpdateManagePasswordsIconAndBubble();
531 UpdateStarDecorationVisibility(); 535 UpdateBookmarkStarVisibility();
532 UpdateTranslateDecoration(); 536 UpdateTranslateDecoration();
533 UpdateZoomDecoration(); 537 UpdateZoomDecoration();
534 RefreshPageActionDecorations(); 538 RefreshPageActionDecorations();
535 RefreshContentSettingsDecorations(); 539 RefreshContentSettingsDecorations();
536 UpdateMicSearchDecorationVisibility(); 540 UpdateMicSearchDecorationVisibility();
537 UpdateGeneratedCreditCardView(); 541 UpdateGeneratedCreditCardView();
538 if (contents) 542 if (contents)
539 omnibox_view_->OnTabChanged(contents); 543 omnibox_view_->OnTabChanged(contents);
540 else 544 else
541 omnibox_view_->Update(); 545 omnibox_view_->Update();
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
651 void LocationBarViewMac::DeletePageActionDecorations() { 655 void LocationBarViewMac::DeletePageActionDecorations() {
652 // TODO(shess): Deleting these decorations could result in the cell 656 // TODO(shess): Deleting these decorations could result in the cell
653 // refering to them before things are laid out again. Meanwhile, at 657 // refering to them before things are laid out again. Meanwhile, at
654 // least fail safe. 658 // least fail safe.
655 [[field_ cell] clearDecorations]; 659 [[field_ cell] clearDecorations];
656 660
657 page_action_decorations_.clear(); 661 page_action_decorations_.clear();
658 } 662 }
659 663
660 void LocationBarViewMac::OnEditBookmarksEnabledChanged() { 664 void LocationBarViewMac::OnEditBookmarksEnabledChanged() {
661 UpdateStarDecorationVisibility(); 665 UpdateBookmarkStarVisibility();
662 OnChanged(); 666 OnChanged();
663 } 667 }
664 668
665 void LocationBarViewMac::RefreshPageActionDecorations() { 669 void LocationBarViewMac::RefreshPageActionDecorations() {
666 if (!IsEditable()) { 670 if (!IsEditable()) {
667 DeletePageActionDecorations(); 671 DeletePageActionDecorations();
668 return; 672 return;
669 } 673 }
670 674
671 WebContents* web_contents = GetWebContents(); 675 WebContents* web_contents = GetWebContents();
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
749 753
750 bool LocationBarViewMac::UpdateZoomDecoration() { 754 bool LocationBarViewMac::UpdateZoomDecoration() {
751 WebContents* web_contents = GetWebContents(); 755 WebContents* web_contents = GetWebContents();
752 if (!web_contents) 756 if (!web_contents)
753 return false; 757 return false;
754 758
755 return zoom_decoration_->UpdateIfNecessary( 759 return zoom_decoration_->UpdateIfNecessary(
756 ZoomController::FromWebContents(web_contents)); 760 ZoomController::FromWebContents(web_contents));
757 } 761 }
758 762
759 void LocationBarViewMac::UpdateStarDecorationVisibility() {
760 star_decoration_->SetVisible(IsStarEnabled());
761 }
762
763 bool LocationBarViewMac::UpdateMicSearchDecorationVisibility() { 763 bool LocationBarViewMac::UpdateMicSearchDecorationVisibility() {
764 bool is_visible = !GetToolbarModel()->input_in_progress() && 764 bool is_visible = !GetToolbarModel()->input_in_progress() &&
765 browser_->search_model()->voice_search_supported(); 765 browser_->search_model()->voice_search_supported();
766 if (mic_search_decoration_->IsVisible() == is_visible) 766 if (mic_search_decoration_->IsVisible() == is_visible)
767 return false; 767 return false;
768 mic_search_decoration_->SetVisible(is_visible); 768 mic_search_decoration_->SetVisible(is_visible);
769 return true; 769 return true;
770 } 770 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h ('k') | chrome/browser/ui/location_bar/location_bar.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698