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

Unified Diff: ash/renderer_context_menu/open_with_menu_controller.h

Issue 1760773004: Add "Open with <ARC-app-name>" items to the context menu (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: return std::pair Created 4 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: ash/renderer_context_menu/open_with_menu_controller.h
diff --git a/ash/renderer_context_menu/open_with_menu_controller.h b/ash/renderer_context_menu/open_with_menu_controller.h
new file mode 100644
index 0000000000000000000000000000000000000000..ed596d6bc67490025d4571ebd167481ed587b250
--- /dev/null
+++ b/ash/renderer_context_menu/open_with_menu_controller.h
@@ -0,0 +1,60 @@
+// Copyright 2016 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.
+
+#ifndef ASH_RENDERER_CONTEXT_MENU_OPEN_WITH_MENU_CONTROLLER_H_
+#define ASH_RENDERER_CONTEXT_MENU_OPEN_WITH_MENU_CONTROLLER_H_
+
+#include "ash/ash_export.h"
+#include "base/macros.h"
+
+class GURL;
+class RenderViewContextMenuProxy;
+
+namespace ash {
+
+// A class for populating and updating "Open with <app>" menu items in a
+// renderer context menu.
+class ASH_EXPORT OpenWithMenuController {
+ public:
+ class Delegate {
+ public:
+ virtual ~Delegate() {}
+ virtual int PopulateOpenWithMenu(RenderViewContextMenuProxy* proxy,
+ int menu_id_start,
+ size_t num_menu_items,
+ const GURL& url) = 0;
+ virtual void ExecuteCommand(int id) = 0;
+ virtual void MenuClosed() = 0;
+ };
+
+ OpenWithMenuController();
+ void SetDelegate(Delegate* delegate);
+
+ // Populates "Open with <app>" context menu items for the |url| either
+ // synchronously or asynchronously. Returns the number of menu items that have
+ // to be enabled right away. When there is nothing to do for the |url|, the
+ // function immediately returns 0. The function adds up to |num_menu_items|
+ // context menu items starting from |menu_id_start| to the |proxy|.
+ int PopulateOpenWithMenu(RenderViewContextMenuProxy* proxy,
+ int menu_id_start,
+ size_t num_menu_items,
+ const GURL& url);
+
+ // Notifies the controller that one of the items in the context menu is
+ // executed. This method can only be called after PopulateOpenWithMenu()
+ // is called and before MenuClosed() is called.
+ void ExecuteCommand(int id);
+
+ // Notifies the controller that the context menu is being closed.
+ void MenuClosed();
+
+ private:
+ Delegate* delegate_;
+
+ DISALLOW_COPY_AND_ASSIGN(OpenWithMenuController);
+};
+
+} // namespace ash
+
+#endif // ASH_RENDERER_CONTEXT_MENU_OPEN_WITH_MENU_CONTROLLER_H_

Powered by Google App Engine
This is Rietveld 408576698