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

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

Issue 419263002: Add ManagePasswordsDecoration and unit tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: exclude resource IDs on Android Created 6 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 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 24 matching lines...) Expand all
35 #import "chrome/browser/ui/cocoa/content_settings/content_setting_bubble_cocoa.h " 35 #import "chrome/browser/ui/cocoa/content_settings/content_setting_bubble_cocoa.h "
36 #import "chrome/browser/ui/cocoa/extensions/extension_popup_controller.h" 36 #import "chrome/browser/ui/cocoa/extensions/extension_popup_controller.h"
37 #import "chrome/browser/ui/cocoa/first_run_bubble_controller.h" 37 #import "chrome/browser/ui/cocoa/first_run_bubble_controller.h"
38 #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field.h" 38 #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field.h"
39 #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_cell.h" 39 #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_cell.h"
40 #import "chrome/browser/ui/cocoa/location_bar/content_setting_decoration.h" 40 #import "chrome/browser/ui/cocoa/location_bar/content_setting_decoration.h"
41 #import "chrome/browser/ui/cocoa/location_bar/ev_bubble_decoration.h" 41 #import "chrome/browser/ui/cocoa/location_bar/ev_bubble_decoration.h"
42 #import "chrome/browser/ui/cocoa/location_bar/generated_credit_card_decoration.h " 42 #import "chrome/browser/ui/cocoa/location_bar/generated_credit_card_decoration.h "
43 #import "chrome/browser/ui/cocoa/location_bar/keyword_hint_decoration.h" 43 #import "chrome/browser/ui/cocoa/location_bar/keyword_hint_decoration.h"
44 #import "chrome/browser/ui/cocoa/location_bar/location_icon_decoration.h" 44 #import "chrome/browser/ui/cocoa/location_bar/location_icon_decoration.h"
45 #import "chrome/browser/ui/cocoa/location_bar/manage_passwords_decoration.h"
45 #import "chrome/browser/ui/cocoa/location_bar/mic_search_decoration.h" 46 #import "chrome/browser/ui/cocoa/location_bar/mic_search_decoration.h"
46 #import "chrome/browser/ui/cocoa/location_bar/origin_chip_decoration.h" 47 #import "chrome/browser/ui/cocoa/location_bar/origin_chip_decoration.h"
47 #import "chrome/browser/ui/cocoa/location_bar/page_action_decoration.h" 48 #import "chrome/browser/ui/cocoa/location_bar/page_action_decoration.h"
48 #import "chrome/browser/ui/cocoa/location_bar/search_button_decoration.h" 49 #import "chrome/browser/ui/cocoa/location_bar/search_button_decoration.h"
49 #import "chrome/browser/ui/cocoa/location_bar/selected_keyword_decoration.h" 50 #import "chrome/browser/ui/cocoa/location_bar/selected_keyword_decoration.h"
50 #import "chrome/browser/ui/cocoa/location_bar/star_decoration.h" 51 #import "chrome/browser/ui/cocoa/location_bar/star_decoration.h"
51 #import "chrome/browser/ui/cocoa/location_bar/translate_decoration.h" 52 #import "chrome/browser/ui/cocoa/location_bar/translate_decoration.h"
52 #import "chrome/browser/ui/cocoa/location_bar/zoom_decoration.h" 53 #import "chrome/browser/ui/cocoa/location_bar/zoom_decoration.h"
53 #import "chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.h" 54 #import "chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.h"
54 #include "chrome/browser/ui/content_settings/content_setting_bubble_model.h" 55 #include "chrome/browser/ui/content_settings/content_setting_bubble_model.h"
55 #include "chrome/browser/ui/content_settings/content_setting_image_model.h" 56 #include "chrome/browser/ui/content_settings/content_setting_image_model.h"
56 #import "chrome/browser/ui/omnibox/omnibox_popup_model.h" 57 #import "chrome/browser/ui/omnibox/omnibox_popup_model.h"
58 #include "chrome/browser/ui/passwords/manage_passwords_ui_controller.h"
57 #include "chrome/browser/ui/tabs/tab_strip_model.h" 59 #include "chrome/browser/ui/tabs/tab_strip_model.h"
58 #include "chrome/browser/ui/toolbar/toolbar_model.h" 60 #include "chrome/browser/ui/toolbar/toolbar_model.h"
59 #include "chrome/browser/ui/zoom/zoom_controller.h" 61 #include "chrome/browser/ui/zoom/zoom_controller.h"
60 #include "chrome/common/chrome_switches.h" 62 #include "chrome/common/chrome_switches.h"
61 #include "chrome/common/pref_names.h" 63 #include "chrome/common/pref_names.h"
62 #include "components/search_engines/template_url.h" 64 #include "components/search_engines/template_url.h"
63 #include "components/search_engines/template_url_service.h" 65 #include "components/search_engines/template_url_service.h"
64 #include "components/translate/core/browser/language_state.h" 66 #include "components/translate/core/browser/language_state.h"
65 #include "content/public/browser/notification_service.h" 67 #include "content/public/browser/notification_service.h"
66 #include "content/public/browser/web_contents.h" 68 #include "content/public/browser/web_contents.h"
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 ev_bubble_decoration_( 127 ev_bubble_decoration_(
126 new EVBubbleDecoration(location_icon_decoration_.get())), 128 new EVBubbleDecoration(location_icon_decoration_.get())),
127 star_decoration_(new StarDecoration(command_updater)), 129 star_decoration_(new StarDecoration(command_updater)),
128 translate_decoration_(new TranslateDecoration(command_updater)), 130 translate_decoration_(new TranslateDecoration(command_updater)),
129 zoom_decoration_(new ZoomDecoration(this)), 131 zoom_decoration_(new ZoomDecoration(this)),
130 keyword_hint_decoration_(new KeywordHintDecoration()), 132 keyword_hint_decoration_(new KeywordHintDecoration()),
131 mic_search_decoration_(new MicSearchDecoration(command_updater)), 133 mic_search_decoration_(new MicSearchDecoration(command_updater)),
132 generated_credit_card_decoration_( 134 generated_credit_card_decoration_(
133 new GeneratedCreditCardDecoration(this)), 135 new GeneratedCreditCardDecoration(this)),
134 search_button_decoration_(new SearchButtonDecoration(this)), 136 search_button_decoration_(new SearchButtonDecoration(this)),
137 manage_passwords_decoration_(
138 new ManagePasswordsDecoration(command_updater)),
135 browser_(browser), 139 browser_(browser),
136 weak_ptr_factory_(this) { 140 weak_ptr_factory_(this) {
137
138 for (size_t i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) { 141 for (size_t i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) {
139 DCHECK_EQ(i, content_setting_decorations_.size()); 142 DCHECK_EQ(i, content_setting_decorations_.size());
140 ContentSettingsType type = static_cast<ContentSettingsType>(i); 143 ContentSettingsType type = static_cast<ContentSettingsType>(i);
141 content_setting_decorations_.push_back( 144 content_setting_decorations_.push_back(
142 new ContentSettingDecoration(type, this, profile)); 145 new ContentSettingDecoration(type, this, profile));
143 } 146 }
144 147
145 registrar_.Add( 148 registrar_.Add(
146 this, 149 this,
147 extensions::NOTIFICATION_EXTENSION_PAGE_ACTION_VISIBILITY_CHANGED, 150 extensions::NOTIFICATION_EXTENSION_PAGE_ACTION_VISIBILITY_CHANGED,
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 211
209 void LocationBarViewMac::FocusSearch() { 212 void LocationBarViewMac::FocusSearch() {
210 omnibox_view_->SetForcedQuery(); 213 omnibox_view_->SetForcedQuery();
211 } 214 }
212 215
213 void LocationBarViewMac::UpdateContentSettingsIcons() { 216 void LocationBarViewMac::UpdateContentSettingsIcons() {
214 if (RefreshContentSettingsDecorations()) 217 if (RefreshContentSettingsDecorations())
215 OnDecorationsChanged(); 218 OnDecorationsChanged();
216 } 219 }
217 220
221 void LocationBarViewMac::UpdateManagePasswordsIconAndBubble() {
222 WebContents* web_contents = GetWebContents();
223 if (!web_contents)
224 return;
225 ManagePasswordsUIController::FromWebContents(web_contents)
226 ->UpdateIconAndBubbleState(manage_passwords_decoration_->icon());
227 }
228
218 void LocationBarViewMac::UpdatePageActions() { 229 void LocationBarViewMac::UpdatePageActions() {
219 size_t count_before = page_action_decorations_.size(); 230 size_t count_before = page_action_decorations_.size();
220 RefreshPageActionDecorations(); 231 RefreshPageActionDecorations();
221 Layout(); 232 Layout();
222 if (page_action_decorations_.size() != count_before) { 233 if (page_action_decorations_.size() != count_before) {
223 content::NotificationService::current()->Notify( 234 content::NotificationService::current()->Notify(
224 extensions::NOTIFICATION_EXTENSION_PAGE_ACTION_COUNT_CHANGED, 235 extensions::NOTIFICATION_EXTENSION_PAGE_ACTION_COUNT_CHANGED,
225 content::Source<LocationBar>(this), 236 content::Source<LocationBar>(this),
226 content::NotificationService::NoDetails()); 237 content::NotificationService::NoDetails());
227 } 238 }
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 [cell addLeftDecoration:origin_chip_decoration_.get()]; 411 [cell addLeftDecoration:origin_chip_decoration_.get()];
401 [cell addLeftDecoration:location_icon_decoration_.get()]; 412 [cell addLeftDecoration:location_icon_decoration_.get()];
402 [cell addLeftDecoration:selected_keyword_decoration_.get()]; 413 [cell addLeftDecoration:selected_keyword_decoration_.get()];
403 if (!origin_chip_decoration_.get()) 414 if (!origin_chip_decoration_.get())
404 [cell addLeftDecoration:ev_bubble_decoration_.get()]; 415 [cell addLeftDecoration:ev_bubble_decoration_.get()];
405 [cell addRightDecoration:search_button_decoration_.get()]; 416 [cell addRightDecoration:search_button_decoration_.get()];
406 [cell addRightDecoration:star_decoration_.get()]; 417 [cell addRightDecoration:star_decoration_.get()];
407 [cell addRightDecoration:translate_decoration_.get()]; 418 [cell addRightDecoration:translate_decoration_.get()];
408 [cell addRightDecoration:zoom_decoration_.get()]; 419 [cell addRightDecoration:zoom_decoration_.get()];
409 [cell addRightDecoration:generated_credit_card_decoration_.get()]; 420 [cell addRightDecoration:generated_credit_card_decoration_.get()];
421 [cell addRightDecoration:manage_passwords_decoration_.get()];
410 422
411 // Note that display order is right to left. 423 // Note that display order is right to left.
412 for (size_t i = 0; i < page_action_decorations_.size(); ++i) { 424 for (size_t i = 0; i < page_action_decorations_.size(); ++i) {
413 [cell addRightDecoration:page_action_decorations_[i]]; 425 [cell addRightDecoration:page_action_decorations_[i]];
414 } 426 }
415 427
416 for (ScopedVector<ContentSettingDecoration>::iterator i = 428 for (ScopedVector<ContentSettingDecoration>::iterator i =
417 content_setting_decorations_.begin(); 429 content_setting_decorations_.begin();
418 i != content_setting_decorations_.end(); ++i) { 430 i != content_setting_decorations_.end(); ++i) {
419 [cell addRightDecoration:*i]; 431 [cell addRightDecoration:*i];
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
789 } 801 }
790 802
791 bool LocationBarViewMac::UpdateMicSearchDecorationVisibility() { 803 bool LocationBarViewMac::UpdateMicSearchDecorationVisibility() {
792 bool is_visible = !GetToolbarModel()->input_in_progress() && 804 bool is_visible = !GetToolbarModel()->input_in_progress() &&
793 browser_->search_model()->voice_search_supported(); 805 browser_->search_model()->voice_search_supported();
794 if (mic_search_decoration_->IsVisible() == is_visible) 806 if (mic_search_decoration_->IsVisible() == is_visible)
795 return false; 807 return false;
796 mic_search_decoration_->SetVisible(is_visible); 808 mic_search_decoration_->SetVisible(is_visible);
797 return true; 809 return true;
798 } 810 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698