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

Side by Side Diff: components/renderer_context_menu/context_menu_content_type.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 "components/renderer_context_menu/context_menu_content_type.h" 5 #include "components/renderer_context_menu/context_menu_content_type.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "content/public/browser/web_contents.h" 8 #include "content/public/browser/web_contents.h"
9 #include "content/public/common/url_constants.h" 9 #include "content/public/common/url_constants.h"
10 #include "third_party/WebKit/public/web/WebContextMenuData.h" 10 #include "third_party/WebKit/public/web/WebContextMenuData.h"
11 11
12 #if defined(ENABLE_EXTENSIONS)
lazyboy 2015/04/30 16:33:31 Since we're moving extensions/ dependency in this
Deepak 2015/05/02 06:25:20 Done.
13 #include "extensions/browser/process_manager.h"
14 #include "extensions/common/extension.h"
15 #endif
16
17 using blink::WebContextMenuData; 12 using blink::WebContextMenuData;
18 using content::WebContents; 13 using content::WebContents;
19 14
20 #if defined(ENABLE_EXTENSIONS)
21 using extensions::Extension;
22 using extensions::ProcessManager;
23 #endif
24
25 namespace { 15 namespace {
26 16
27 bool IsDevToolsURL(const GURL& url) { 17 bool IsDevToolsURL(const GURL& url) {
28 return url.SchemeIs(content::kChromeDevToolsScheme); 18 return url.SchemeIs(content::kChromeDevToolsScheme);
29 } 19 }
30 20
31 bool DefaultIsInternalResourcesURL(const GURL& url) { 21 bool DefaultIsInternalResourcesURL(const GURL& url) {
32 return url.SchemeIs(content::kChromeUIScheme); 22 return url.SchemeIs(content::kChromeUIScheme);
33 } 23 }
34 24
35 } // namespace 25 } // namespace
36 26
37 ContextMenuContentType::ContextMenuContentType( 27 ContextMenuContentType::ContextMenuContentType(
38 content::WebContents* web_contents, 28 content::WebContents* web_contents,
39 const content::ContextMenuParams& params, 29 const content::ContextMenuParams& params,
40 bool supports_custom_items) 30 bool supports_custom_items)
41 : params_(params), 31 : params_(params),
42 source_web_contents_(web_contents), 32 source_web_contents_(web_contents),
43 supports_custom_items_(supports_custom_items), 33 supports_custom_items_(supports_custom_items),
44 internal_resources_url_checker_( 34 internal_resources_url_checker_(
45 base::Bind(&DefaultIsInternalResourcesURL)) { 35 base::Bind(&DefaultIsInternalResourcesURL)) {
46 } 36 }
47 37
48 ContextMenuContentType::~ContextMenuContentType() { 38 ContextMenuContentType::~ContextMenuContentType() {
49 } 39 }
50 40
51 #if defined(ENABLE_EXTENSIONS)
52 const Extension* ContextMenuContentType::GetExtension() const {
53 ProcessManager* process_manager =
54 ProcessManager::Get(source_web_contents_->GetBrowserContext());
55 return process_manager->GetExtensionForWebContents(
56 source_web_contents_);
57 }
58 #endif
59
60 bool ContextMenuContentType::SupportsGroup(int group) { 41 bool ContextMenuContentType::SupportsGroup(int group) {
61 const bool has_selection = !params_.selection_text.empty(); 42 const bool has_selection = !params_.selection_text.empty();
62 43
63 if (supports_custom_items_ && !params_.custom_items.empty()) { 44 if (supports_custom_items_ && !params_.custom_items.empty()) {
64 if (group == ITEM_GROUP_CUSTOM) 45 if (group == ITEM_GROUP_CUSTOM)
65 return true; 46 return true;
66 47
67 if (!has_selection) { 48 if (!has_selection) {
68 // For menus with custom items, if there is no selection, we do not 49 // For menus with custom items, if there is no selection, we do not
69 // add items other than developer items. And for Pepper menu, don't even 50 // add items other than developer items. And for Pepper menu, don't even
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 163
183 default: 164 default:
184 NOTREACHED(); 165 NOTREACHED();
185 return false; 166 return false;
186 } 167 }
187 } 168 }
188 169
189 bool ContextMenuContentType::IsInternalResourcesURL(const GURL& url) { 170 bool ContextMenuContentType::IsInternalResourcesURL(const GURL& url) {
190 return internal_resources_url_checker_.Run(url); 171 return internal_resources_url_checker_.Run(url);
191 } 172 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698