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

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

Issue 10874068: When using action box on Mac, hide star when page is not bookmarked. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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/command_line.h" 8 #include "base/command_line.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 // TODO(gbillock): Implement web intents tool for mac 243 // TODO(gbillock): Implement web intents tool for mac
244 } 244 }
245 245
246 void LocationBarViewMac::SaveStateToContents(WebContents* contents) { 246 void LocationBarViewMac::SaveStateToContents(WebContents* contents) {
247 // TODO(shess): Why SaveStateToContents vs SaveStateToTab? 247 // TODO(shess): Why SaveStateToContents vs SaveStateToTab?
248 omnibox_view_->SaveStateToTab(contents); 248 omnibox_view_->SaveStateToTab(contents);
249 } 249 }
250 250
251 void LocationBarViewMac::Update(const WebContents* contents, 251 void LocationBarViewMac::Update(const WebContents* contents,
252 bool should_restore_state) { 252 bool should_restore_state) {
253 bool star_enabled = IsStarEnabled(); 253 command_updater_->UpdateCommandEnabled(IDC_BOOKMARK_PAGE, IsStarEnabled());
254 command_updater_->UpdateCommandEnabled(IDC_BOOKMARK_PAGE, star_enabled); 254 UpdateStarDecorationVisibility();
255 star_decoration_->SetVisible(star_enabled);
256 UpdateChromeToMobileEnabled(); 255 UpdateChromeToMobileEnabled();
257 UpdateZoomDecoration(); 256 UpdateZoomDecoration();
258 RefreshPageActionDecorations(); 257 RefreshPageActionDecorations();
259 RefreshContentSettingsDecorations(); 258 RefreshContentSettingsDecorations();
260 // OmniboxView restores state if the tab is non-NULL. 259 // OmniboxView restores state if the tab is non-NULL.
261 omnibox_view_->Update(should_restore_state ? contents : NULL); 260 omnibox_view_->Update(should_restore_state ? contents : NULL);
262 OnChanged(); 261 OnChanged();
263 } 262 }
264 263
265 void LocationBarViewMac::OnAutocompleteAccept( 264 void LocationBarViewMac::OnAutocompleteAccept(
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
471 } 470 }
472 471
473 void LocationBarViewMac::TestPageActionPressed(size_t index) { 472 void LocationBarViewMac::TestPageActionPressed(size_t index) {
474 DCHECK_LT(index, page_action_decorations_.size()); 473 DCHECK_LT(index, page_action_decorations_.size());
475 if (index < page_action_decorations_.size()) 474 if (index < page_action_decorations_.size())
476 page_action_decorations_[index]->OnMousePressed(NSZeroRect); 475 page_action_decorations_[index]->OnMousePressed(NSZeroRect);
477 } 476 }
478 477
479 void LocationBarViewMac::SetEditable(bool editable) { 478 void LocationBarViewMac::SetEditable(bool editable) {
480 [field_ setEditable:editable ? YES : NO]; 479 [field_ setEditable:editable ? YES : NO];
481 star_decoration_->SetVisible(IsStarEnabled()); 480 UpdateStarDecorationVisibility();
482 UpdateChromeToMobileEnabled(); 481 UpdateChromeToMobileEnabled();
483 UpdateZoomDecoration(); 482 UpdateZoomDecoration();
484 UpdatePageActions(); 483 UpdatePageActions();
485 Layout(); 484 Layout();
486 } 485 }
487 486
488 bool LocationBarViewMac::IsEditable() { 487 bool LocationBarViewMac::IsEditable() {
489 return [field_ isEditable] ? true : false; 488 return [field_ isEditable] ? true : false;
490 } 489 }
491 490
492 void LocationBarViewMac::OnDecorationsChanged() { 491 void LocationBarViewMac::OnDecorationsChanged() {
493 // TODO(shess): The field-editor frame and cursor rects should not 492 // TODO(shess): The field-editor frame and cursor rects should not
494 // change, here. 493 // change, here.
495 [field_ updateCursorAndToolTipRects]; 494 [field_ updateCursorAndToolTipRects];
496 [field_ resetFieldEditorFrameIfNeeded]; 495 [field_ resetFieldEditorFrameIfNeeded];
497 [field_ setNeedsDisplay:YES]; 496 [field_ setNeedsDisplay:YES];
498 } 497 }
499 498
500 void LocationBarViewMac::SetStarred(bool starred) { 499 void LocationBarViewMac::SetStarred(bool starred) {
501 star_decoration_->SetStarred(starred); 500 star_decoration_->SetStarred(starred);
501 UpdateStarDecorationVisibility();
502 OnDecorationsChanged(); 502 OnDecorationsChanged();
503 } 503 }
504 504
505 void LocationBarViewMac::SetChromeToMobileDecorationLit(bool lit) { 505 void LocationBarViewMac::SetChromeToMobileDecorationLit(bool lit) {
506 chrome_to_mobile_decoration_->SetLit(lit); 506 chrome_to_mobile_decoration_->SetLit(lit);
507 OnDecorationsChanged(); 507 OnDecorationsChanged();
508 } 508 }
509 509
510 void LocationBarViewMac::ZoomChangedForActiveTab(bool can_show_bubble) { 510 void LocationBarViewMac::ZoomChangedForActiveTab(bool can_show_bubble) {
511 UpdateZoomDecoration(); 511 UpdateZoomDecoration();
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
577 577
578 case chrome::NOTIFICATION_EXTENSION_LOCATION_BAR_UPDATED: { 578 case chrome::NOTIFICATION_EXTENSION_LOCATION_BAR_UPDATED: {
579 // Only update if the updated action box was for the active tab contents. 579 // Only update if the updated action box was for the active tab contents.
580 TabContents* target_tab = content::Details<TabContents>(details).ptr(); 580 TabContents* target_tab = content::Details<TabContents>(details).ptr();
581 if (target_tab == GetTabContents()) 581 if (target_tab == GetTabContents())
582 UpdatePageActions(); 582 UpdatePageActions();
583 break; 583 break;
584 } 584 }
585 585
586 case chrome::NOTIFICATION_PREF_CHANGED: 586 case chrome::NOTIFICATION_PREF_CHANGED:
587 star_decoration_->SetVisible(IsStarEnabled()); 587 UpdateStarDecorationVisibility();
588 UpdateChromeToMobileEnabled(); 588 UpdateChromeToMobileEnabled();
589 OnChanged(); 589 OnChanged();
590 break; 590 break;
591 591
592 default: 592 default:
593 NOTREACHED() << "Unexpected notification"; 593 NOTREACHED() << "Unexpected notification";
594 break; 594 break;
595 } 595 }
596 } 596 }
597 597
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
760 command_updater_->UpdateCommandEnabled(IDC_CHROME_TO_MOBILE_PAGE, enabled); 760 command_updater_->UpdateCommandEnabled(IDC_CHROME_TO_MOBILE_PAGE, enabled);
761 } 761 }
762 762
763 void LocationBarViewMac::UpdateZoomDecoration() { 763 void LocationBarViewMac::UpdateZoomDecoration() {
764 TabContents* tab_contents = GetTabContents(); 764 TabContents* tab_contents = GetTabContents();
765 if (!tab_contents) 765 if (!tab_contents)
766 return; 766 return;
767 767
768 zoom_decoration_->Update(tab_contents->zoom_controller()); 768 zoom_decoration_->Update(tab_contents->zoom_controller());
769 } 769 }
770
771 void LocationBarViewMac::UpdateStarDecorationVisibility() {
772 bool action_box_enabled =
773 CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableActionBox);
774 // If the action box is enabled, only show the star if it's lit.
775 star_decoration_->SetVisible(IsStarEnabled() &&
776 (star_decoration_->starred() || !action_box_enabled));
Scott Hess - ex-Googler 2012/08/27 19:47:31 I think this condition is needlessly complicated.
beaudoin 2012/08/27 21:25:48 Good job on that truth table! This indeed simplifi
777 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h ('k') | chrome/browser/ui/cocoa/location_bar/star_decoration.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698