| 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/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 577 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 588 | 588 | 
| 589   page_action_decorations_.reset(); | 589   page_action_decorations_.reset(); | 
| 590 } | 590 } | 
| 591 | 591 | 
| 592 void LocationBarViewMac::RefreshPageActionDecorations() { | 592 void LocationBarViewMac::RefreshPageActionDecorations() { | 
| 593   if (!IsEditable()) { | 593   if (!IsEditable()) { | 
| 594     DeletePageActionDecorations(); | 594     DeletePageActionDecorations(); | 
| 595     return; | 595     return; | 
| 596   } | 596   } | 
| 597 | 597 | 
| 598   std::vector<ExtensionAction*> page_actions; |  | 
| 599 |  | 
| 600   TabContents* tab_contents = GetTabContents(); | 598   TabContents* tab_contents = GetTabContents(); | 
| 601   if (!tab_contents) { | 599   if (!tab_contents) { | 
| 602     DeletePageActionDecorations();  // Necessary? | 600     DeletePageActionDecorations();  // Necessary? | 
| 603     return; | 601     return; | 
| 604   } | 602   } | 
| 605 | 603 | 
| 606   extensions::LocationBarController* controller = | 604   std::vector<ExtensionAction*> new_page_actions = | 
| 607       tab_contents->extension_tab_helper()->location_bar_controller(); | 605       tab_contents->extension_tab_helper()->location_bar_controller()-> | 
| 608   page_actions.swap(*controller->GetCurrentActions()); | 606           GetCurrentActions(); | 
| 609 | 607 | 
| 610   // On startup we sometimes haven't loaded any extensions. This makes sure | 608   if (new_page_actions != page_actions_) { | 
| 611   // we catch up when the extensions (and any Page Actions) load. | 609     page_actions_.swap(new_page_actions); | 
| 612   if (page_actions.size() != page_action_decorations_.size()) { | 610     DeletePageActionDecorations(); | 
| 613     DeletePageActionDecorations();  // Delete the old views (if any). | 611     for (size_t i = 0; i < page_actions_.size(); ++i) { | 
| 614 |  | 
| 615     for (size_t i = 0; i < page_actions.size(); ++i) { |  | 
| 616       page_action_decorations_.push_back( | 612       page_action_decorations_.push_back( | 
| 617           new PageActionDecoration(this, profile_, page_actions[i])); | 613           new PageActionDecoration(this, profile_, page_actions_[i])); | 
| 618     } | 614     } | 
| 619   } | 615   } | 
| 620 | 616 | 
| 621   GURL url = GURL(toolbar_model_->GetText()); | 617   GURL url = GURL(toolbar_model_->GetText()); | 
| 622   for (size_t i = 0; i < page_action_decorations_.size(); ++i) { | 618   for (size_t i = 0; i < page_action_decorations_.size(); ++i) { | 
| 623     page_action_decorations_[i]->UpdateVisibility( | 619     page_action_decorations_[i]->UpdateVisibility( | 
| 624         toolbar_model_->input_in_progress() ? | 620         toolbar_model_->input_in_progress() ? | 
| 625             NULL : tab_contents->web_contents(), | 621             NULL : tab_contents->web_contents(), | 
| 626         url); | 622         url); | 
| 627   } | 623   } | 
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 710 void LocationBarViewMac::UpdateChromeToMobileEnabled() { | 706 void LocationBarViewMac::UpdateChromeToMobileEnabled() { | 
| 711   if (!chrome_to_mobile_decoration_.get()) | 707   if (!chrome_to_mobile_decoration_.get()) | 
| 712     return; | 708     return; | 
| 713 | 709 | 
| 714   DCHECK(ChromeToMobileService::IsChromeToMobileEnabled()); | 710   DCHECK(ChromeToMobileService::IsChromeToMobileEnabled()); | 
| 715   bool enabled = [field_ isEditable] && !toolbar_model_->input_in_progress() && | 711   bool enabled = [field_ isEditable] && !toolbar_model_->input_in_progress() && | 
| 716       ChromeToMobileServiceFactory::GetForProfile(profile_)->HasDevices(); | 712       ChromeToMobileServiceFactory::GetForProfile(profile_)->HasDevices(); | 
| 717   chrome_to_mobile_decoration_->SetVisible(enabled); | 713   chrome_to_mobile_decoration_->SetVisible(enabled); | 
| 718   command_updater_->UpdateCommandEnabled(IDC_CHROME_TO_MOBILE_PAGE, enabled); | 714   command_updater_->UpdateCommandEnabled(IDC_CHROME_TO_MOBILE_PAGE, enabled); | 
| 719 } | 715 } | 
| OLD | NEW | 
|---|