Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(302)

Side by Side Diff: chrome/browser/ui/views/location_bar/location_bar_view.cc

Issue 6837021: Disable bookmark editing (views UI). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 mode_(mode), 116 mode_(mode),
116 show_focus_rect_(false), 117 show_focus_rect_(false),
117 bubble_type_(FirstRun::MINIMAL_BUBBLE), 118 bubble_type_(FirstRun::MINIMAL_BUBBLE),
118 template_url_model_(NULL) { 119 template_url_model_(NULL) {
119 DCHECK(profile_); 120 DCHECK(profile_);
120 SetID(VIEW_ID_LOCATION_BAR); 121 SetID(VIEW_ID_LOCATION_BAR);
121 SetFocusable(true); 122 SetFocusable(true);
122 123
123 if (mode_ == NORMAL) 124 if (mode_ == NORMAL)
124 painter_.reset(new views::HorizontalPainter(kNormalModeBackgroundImages)); 125 painter_.reset(new views::HorizontalPainter(kNormalModeBackgroundImages));
126
127 edit_bookmarks_enabled_.Init(prefs::kEditBookmarksEnabled,
128 profile_->GetPrefs(), this);
125 } 129 }
126 130
127 LocationBarView::~LocationBarView() { 131 LocationBarView::~LocationBarView() {
128 if (template_url_model_) 132 if (template_url_model_)
129 template_url_model_->RemoveObserver(this); 133 template_url_model_->RemoveObserver(this);
130 } 134 }
131 135
132 void LocationBarView::Init() { 136 void LocationBarView::Init() {
133 if (mode_ == POPUP) { 137 if (mode_ == POPUP) {
134 font_ = ResourceBundle::GetSharedInstance().GetFont( 138 font_ = ResourceBundle::GetSharedInstance().GetFont(
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 BACKGROUND)); 261 BACKGROUND));
258 } 262 }
259 263
260 default: 264 default:
261 NOTREACHED(); 265 NOTREACHED();
262 return GetColor(security_level, TEXT); 266 return GetColor(security_level, TEXT);
263 } 267 }
264 } 268 }
265 269
266 void LocationBarView::Update(const TabContents* tab_for_state_restoring) { 270 void LocationBarView::Update(const TabContents* tab_for_state_restoring) {
267 bool star_enabled = star_view_ && !model_->input_in_progress(); 271 bool star_enabled = star_view_ && !model_->input_in_progress() &&
272 edit_bookmarks_enabled_.GetValue();
268 command_updater_->UpdateCommandEnabled(IDC_BOOKMARK_PAGE, star_enabled); 273 command_updater_->UpdateCommandEnabled(IDC_BOOKMARK_PAGE, star_enabled);
269 if (star_view_) 274 if (star_view_)
270 star_view_->SetVisible(star_enabled); 275 star_view_->SetVisible(star_enabled);
271 RefreshContentSettingViews(); 276 RefreshContentSettingViews();
272 RefreshPageActionViews(); 277 RefreshPageActionViews();
273 // Don't Update in app launcher mode so that the location entry does not show 278 // Don't Update in app launcher mode so that the location entry does not show
274 // a URL or security background. 279 // a URL or security background.
275 if (mode_ != APP_LAUNCHER) 280 if (mode_ != APP_LAUNCHER)
276 location_entry_->Update(tab_for_state_restoring); 281 location_entry_->Update(tab_for_state_restoring);
277 OnChanged(); 282 OnChanged();
(...skipping 898 matching lines...) Expand 10 before | Expand all | Expand 10 after
1176 1181
1177 NOTREACHED(); 1182 NOTREACHED();
1178 } 1183 }
1179 1184
1180 void LocationBarView::OnTemplateURLModelChanged() { 1185 void LocationBarView::OnTemplateURLModelChanged() {
1181 template_url_model_->RemoveObserver(this); 1186 template_url_model_->RemoveObserver(this);
1182 template_url_model_ = NULL; 1187 template_url_model_ = NULL;
1183 ShowFirstRunBubble(bubble_type_); 1188 ShowFirstRunBubble(bubble_type_);
1184 } 1189 }
1185 1190
1191 void LocationBarView::Observe(NotificationType type,
1192 const NotificationSource& source,
1193 const NotificationDetails& details) {
1194 if (type.value == NotificationType::PREF_CHANGED) {
1195 std::string* name = Details<std::string>(details).ptr();
1196 if (*name == prefs::kEditBookmarksEnabled) {
sky 2011/04/13 14:28:55 nit: no {}
Joao da Silva 2011/04/13 14:42:42 Done.
1197 Update(NULL);
1198 }
1199 }
1200 }
1201
1186 #if defined(OS_WIN) 1202 #if defined(OS_WIN)
1187 bool LocationBarView::HasValidSuggestText() const { 1203 bool LocationBarView::HasValidSuggestText() const {
1188 return suggested_text_view_ && !suggested_text_view_->size().IsEmpty() && 1204 return suggested_text_view_ && !suggested_text_view_->size().IsEmpty() &&
1189 !suggested_text_view_->GetText().empty(); 1205 !suggested_text_view_->GetText().empty();
1190 } 1206 }
1191 #endif 1207 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698