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

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

Issue 40483003: [rAC, OSX] Add "generated CC" info bubble. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Final fixes (arrow position etc.) Created 7 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 | 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 16 matching lines...) Expand all
27 #include "chrome/browser/search_engines/template_url_service.h" 27 #include "chrome/browser/search_engines/template_url_service.h"
28 #include "chrome/browser/search_engines/template_url_service_factory.h" 28 #include "chrome/browser/search_engines/template_url_service_factory.h"
29 #include "chrome/browser/ui/browser_instant_controller.h" 29 #include "chrome/browser/ui/browser_instant_controller.h"
30 #include "chrome/browser/ui/browser_list.h" 30 #include "chrome/browser/ui/browser_list.h"
31 #import "chrome/browser/ui/cocoa/content_settings/content_setting_bubble_cocoa.h " 31 #import "chrome/browser/ui/cocoa/content_settings/content_setting_bubble_cocoa.h "
32 #import "chrome/browser/ui/cocoa/extensions/extension_popup_controller.h" 32 #import "chrome/browser/ui/cocoa/extensions/extension_popup_controller.h"
33 #import "chrome/browser/ui/cocoa/first_run_bubble_controller.h" 33 #import "chrome/browser/ui/cocoa/first_run_bubble_controller.h"
34 #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field.h" 34 #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field.h"
35 #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_cell.h" 35 #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_cell.h"
36 #import "chrome/browser/ui/cocoa/location_bar/content_setting_decoration.h" 36 #import "chrome/browser/ui/cocoa/location_bar/content_setting_decoration.h"
37 #import "chrome/browser/ui/cocoa/location_bar/generated_credit_card_decoration.h "
37 #import "chrome/browser/ui/cocoa/location_bar/ev_bubble_decoration.h" 38 #import "chrome/browser/ui/cocoa/location_bar/ev_bubble_decoration.h"
38 #import "chrome/browser/ui/cocoa/location_bar/keyword_hint_decoration.h" 39 #import "chrome/browser/ui/cocoa/location_bar/keyword_hint_decoration.h"
39 #import "chrome/browser/ui/cocoa/location_bar/location_icon_decoration.h" 40 #import "chrome/browser/ui/cocoa/location_bar/location_icon_decoration.h"
40 #import "chrome/browser/ui/cocoa/location_bar/mic_search_decoration.h" 41 #import "chrome/browser/ui/cocoa/location_bar/mic_search_decoration.h"
41 #import "chrome/browser/ui/cocoa/location_bar/page_action_decoration.h" 42 #import "chrome/browser/ui/cocoa/location_bar/page_action_decoration.h"
42 #import "chrome/browser/ui/cocoa/location_bar/selected_keyword_decoration.h" 43 #import "chrome/browser/ui/cocoa/location_bar/selected_keyword_decoration.h"
43 #import "chrome/browser/ui/cocoa/location_bar/star_decoration.h" 44 #import "chrome/browser/ui/cocoa/location_bar/star_decoration.h"
44 #import "chrome/browser/ui/cocoa/location_bar/zoom_decoration.h" 45 #import "chrome/browser/ui/cocoa/location_bar/zoom_decoration.h"
45 #import "chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.h" 46 #import "chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.h"
46 #include "chrome/browser/ui/content_settings/content_setting_bubble_model.h" 47 #include "chrome/browser/ui/content_settings/content_setting_bubble_model.h"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 omnibox_view_(new OmniboxViewMac(this, profile, command_updater, field)), 87 omnibox_view_(new OmniboxViewMac(this, profile, command_updater, field)),
87 field_(field), 88 field_(field),
88 location_icon_decoration_(new LocationIconDecoration(this)), 89 location_icon_decoration_(new LocationIconDecoration(this)),
89 selected_keyword_decoration_(new SelectedKeywordDecoration()), 90 selected_keyword_decoration_(new SelectedKeywordDecoration()),
90 ev_bubble_decoration_( 91 ev_bubble_decoration_(
91 new EVBubbleDecoration(location_icon_decoration_.get())), 92 new EVBubbleDecoration(location_icon_decoration_.get())),
92 star_decoration_(new StarDecoration(command_updater)), 93 star_decoration_(new StarDecoration(command_updater)),
93 zoom_decoration_(new ZoomDecoration(this)), 94 zoom_decoration_(new ZoomDecoration(this)),
94 keyword_hint_decoration_(new KeywordHintDecoration()), 95 keyword_hint_decoration_(new KeywordHintDecoration()),
95 mic_search_decoration_(new MicSearchDecoration(command_updater)), 96 mic_search_decoration_(new MicSearchDecoration(command_updater)),
97 generated_credit_card_decoration_(
98 new GeneratedCreditCardDecoration(this)),
96 profile_(profile), 99 profile_(profile),
97 browser_(browser), 100 browser_(browser),
98 weak_ptr_factory_(this) { 101 weak_ptr_factory_(this) {
99 102
100 for (size_t i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) { 103 for (size_t i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) {
101 DCHECK_EQ(i, content_setting_decorations_.size()); 104 DCHECK_EQ(i, content_setting_decorations_.size());
102 ContentSettingsType type = static_cast<ContentSettingsType>(i); 105 ContentSettingsType type = static_cast<ContentSettingsType>(i);
103 content_setting_decorations_.push_back( 106 content_setting_decorations_.push_back(
104 new ContentSettingDecoration(type, this, profile_)); 107 new ContentSettingDecoration(type, this, profile_));
105 } 108 }
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 content::Source<LocationBar>(this), 195 content::Source<LocationBar>(this),
193 content::NotificationService::NoDetails()); 196 content::NotificationService::NoDetails());
194 } 197 }
195 } 198 }
196 199
197 void LocationBarViewMac::UpdateOpenPDFInReaderPrompt() { 200 void LocationBarViewMac::UpdateOpenPDFInReaderPrompt() {
198 // Not implemented on Mac. 201 // Not implemented on Mac.
199 } 202 }
200 203
201 void LocationBarViewMac::UpdateGeneratedCreditCardView() { 204 void LocationBarViewMac::UpdateGeneratedCreditCardView() {
202 // TODO(dbeam): encourage groby@ to implement via prodding or chocolate. 205 generated_credit_card_decoration_->Update();
203 NOTIMPLEMENTED();
204 } 206 }
205 207
206 void LocationBarViewMac::SaveStateToContents(WebContents* contents) { 208 void LocationBarViewMac::SaveStateToContents(WebContents* contents) {
207 // TODO(shess): Why SaveStateToContents vs SaveStateToTab? 209 // TODO(shess): Why SaveStateToContents vs SaveStateToTab?
208 omnibox_view_->SaveStateToTab(contents); 210 omnibox_view_->SaveStateToTab(contents);
209 } 211 }
210 212
211 void LocationBarViewMac::Revert() { 213 void LocationBarViewMac::Revert() {
212 omnibox_view_->RevertAll(); 214 omnibox_view_->RevertAll();
213 } 215 }
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 } else { 317 } else {
316 const NSRect frame = 318 const NSRect frame =
317 [cell frameForDecoration:location_icon_decoration_.get() 319 [cell frameForDecoration:location_icon_decoration_.get()
318 inFrame:[field_ bounds]]; 320 inFrame:[field_ bounds]];
319 const NSPoint point = 321 const NSPoint point =
320 location_icon_decoration_->GetBubblePointInFrame(frame); 322 location_icon_decoration_->GetBubblePointInFrame(frame);
321 return [field_ convertPoint:point toView:nil]; 323 return [field_ convertPoint:point toView:nil];
322 } 324 }
323 } 325 }
324 326
327 NSPoint LocationBarViewMac::GetGeneratedCreditCardBubblePoint() const {
328 AutocompleteTextFieldCell* cell = [field_ cell];
329 const NSRect frame =
330 [cell frameForDecoration:generated_credit_card_decoration_.get()
331 inFrame:[field_ bounds]];
332 const NSPoint point =
333 generated_credit_card_decoration_->GetBubblePointInFrame(frame);
334 return [field_ convertPoint:point toView:nil];
335 }
336
325 void LocationBarViewMac::OnDecorationsChanged() { 337 void LocationBarViewMac::OnDecorationsChanged() {
326 // TODO(shess): The field-editor frame and cursor rects should not 338 // TODO(shess): The field-editor frame and cursor rects should not
327 // change, here. 339 // change, here.
328 [field_ updateMouseTracking]; 340 [field_ updateMouseTracking];
329 [field_ resetFieldEditorFrameIfNeeded]; 341 [field_ resetFieldEditorFrameIfNeeded];
330 [field_ setNeedsDisplay:YES]; 342 [field_ setNeedsDisplay:YES];
331 } 343 }
332 344
333 // TODO(shess): This function should over time grow to closely match 345 // TODO(shess): This function should over time grow to closely match
334 // the views Layout() function. 346 // the views Layout() function.
335 void LocationBarViewMac::Layout() { 347 void LocationBarViewMac::Layout() {
336 AutocompleteTextFieldCell* cell = [field_ cell]; 348 AutocompleteTextFieldCell* cell = [field_ cell];
337 349
338 // Reset the left-hand decorations. 350 // Reset the left-hand decorations.
339 // TODO(shess): Shortly, this code will live somewhere else, like in 351 // TODO(shess): Shortly, this code will live somewhere else, like in
340 // the constructor. I am still wrestling with how best to deal with 352 // the constructor. I am still wrestling with how best to deal with
341 // right-hand decorations, which are not a static set. 353 // right-hand decorations, which are not a static set.
342 [cell clearDecorations]; 354 [cell clearDecorations];
343 [cell addLeftDecoration:location_icon_decoration_.get()]; 355 [cell addLeftDecoration:location_icon_decoration_.get()];
344 [cell addLeftDecoration:selected_keyword_decoration_.get()]; 356 [cell addLeftDecoration:selected_keyword_decoration_.get()];
345 [cell addLeftDecoration:ev_bubble_decoration_.get()]; 357 [cell addLeftDecoration:ev_bubble_decoration_.get()];
346 [cell addRightDecoration:star_decoration_.get()]; 358 [cell addRightDecoration:star_decoration_.get()];
347 [cell addRightDecoration:zoom_decoration_.get()]; 359 [cell addRightDecoration:zoom_decoration_.get()];
360 [cell addRightDecoration:generated_credit_card_decoration_.get()];
348 361
349 // Note that display order is right to left. 362 // Note that display order is right to left.
350 for (size_t i = 0; i < page_action_decorations_.size(); ++i) { 363 for (size_t i = 0; i < page_action_decorations_.size(); ++i) {
351 [cell addRightDecoration:page_action_decorations_[i]]; 364 [cell addRightDecoration:page_action_decorations_[i]];
352 } 365 }
353 366
354 // Iterate through |content_setting_decorations_| in reverse order so that 367 // Iterate through |content_setting_decorations_| in reverse order so that
355 // the order in which the decorations are drawn matches the Views code. 368 // the order in which the decorations are drawn matches the Views code.
356 for (ScopedVector<ContentSettingDecoration>::reverse_iterator i = 369 for (ScopedVector<ContentSettingDecoration>::reverse_iterator i =
357 content_setting_decorations_.rbegin(); 370 content_setting_decorations_.rbegin();
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
462 475
463 void LocationBarViewMac::Update(const WebContents* contents) { 476 void LocationBarViewMac::Update(const WebContents* contents) {
464 command_updater()->UpdateCommandEnabled(IDC_BOOKMARK_PAGE, IsStarEnabled()); 477 command_updater()->UpdateCommandEnabled(IDC_BOOKMARK_PAGE, IsStarEnabled());
465 command_updater()->UpdateCommandEnabled(IDC_BOOKMARK_PAGE_FROM_STAR, 478 command_updater()->UpdateCommandEnabled(IDC_BOOKMARK_PAGE_FROM_STAR,
466 IsStarEnabled()); 479 IsStarEnabled());
467 UpdateStarDecorationVisibility(); 480 UpdateStarDecorationVisibility();
468 UpdateZoomDecoration(); 481 UpdateZoomDecoration();
469 RefreshPageActionDecorations(); 482 RefreshPageActionDecorations();
470 RefreshContentSettingsDecorations(); 483 RefreshContentSettingsDecorations();
471 UpdateMicSearchDecorationVisibility(); 484 UpdateMicSearchDecorationVisibility();
485 UpdateGeneratedCreditCardView();
472 if (contents) 486 if (contents)
473 omnibox_view_->OnTabChanged(contents); 487 omnibox_view_->OnTabChanged(contents);
474 else 488 else
475 omnibox_view_->Update(); 489 omnibox_view_->Update();
476 OnChanged(); 490 OnChanged();
477 } 491 }
478 492
479 void LocationBarViewMac::OnChanged() { 493 void LocationBarViewMac::OnChanged() {
480 // Update the location-bar icon. 494 // Update the location-bar icon.
481 const int resource_id = omnibox_view_->GetIcon(); 495 const int resource_id = omnibox_view_->GetIcon();
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
683 } 697 }
684 698
685 bool LocationBarViewMac::UpdateMicSearchDecorationVisibility() { 699 bool LocationBarViewMac::UpdateMicSearchDecorationVisibility() {
686 bool is_visible = !GetToolbarModel()->input_in_progress() && 700 bool is_visible = !GetToolbarModel()->input_in_progress() &&
687 browser_->search_model()->voice_search_supported(); 701 browser_->search_model()->voice_search_supported();
688 if (mic_search_decoration_->IsVisible() == is_visible) 702 if (mic_search_decoration_->IsVisible() == is_visible)
689 return false; 703 return false;
690 mic_search_decoration_->SetVisible(is_visible); 704 mic_search_decoration_->SetVisible(is_visible);
691 return true; 705 return true;
692 } 706 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698