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

Unified Diff: chrome/browser/renderer_context_menu/context_menu_content_type.cc

Issue 202993002: Fix "unreachable code" warnings (MSVC warning 4702) in chrome/browser/. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 6 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/renderer_context_menu/context_menu_content_type.cc
===================================================================
--- chrome/browser/renderer_context_menu/context_menu_content_type.cc (revision 256983)
+++ chrome/browser/renderer_context_menu/context_menu_content_type.cc (working copy)
@@ -28,9 +28,8 @@
}
bool IsInternalResourcesURL(const GURL& url) {
- if (!url.SchemeIs(content::kChromeUIScheme))
- return false;
- return url.host() == chrome::kChromeUISyncResourcesHost;
+ return url.SchemeIs(content::kChromeUIScheme) &&
+ (url.host() == chrome::kChromeUISyncResourcesHost);
}
} // namespace
@@ -43,21 +42,12 @@
source_web_contents_(WebContents::FromRenderFrameHost(render_frame_host)),
profile_(Profile::FromBrowserContext(
source_web_contents_->GetBrowserContext())),
- supports_custom_items_(supports_custom_items),
- has_custom_items_(false) {
- Initialize();
+ supports_custom_items_(supports_custom_items) {
}
ContextMenuContentType::~ContextMenuContentType() {
}
-void ContextMenuContentType::Initialize() {
- // Save it in |has_custom_items_| so we don't have to repeatedly call
- // HasCustomItems().
- has_custom_items_ = supports_custom_items_ &&
- HasCustomItems(params_.custom_items);
-}
-
const Extension* ContextMenuContentType::GetExtension() const {
extensions::ExtensionSystem* system =
extensions::ExtensionSystem::Get(profile_);
@@ -69,22 +59,10 @@
source_web_contents_->GetRenderViewHost());
}
-bool ContextMenuContentType::HasCustomItems(
- const std::vector<content::MenuItem>& items) const {
- for (size_t i = 0; i < items.size(); ++i) {
- if (IDC_CONTENT_CONTEXT_CUSTOM_FIRST + items[i].action >=
- IDC_CONTENT_CONTEXT_CUSTOM_LAST) {
- return false;
- }
- return true;
- }
- return false;
-}
-
bool ContextMenuContentType::SupportsGroup(int group) {
const bool has_selection = !params_.selection_text.empty();
- if (has_custom_items_) {
+ if (supports_custom_items_ && !params_.custom_items.empty()) {
if (group == ITEM_GROUP_CUSTOM)
return true;
@@ -111,7 +89,8 @@
switch (group) {
case ITEM_GROUP_CUSTOM:
- return has_custom_items_;
+ return supports_custom_items_ && !params_.custom_items.empty();
+
case ITEM_GROUP_PAGE: {
bool is_candidate =
params_.media_type == WebContextMenuData::MediaTypeNone &&
@@ -124,49 +103,68 @@
!IsDevToolsURL(params_.page_url) &&
!IsInternalResourcesURL(params_.page_url);
}
+
case ITEM_GROUP_FRAME: {
+
bool page_group_supported = SupportsGroupInternal(ITEM_GROUP_PAGE);
return page_group_supported && !params_.frame_url.is_empty() &&
!IsDevToolsURL(params_.frame_url) &&
!IsInternalResourcesURL(params_.page_url);
}
+
case ITEM_GROUP_LINK:
return has_link;
+
case ITEM_GROUP_MEDIA_IMAGE:
return params_.media_type == WebContextMenuData::MediaTypeImage;
+
case ITEM_GROUP_SEARCHWEBFORIMAGE:
// Image menu items imply search web for image item.
return SupportsGroupInternal(ITEM_GROUP_MEDIA_IMAGE);
+
case ITEM_GROUP_MEDIA_VIDEO:
return params_.media_type == WebContextMenuData::MediaTypeVideo;
+
case ITEM_GROUP_MEDIA_AUDIO:
return params_.media_type == WebContextMenuData::MediaTypeAudio;
+
case ITEM_GROUP_MEDIA_PLUGIN:
return params_.media_type == WebContextMenuData::MediaTypePlugin;
+
case ITEM_GROUP_MEDIA_FILE:
-#ifdef WEBCONTEXT_MEDIATYPEFILE_DEFINED
+#if defined(WEBCONTEXT_MEDIATYPEFILE_DEFINED)
return params_.media_type == WebContextMenuData::MediaTypeFile;
+#else
+ return false;
#endif
- return false;
+
case ITEM_GROUP_EDITABLE:
return params_.is_editable;
+
case ITEM_GROUP_COPY:
return !params_.is_editable && has_selection;
+
case ITEM_GROUP_SEARCH_PROVIDER:
return has_selection;
+
case ITEM_GROUP_PRINT: {
bool enable = has_selection && !IsDevToolsURL(params_.page_url);
// Image menu items also imply print items.
return enable || SupportsGroupInternal(ITEM_GROUP_MEDIA_IMAGE);
}
+
case ITEM_GROUP_ALL_EXTENSION:
return !IsDevToolsURL(params_.page_url);
+
case ITEM_GROUP_CURRENT_EXTENSION:
return false;
+
case ITEM_GROUP_DEVELOPER:
return true;
+
case ITEM_GROUP_DEVTOOLS_UNPACKED_EXT:
return false;
+
case ITEM_GROUP_PRINT_PREVIEW:
#if defined(ENABLE_FULL_PRINTING)
return true;
@@ -173,8 +171,9 @@
#else
return false;
#endif
+
+ default:
+ NOTREACHED();
+ return false;
}
-
- NOTREACHED();
- return false;
}

Powered by Google App Engine
This is Rietveld 408576698