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

Side by Side Diff: chrome/browser/renderer_context_menu/context_menu_content_type_platform_app.cc

Issue 1117893002: Moving extension code out of "components/" to avoid layering violations. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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
OLDNEW
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 #if defined(ENABLE_EXTENSIONS)
15 using extensions::Extension;
16 using extensions::ProcessManager;
17 #endif
18
12 ContextMenuContentTypePlatformApp::ContextMenuContentTypePlatformApp( 19 ContextMenuContentTypePlatformApp::ContextMenuContentTypePlatformApp(
13 content::WebContents* web_contents, 20 content::WebContents* web_contents,
14 const content::ContextMenuParams& params) 21 const content::ContextMenuParams& params)
15 : ContextMenuContentType(web_contents, params, false) { 22 : ContextMenuContentType(web_contents, params, false) {
16 } 23 }
17 24
18 ContextMenuContentTypePlatformApp::~ContextMenuContentTypePlatformApp() { 25 ContextMenuContentTypePlatformApp::~ContextMenuContentTypePlatformApp() {
19 } 26 }
20 27
28 #if defined(ENABLE_EXTENSIONS)
29 const Extension* ContextMenuContentTypePlatformApp::GetExtension() const {
30 ProcessManager* process_manager =
31 ProcessManager::Get(source_web_contents()->GetBrowserContext());
32 return process_manager->GetExtensionForWebContents(
33 source_web_contents());
34 }
35 #endif
36
21 bool ContextMenuContentTypePlatformApp::SupportsGroup(int group) { 37 bool ContextMenuContentTypePlatformApp::SupportsGroup(int group) {
22 const extensions::Extension* platform_app = GetExtension(); 38 const extensions::Extension* platform_app = GetExtension();
23 39
24 // The RVH might be for a process sandboxed from the extension. 40 // The RVH might be for a process sandboxed from the extension.
25 if (!platform_app) 41 if (!platform_app)
26 return false; 42 return false;
27 43
28 DCHECK(platform_app->is_platform_app()); 44 DCHECK(platform_app->is_platform_app());
29 45
30 switch (group) { 46 switch (group) {
31 // Add undo/redo, cut/copy/paste etc for text fields. 47 // Add undo/redo, cut/copy/paste etc for text fields.
32 case ITEM_GROUP_EDITABLE: 48 case ITEM_GROUP_EDITABLE:
33 case ITEM_GROUP_COPY: 49 case ITEM_GROUP_COPY:
34 return ContextMenuContentType::SupportsGroup(group); 50 return ContextMenuContentType::SupportsGroup(group);
35 case ITEM_GROUP_CURRENT_EXTENSION: 51 case ITEM_GROUP_CURRENT_EXTENSION:
36 return true; 52 return true;
37 case ITEM_GROUP_DEVTOOLS_UNPACKED_EXT: 53 case ITEM_GROUP_DEVTOOLS_UNPACKED_EXT:
38 // Add dev tools for unpacked extensions. 54 // Add dev tools for unpacked extensions.
39 return extensions::Manifest::IsUnpackedLocation( 55 return extensions::Manifest::IsUnpackedLocation(
40 platform_app->location()) || 56 platform_app->location()) ||
41 base::CommandLine::ForCurrentProcess()->HasSwitch( 57 base::CommandLine::ForCurrentProcess()->HasSwitch(
42 switches::kDebugPackedApps); 58 switches::kDebugPackedApps);
43 default: 59 default:
44 return false; 60 return false;
45 } 61 }
46 } 62 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698