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

Side by Side Diff: chrome/browser/chromeos/arc/open_with_menu_controller_delegate.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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_CHROMEOS_ARC_OPEN_WITH_MENU_CONTROLLER_DELEGATE_H_
6 #define CHROME_BROWSER_CHROMEOS_ARC_OPEN_WITH_MENU_CONTROLLER_DELEGATE_H_
7
8 #include <unordered_map>
9
hidehiko 2016/03/16 02:23:53 nit: #include <utility> here for std::pair
Yusuke Sato 2016/03/31 14:46:29 Done.
10 #include "base/compiler_specific.h"
11 #include "base/macros.h"
12 #include "base/memory/weak_ptr.h"
13 #include "base/strings/string16.h"
14 #include "base/timer/timer.h"
15 #include "components/arc/common/intent_helper.mojom.h"
16 #include "components/renderer_context_menu/render_view_context_menu_observer.h"
17 #include "ui/base/models/simple_menu_model.h"
18 #include "url/gurl.h"
19
20 class RenderViewContextMenuProxy;
21
22 namespace arc {
23
24 class ArcBridgeService;
25
26 // A class for populating "Open with <ARC app>" menu items in a renderer context
27 // menu.
28 class OpenWithMenuControllerDelegate {
29 public:
30 using HandlerMap = std::unordered_map<int, UrlHandlerInfoPtr>;
31
32 explicit OpenWithMenuControllerDelegate(ArcBridgeService* bridge_service);
33 ~OpenWithMenuControllerDelegate();
34
35 int Init(RenderViewContextMenuProxy* proxy,
36 int main_menu_id_start,
37 size_t num_main_menu_items,
38 const GURL& url);
39 void ExecuteCommand(int id);
40
41 static std::pair<HandlerMap, int> BuildHandlersMapForTesting(
42 int menu_id_start,
43 size_t num_menu_items,
44 mojo::Array<UrlHandlerInfoPtr> handlers);
45
46 private:
47 base::string16 GetLabelForCommandId(int command_id) const;
48 IntentHelperInstance* GetIntentHelper();
49
50 // A callback function called when a mojo IPC issued in InitMenu finishes.
51 void OnUrlHandlerList(mojo::Array<UrlHandlerInfoPtr> handlers);
52
53 // The callback function for base::RepeatingTimer. This function updates the
54 // "loading..." animation in the context-menu item.
55 void OnAnimationTimerExpired();
56
57 // The bridge service.
58 ArcBridgeService* const bridge_service_;
59
60 RenderViewContextMenuProxy* proxy_;
61 std::set<int> all_command_ids_;
62 int main_menu_id_start_;
63 size_t num_main_menu_items_;
64 GURL link_url_;
65 ui::SimpleMenuModel sub_menu_;
66
67 // The string used for animation until we receive a response from the ARC
68 // process. The current animation just adds periods at the end of this string:
69 // 'Loading' -> 'Loading.' -> 'Loading..' -> 'Loading...' (-> 'Loading')
70 base::string16 loading_message_;
71 size_t loading_frame_;
72
73 // A timer used for loading animation.
74 base::RepeatingTimer animation_timer_;
75
76 // A map from a command ID to a handler.
77 HandlerMap handlers_;
78
79 // Always keep this the last member of this class to make sure it's the
80 // first thing to be destructed.
81 base::WeakPtrFactory<OpenWithMenuControllerDelegate> weak_ptr_factory_;
82
83 DISALLOW_COPY_AND_ASSIGN(OpenWithMenuControllerDelegate);
84 };
85
86 } // namespace arc
87
88 #endif // CHROME_BROWSER_CHROMEOS_ARC_OPEN_WITH_MENU_CONTROLLER_DELEGATE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698