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 10 matching lines...) Expand all Loading... |
21 #include "chrome/browser/extensions/extension_browser_event_router.h" | 21 #include "chrome/browser/extensions/extension_browser_event_router.h" |
22 #include "chrome/browser/extensions/extension_service.h" | 22 #include "chrome/browser/extensions/extension_service.h" |
23 #include "chrome/browser/extensions/extension_tab_helper.h" | 23 #include "chrome/browser/extensions/extension_tab_helper.h" |
24 #include "chrome/browser/extensions/location_bar_controller.h" | 24 #include "chrome/browser/extensions/location_bar_controller.h" |
25 #include "chrome/browser/instant/instant_controller.h" | 25 #include "chrome/browser/instant/instant_controller.h" |
26 #include "chrome/browser/profiles/profile.h" | 26 #include "chrome/browser/profiles/profile.h" |
27 #include "chrome/browser/search_engines/template_url.h" | 27 #include "chrome/browser/search_engines/template_url.h" |
28 #include "chrome/browser/search_engines/template_url_service.h" | 28 #include "chrome/browser/search_engines/template_url_service.h" |
29 #include "chrome/browser/search_engines/template_url_service_factory.h" | 29 #include "chrome/browser/search_engines/template_url_service_factory.h" |
30 #include "chrome/browser/ui/browser_list.h" | 30 #include "chrome/browser/ui/browser_list.h" |
| 31 #include "chrome/browser/ui/browser_tabstrip.h" |
31 #import "chrome/browser/ui/cocoa/content_settings/content_setting_bubble_cocoa.h
" | 32 #import "chrome/browser/ui/cocoa/content_settings/content_setting_bubble_cocoa.h
" |
32 #include "chrome/browser/ui/cocoa/event_utils.h" | 33 #include "chrome/browser/ui/cocoa/event_utils.h" |
33 #import "chrome/browser/ui/cocoa/extensions/extension_action_context_menu.h" | 34 #import "chrome/browser/ui/cocoa/extensions/extension_action_context_menu.h" |
34 #import "chrome/browser/ui/cocoa/extensions/extension_popup_controller.h" | 35 #import "chrome/browser/ui/cocoa/extensions/extension_popup_controller.h" |
35 #import "chrome/browser/ui/cocoa/first_run_bubble_controller.h" | 36 #import "chrome/browser/ui/cocoa/first_run_bubble_controller.h" |
36 #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field.h" | 37 #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field.h" |
37 #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_cell.h" | 38 #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_cell.h" |
38 #import "chrome/browser/ui/cocoa/location_bar/chrome_to_mobile_decoration.h" | 39 #import "chrome/browser/ui/cocoa/location_bar/chrome_to_mobile_decoration.h" |
39 #import "chrome/browser/ui/cocoa/location_bar/content_setting_decoration.h" | 40 #import "chrome/browser/ui/cocoa/location_bar/content_setting_decoration.h" |
40 #import "chrome/browser/ui/cocoa/location_bar/ev_bubble_decoration.h" | 41 #import "chrome/browser/ui/cocoa/location_bar/ev_bubble_decoration.h" |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
315 | 316 |
316 string16 LocationBarViewMac::GetTitle() const { | 317 string16 LocationBarViewMac::GetTitle() const { |
317 return browser_->GetWindowTitleForCurrentTab(); | 318 return browser_->GetWindowTitleForCurrentTab(); |
318 } | 319 } |
319 | 320 |
320 InstantController* LocationBarViewMac::GetInstant() { | 321 InstantController* LocationBarViewMac::GetInstant() { |
321 return browser_->instant(); | 322 return browser_->instant(); |
322 } | 323 } |
323 | 324 |
324 TabContents* LocationBarViewMac::GetTabContents() const { | 325 TabContents* LocationBarViewMac::GetTabContents() const { |
325 return browser_->GetActiveTabContents(); | 326 return chrome::GetActiveTabContents(browser_); |
326 } | 327 } |
327 | 328 |
328 void LocationBarViewMac::Revert() { | 329 void LocationBarViewMac::Revert() { |
329 omnibox_view_->RevertAll(); | 330 omnibox_view_->RevertAll(); |
330 } | 331 } |
331 | 332 |
332 const OmniboxView* LocationBarViewMac::GetLocationEntry() const { | 333 const OmniboxView* LocationBarViewMac::GetLocationEntry() const { |
333 return omnibox_view_.get(); | 334 return omnibox_view_.get(); |
334 } | 335 } |
335 | 336 |
(...skipping 13 matching lines...) Expand all Loading... |
349 int LocationBarViewMac::PageActionVisibleCount() { | 350 int LocationBarViewMac::PageActionVisibleCount() { |
350 int result = 0; | 351 int result = 0; |
351 for (size_t i = 0; i < page_action_decorations_.size(); ++i) { | 352 for (size_t i = 0; i < page_action_decorations_.size(); ++i) { |
352 if (page_action_decorations_[i]->IsVisible()) | 353 if (page_action_decorations_[i]->IsVisible()) |
353 ++result; | 354 ++result; |
354 } | 355 } |
355 return result; | 356 return result; |
356 } | 357 } |
357 | 358 |
358 WebContents* LocationBarViewMac::GetWebContents() const { | 359 WebContents* LocationBarViewMac::GetWebContents() const { |
359 return browser_->GetActiveWebContents(); | 360 return chrome::GetActiveWebContents(browser_); |
360 } | 361 } |
361 | 362 |
362 PageActionDecoration* LocationBarViewMac::GetPageActionDecoration( | 363 PageActionDecoration* LocationBarViewMac::GetPageActionDecoration( |
363 ExtensionAction* page_action) { | 364 ExtensionAction* page_action) { |
364 DCHECK(page_action); | 365 DCHECK(page_action); |
365 for (size_t i = 0; i < page_action_decorations_.size(); ++i) { | 366 for (size_t i = 0; i < page_action_decorations_.size(); ++i) { |
366 if (page_action_decorations_[i]->page_action() == page_action) | 367 if (page_action_decorations_[i]->page_action() == page_action) |
367 return page_action_decorations_[i]; | 368 return page_action_decorations_[i]; |
368 } | 369 } |
369 // If |page_action| is the browser action of an extension, no element in | 370 // If |page_action| is the browser action of an extension, no element in |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
567 } | 568 } |
568 | 569 |
569 void LocationBarViewMac::PostNotification(NSString* notification) { | 570 void LocationBarViewMac::PostNotification(NSString* notification) { |
570 [[NSNotificationCenter defaultCenter] postNotificationName:notification | 571 [[NSNotificationCenter defaultCenter] postNotificationName:notification |
571 object:[NSValue valueWithPointer:this]]; | 572 object:[NSValue valueWithPointer:this]]; |
572 } | 573 } |
573 | 574 |
574 bool LocationBarViewMac::RefreshContentSettingsDecorations() { | 575 bool LocationBarViewMac::RefreshContentSettingsDecorations() { |
575 const bool input_in_progress = toolbar_model_->input_in_progress(); | 576 const bool input_in_progress = toolbar_model_->input_in_progress(); |
576 WebContents* web_contents = | 577 WebContents* web_contents = |
577 input_in_progress ? NULL : browser_->GetActiveWebContents(); | 578 input_in_progress ? NULL : chrome::GetActiveWebContents(browser_); |
578 bool icons_updated = false; | 579 bool icons_updated = false; |
579 for (size_t i = 0; i < content_setting_decorations_.size(); ++i) { | 580 for (size_t i = 0; i < content_setting_decorations_.size(); ++i) { |
580 icons_updated |= | 581 icons_updated |= |
581 content_setting_decorations_[i]->UpdateFromWebContents(web_contents); | 582 content_setting_decorations_[i]->UpdateFromWebContents(web_contents); |
582 } | 583 } |
583 return icons_updated; | 584 return icons_updated; |
584 } | 585 } |
585 | 586 |
586 void LocationBarViewMac::DeletePageActionDecorations() { | 587 void LocationBarViewMac::DeletePageActionDecorations() { |
587 // TODO(shess): Deleting these decorations could result in the cell | 588 // TODO(shess): Deleting these decorations could result in the cell |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
717 void LocationBarViewMac::UpdateChromeToMobileEnabled() { | 718 void LocationBarViewMac::UpdateChromeToMobileEnabled() { |
718 if (!chrome_to_mobile_decoration_.get()) | 719 if (!chrome_to_mobile_decoration_.get()) |
719 return; | 720 return; |
720 | 721 |
721 DCHECK(ChromeToMobileService::IsChromeToMobileEnabled()); | 722 DCHECK(ChromeToMobileService::IsChromeToMobileEnabled()); |
722 bool enabled = [field_ isEditable] && !toolbar_model_->input_in_progress() && | 723 bool enabled = [field_ isEditable] && !toolbar_model_->input_in_progress() && |
723 ChromeToMobileServiceFactory::GetForProfile(profile_)->HasDevices(); | 724 ChromeToMobileServiceFactory::GetForProfile(profile_)->HasDevices(); |
724 chrome_to_mobile_decoration_->SetVisible(enabled); | 725 chrome_to_mobile_decoration_->SetVisible(enabled); |
725 command_updater_->UpdateCommandEnabled(IDC_CHROME_TO_MOBILE_PAGE, enabled); | 726 command_updater_->UpdateCommandEnabled(IDC_CHROME_TO_MOBILE_PAGE, enabled); |
726 } | 727 } |
OLD | NEW |