Chromium Code Reviews| Index: chrome/browser/tab_contents/menu_category_factory.cc |
| diff --git a/chrome/browser/tab_contents/menu_category_factory.cc b/chrome/browser/tab_contents/menu_category_factory.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..d5a3042240d6f112a3e12d3189be376b272a7b13 |
| --- /dev/null |
| +++ b/chrome/browser/tab_contents/menu_category_factory.cc |
| @@ -0,0 +1,49 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "chrome/browser/tab_contents/menu_category_factory.h" |
| + |
| +#include "chrome/browser/app_mode/app_mode_utils.h" |
| +#include "chrome/browser/tab_contents/menu_category_app_mode.h" |
| +#include "chrome/browser/tab_contents/menu_category_base.h" |
| +#include "chrome/browser/tab_contents/menu_category_extension_popup.h" |
| +#include "chrome/browser/tab_contents/menu_category_guest.h" |
| +#include "chrome/browser/tab_contents/menu_category_panel.h" |
| +#include "chrome/browser/tab_contents/menu_category_platform_app.h" |
| +#include "content/public/browser/render_frame_host.h" |
| +#include "content/public/browser/render_process_host.h" |
| +#include "content/public/browser/web_contents.h" |
| +#include "extensions/browser/view_type_utils.h" |
| +#include "extensions/common/extension.h" |
| + |
| +MenuCategoryFactory::MenuCategoryFactory() { |
| +} |
| + |
| +MenuCategoryFactory::~MenuCategoryFactory() { |
| +} |
| + |
| +// static. |
| +MenuCategoryBase* MenuCategoryFactory::Create( |
| + content::WebContents* web_contents, |
| + content::RenderFrameHost* render_frame_host, |
| + const content::ContextMenuParams& params) { |
| + if (render_frame_host && render_frame_host->GetProcess()->IsGuest()) |
| + return new MenuCategoryGuest(render_frame_host, params); |
|
Fady Samuel
2014/02/24 19:07:29
I would love for this to be moved to chrome/browse
lazyboy
2014/02/24 23:45:00
Done.
|
| + |
| + if (chrome::IsRunningInForcedAppMode()) |
| + return new MenuCategoryAppMode(render_frame_host, params); |
| + |
| + const extensions::ViewType view_type = extensions::GetViewType(web_contents); |
| + |
| + if (view_type == extensions::VIEW_TYPE_APP_WINDOW) |
| + return new MenuCategoryPlatformApp(render_frame_host, params); |
| + |
| + if (view_type == extensions::VIEW_TYPE_EXTENSION_POPUP) |
| + return new MenuCategoryExtensionPopup(render_frame_host, params); |
| + |
| + if (view_type == extensions::VIEW_TYPE_PANEL) |
| + return new MenuCategoryPanel(render_frame_host, params); |
| + |
| + return new MenuCategoryBase(render_frame_host, params); |
| +} |