| 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 23 matching lines...) Expand all Loading... |
| 34 #import "chrome/browser/ui/cocoa/location_bar/ev_bubble_decoration.h" | 34 #import "chrome/browser/ui/cocoa/location_bar/ev_bubble_decoration.h" |
| 35 #import "chrome/browser/ui/cocoa/location_bar/keyword_hint_decoration.h" | 35 #import "chrome/browser/ui/cocoa/location_bar/keyword_hint_decoration.h" |
| 36 #import "chrome/browser/ui/cocoa/location_bar/location_icon_decoration.h" | 36 #import "chrome/browser/ui/cocoa/location_bar/location_icon_decoration.h" |
| 37 #import "chrome/browser/ui/cocoa/location_bar/page_action_decoration.h" | 37 #import "chrome/browser/ui/cocoa/location_bar/page_action_decoration.h" |
| 38 #import "chrome/browser/ui/cocoa/location_bar/selected_keyword_decoration.h" | 38 #import "chrome/browser/ui/cocoa/location_bar/selected_keyword_decoration.h" |
| 39 #import "chrome/browser/ui/cocoa/location_bar/star_decoration.h" | 39 #import "chrome/browser/ui/cocoa/location_bar/star_decoration.h" |
| 40 #import "chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.h" | 40 #import "chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.h" |
| 41 #include "chrome/browser/ui/content_settings/content_setting_bubble_model.h" | 41 #include "chrome/browser/ui/content_settings/content_setting_bubble_model.h" |
| 42 #include "chrome/browser/ui/content_settings/content_setting_image_model.h" | 42 #include "chrome/browser/ui/content_settings/content_setting_image_model.h" |
| 43 #include "chrome/browser/ui/omnibox/location_bar_util.h" | 43 #include "chrome/browser/ui/omnibox/location_bar_util.h" |
| 44 #include "chrome/common/chrome_notification_types.h" |
| 44 #include "chrome/common/extensions/extension.h" | 45 #include "chrome/common/extensions/extension.h" |
| 45 #include "chrome/common/extensions/extension_action.h" | 46 #include "chrome/common/extensions/extension_action.h" |
| 46 #include "chrome/common/extensions/extension_resource.h" | 47 #include "chrome/common/extensions/extension_resource.h" |
| 47 #include "chrome/common/pref_names.h" | 48 #include "chrome/common/pref_names.h" |
| 48 #include "content/browser/tab_contents/navigation_entry.h" | 49 #include "content/browser/tab_contents/navigation_entry.h" |
| 49 #include "content/browser/tab_contents/tab_contents.h" | 50 #include "content/browser/tab_contents/tab_contents.h" |
| 50 #include "content/common/notification_service.h" | 51 #include "content/common/notification_service.h" |
| 51 #include "grit/generated_resources.h" | 52 #include "grit/generated_resources.h" |
| 52 #include "grit/theme_resources.h" | 53 #include "grit/theme_resources.h" |
| 53 #include "net/base/net_util.h" | 54 #include "net/base/net_util.h" |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 transition_(PageTransition::TYPED), | 94 transition_(PageTransition::TYPED), |
| 94 first_run_bubble_(this) { | 95 first_run_bubble_(this) { |
| 95 for (size_t i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) { | 96 for (size_t i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) { |
| 96 DCHECK_EQ(i, content_setting_decorations_.size()); | 97 DCHECK_EQ(i, content_setting_decorations_.size()); |
| 97 ContentSettingsType type = static_cast<ContentSettingsType>(i); | 98 ContentSettingsType type = static_cast<ContentSettingsType>(i); |
| 98 content_setting_decorations_.push_back( | 99 content_setting_decorations_.push_back( |
| 99 new ContentSettingDecoration(type, this, profile_)); | 100 new ContentSettingDecoration(type, this, profile_)); |
| 100 } | 101 } |
| 101 | 102 |
| 102 registrar_.Add(this, | 103 registrar_.Add(this, |
| 103 NotificationType::EXTENSION_PAGE_ACTION_VISIBILITY_CHANGED, | 104 chrome::NOTIFICATION_EXTENSION_PAGE_ACTION_VISIBILITY_CHANGED, |
| 104 NotificationService::AllSources()); | 105 NotificationService::AllSources()); |
| 105 | 106 |
| 106 edit_bookmarks_enabled_.Init(prefs::kEditBookmarksEnabled, | 107 edit_bookmarks_enabled_.Init(prefs::kEditBookmarksEnabled, |
| 107 profile_->GetPrefs(), this); | 108 profile_->GetPrefs(), this); |
| 108 } | 109 } |
| 109 | 110 |
| 110 LocationBarViewMac::~LocationBarViewMac() { | 111 LocationBarViewMac::~LocationBarViewMac() { |
| 111 // Disconnect from cell in case it outlives us. | 112 // Disconnect from cell in case it outlives us. |
| 112 [[field_ cell] clearDecorations]; | 113 [[field_ cell] clearDecorations]; |
| 113 } | 114 } |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 [field_ setNeedsDisplay:YES]; | 175 [field_ setNeedsDisplay:YES]; |
| 175 } | 176 } |
| 176 } | 177 } |
| 177 | 178 |
| 178 void LocationBarViewMac::UpdatePageActions() { | 179 void LocationBarViewMac::UpdatePageActions() { |
| 179 size_t count_before = page_action_decorations_.size(); | 180 size_t count_before = page_action_decorations_.size(); |
| 180 RefreshPageActionDecorations(); | 181 RefreshPageActionDecorations(); |
| 181 Layout(); | 182 Layout(); |
| 182 if (page_action_decorations_.size() != count_before) { | 183 if (page_action_decorations_.size() != count_before) { |
| 183 NotificationService::current()->Notify( | 184 NotificationService::current()->Notify( |
| 184 NotificationType::EXTENSION_PAGE_ACTION_COUNT_CHANGED, | 185 chrome::NOTIFICATION_EXTENSION_PAGE_ACTION_COUNT_CHANGED, |
| 185 Source<LocationBar>(this), | 186 Source<LocationBar>(this), |
| 186 NotificationService::NoDetails()); | 187 NotificationService::NoDetails()); |
| 187 } | 188 } |
| 188 } | 189 } |
| 189 | 190 |
| 190 void LocationBarViewMac::InvalidatePageActions() { | 191 void LocationBarViewMac::InvalidatePageActions() { |
| 191 size_t count_before = page_action_decorations_.size(); | 192 size_t count_before = page_action_decorations_.size(); |
| 192 DeletePageActionDecorations(); | 193 DeletePageActionDecorations(); |
| 193 Layout(); | 194 Layout(); |
| 194 if (page_action_decorations_.size() != count_before) { | 195 if (page_action_decorations_.size() != count_before) { |
| 195 NotificationService::current()->Notify( | 196 NotificationService::current()->Notify( |
| 196 NotificationType::EXTENSION_PAGE_ACTION_COUNT_CHANGED, | 197 chrome::NOTIFICATION_EXTENSION_PAGE_ACTION_COUNT_CHANGED, |
| 197 Source<LocationBar>(this), | 198 Source<LocationBar>(this), |
| 198 NotificationService::NoDetails()); | 199 NotificationService::NoDetails()); |
| 199 } | 200 } |
| 200 } | 201 } |
| 201 | 202 |
| 202 void LocationBarViewMac::SaveStateToContents(TabContents* contents) { | 203 void LocationBarViewMac::SaveStateToContents(TabContents* contents) { |
| 203 // TODO(shess): Why SaveStateToContents vs SaveStateToTab? | 204 // TODO(shess): Why SaveStateToContents vs SaveStateToTab? |
| 204 omnibox_view_->SaveStateToTab(contents); | 205 omnibox_view_->SaveStateToTab(contents); |
| 205 } | 206 } |
| 206 | 207 |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 467 profile_)->GetTemplateURLForKeyword(keyword); | 468 profile_)->GetTemplateURLForKeyword(keyword); |
| 468 if (template_url && template_url->IsExtensionKeyword()) { | 469 if (template_url && template_url->IsExtensionKeyword()) { |
| 469 const SkBitmap& bitmap = profile_->GetExtensionService()-> | 470 const SkBitmap& bitmap = profile_->GetExtensionService()-> |
| 470 GetOmniboxIcon(template_url->GetExtensionId()); | 471 GetOmniboxIcon(template_url->GetExtensionId()); |
| 471 return gfx::SkBitmapToNSImage(bitmap); | 472 return gfx::SkBitmapToNSImage(bitmap); |
| 472 } | 473 } |
| 473 | 474 |
| 474 return OmniboxViewMac::ImageForResource(IDR_OMNIBOX_SEARCH); | 475 return OmniboxViewMac::ImageForResource(IDR_OMNIBOX_SEARCH); |
| 475 } | 476 } |
| 476 | 477 |
| 477 void LocationBarViewMac::Observe(NotificationType type, | 478 void LocationBarViewMac::Observe(int type, |
| 478 const NotificationSource& source, | 479 const NotificationSource& source, |
| 479 const NotificationDetails& details) { | 480 const NotificationDetails& details) { |
| 480 switch (type.value) { | 481 switch (type) { |
| 481 case NotificationType::EXTENSION_PAGE_ACTION_VISIBILITY_CHANGED: { | 482 case chrome::NOTIFICATION_EXTENSION_PAGE_ACTION_VISIBILITY_CHANGED: { |
| 482 TabContents* contents = GetTabContents(); | 483 TabContents* contents = GetTabContents(); |
| 483 if (Details<TabContents>(contents) != details) | 484 if (Details<TabContents>(contents) != details) |
| 484 return; | 485 return; |
| 485 | 486 |
| 486 [field_ updateCursorAndToolTipRects]; | 487 [field_ updateCursorAndToolTipRects]; |
| 487 [field_ setNeedsDisplay:YES]; | 488 [field_ setNeedsDisplay:YES]; |
| 488 break; | 489 break; |
| 489 } | 490 } |
| 490 | 491 |
| 491 case NotificationType::PREF_CHANGED: | 492 case chrome::NOTIFICATION_PREF_CHANGED: |
| 492 star_decoration_->SetVisible(IsStarEnabled()); | 493 star_decoration_->SetVisible(IsStarEnabled()); |
| 493 OnChanged(); | 494 OnChanged(); |
| 494 break; | 495 break; |
| 495 | 496 |
| 496 default: | 497 default: |
| 497 NOTREACHED() << "Unexpected notification"; | 498 NOTREACHED() << "Unexpected notification"; |
| 498 break; | 499 break; |
| 499 } | 500 } |
| 500 } | 501 } |
| 501 | 502 |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 636 | 637 |
| 637 [field_ setNeedsDisplay:YES]; | 638 [field_ setNeedsDisplay:YES]; |
| 638 } | 639 } |
| 639 | 640 |
| 640 bool LocationBarViewMac::IsStarEnabled() { | 641 bool LocationBarViewMac::IsStarEnabled() { |
| 641 return [field_ isEditable] && | 642 return [field_ isEditable] && |
| 642 browser_defaults::bookmarks_enabled && | 643 browser_defaults::bookmarks_enabled && |
| 643 !toolbar_model_->input_in_progress() && | 644 !toolbar_model_->input_in_progress() && |
| 644 edit_bookmarks_enabled_.GetValue(); | 645 edit_bookmarks_enabled_.GetValue(); |
| 645 } | 646 } |
| OLD | NEW |