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 "chrome/browser/renderer_context_menu/context_menu_content_type_platfor
m_app.h" | 5 #include "chrome/browser/renderer_context_menu/context_menu_content_type_platfor
m_app.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "chrome/common/chrome_switches.h" | 8 #include "chrome/common/chrome_switches.h" |
| 9 #include "content/public/browser/web_contents.h" |
| 10 #include "extensions/browser/process_manager.h" |
9 #include "extensions/common/extension.h" | 11 #include "extensions/common/extension.h" |
10 #include "extensions/common/manifest.h" | 12 #include "extensions/common/manifest.h" |
11 | 13 |
| 14 using extensions::Extension; |
| 15 using extensions::ProcessManager; |
| 16 |
12 ContextMenuContentTypePlatformApp::ContextMenuContentTypePlatformApp( | 17 ContextMenuContentTypePlatformApp::ContextMenuContentTypePlatformApp( |
13 content::WebContents* web_contents, | 18 content::WebContents* web_contents, |
14 const content::ContextMenuParams& params) | 19 const content::ContextMenuParams& params) |
15 : ContextMenuContentType(web_contents, params, false) { | 20 : ContextMenuContentType(web_contents, params, false) { |
16 } | 21 } |
17 | 22 |
18 ContextMenuContentTypePlatformApp::~ContextMenuContentTypePlatformApp() { | 23 ContextMenuContentTypePlatformApp::~ContextMenuContentTypePlatformApp() { |
19 } | 24 } |
20 | 25 |
| 26 const Extension* ContextMenuContentTypePlatformApp::GetExtension() const { |
| 27 ProcessManager* process_manager = |
| 28 ProcessManager::Get(source_web_contents()->GetBrowserContext()); |
| 29 return process_manager->GetExtensionForWebContents( |
| 30 source_web_contents()); |
| 31 } |
| 32 |
21 bool ContextMenuContentTypePlatformApp::SupportsGroup(int group) { | 33 bool ContextMenuContentTypePlatformApp::SupportsGroup(int group) { |
22 const extensions::Extension* platform_app = GetExtension(); | 34 const extensions::Extension* platform_app = GetExtension(); |
23 | 35 |
24 // The RVH might be for a process sandboxed from the extension. | 36 // The RVH might be for a process sandboxed from the extension. |
25 if (!platform_app) | 37 if (!platform_app) |
26 return false; | 38 return false; |
27 | 39 |
28 DCHECK(platform_app->is_platform_app()); | 40 DCHECK(platform_app->is_platform_app()); |
29 | 41 |
30 switch (group) { | 42 switch (group) { |
31 // Add undo/redo, cut/copy/paste etc for text fields. | 43 // Add undo/redo, cut/copy/paste etc for text fields. |
32 case ITEM_GROUP_EDITABLE: | 44 case ITEM_GROUP_EDITABLE: |
33 case ITEM_GROUP_COPY: | 45 case ITEM_GROUP_COPY: |
34 return ContextMenuContentType::SupportsGroup(group); | 46 return ContextMenuContentType::SupportsGroup(group); |
35 case ITEM_GROUP_CURRENT_EXTENSION: | 47 case ITEM_GROUP_CURRENT_EXTENSION: |
36 return true; | 48 return true; |
37 case ITEM_GROUP_DEVTOOLS_UNPACKED_EXT: | 49 case ITEM_GROUP_DEVTOOLS_UNPACKED_EXT: |
38 // Add dev tools for unpacked extensions. | 50 // Add dev tools for unpacked extensions. |
39 return extensions::Manifest::IsUnpackedLocation( | 51 return extensions::Manifest::IsUnpackedLocation( |
40 platform_app->location()) || | 52 platform_app->location()) || |
41 base::CommandLine::ForCurrentProcess()->HasSwitch( | 53 base::CommandLine::ForCurrentProcess()->HasSwitch( |
42 switches::kDebugPackedApps); | 54 switches::kDebugPackedApps); |
43 default: | 55 default: |
44 return false; | 56 return false; |
45 } | 57 } |
46 } | 58 } |
OLD | NEW |