| 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 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" | 5 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" |
| 6 | 6 |
| 7 #if defined(OS_LINUX) | 7 #if defined(OS_LINUX) |
| 8 #include <gtk/gtk.h> | 8 #include <gtk/gtk.h> |
| 9 #endif | 9 #endif |
| 10 | 10 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 #include "chrome/browser/ui/views/browser_dialogs.h" | 26 #include "chrome/browser/ui/views/browser_dialogs.h" |
| 27 #include "chrome/browser/ui/views/location_bar/content_setting_image_view.h" | 27 #include "chrome/browser/ui/views/location_bar/content_setting_image_view.h" |
| 28 #include "chrome/browser/ui/views/location_bar/ev_bubble_view.h" | 28 #include "chrome/browser/ui/views/location_bar/ev_bubble_view.h" |
| 29 #include "chrome/browser/ui/views/location_bar/keyword_hint_view.h" | 29 #include "chrome/browser/ui/views/location_bar/keyword_hint_view.h" |
| 30 #include "chrome/browser/ui/views/location_bar/location_icon_view.h" | 30 #include "chrome/browser/ui/views/location_bar/location_icon_view.h" |
| 31 #include "chrome/browser/ui/views/location_bar/page_action_image_view.h" | 31 #include "chrome/browser/ui/views/location_bar/page_action_image_view.h" |
| 32 #include "chrome/browser/ui/views/location_bar/page_action_with_badge_view.h" | 32 #include "chrome/browser/ui/views/location_bar/page_action_with_badge_view.h" |
| 33 #include "chrome/browser/ui/views/location_bar/selected_keyword_view.h" | 33 #include "chrome/browser/ui/views/location_bar/selected_keyword_view.h" |
| 34 #include "chrome/browser/ui/views/location_bar/star_view.h" | 34 #include "chrome/browser/ui/views/location_bar/star_view.h" |
| 35 #include "chrome/common/chrome_switches.h" | 35 #include "chrome/common/chrome_switches.h" |
| 36 #include "chrome/common/pref_names.h" |
| 36 #include "content/browser/renderer_host/render_widget_host_view.h" | 37 #include "content/browser/renderer_host/render_widget_host_view.h" |
| 37 #include "content/common/notification_service.h" | 38 #include "content/common/notification_service.h" |
| 38 #include "grit/generated_resources.h" | 39 #include "grit/generated_resources.h" |
| 39 #include "grit/theme_resources.h" | 40 #include "grit/theme_resources.h" |
| 40 #include "ui/base/accessibility/accessible_view_state.h" | 41 #include "ui/base/accessibility/accessible_view_state.h" |
| 41 #include "ui/base/dragdrop/drag_drop_types.h" | 42 #include "ui/base/dragdrop/drag_drop_types.h" |
| 42 #include "ui/base/l10n/l10n_util.h" | 43 #include "ui/base/l10n/l10n_util.h" |
| 43 #include "ui/base/resource/resource_bundle.h" | 44 #include "ui/base/resource/resource_bundle.h" |
| 44 #include "ui/base/theme_provider.h" | 45 #include "ui/base/theme_provider.h" |
| 45 #include "ui/gfx/canvas_skia.h" | 46 #include "ui/gfx/canvas_skia.h" |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 mode_(mode), | 118 mode_(mode), |
| 118 show_focus_rect_(false), | 119 show_focus_rect_(false), |
| 119 bubble_type_(FirstRun::MINIMAL_BUBBLE), | 120 bubble_type_(FirstRun::MINIMAL_BUBBLE), |
| 120 template_url_model_(NULL) { | 121 template_url_model_(NULL) { |
| 121 DCHECK(profile_); | 122 DCHECK(profile_); |
| 122 SetID(VIEW_ID_LOCATION_BAR); | 123 SetID(VIEW_ID_LOCATION_BAR); |
| 123 SetFocusable(true); | 124 SetFocusable(true); |
| 124 | 125 |
| 125 if (mode_ == NORMAL) | 126 if (mode_ == NORMAL) |
| 126 painter_.reset(new views::HorizontalPainter(kNormalModeBackgroundImages)); | 127 painter_.reset(new views::HorizontalPainter(kNormalModeBackgroundImages)); |
| 128 |
| 129 edit_bookmarks_enabled_.Init(prefs::kEditBookmarksEnabled, |
| 130 profile_->GetPrefs(), this); |
| 127 } | 131 } |
| 128 | 132 |
| 129 LocationBarView::~LocationBarView() { | 133 LocationBarView::~LocationBarView() { |
| 130 if (template_url_model_) | 134 if (template_url_model_) |
| 131 template_url_model_->RemoveObserver(this); | 135 template_url_model_->RemoveObserver(this); |
| 132 } | 136 } |
| 133 | 137 |
| 134 void LocationBarView::Init() { | 138 void LocationBarView::Init() { |
| 135 if (mode_ == POPUP) { | 139 if (mode_ == POPUP) { |
| 136 font_ = ResourceBundle::GetSharedInstance().GetFont( | 140 font_ = ResourceBundle::GetSharedInstance().GetFont( |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 BACKGROUND)); | 263 BACKGROUND)); |
| 260 } | 264 } |
| 261 | 265 |
| 262 default: | 266 default: |
| 263 NOTREACHED(); | 267 NOTREACHED(); |
| 264 return GetColor(security_level, TEXT); | 268 return GetColor(security_level, TEXT); |
| 265 } | 269 } |
| 266 } | 270 } |
| 267 | 271 |
| 268 void LocationBarView::Update(const TabContents* tab_for_state_restoring) { | 272 void LocationBarView::Update(const TabContents* tab_for_state_restoring) { |
| 269 bool star_enabled = star_view_ && !model_->input_in_progress(); | 273 bool star_enabled = star_view_ && !model_->input_in_progress() && |
| 274 edit_bookmarks_enabled_.GetValue(); |
| 270 command_updater_->UpdateCommandEnabled(IDC_BOOKMARK_PAGE, star_enabled); | 275 command_updater_->UpdateCommandEnabled(IDC_BOOKMARK_PAGE, star_enabled); |
| 271 if (star_view_) | 276 if (star_view_) |
| 272 star_view_->SetVisible(star_enabled); | 277 star_view_->SetVisible(star_enabled); |
| 273 RefreshContentSettingViews(); | 278 RefreshContentSettingViews(); |
| 274 RefreshPageActionViews(); | 279 RefreshPageActionViews(); |
| 275 // Don't Update in app launcher mode so that the location entry does not show | 280 // Don't Update in app launcher mode so that the location entry does not show |
| 276 // a URL or security background. | 281 // a URL or security background. |
| 277 if (mode_ != APP_LAUNCHER) | 282 if (mode_ != APP_LAUNCHER) |
| 278 location_entry_->Update(tab_for_state_restoring); | 283 location_entry_->Update(tab_for_state_restoring); |
| 279 OnChanged(); | 284 OnChanged(); |
| (...skipping 898 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1178 | 1183 |
| 1179 NOTREACHED(); | 1184 NOTREACHED(); |
| 1180 } | 1185 } |
| 1181 | 1186 |
| 1182 void LocationBarView::OnTemplateURLModelChanged() { | 1187 void LocationBarView::OnTemplateURLModelChanged() { |
| 1183 template_url_model_->RemoveObserver(this); | 1188 template_url_model_->RemoveObserver(this); |
| 1184 template_url_model_ = NULL; | 1189 template_url_model_ = NULL; |
| 1185 ShowFirstRunBubble(bubble_type_); | 1190 ShowFirstRunBubble(bubble_type_); |
| 1186 } | 1191 } |
| 1187 | 1192 |
| 1193 void LocationBarView::Observe(NotificationType type, |
| 1194 const NotificationSource& source, |
| 1195 const NotificationDetails& details) { |
| 1196 if (type.value == NotificationType::PREF_CHANGED) { |
| 1197 std::string* name = Details<std::string>(details).ptr(); |
| 1198 if (*name == prefs::kEditBookmarksEnabled) |
| 1199 Update(NULL); |
| 1200 } |
| 1201 } |
| 1202 |
| 1188 #if defined(OS_WIN) | 1203 #if defined(OS_WIN) |
| 1189 bool LocationBarView::HasValidSuggestText() const { | 1204 bool LocationBarView::HasValidSuggestText() const { |
| 1190 return suggested_text_view_ && !suggested_text_view_->size().IsEmpty() && | 1205 return suggested_text_view_ && !suggested_text_view_->size().IsEmpty() && |
| 1191 !suggested_text_view_->GetText().empty(); | 1206 !suggested_text_view_->GetText().empty(); |
| 1192 } | 1207 } |
| 1193 #endif | 1208 #endif |
| OLD | NEW |