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

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

Issue 731423002: Remove OriginChip code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix gyp file and bad merge Created 5 years, 10 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
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/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/generated_credit_card_decoration.h " 40 #import "chrome/browser/ui/cocoa/location_bar/generated_credit_card_decoration.h "
41 #import "chrome/browser/ui/cocoa/location_bar/keyword_hint_decoration.h" 41 #import "chrome/browser/ui/cocoa/location_bar/keyword_hint_decoration.h"
42 #import "chrome/browser/ui/cocoa/location_bar/location_icon_decoration.h" 42 #import "chrome/browser/ui/cocoa/location_bar/location_icon_decoration.h"
43 #import "chrome/browser/ui/cocoa/location_bar/manage_passwords_decoration.h" 43 #import "chrome/browser/ui/cocoa/location_bar/manage_passwords_decoration.h"
44 #import "chrome/browser/ui/cocoa/location_bar/mic_search_decoration.h" 44 #import "chrome/browser/ui/cocoa/location_bar/mic_search_decoration.h"
45 #import "chrome/browser/ui/cocoa/location_bar/origin_chip_decoration.h"
46 #import "chrome/browser/ui/cocoa/location_bar/page_action_decoration.h" 45 #import "chrome/browser/ui/cocoa/location_bar/page_action_decoration.h"
47 #import "chrome/browser/ui/cocoa/location_bar/search_button_decoration.h" 46 #import "chrome/browser/ui/cocoa/location_bar/search_button_decoration.h"
48 #import "chrome/browser/ui/cocoa/location_bar/selected_keyword_decoration.h" 47 #import "chrome/browser/ui/cocoa/location_bar/selected_keyword_decoration.h"
49 #import "chrome/browser/ui/cocoa/location_bar/star_decoration.h" 48 #import "chrome/browser/ui/cocoa/location_bar/star_decoration.h"
50 #import "chrome/browser/ui/cocoa/location_bar/translate_decoration.h" 49 #import "chrome/browser/ui/cocoa/location_bar/translate_decoration.h"
51 #import "chrome/browser/ui/cocoa/location_bar/zoom_decoration.h" 50 #import "chrome/browser/ui/cocoa/location_bar/zoom_decoration.h"
52 #import "chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.h" 51 #import "chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.h"
53 #include "chrome/browser/ui/content_settings/content_setting_bubble_model.h" 52 #include "chrome/browser/ui/content_settings/content_setting_bubble_model.h"
54 #include "chrome/browser/ui/content_settings/content_setting_image_model.h" 53 #include "chrome/browser/ui/content_settings/content_setting_image_model.h"
55 #import "chrome/browser/ui/omnibox/omnibox_popup_model.h" 54 #import "chrome/browser/ui/omnibox/omnibox_popup_model.h"
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 base::Unretained(this))); 131 base::Unretained(this)));
133 132
134 browser_->search_model()->AddObserver(this); 133 browser_->search_model()->AddObserver(this);
135 134
136 ui_zoom::ZoomEventManager::GetForBrowserContext(profile) 135 ui_zoom::ZoomEventManager::GetForBrowserContext(profile)
137 ->AddZoomEventManagerObserver(this); 136 ->AddZoomEventManagerObserver(this);
138 137
139 [[field_ cell] setIsPopupMode: 138 [[field_ cell] setIsPopupMode:
140 !browser->SupportsWindowFeature(Browser::FEATURE_TABSTRIP)]; 139 !browser->SupportsWindowFeature(Browser::FEATURE_TABSTRIP)];
141 140
142 if (chrome::ShouldDisplayOriginChip())
143 origin_chip_decoration_.reset(new OriginChipDecoration(
144 this, location_icon_decoration_.get()));
145
146 // Sets images for the decorations, and performs a layout. This call ensures 141 // Sets images for the decorations, and performs a layout. This call ensures
147 // that this class is in a consistent state after initialization. 142 // that this class is in a consistent state after initialization.
148 OnChanged(); 143 OnChanged();
149 } 144 }
150 145
151 LocationBarViewMac::~LocationBarViewMac() { 146 LocationBarViewMac::~LocationBarViewMac() {
152 // Disconnect from cell in case it outlives us. 147 // Disconnect from cell in case it outlives us.
153 [[field_ cell] clearDecorations]; 148 [[field_ cell] clearDecorations];
154 149
155 browser_->search_model()->RemoveObserver(this); 150 browser_->search_model()->RemoveObserver(this);
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 357
363 NSPoint LocationBarViewMac::GetTranslateBubblePoint() const { 358 NSPoint LocationBarViewMac::GetTranslateBubblePoint() const {
364 return [field_ bubblePointForDecoration:translate_decoration_.get()]; 359 return [field_ bubblePointForDecoration:translate_decoration_.get()];
365 } 360 }
366 361
367 NSPoint LocationBarViewMac::GetManagePasswordsBubblePoint() const { 362 NSPoint LocationBarViewMac::GetManagePasswordsBubblePoint() const {
368 return [field_ bubblePointForDecoration:manage_passwords_decoration_.get()]; 363 return [field_ bubblePointForDecoration:manage_passwords_decoration_.get()];
369 } 364 }
370 365
371 NSPoint LocationBarViewMac::GetPageInfoBubblePoint() const { 366 NSPoint LocationBarViewMac::GetPageInfoBubblePoint() const {
372 if (origin_chip_decoration_ && origin_chip_decoration_->IsVisible()) { 367 if (ev_bubble_decoration_->IsVisible()) {
373 return [field_ bubblePointForDecoration:origin_chip_decoration_.get()];
374 } else if (ev_bubble_decoration_->IsVisible()) {
375 return [field_ bubblePointForDecoration:ev_bubble_decoration_.get()]; 368 return [field_ bubblePointForDecoration:ev_bubble_decoration_.get()];
376 } else { 369 } else {
377 return [field_ bubblePointForDecoration:location_icon_decoration_.get()]; 370 return [field_ bubblePointForDecoration:location_icon_decoration_.get()];
378 } 371 }
379 } 372 }
380 373
381 NSPoint LocationBarViewMac::GetGeneratedCreditCardBubblePoint() const { 374 NSPoint LocationBarViewMac::GetGeneratedCreditCardBubblePoint() const {
382 return 375 return
383 [field_ bubblePointForDecoration:generated_credit_card_decoration_.get()]; 376 [field_ bubblePointForDecoration:generated_credit_card_decoration_.get()];
384 } 377 }
385 378
386 void LocationBarViewMac::OnDecorationsChanged() { 379 void LocationBarViewMac::OnDecorationsChanged() {
387 // TODO(shess): The field-editor frame and cursor rects should not 380 // TODO(shess): The field-editor frame and cursor rects should not
388 // change, here. 381 // change, here.
389 [field_ updateMouseTracking]; 382 [field_ updateMouseTracking];
390 [field_ resetFieldEditorFrameIfNeeded]; 383 [field_ resetFieldEditorFrameIfNeeded];
391 [field_ setNeedsDisplay:YES]; 384 [field_ setNeedsDisplay:YES];
392 } 385 }
393 386
394 // TODO(shess): This function should over time grow to closely match 387 // TODO(shess): This function should over time grow to closely match
395 // the views Layout() function. 388 // the views Layout() function.
396 void LocationBarViewMac::Layout() { 389 void LocationBarViewMac::Layout() {
397 AutocompleteTextFieldCell* cell = [field_ cell]; 390 AutocompleteTextFieldCell* cell = [field_ cell];
398 391
399 // Reset the left-hand decorations. 392 // Reset the left-hand decorations.
400 // TODO(shess): Shortly, this code will live somewhere else, like in 393 // TODO(shess): Shortly, this code will live somewhere else, like in
401 // the constructor. I am still wrestling with how best to deal with 394 // the constructor. I am still wrestling with how best to deal with
402 // right-hand decorations, which are not a static set. 395 // right-hand decorations, which are not a static set.
403 [cell clearDecorations]; 396 [cell clearDecorations];
404 if (origin_chip_decoration_.get())
405 [cell addLeftDecoration:origin_chip_decoration_.get()];
406 [cell addLeftDecoration:location_icon_decoration_.get()]; 397 [cell addLeftDecoration:location_icon_decoration_.get()];
407 [cell addLeftDecoration:selected_keyword_decoration_.get()]; 398 [cell addLeftDecoration:selected_keyword_decoration_.get()];
408 if (!origin_chip_decoration_.get()) 399 [cell addLeftDecoration:ev_bubble_decoration_.get()];
409 [cell addLeftDecoration:ev_bubble_decoration_.get()];
410 [cell addRightDecoration:search_button_decoration_.get()]; 400 [cell addRightDecoration:search_button_decoration_.get()];
411 [cell addRightDecoration:star_decoration_.get()]; 401 [cell addRightDecoration:star_decoration_.get()];
412 [cell addRightDecoration:translate_decoration_.get()]; 402 [cell addRightDecoration:translate_decoration_.get()];
413 [cell addRightDecoration:zoom_decoration_.get()]; 403 [cell addRightDecoration:zoom_decoration_.get()];
414 [cell addRightDecoration:generated_credit_card_decoration_.get()]; 404 [cell addRightDecoration:generated_credit_card_decoration_.get()];
415 [cell addRightDecoration:manage_passwords_decoration_.get()]; 405 [cell addRightDecoration:manage_passwords_decoration_.get()];
416 406
417 // Note that display order is right to left. 407 // Note that display order is right to left.
418 for (size_t i = 0; i < page_action_decorations_.size(); ++i) { 408 for (size_t i = 0; i < page_action_decorations_.size(); ++i) {
419 [cell addRightDecoration:page_action_decorations_[i]]; 409 [cell addRightDecoration:page_action_decorations_[i]];
420 } 410 }
421 411
422 for (ScopedVector<ContentSettingDecoration>::iterator i = 412 for (ScopedVector<ContentSettingDecoration>::iterator i =
423 content_setting_decorations_.begin(); 413 content_setting_decorations_.begin();
424 i != content_setting_decorations_.end(); ++i) { 414 i != content_setting_decorations_.end(); ++i) {
425 [cell addRightDecoration:*i]; 415 [cell addRightDecoration:*i];
426 } 416 }
427 417
428 [cell addRightDecoration:keyword_hint_decoration_.get()]; 418 [cell addRightDecoration:keyword_hint_decoration_.get()];
429 [cell addRightDecoration:mic_search_decoration_.get()]; 419 [cell addRightDecoration:mic_search_decoration_.get()];
430 420
431 // By default only the location icon is visible. 421 // By default only the location icon is visible.
432 location_icon_decoration_->SetVisible(!origin_chip_decoration_.get() || 422 location_icon_decoration_->SetVisible(true);
433 !origin_chip_decoration_->IsVisible());
434 selected_keyword_decoration_->SetVisible(false); 423 selected_keyword_decoration_->SetVisible(false);
435 ev_bubble_decoration_->SetVisible(false); 424 ev_bubble_decoration_->SetVisible(false);
436 keyword_hint_decoration_->SetVisible(false); 425 keyword_hint_decoration_->SetVisible(false);
437 426
438 // Get the keyword to use for keyword-search and hinting. 427 // Get the keyword to use for keyword-search and hinting.
439 const base::string16 keyword = omnibox_view_->model()->keyword(); 428 const base::string16 keyword = omnibox_view_->model()->keyword();
440 base::string16 short_name; 429 base::string16 short_name;
441 bool is_extension_keyword = false; 430 bool is_extension_keyword = false;
442 if (!keyword.empty()) { 431 if (!keyword.empty()) {
443 short_name = TemplateURLServiceFactory::GetForProfile(profile())-> 432 short_name = TemplateURLServiceFactory::GetForProfile(profile())->
444 GetKeywordShortName(keyword, &is_extension_keyword); 433 GetKeywordShortName(keyword, &is_extension_keyword);
445 } 434 }
446 435
447 const bool is_keyword_hint = omnibox_view_->model()->is_keyword_hint(); 436 const bool is_keyword_hint = omnibox_view_->model()->is_keyword_hint();
448 if (!keyword.empty() && !is_keyword_hint) { 437 if (!keyword.empty() && !is_keyword_hint) {
449 // Switch from location icon to keyword mode. 438 // Switch from location icon to keyword mode.
450 location_icon_decoration_->SetVisible(false); 439 location_icon_decoration_->SetVisible(false);
451 selected_keyword_decoration_->SetVisible(true); 440 selected_keyword_decoration_->SetVisible(true);
452 selected_keyword_decoration_->SetKeyword(short_name, is_extension_keyword); 441 selected_keyword_decoration_->SetKeyword(short_name, is_extension_keyword);
453 selected_keyword_decoration_->SetImage(GetKeywordImage(keyword)); 442 selected_keyword_decoration_->SetImage(GetKeywordImage(keyword));
454 } else if ((GetToolbarModel()->GetSecurityLevel(false) == 443 } else if ((GetToolbarModel()->GetSecurityLevel(false) ==
455 ToolbarModel::EV_SECURE) && !origin_chip_decoration_.get()) { 444 ToolbarModel::EV_SECURE)) {
456 // Switch from location icon to show the EV bubble instead. 445 // Switch from location icon to show the EV bubble instead.
457 location_icon_decoration_->SetVisible(false); 446 location_icon_decoration_->SetVisible(false);
458 ev_bubble_decoration_->SetVisible(true); 447 ev_bubble_decoration_->SetVisible(true);
459 448
460 base::string16 label(GetToolbarModel()->GetEVCertName()); 449 base::string16 label(GetToolbarModel()->GetEVCertName());
461 ev_bubble_decoration_->SetFullLabel(base::SysUTF16ToNSString(label)); 450 ev_bubble_decoration_->SetFullLabel(base::SysUTF16ToNSString(label));
462 } else if (!keyword.empty() && is_keyword_hint) { 451 } else if (!keyword.empty() && is_keyword_hint) {
463 keyword_hint_decoration_->SetKeyword(short_name, 452 keyword_hint_decoration_->SetKeyword(short_name,
464 is_extension_keyword); 453 is_extension_keyword);
465 keyword_hint_decoration_->SetVisible(true); 454 keyword_hint_decoration_->SetVisible(true);
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
547 OnChanged(); 536 OnChanged();
548 } 537 }
549 538
550 void LocationBarViewMac::OnChanged() { 539 void LocationBarViewMac::OnChanged() {
551 // Update the location-bar icon. 540 // Update the location-bar icon.
552 const int resource_id = omnibox_view_->GetIcon(); 541 const int resource_id = omnibox_view_->GetIcon();
553 NSImage* image = OmniboxViewMac::ImageForResource(resource_id); 542 NSImage* image = OmniboxViewMac::ImageForResource(resource_id);
554 location_icon_decoration_->SetImage(image); 543 location_icon_decoration_->SetImage(image);
555 ev_bubble_decoration_->SetImage(image); 544 ev_bubble_decoration_->SetImage(image);
556 545
557 if (origin_chip_decoration_.get())
558 origin_chip_decoration_->Update();
559
560 ToolbarModel* toolbar_model = GetToolbarModel(); 546 ToolbarModel* toolbar_model = GetToolbarModel();
561 const chrome::DisplaySearchButtonConditions conditions = 547 const chrome::DisplaySearchButtonConditions conditions =
562 chrome::GetDisplaySearchButtonConditions(); 548 chrome::GetDisplaySearchButtonConditions();
563 const bool meets_conditions = 549 const bool meets_conditions =
564 (conditions == chrome::DISPLAY_SEARCH_BUTTON_ALWAYS) || 550 (conditions == chrome::DISPLAY_SEARCH_BUTTON_ALWAYS) ||
565 ((conditions != chrome::DISPLAY_SEARCH_BUTTON_NEVER) && 551 ((conditions != chrome::DISPLAY_SEARCH_BUTTON_NEVER) &&
566 (toolbar_model->WouldPerformSearchTermReplacement(true) || 552 (toolbar_model->WouldPerformSearchTermReplacement(true) ||
567 ((conditions == chrome::DISPLAY_SEARCH_BUTTON_FOR_STR_OR_IIP) && 553 ((conditions == chrome::DISPLAY_SEARCH_BUTTON_FOR_STR_OR_IIP) &&
568 toolbar_model->input_in_progress()))); 554 toolbar_model->input_in_progress())));
569 search_button_decoration_->SetVisible( 555 search_button_decoration_->SetVisible(
(...skipping 14 matching lines...) Expand all
584 570
585 void LocationBarViewMac::OnSetFocus() { 571 void LocationBarViewMac::OnSetFocus() {
586 // Update the keyword and search hint states. 572 // Update the keyword and search hint states.
587 OnChanged(); 573 OnChanged();
588 } 574 }
589 575
590 void LocationBarViewMac::ShowURL() { 576 void LocationBarViewMac::ShowURL() {
591 omnibox_view_->ShowURL(); 577 omnibox_view_->ShowURL();
592 } 578 }
593 579
594 void LocationBarViewMac::HideURL() {
595 omnibox_view_->HideURL();
596 }
597
598 void LocationBarViewMac::EndOriginChipAnimations(bool cancel_fade) {
599 }
600
601 InstantController* LocationBarViewMac::GetInstant() { 580 InstantController* LocationBarViewMac::GetInstant() {
602 return browser_->instant_controller() ? 581 return browser_->instant_controller() ?
603 browser_->instant_controller()->instant() : NULL; 582 browser_->instant_controller()->instant() : NULL;
604 } 583 }
605 584
606 WebContents* LocationBarViewMac::GetWebContents() { 585 WebContents* LocationBarViewMac::GetWebContents() {
607 return browser_->tab_strip_model()->GetActiveWebContents(); 586 return browser_->tab_strip_model()->GetActiveWebContents();
608 } 587 }
609 588
610 ToolbarModel* LocationBarViewMac::GetToolbarModel() { 589 ToolbarModel* LocationBarViewMac::GetToolbarModel() {
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
777 } 756 }
778 757
779 bool LocationBarViewMac::UpdateMicSearchDecorationVisibility() { 758 bool LocationBarViewMac::UpdateMicSearchDecorationVisibility() {
780 bool is_visible = !GetToolbarModel()->input_in_progress() && 759 bool is_visible = !GetToolbarModel()->input_in_progress() &&
781 browser_->search_model()->voice_search_supported(); 760 browser_->search_model()->voice_search_supported();
782 if (mic_search_decoration_->IsVisible() == is_visible) 761 if (mic_search_decoration_->IsVisible() == is_visible)
783 return false; 762 return false;
784 mic_search_decoration_->SetVisible(is_visible); 763 mic_search_decoration_->SetVisible(is_visible);
785 return true; 764 return true;
786 } 765 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698