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

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

Issue 1428423002: Remove setVoiceSearchSupported part of EmbeddedSearch SearchBox API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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 22 matching lines...) Expand all
33 #import "chrome/browser/ui/cocoa/content_settings/content_setting_bubble_cocoa.h " 33 #import "chrome/browser/ui/cocoa/content_settings/content_setting_bubble_cocoa.h "
34 #import "chrome/browser/ui/cocoa/extensions/extension_popup_controller.h" 34 #import "chrome/browser/ui/cocoa/extensions/extension_popup_controller.h"
35 #import "chrome/browser/ui/cocoa/first_run_bubble_controller.h" 35 #import "chrome/browser/ui/cocoa/first_run_bubble_controller.h"
36 #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field.h" 36 #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field.h"
37 #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_cell.h" 37 #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_cell.h"
38 #import "chrome/browser/ui/cocoa/location_bar/content_setting_decoration.h" 38 #import "chrome/browser/ui/cocoa/location_bar/content_setting_decoration.h"
39 #import "chrome/browser/ui/cocoa/location_bar/ev_bubble_decoration.h" 39 #import "chrome/browser/ui/cocoa/location_bar/ev_bubble_decoration.h"
40 #import "chrome/browser/ui/cocoa/location_bar/keyword_hint_decoration.h" 40 #import "chrome/browser/ui/cocoa/location_bar/keyword_hint_decoration.h"
41 #import "chrome/browser/ui/cocoa/location_bar/location_icon_decoration.h" 41 #import "chrome/browser/ui/cocoa/location_bar/location_icon_decoration.h"
42 #import "chrome/browser/ui/cocoa/location_bar/manage_passwords_decoration.h" 42 #import "chrome/browser/ui/cocoa/location_bar/manage_passwords_decoration.h"
43 #import "chrome/browser/ui/cocoa/location_bar/mic_search_decoration.h"
44 #import "chrome/browser/ui/cocoa/location_bar/page_action_decoration.h" 43 #import "chrome/browser/ui/cocoa/location_bar/page_action_decoration.h"
45 #import "chrome/browser/ui/cocoa/location_bar/selected_keyword_decoration.h" 44 #import "chrome/browser/ui/cocoa/location_bar/selected_keyword_decoration.h"
46 #import "chrome/browser/ui/cocoa/location_bar/star_decoration.h" 45 #import "chrome/browser/ui/cocoa/location_bar/star_decoration.h"
47 #import "chrome/browser/ui/cocoa/location_bar/translate_decoration.h" 46 #import "chrome/browser/ui/cocoa/location_bar/translate_decoration.h"
48 #import "chrome/browser/ui/cocoa/location_bar/zoom_decoration.h" 47 #import "chrome/browser/ui/cocoa/location_bar/zoom_decoration.h"
49 #import "chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.h" 48 #import "chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.h"
50 #import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h" 49 #import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h"
51 #include "chrome/browser/ui/content_settings/content_setting_bubble_model.h" 50 #include "chrome/browser/ui/content_settings/content_setting_bubble_model.h"
52 #include "chrome/browser/ui/content_settings/content_setting_image_model.h" 51 #include "chrome/browser/ui/content_settings/content_setting_image_model.h"
53 #include "chrome/browser/ui/passwords/manage_passwords_ui_controller.h" 52 #include "chrome/browser/ui/passwords/manage_passwords_ui_controller.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 omnibox_view_(new OmniboxViewMac(this, profile, command_updater, field)), 94 omnibox_view_(new OmniboxViewMac(this, profile, command_updater, field)),
96 field_(field), 95 field_(field),
97 location_icon_decoration_(new LocationIconDecoration(this)), 96 location_icon_decoration_(new LocationIconDecoration(this)),
98 selected_keyword_decoration_(new SelectedKeywordDecoration()), 97 selected_keyword_decoration_(new SelectedKeywordDecoration()),
99 ev_bubble_decoration_( 98 ev_bubble_decoration_(
100 new EVBubbleDecoration(location_icon_decoration_.get())), 99 new EVBubbleDecoration(location_icon_decoration_.get())),
101 star_decoration_(new StarDecoration(command_updater)), 100 star_decoration_(new StarDecoration(command_updater)),
102 translate_decoration_(new TranslateDecoration(command_updater)), 101 translate_decoration_(new TranslateDecoration(command_updater)),
103 zoom_decoration_(new ZoomDecoration(this)), 102 zoom_decoration_(new ZoomDecoration(this)),
104 keyword_hint_decoration_(new KeywordHintDecoration()), 103 keyword_hint_decoration_(new KeywordHintDecoration()),
105 mic_search_decoration_(new MicSearchDecoration(command_updater)),
106 manage_passwords_decoration_( 104 manage_passwords_decoration_(
107 new ManagePasswordsDecoration(command_updater, this)), 105 new ManagePasswordsDecoration(command_updater, this)),
108 browser_(browser), 106 browser_(browser),
109 location_bar_visible_(true), 107 location_bar_visible_(true),
110 weak_ptr_factory_(this) { 108 weak_ptr_factory_(this) {
111 for (ContentSettingsType type : 109 for (ContentSettingsType type :
112 ContentSettingBubbleModel::GetSupportedBubbleTypes()) { 110 ContentSettingBubbleModel::GetSupportedBubbleTypes()) {
113 content_setting_decorations_.push_back( 111 content_setting_decorations_.push_back(
114 new ContentSettingDecoration(type, this, profile)); 112 new ContentSettingDecoration(type, this, profile));
115 } 113 }
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 [cell addRightDecoration:page_action_decorations_[i]]; 401 [cell addRightDecoration:page_action_decorations_[i]];
404 } 402 }
405 403
406 for (ScopedVector<ContentSettingDecoration>::iterator i = 404 for (ScopedVector<ContentSettingDecoration>::iterator i =
407 content_setting_decorations_.begin(); 405 content_setting_decorations_.begin();
408 i != content_setting_decorations_.end(); ++i) { 406 i != content_setting_decorations_.end(); ++i) {
409 [cell addRightDecoration:*i]; 407 [cell addRightDecoration:*i];
410 } 408 }
411 409
412 [cell addRightDecoration:keyword_hint_decoration_.get()]; 410 [cell addRightDecoration:keyword_hint_decoration_.get()];
413 [cell addRightDecoration:mic_search_decoration_.get()];
414 411
415 // By default only the location icon is visible. 412 // By default only the location icon is visible.
416 location_icon_decoration_->SetVisible(true); 413 location_icon_decoration_->SetVisible(true);
417 selected_keyword_decoration_->SetVisible(false); 414 selected_keyword_decoration_->SetVisible(false);
418 ev_bubble_decoration_->SetVisible(false); 415 ev_bubble_decoration_->SetVisible(false);
419 keyword_hint_decoration_->SetVisible(false); 416 keyword_hint_decoration_->SetVisible(false);
420 417
421 // Get the keyword to use for keyword-search and hinting. 418 // Get the keyword to use for keyword-search and hinting.
422 const base::string16 keyword = omnibox_view_->model()->keyword(); 419 const base::string16 keyword = omnibox_view_->model()->keyword();
423 base::string16 short_name; 420 base::string16 short_name;
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 omnibox_view_->ResetTabState(contents); 513 omnibox_view_->ResetTabState(contents);
517 } 514 }
518 515
519 void LocationBarViewMac::Update(const WebContents* contents) { 516 void LocationBarViewMac::Update(const WebContents* contents) {
520 UpdateManagePasswordsIconAndBubble(); 517 UpdateManagePasswordsIconAndBubble();
521 UpdateBookmarkStarVisibility(); 518 UpdateBookmarkStarVisibility();
522 UpdateTranslateDecoration(); 519 UpdateTranslateDecoration();
523 UpdateZoomDecoration(/*default_zoom_changed=*/false); 520 UpdateZoomDecoration(/*default_zoom_changed=*/false);
524 RefreshPageActionDecorations(); 521 RefreshPageActionDecorations();
525 RefreshContentSettingsDecorations(); 522 RefreshContentSettingsDecorations();
526 UpdateMicSearchDecorationVisibility();
527 if (contents) 523 if (contents)
528 omnibox_view_->OnTabChanged(contents); 524 omnibox_view_->OnTabChanged(contents);
529 else 525 else
530 omnibox_view_->Update(); 526 omnibox_view_->Update();
531 OnChanged(); 527 OnChanged();
532 } 528 }
533 529
534 void LocationBarViewMac::UpdateWithoutTabRestore() { 530 void LocationBarViewMac::UpdateWithoutTabRestore() {
535 Update(nullptr); 531 Update(nullptr);
536 } 532 }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
577 profile())->GetTemplateURLForKeyword(keyword); 573 profile())->GetTemplateURLForKeyword(keyword);
578 if (template_url && 574 if (template_url &&
579 (template_url->GetType() == TemplateURL::OMNIBOX_API_EXTENSION)) { 575 (template_url->GetType() == TemplateURL::OMNIBOX_API_EXTENSION)) {
580 return extensions::OmniboxAPI::Get(profile())-> 576 return extensions::OmniboxAPI::Get(profile())->
581 GetOmniboxIcon(template_url->GetExtensionId()).AsNSImage(); 577 GetOmniboxIcon(template_url->GetExtensionId()).AsNSImage();
582 } 578 }
583 579
584 return OmniboxViewMac::ImageForResource(IDR_OMNIBOX_SEARCH); 580 return OmniboxViewMac::ImageForResource(IDR_OMNIBOX_SEARCH);
585 } 581 }
586 582
587 void LocationBarViewMac::ModelChanged(const SearchModel::State& old_state,
588 const SearchModel::State& new_state) {
589 if (UpdateMicSearchDecorationVisibility())
590 Layout();
591 }
592
593 void LocationBarViewMac::PostNotification(NSString* notification) { 583 void LocationBarViewMac::PostNotification(NSString* notification) {
594 [[NSNotificationCenter defaultCenter] postNotificationName:notification 584 [[NSNotificationCenter defaultCenter] postNotificationName:notification
595 object:[NSValue valueWithPointer:this]]; 585 object:[NSValue valueWithPointer:this]];
596 } 586 }
597 587
598 PageActionDecoration* LocationBarViewMac::GetPageActionDecoration( 588 PageActionDecoration* LocationBarViewMac::GetPageActionDecoration(
599 ExtensionAction* page_action) { 589 ExtensionAction* page_action) {
600 DCHECK(page_action); 590 DCHECK(page_action);
601 for (size_t i = 0; i < page_action_decorations_.size(); ++i) { 591 for (size_t i = 0; i < page_action_decorations_.size(); ++i) {
602 if (page_action_decorations_[i]->GetPageAction() == page_action) 592 if (page_action_decorations_[i]->GetPageAction() == page_action)
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
720 710
721 return zoom_decoration_->UpdateIfNecessary( 711 return zoom_decoration_->UpdateIfNecessary(
722 ui_zoom::ZoomController::FromWebContents(web_contents), 712 ui_zoom::ZoomController::FromWebContents(web_contents),
723 default_zoom_changed); 713 default_zoom_changed);
724 } 714 }
725 715
726 void LocationBarViewMac::OnDefaultZoomLevelChanged() { 716 void LocationBarViewMac::OnDefaultZoomLevelChanged() {
727 if (UpdateZoomDecoration(/*default_zoom_changed=*/true)) 717 if (UpdateZoomDecoration(/*default_zoom_changed=*/true))
728 OnDecorationsChanged(); 718 OnDecorationsChanged();
729 } 719 }
730
731 bool LocationBarViewMac::UpdateMicSearchDecorationVisibility() {
732 bool is_visible = !GetToolbarModel()->input_in_progress() &&
733 browser_->search_model()->voice_search_supported();
734 if (mic_search_decoration_->IsVisible() == is_visible)
735 return false;
736 mic_search_decoration_->SetVisible(is_visible);
737 return true;
738 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698