| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/stl_util-inl.h" | 7 #include "base/stl_util-inl.h" |
| 8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
| 9 #include "base/sys_string_conversions.h" | 9 #include "base/sys_string_conversions.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 transition_(PageTransition::TYPED), | 93 transition_(PageTransition::TYPED), |
| 94 first_run_bubble_(this) { | 94 first_run_bubble_(this) { |
| 95 for (size_t i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) { | 95 for (size_t i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) { |
| 96 DCHECK_EQ(i, content_setting_decorations_.size()); | 96 DCHECK_EQ(i, content_setting_decorations_.size()); |
| 97 ContentSettingsType type = static_cast<ContentSettingsType>(i); | 97 ContentSettingsType type = static_cast<ContentSettingsType>(i); |
| 98 content_setting_decorations_.push_back( | 98 content_setting_decorations_.push_back( |
| 99 new ContentSettingDecoration(type, this, profile_)); | 99 new ContentSettingDecoration(type, this, profile_)); |
| 100 } | 100 } |
| 101 | 101 |
| 102 registrar_.Add(this, | 102 registrar_.Add(this, |
| 103 NotificationType::EXTENSION_PAGE_ACTION_VISIBILITY_CHANGED, | 103 chrome::EXTENSION_PAGE_ACTION_VISIBILITY_CHANGED, |
| 104 NotificationService::AllSources()); | 104 NotificationService::AllSources()); |
| 105 | 105 |
| 106 edit_bookmarks_enabled_.Init(prefs::kEditBookmarksEnabled, | 106 edit_bookmarks_enabled_.Init(prefs::kEditBookmarksEnabled, |
| 107 profile_->GetPrefs(), this); | 107 profile_->GetPrefs(), this); |
| 108 } | 108 } |
| 109 | 109 |
| 110 LocationBarViewMac::~LocationBarViewMac() { | 110 LocationBarViewMac::~LocationBarViewMac() { |
| 111 // Disconnect from cell in case it outlives us. | 111 // Disconnect from cell in case it outlives us. |
| 112 [[field_ cell] clearDecorations]; | 112 [[field_ cell] clearDecorations]; |
| 113 } | 113 } |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 [field_ setNeedsDisplay:YES]; | 174 [field_ setNeedsDisplay:YES]; |
| 175 } | 175 } |
| 176 } | 176 } |
| 177 | 177 |
| 178 void LocationBarViewMac::UpdatePageActions() { | 178 void LocationBarViewMac::UpdatePageActions() { |
| 179 size_t count_before = page_action_decorations_.size(); | 179 size_t count_before = page_action_decorations_.size(); |
| 180 RefreshPageActionDecorations(); | 180 RefreshPageActionDecorations(); |
| 181 Layout(); | 181 Layout(); |
| 182 if (page_action_decorations_.size() != count_before) { | 182 if (page_action_decorations_.size() != count_before) { |
| 183 NotificationService::current()->Notify( | 183 NotificationService::current()->Notify( |
| 184 NotificationType::EXTENSION_PAGE_ACTION_COUNT_CHANGED, | 184 chrome::EXTENSION_PAGE_ACTION_COUNT_CHANGED, |
| 185 Source<LocationBar>(this), | 185 Source<LocationBar>(this), |
| 186 NotificationService::NoDetails()); | 186 NotificationService::NoDetails()); |
| 187 } | 187 } |
| 188 } | 188 } |
| 189 | 189 |
| 190 void LocationBarViewMac::InvalidatePageActions() { | 190 void LocationBarViewMac::InvalidatePageActions() { |
| 191 size_t count_before = page_action_decorations_.size(); | 191 size_t count_before = page_action_decorations_.size(); |
| 192 DeletePageActionDecorations(); | 192 DeletePageActionDecorations(); |
| 193 Layout(); | 193 Layout(); |
| 194 if (page_action_decorations_.size() != count_before) { | 194 if (page_action_decorations_.size() != count_before) { |
| 195 NotificationService::current()->Notify( | 195 NotificationService::current()->Notify( |
| 196 NotificationType::EXTENSION_PAGE_ACTION_COUNT_CHANGED, | 196 chrome::EXTENSION_PAGE_ACTION_COUNT_CHANGED, |
| 197 Source<LocationBar>(this), | 197 Source<LocationBar>(this), |
| 198 NotificationService::NoDetails()); | 198 NotificationService::NoDetails()); |
| 199 } | 199 } |
| 200 } | 200 } |
| 201 | 201 |
| 202 void LocationBarViewMac::SaveStateToContents(TabContents* contents) { | 202 void LocationBarViewMac::SaveStateToContents(TabContents* contents) { |
| 203 // TODO(shess): Why SaveStateToContents vs SaveStateToTab? | 203 // TODO(shess): Why SaveStateToContents vs SaveStateToTab? |
| 204 omnibox_view_->SaveStateToTab(contents); | 204 omnibox_view_->SaveStateToTab(contents); |
| 205 } | 205 } |
| 206 | 206 |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 471 return gfx::SkBitmapToNSImage(bitmap); | 471 return gfx::SkBitmapToNSImage(bitmap); |
| 472 } | 472 } |
| 473 | 473 |
| 474 return OmniboxViewMac::ImageForResource(IDR_OMNIBOX_SEARCH); | 474 return OmniboxViewMac::ImageForResource(IDR_OMNIBOX_SEARCH); |
| 475 } | 475 } |
| 476 | 476 |
| 477 void LocationBarViewMac::Observe(NotificationType type, | 477 void LocationBarViewMac::Observe(NotificationType type, |
| 478 const NotificationSource& source, | 478 const NotificationSource& source, |
| 479 const NotificationDetails& details) { | 479 const NotificationDetails& details) { |
| 480 switch (type.value) { | 480 switch (type.value) { |
| 481 case NotificationType::EXTENSION_PAGE_ACTION_VISIBILITY_CHANGED: { | 481 case chrome::EXTENSION_PAGE_ACTION_VISIBILITY_CHANGED: { |
| 482 TabContents* contents = GetTabContents(); | 482 TabContents* contents = GetTabContents(); |
| 483 if (Details<TabContents>(contents) != details) | 483 if (Details<TabContents>(contents) != details) |
| 484 return; | 484 return; |
| 485 | 485 |
| 486 [field_ updateCursorAndToolTipRects]; | 486 [field_ updateCursorAndToolTipRects]; |
| 487 [field_ setNeedsDisplay:YES]; | 487 [field_ setNeedsDisplay:YES]; |
| 488 break; | 488 break; |
| 489 } | 489 } |
| 490 | 490 |
| 491 case NotificationType::PREF_CHANGED: | 491 case chrome::PREF_CHANGED: |
| 492 star_decoration_->SetVisible(IsStarEnabled()); | 492 star_decoration_->SetVisible(IsStarEnabled()); |
| 493 OnChanged(); | 493 OnChanged(); |
| 494 break; | 494 break; |
| 495 | 495 |
| 496 default: | 496 default: |
| 497 NOTREACHED() << "Unexpected notification"; | 497 NOTREACHED() << "Unexpected notification"; |
| 498 break; | 498 break; |
| 499 } | 499 } |
| 500 } | 500 } |
| 501 | 501 |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 636 | 636 |
| 637 [field_ setNeedsDisplay:YES]; | 637 [field_ setNeedsDisplay:YES]; |
| 638 } | 638 } |
| 639 | 639 |
| 640 bool LocationBarViewMac::IsStarEnabled() { | 640 bool LocationBarViewMac::IsStarEnabled() { |
| 641 return [field_ isEditable] && | 641 return [field_ isEditable] && |
| 642 browser_defaults::bookmarks_enabled && | 642 browser_defaults::bookmarks_enabled && |
| 643 !toolbar_model_->input_in_progress() && | 643 !toolbar_model_->input_in_progress() && |
| 644 edit_bookmarks_enabled_.GetValue(); | 644 edit_bookmarks_enabled_.GetValue(); |
| 645 } | 645 } |
| OLD | NEW |