OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/renderer_context_menu/render_view_context_menu_base.h" | 5 #include "components/renderer_context_menu/render_view_context_menu_base.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 return browser_context_; | 243 return browser_context_; |
244 } | 244 } |
245 | 245 |
246 bool RenderViewContextMenuBase::AppendCustomItems() { | 246 bool RenderViewContextMenuBase::AppendCustomItems() { |
247 size_t total_items = 0; | 247 size_t total_items = 0; |
248 AddCustomItemsToMenu(params_.custom_items, 0, &total_items, this, | 248 AddCustomItemsToMenu(params_.custom_items, 0, &total_items, this, |
249 &menu_model_); | 249 &menu_model_); |
250 return total_items > 0; | 250 return total_items > 0; |
251 } | 251 } |
252 | 252 |
253 // Menu delegate functions ----------------------------------------------------- | 253 bool RenderViewContextMenuBase::GetCommandIdEnabled( |
254 | 254 int id, |
255 bool RenderViewContextMenuBase::IsCommandIdEnabled(int id) const { | 255 bool* enabled) const { |
256 // If this command is is added by one of our observers, we dispatch | 256 // If this command is is added by one of our observers, we dispatch |
257 // it to the observer. | 257 // it to the observer. |
258 ObserverListBase<RenderViewContextMenuObserver>::Iterator it(observers_); | 258 ObserverListBase<RenderViewContextMenuObserver>::Iterator it(observers_); |
259 RenderViewContextMenuObserver* observer; | 259 RenderViewContextMenuObserver* observer; |
260 while ((observer = it.GetNext()) != NULL) { | 260 while ((observer = it.GetNext()) != NULL) { |
261 if (observer->IsCommandIdSupported(id)) | 261 if (observer->IsCommandIdSupported(id)) { |
262 return observer->IsCommandIdEnabled(id); | 262 *enabled = observer->IsCommandIdEnabled(id); |
| 263 return true; |
| 264 } |
263 } | 265 } |
264 | 266 |
265 // Custom items. | 267 // Custom items. |
266 if (IsContentCustomCommandId(id)) | 268 if (IsContentCustomCommandId(id)) { |
267 return IsCustomItemEnabled(id); | 269 *enabled = IsCustomItemEnabled(id); |
| 270 return true; |
| 271 } |
268 | 272 |
269 return false; | 273 return false; |
270 } | 274 } |
271 | 275 |
| 276 // Menu delegate functions ----------------------------------------------------- |
| 277 |
272 bool RenderViewContextMenuBase::IsCommandIdChecked(int id) const { | 278 bool RenderViewContextMenuBase::IsCommandIdChecked(int id) const { |
273 // If this command is is added by one of our observers, we dispatch it to the | 279 // If this command is is added by one of our observers, we dispatch it to the |
274 // observer. | 280 // observer. |
275 ObserverListBase<RenderViewContextMenuObserver>::Iterator it(observers_); | 281 ObserverListBase<RenderViewContextMenuObserver>::Iterator it(observers_); |
276 RenderViewContextMenuObserver* observer; | 282 RenderViewContextMenuObserver* observer; |
277 while ((observer = it.GetNext()) != NULL) { | 283 while ((observer = it.GetNext()) != NULL) { |
278 if (observer->IsCommandIdSupported(id)) | 284 if (observer->IsCommandIdSupported(id)) |
279 return observer->IsCommandIdChecked(id); | 285 return observer->IsCommandIdChecked(id); |
280 } | 286 } |
281 | 287 |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
378 } | 384 } |
379 | 385 |
380 bool RenderViewContextMenuBase::IsCustomItemChecked(int id) const { | 386 bool RenderViewContextMenuBase::IsCustomItemChecked(int id) const { |
381 return IsCustomItemCheckedInternal(params_.custom_items, id); | 387 return IsCustomItemCheckedInternal(params_.custom_items, id); |
382 } | 388 } |
383 | 389 |
384 bool RenderViewContextMenuBase::IsCustomItemEnabled(int id) const { | 390 bool RenderViewContextMenuBase::IsCustomItemEnabled(int id) const { |
385 return IsCustomItemEnabledInternal(params_.custom_items, id); | 391 return IsCustomItemEnabledInternal(params_.custom_items, id); |
386 } | 392 } |
387 | 393 |
OLD | NEW |