| OLD | NEW | 
|---|
| 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 298 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 309   location_icon_decoration_->SetImage(image); | 309   location_icon_decoration_->SetImage(image); | 
| 310   ev_bubble_decoration_->SetImage(image); | 310   ev_bubble_decoration_->SetImage(image); | 
| 311   Layout(); | 311   Layout(); | 
| 312 } | 312 } | 
| 313 | 313 | 
| 314 void LocationBarViewMac::OnSelectionBoundsChanged() { | 314 void LocationBarViewMac::OnSelectionBoundsChanged() { | 
| 315   NOTIMPLEMENTED(); | 315   NOTIMPLEMENTED(); | 
| 316 } | 316 } | 
| 317 | 317 | 
| 318 void LocationBarViewMac::OnInputInProgress(bool in_progress) { | 318 void LocationBarViewMac::OnInputInProgress(bool in_progress) { | 
| 319   toolbar_model_->set_input_in_progress(in_progress); | 319   toolbar_model_->SetInputInProgress(in_progress); | 
| 320   Update(NULL, false); | 320   Update(NULL, false); | 
| 321 } | 321 } | 
| 322 | 322 | 
| 323 void LocationBarViewMac::OnSetFocus() { | 323 void LocationBarViewMac::OnSetFocus() { | 
| 324   // Update the keyword and search hint states. | 324   // Update the keyword and search hint states. | 
| 325   OnChanged(); | 325   OnChanged(); | 
| 326 } | 326 } | 
| 327 | 327 | 
| 328 void LocationBarViewMac::OnKillFocus() { | 328 void LocationBarViewMac::OnKillFocus() { | 
| 329   // Do nothing. | 329   // Do nothing. | 
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 609       break; | 609       break; | 
| 610   } | 610   } | 
| 611 } | 611 } | 
| 612 | 612 | 
| 613 void LocationBarViewMac::PostNotification(NSString* notification) { | 613 void LocationBarViewMac::PostNotification(NSString* notification) { | 
| 614   [[NSNotificationCenter defaultCenter] postNotificationName:notification | 614   [[NSNotificationCenter defaultCenter] postNotificationName:notification | 
| 615                                         object:[NSValue valueWithPointer:this]]; | 615                                         object:[NSValue valueWithPointer:this]]; | 
| 616 } | 616 } | 
| 617 | 617 | 
| 618 bool LocationBarViewMac::RefreshContentSettingsDecorations() { | 618 bool LocationBarViewMac::RefreshContentSettingsDecorations() { | 
| 619   const bool input_in_progress = toolbar_model_->input_in_progress(); | 619   const bool input_in_progress = toolbar_model_->GetInputInProgress(); | 
| 620   WebContents* web_contents = | 620   WebContents* web_contents = | 
| 621       input_in_progress ? NULL : chrome::GetActiveWebContents(browser_); | 621       input_in_progress ? NULL : chrome::GetActiveWebContents(browser_); | 
| 622   bool icons_updated = false; | 622   bool icons_updated = false; | 
| 623   for (size_t i = 0; i < content_setting_decorations_.size(); ++i) { | 623   for (size_t i = 0; i < content_setting_decorations_.size(); ++i) { | 
| 624     icons_updated |= | 624     icons_updated |= | 
| 625         content_setting_decorations_[i]->UpdateFromWebContents(web_contents); | 625         content_setting_decorations_[i]->UpdateFromWebContents(web_contents); | 
| 626   } | 626   } | 
| 627   return icons_updated; | 627   return icons_updated; | 
| 628 } | 628 } | 
| 629 | 629 | 
| (...skipping 27 matching lines...) Expand all  Loading... | 
| 657     DeletePageActionDecorations(); | 657     DeletePageActionDecorations(); | 
| 658     for (size_t i = 0; i < page_actions_.size(); ++i) { | 658     for (size_t i = 0; i < page_actions_.size(); ++i) { | 
| 659       page_action_decorations_.push_back( | 659       page_action_decorations_.push_back( | 
| 660           new PageActionDecoration(this, browser_, page_actions_[i])); | 660           new PageActionDecoration(this, browser_, page_actions_[i])); | 
| 661     } | 661     } | 
| 662   } | 662   } | 
| 663 | 663 | 
| 664   GURL url = toolbar_model_->GetURL(); | 664   GURL url = toolbar_model_->GetURL(); | 
| 665   for (size_t i = 0; i < page_action_decorations_.size(); ++i) { | 665   for (size_t i = 0; i < page_action_decorations_.size(); ++i) { | 
| 666     page_action_decorations_[i]->UpdateVisibility( | 666     page_action_decorations_[i]->UpdateVisibility( | 
| 667         toolbar_model_->input_in_progress() ? | 667         toolbar_model_->GetInputInProgress() ? | 
| 668             NULL : tab_contents->web_contents(), | 668             NULL : tab_contents->web_contents(), | 
| 669         url); | 669         url); | 
| 670   } | 670   } | 
| 671 } | 671 } | 
| 672 | 672 | 
| 673 void LocationBarViewMac::RefreshWebIntentsButtonDecoration() { | 673 void LocationBarViewMac::RefreshWebIntentsButtonDecoration() { | 
| 674   TabContents* tab_contents = GetTabContents(); | 674   TabContents* tab_contents = GetTabContents(); | 
| 675   if (!tab_contents) { | 675   if (!tab_contents) { | 
| 676     web_intents_button_decoration_->SetVisible(false); | 676     web_intents_button_decoration_->SetVisible(false); | 
| 677     return; | 677     return; | 
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 757   AutocompleteTextFieldCell* cell = [field_ cell]; | 757   AutocompleteTextFieldCell* cell = [field_ cell]; | 
| 758   NSRect frame = [cell frameForDecoration:decoration | 758   NSRect frame = [cell frameForDecoration:decoration | 
| 759                                   inFrame:[field_ bounds]]; | 759                                   inFrame:[field_ bounds]]; | 
| 760   if (!NSIsEmptyRect(frame)) | 760   if (!NSIsEmptyRect(frame)) | 
| 761     [field_ setNeedsDisplayInRect:frame]; | 761     [field_ setNeedsDisplayInRect:frame]; | 
| 762 } | 762 } | 
| 763 | 763 | 
| 764 bool LocationBarViewMac::IsStarEnabled() { | 764 bool LocationBarViewMac::IsStarEnabled() { | 
| 765   return [field_ isEditable] && | 765   return [field_ isEditable] && | 
| 766          browser_defaults::bookmarks_enabled && | 766          browser_defaults::bookmarks_enabled && | 
| 767          !toolbar_model_->input_in_progress() && | 767          !toolbar_model_->GetInputInProgress() && | 
| 768          edit_bookmarks_enabled_.GetValue(); | 768          edit_bookmarks_enabled_.GetValue(); | 
| 769 } | 769 } | 
| 770 | 770 | 
| 771 void LocationBarViewMac::UpdateChromeToMobileEnabled() { | 771 void LocationBarViewMac::UpdateChromeToMobileEnabled() { | 
| 772   ChromeToMobileService* chrome_to_mobile_service = | 772   ChromeToMobileService* chrome_to_mobile_service = | 
| 773       ChromeToMobileServiceFactory::GetForProfile(profile_); | 773       ChromeToMobileServiceFactory::GetForProfile(profile_); | 
| 774   command_updater_->UpdateCommandEnabled(IDC_CHROME_TO_MOBILE_PAGE, | 774   command_updater_->UpdateCommandEnabled(IDC_CHROME_TO_MOBILE_PAGE, | 
| 775       [field_ isEditable] && !toolbar_model_->input_in_progress() && | 775       [field_ isEditable] && !toolbar_model_->GetInputInProgress() && | 
| 776       chrome_to_mobile_service && chrome_to_mobile_service->HasMobiles()); | 776       chrome_to_mobile_service && chrome_to_mobile_service->HasMobiles()); | 
| 777 } | 777 } | 
| 778 | 778 | 
| 779 void LocationBarViewMac::UpdateZoomDecoration() { | 779 void LocationBarViewMac::UpdateZoomDecoration() { | 
| 780   TabContents* tab_contents = GetTabContents(); | 780   TabContents* tab_contents = GetTabContents(); | 
| 781   if (!tab_contents) | 781   if (!tab_contents) | 
| 782     return; | 782     return; | 
| 783 | 783 | 
| 784   ZoomController* zoom_controller = | 784   ZoomController* zoom_controller = | 
| 785       ZoomController::FromWebContents(tab_contents->web_contents()); | 785       ZoomController::FromWebContents(tab_contents->web_contents()); | 
| 786   zoom_decoration_->Update(zoom_controller); | 786   zoom_decoration_->Update(zoom_controller); | 
| 787 } | 787 } | 
| 788 | 788 | 
| 789 void LocationBarViewMac::UpdateStarDecorationVisibility() { | 789 void LocationBarViewMac::UpdateStarDecorationVisibility() { | 
| 790   // If the action box is enabled, only show the star if it's lit. | 790   // If the action box is enabled, only show the star if it's lit. | 
| 791   bool visible = IsStarEnabled(); | 791   bool visible = IsStarEnabled(); | 
| 792   if (!star_decoration_->starred() && | 792   if (!star_decoration_->starred() && | 
| 793       extensions::switch_utils::IsActionBoxEnabled()) | 793       extensions::switch_utils::IsActionBoxEnabled()) | 
| 794     visible = false; | 794     visible = false; | 
| 795   star_decoration_->SetVisible(visible); | 795   star_decoration_->SetVisible(visible); | 
| 796 } | 796 } | 
| 797 | 797 | 
| 798 void LocationBarViewMac::UpdatePlusDecorationVisibility() { | 798 void LocationBarViewMac::UpdatePlusDecorationVisibility() { | 
| 799   if (extensions::switch_utils::IsActionBoxEnabled()) { | 799   if (extensions::switch_utils::IsActionBoxEnabled()) { | 
| 800     // If the action box is enabled, hide it when input is in progress. | 800     // If the action box is enabled, hide it when input is in progress. | 
| 801     plus_decoration_->SetVisible(!toolbar_model_->input_in_progress()); | 801     plus_decoration_->SetVisible(!toolbar_model_->GetInputInProgress()); | 
| 802   } | 802   } | 
| 803 } | 803 } | 
| OLD | NEW | 
|---|