OLD | NEW |
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 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 prefs::kEditBookmarksEnabled, profile->GetPrefs(), | 157 prefs::kEditBookmarksEnabled, profile->GetPrefs(), |
158 base::Bind(&LocationBarViewMac::OnEditBookmarksEnabledChanged, | 158 base::Bind(&LocationBarViewMac::OnEditBookmarksEnabledChanged, |
159 base::Unretained(this))); | 159 base::Unretained(this))); |
160 | 160 |
161 browser_->search_model()->AddObserver(this); | 161 browser_->search_model()->AddObserver(this); |
162 | 162 |
163 [[field_ cell] setIsPopupMode: | 163 [[field_ cell] setIsPopupMode: |
164 !browser->SupportsWindowFeature(Browser::FEATURE_TABSTRIP)]; | 164 !browser->SupportsWindowFeature(Browser::FEATURE_TABSTRIP)]; |
165 | 165 |
166 if (chrome::ShouldDisplayOriginChipV2()) | 166 if (chrome::ShouldDisplayOriginChipV2()) |
167 origin_chip_decoration_.reset(new OriginChipDecoration(this)); | 167 origin_chip_decoration_.reset(new OriginChipDecoration( |
| 168 this, location_icon_decoration_.get())); |
168 } | 169 } |
169 | 170 |
170 LocationBarViewMac::~LocationBarViewMac() { | 171 LocationBarViewMac::~LocationBarViewMac() { |
171 // Disconnect from cell in case it outlives us. | 172 // Disconnect from cell in case it outlives us. |
172 [[field_ cell] clearDecorations]; | 173 [[field_ cell] clearDecorations]; |
173 | 174 |
174 browser_->search_model()->RemoveObserver(this); | 175 browser_->search_model()->RemoveObserver(this); |
175 } | 176 } |
176 | 177 |
177 void LocationBarViewMac::ShowFirstRunBubble() { | 178 void LocationBarViewMac::ShowFirstRunBubble() { |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 } | 299 } |
299 } | 300 } |
300 | 301 |
301 NOTREACHED(); | 302 NOTREACHED(); |
302 return NULL; | 303 return NULL; |
303 } | 304 } |
304 | 305 |
305 void LocationBarViewMac::TestPageActionPressed(size_t index) { | 306 void LocationBarViewMac::TestPageActionPressed(size_t index) { |
306 DCHECK_LT(index, page_action_decorations_.size()); | 307 DCHECK_LT(index, page_action_decorations_.size()); |
307 if (index < page_action_decorations_.size()) | 308 if (index < page_action_decorations_.size()) |
308 page_action_decorations_[index]->OnMousePressed(NSZeroRect); | 309 page_action_decorations_[index]->OnMousePressed(NSZeroRect, NSZeroPoint); |
309 } | 310 } |
310 | 311 |
311 bool LocationBarViewMac::GetBookmarkStarVisibility() { | 312 bool LocationBarViewMac::GetBookmarkStarVisibility() { |
312 DCHECK(star_decoration_.get()); | 313 DCHECK(star_decoration_.get()); |
313 return star_decoration_->IsVisible(); | 314 return star_decoration_->IsVisible(); |
314 } | 315 } |
315 | 316 |
316 void LocationBarViewMac::SetEditable(bool editable) { | 317 void LocationBarViewMac::SetEditable(bool editable) { |
317 [field_ setEditable:editable ? YES : NO]; | 318 [field_ setEditable:editable ? YES : NO]; |
318 UpdateStarDecorationVisibility(); | 319 UpdateStarDecorationVisibility(); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
355 NSPoint LocationBarViewMac::GetBookmarkBubblePoint() const { | 356 NSPoint LocationBarViewMac::GetBookmarkBubblePoint() const { |
356 DCHECK(IsStarEnabled()); | 357 DCHECK(IsStarEnabled()); |
357 return [field_ bubblePointForDecoration:star_decoration_.get()]; | 358 return [field_ bubblePointForDecoration:star_decoration_.get()]; |
358 } | 359 } |
359 | 360 |
360 NSPoint LocationBarViewMac::GetTranslateBubblePoint() const { | 361 NSPoint LocationBarViewMac::GetTranslateBubblePoint() const { |
361 return [field_ bubblePointForDecoration:translate_decoration_.get()]; | 362 return [field_ bubblePointForDecoration:translate_decoration_.get()]; |
362 } | 363 } |
363 | 364 |
364 NSPoint LocationBarViewMac::GetPageInfoBubblePoint() const { | 365 NSPoint LocationBarViewMac::GetPageInfoBubblePoint() const { |
365 if (ev_bubble_decoration_->IsVisible()) { | 366 if (origin_chip_decoration_ && origin_chip_decoration_->IsVisible()) { |
| 367 return [field_ bubblePointForDecoration:origin_chip_decoration_.get()]; |
| 368 } else if (ev_bubble_decoration_->IsVisible()) { |
366 return [field_ bubblePointForDecoration:ev_bubble_decoration_.get()]; | 369 return [field_ bubblePointForDecoration:ev_bubble_decoration_.get()]; |
367 } else { | 370 } else { |
368 return [field_ bubblePointForDecoration:location_icon_decoration_.get()]; | 371 return [field_ bubblePointForDecoration:location_icon_decoration_.get()]; |
369 } | 372 } |
370 } | 373 } |
371 | 374 |
372 NSPoint LocationBarViewMac::GetGeneratedCreditCardBubblePoint() const { | 375 NSPoint LocationBarViewMac::GetGeneratedCreditCardBubblePoint() const { |
373 return | 376 return |
374 [field_ bubblePointForDecoration:generated_credit_card_decoration_.get()]; | 377 [field_ bubblePointForDecoration:generated_credit_card_decoration_.get()]; |
375 } | 378 } |
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
789 } | 792 } |
790 | 793 |
791 bool LocationBarViewMac::UpdateMicSearchDecorationVisibility() { | 794 bool LocationBarViewMac::UpdateMicSearchDecorationVisibility() { |
792 bool is_visible = !GetToolbarModel()->input_in_progress() && | 795 bool is_visible = !GetToolbarModel()->input_in_progress() && |
793 browser_->search_model()->voice_search_supported(); | 796 browser_->search_model()->voice_search_supported(); |
794 if (mic_search_decoration_->IsVisible() == is_visible) | 797 if (mic_search_decoration_->IsVisible() == is_visible) |
795 return false; | 798 return false; |
796 mic_search_decoration_->SetVisible(is_visible); | 799 mic_search_decoration_->SetVisible(is_visible); |
797 return true; | 800 return true; |
798 } | 801 } |
OLD | NEW |