Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / guest_view / web_view / context_menu_content_type_web_view.cc
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/guest_view/web_view/context_menu_content_type_web_view.h"
6
7 #include "base/command_line.h"
8 #include "chrome/common/chrome_switches.h"
9 #include "extensions/common/extension.h"
10 #include "extensions/common/manifest.h"
11
12 ContextMenuContentTypeWebView::ContextMenuContentTypeWebView(
13     content::WebContents* web_contents,
14     const content::ContextMenuParams& params)
15     : ContextMenuContentType(web_contents, params, true) {
16 }
17
18 ContextMenuContentTypeWebView::~ContextMenuContentTypeWebView() {
19 }
20
21 bool ContextMenuContentTypeWebView::SupportsGroup(int group) {
22   switch (group) {
23     case ITEM_GROUP_PAGE:
24     case ITEM_GROUP_FRAME:
25     case ITEM_GROUP_LINK:
26     case ITEM_GROUP_SEARCHWEBFORIMAGE:
27     case ITEM_GROUP_SEARCH_PROVIDER:
28     case ITEM_GROUP_PRINT:
29     case ITEM_GROUP_ALL_EXTENSION:
30     case ITEM_GROUP_PRINT_PREVIEW:
31       return false;
32     case ITEM_GROUP_CURRENT_EXTENSION:
33       // Show contextMenus API items.
34       return true;
35     case ITEM_GROUP_DEVELOPER:
36       // TODO(lazyboy): Enable this for mac too when http://crbug.com/380405 is
37       // fixed.
38 #if !defined(OS_MACOSX)
39       {
40         // Add dev tools for unpacked extensions.
41         const extensions::Extension* embedder_platform_app = GetExtension();
42         return !embedder_platform_app ||
43             extensions::Manifest::IsUnpackedLocation(
44                 embedder_platform_app->location()) ||
45             CommandLine::ForCurrentProcess()->HasSwitch(
46                 switches::kDebugPackedApps);
47       }
48 #else
49       return ContextMenuContentType::SupportsGroup(group);
50 #endif
51     default:
52       return ContextMenuContentType::SupportsGroup(group);
53   }
54 }