| 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/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "base/sys_string_conversions.h" | 10 #include "base/sys_string_conversions.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 #include "chrome/browser/ui/content_settings/content_setting_bubble_model.h" | 42 #include "chrome/browser/ui/content_settings/content_setting_bubble_model.h" |
| 43 #include "chrome/browser/ui/content_settings/content_setting_image_model.h" | 43 #include "chrome/browser/ui/content_settings/content_setting_image_model.h" |
| 44 #include "chrome/browser/ui/omnibox/location_bar_util.h" | 44 #include "chrome/browser/ui/omnibox/location_bar_util.h" |
| 45 #include "chrome/common/chrome_notification_types.h" | 45 #include "chrome/common/chrome_notification_types.h" |
| 46 #include "chrome/common/extensions/extension.h" | 46 #include "chrome/common/extensions/extension.h" |
| 47 #include "chrome/common/extensions/extension_action.h" | 47 #include "chrome/common/extensions/extension_action.h" |
| 48 #include "chrome/common/extensions/extension_resource.h" | 48 #include "chrome/common/extensions/extension_resource.h" |
| 49 #include "chrome/common/pref_names.h" | 49 #include "chrome/common/pref_names.h" |
| 50 #include "content/browser/tab_contents/navigation_entry.h" | 50 #include "content/browser/tab_contents/navigation_entry.h" |
| 51 #include "content/browser/tab_contents/tab_contents.h" | 51 #include "content/browser/tab_contents/tab_contents.h" |
| 52 #include "content/common/notification_service.h" | 52 #include "content/public/browser/notification_service.h" |
| 53 #include "grit/generated_resources.h" | 53 #include "grit/generated_resources.h" |
| 54 #include "grit/theme_resources.h" | 54 #include "grit/theme_resources.h" |
| 55 #include "net/base/net_util.h" | 55 #include "net/base/net_util.h" |
| 56 #include "skia/ext/skia_utils_mac.h" | 56 #include "skia/ext/skia_utils_mac.h" |
| 57 #include "third_party/skia/include/core/SkBitmap.h" | 57 #include "third_party/skia/include/core/SkBitmap.h" |
| 58 #include "ui/base/l10n/l10n_util_mac.h" | 58 #include "ui/base/l10n/l10n_util_mac.h" |
| 59 #include "ui/base/resource/resource_bundle.h" | 59 #include "ui/base/resource/resource_bundle.h" |
| 60 | 60 |
| 61 namespace { | 61 namespace { |
| 62 | 62 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 weak_ptr_factory_(this) { | 98 weak_ptr_factory_(this) { |
| 99 for (size_t i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) { | 99 for (size_t i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) { |
| 100 DCHECK_EQ(i, content_setting_decorations_.size()); | 100 DCHECK_EQ(i, content_setting_decorations_.size()); |
| 101 ContentSettingsType type = static_cast<ContentSettingsType>(i); | 101 ContentSettingsType type = static_cast<ContentSettingsType>(i); |
| 102 content_setting_decorations_.push_back( | 102 content_setting_decorations_.push_back( |
| 103 new ContentSettingDecoration(type, this, profile_)); | 103 new ContentSettingDecoration(type, this, profile_)); |
| 104 } | 104 } |
| 105 | 105 |
| 106 registrar_.Add(this, | 106 registrar_.Add(this, |
| 107 chrome::NOTIFICATION_EXTENSION_PAGE_ACTION_VISIBILITY_CHANGED, | 107 chrome::NOTIFICATION_EXTENSION_PAGE_ACTION_VISIBILITY_CHANGED, |
| 108 NotificationService::AllSources()); | 108 content::NotificationService::AllSources()); |
| 109 | 109 |
| 110 edit_bookmarks_enabled_.Init(prefs::kEditBookmarksEnabled, | 110 edit_bookmarks_enabled_.Init(prefs::kEditBookmarksEnabled, |
| 111 profile_->GetPrefs(), this); | 111 profile_->GetPrefs(), this); |
| 112 } | 112 } |
| 113 | 113 |
| 114 LocationBarViewMac::~LocationBarViewMac() { | 114 LocationBarViewMac::~LocationBarViewMac() { |
| 115 // Disconnect from cell in case it outlives us. | 115 // Disconnect from cell in case it outlives us. |
| 116 [[field_ cell] clearDecorations]; | 116 [[field_ cell] clearDecorations]; |
| 117 } | 117 } |
| 118 | 118 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 [field_ updateCursorAndToolTipRects]; | 177 [field_ updateCursorAndToolTipRects]; |
| 178 [field_ setNeedsDisplay:YES]; | 178 [field_ setNeedsDisplay:YES]; |
| 179 } | 179 } |
| 180 } | 180 } |
| 181 | 181 |
| 182 void LocationBarViewMac::UpdatePageActions() { | 182 void LocationBarViewMac::UpdatePageActions() { |
| 183 size_t count_before = page_action_decorations_.size(); | 183 size_t count_before = page_action_decorations_.size(); |
| 184 RefreshPageActionDecorations(); | 184 RefreshPageActionDecorations(); |
| 185 Layout(); | 185 Layout(); |
| 186 if (page_action_decorations_.size() != count_before) { | 186 if (page_action_decorations_.size() != count_before) { |
| 187 NotificationService::current()->Notify( | 187 content::NotificationService::current()->Notify( |
| 188 chrome::NOTIFICATION_EXTENSION_PAGE_ACTION_COUNT_CHANGED, | 188 chrome::NOTIFICATION_EXTENSION_PAGE_ACTION_COUNT_CHANGED, |
| 189 content::Source<LocationBar>(this), | 189 content::Source<LocationBar>(this), |
| 190 NotificationService::NoDetails()); | 190 content::NotificationService::NoDetails()); |
| 191 } | 191 } |
| 192 } | 192 } |
| 193 | 193 |
| 194 void LocationBarViewMac::InvalidatePageActions() { | 194 void LocationBarViewMac::InvalidatePageActions() { |
| 195 size_t count_before = page_action_decorations_.size(); | 195 size_t count_before = page_action_decorations_.size(); |
| 196 DeletePageActionDecorations(); | 196 DeletePageActionDecorations(); |
| 197 Layout(); | 197 Layout(); |
| 198 if (page_action_decorations_.size() != count_before) { | 198 if (page_action_decorations_.size() != count_before) { |
| 199 NotificationService::current()->Notify( | 199 content::NotificationService::current()->Notify( |
| 200 chrome::NOTIFICATION_EXTENSION_PAGE_ACTION_COUNT_CHANGED, | 200 chrome::NOTIFICATION_EXTENSION_PAGE_ACTION_COUNT_CHANGED, |
| 201 content::Source<LocationBar>(this), | 201 content::Source<LocationBar>(this), |
| 202 NotificationService::NoDetails()); | 202 content::NotificationService::NoDetails()); |
| 203 } | 203 } |
| 204 } | 204 } |
| 205 | 205 |
| 206 void LocationBarViewMac::SaveStateToContents(TabContents* contents) { | 206 void LocationBarViewMac::SaveStateToContents(TabContents* contents) { |
| 207 // TODO(shess): Why SaveStateToContents vs SaveStateToTab? | 207 // TODO(shess): Why SaveStateToContents vs SaveStateToTab? |
| 208 omnibox_view_->SaveStateToTab(contents); | 208 omnibox_view_->SaveStateToTab(contents); |
| 209 } | 209 } |
| 210 | 210 |
| 211 void LocationBarViewMac::Update(const TabContents* contents, | 211 void LocationBarViewMac::Update(const TabContents* contents, |
| 212 bool should_restore_state) { | 212 bool should_restore_state) { |
| (...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 641 | 641 |
| 642 [field_ setNeedsDisplay:YES]; | 642 [field_ setNeedsDisplay:YES]; |
| 643 } | 643 } |
| 644 | 644 |
| 645 bool LocationBarViewMac::IsStarEnabled() { | 645 bool LocationBarViewMac::IsStarEnabled() { |
| 646 return [field_ isEditable] && | 646 return [field_ isEditable] && |
| 647 browser_defaults::bookmarks_enabled && | 647 browser_defaults::bookmarks_enabled && |
| 648 !toolbar_model_->input_in_progress() && | 648 !toolbar_model_->input_in_progress() && |
| 649 edit_bookmarks_enabled_.GetValue(); | 649 edit_bookmarks_enabled_.GetValue(); |
| 650 } | 650 } |
| OLD | NEW |