ozone: evdev: Sync caps lock LED state to evdev
[chromium-blink-merge.git] / extensions / browser / guest_view / mime_handler_view / mime_handler_view_guest.h
blobb9eb252469bd8563f5530523dba5f47ac32b4eb9
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
3 // found in the LICENSE file.
5 #ifndef EXTENSIONS_BROWSER_GUEST_VIEW_MIME_HANDLER_VIEW_MIME_HANDLER_VIEW_GUEST_H_
6 #define EXTENSIONS_BROWSER_GUEST_VIEW_MIME_HANDLER_VIEW_MIME_HANDLER_VIEW_GUEST_H_
8 #include "base/memory/weak_ptr.h"
9 #include "extensions/browser/extension_function_dispatcher.h"
10 #include "extensions/browser/guest_view/guest_view.h"
12 namespace content {
13 class WebContents;
14 struct ContextMenuParams;
15 struct StreamInfo;
16 } // namespace content
18 namespace extensions {
19 class MimeHandlerViewGuestDelegate;
21 // A container for a StreamHandle and any other information necessary for a
22 // MimeHandler to handle a resource stream.
23 class StreamContainer {
24 public:
25 StreamContainer(scoped_ptr<content::StreamInfo> stream,
26 int tab_id,
27 bool embedded,
28 const GURL& handler_url,
29 const std::string& extension_id);
30 ~StreamContainer();
32 // Aborts the stream.
33 void Abort(const base::Closure& callback);
35 base::WeakPtr<StreamContainer> GetWeakPtr();
37 const content::StreamInfo* stream_info() const { return stream_.get(); }
38 bool embedded() const { return embedded_; }
39 int tab_id() const { return tab_id_; }
40 GURL handler_url() const { return handler_url_; }
41 std::string extension_id() const { return extension_id_; }
43 private:
44 const scoped_ptr<content::StreamInfo> stream_;
45 const bool embedded_;
46 const int tab_id_;
47 const GURL handler_url_;
48 const std::string extension_id_;
50 base::WeakPtrFactory<StreamContainer> weak_factory_;
53 class MimeHandlerViewGuest : public GuestView<MimeHandlerViewGuest>,
54 public ExtensionFunctionDispatcher::Delegate {
55 public:
56 static GuestViewBase* Create(content::WebContents* owner_web_contents);
58 static const char Type[];
60 // ExtensionFunctionDispatcher::Delegate implementation.
61 WindowController* GetExtensionWindowController() const override;
62 content::WebContents* GetAssociatedWebContents() const override;
64 // GuestViewBase implementation.
65 const char* GetAPINamespace() const override;
66 int GetTaskPrefix() const override;
67 void CreateWebContents(const base::DictionaryValue& create_params,
68 const WebContentsCreatedCallback& callback) override;
69 void DidAttachToEmbedder() override;
70 void DidInitialize(const base::DictionaryValue& create_params) override;
71 bool ZoomPropagatesFromEmbedderToGuest() const override;
73 // content::BrowserPluginGuestDelegate implementation
74 bool Find(int request_id,
75 const base::string16& search_text,
76 const blink::WebFindOptions& options) override;
77 bool StopFinding(content::StopFindAction action) override;
79 // WebContentsDelegate implementation.
80 content::WebContents* OpenURLFromTab(
81 content::WebContents* source,
82 const content::OpenURLParams& params) override;
83 bool HandleContextMenu(const content::ContextMenuParams& params) override;
84 bool PreHandleGestureEvent(content::WebContents* source,
85 const blink::WebGestureEvent& event) override;
86 content::JavaScriptDialogManager* GetJavaScriptDialogManager(
87 content::WebContents* source) override;
88 void FindReply(content::WebContents* web_contents,
89 int request_id,
90 int number_of_matches,
91 const gfx::Rect& selection_rect,
92 int active_match_ordinal,
93 bool final_update) override;
94 bool SaveFrame(const GURL& url, const content::Referrer& referrer) override;
96 // content::WebContentsObserver implementation.
97 void DocumentOnLoadCompletedInMainFrame() override;
98 bool OnMessageReceived(const IPC::Message& message) override;
100 std::string view_id() const { return view_id_; }
101 base::WeakPtr<StreamContainer> GetStream() const;
103 private:
104 explicit MimeHandlerViewGuest(content::WebContents* owner_web_contents);
105 ~MimeHandlerViewGuest() override;
107 void OnRequest(const ExtensionHostMsg_Request_Params& params);
109 scoped_ptr<MimeHandlerViewGuestDelegate> delegate_;
110 scoped_ptr<ExtensionFunctionDispatcher> extension_function_dispatcher_;
111 scoped_ptr<StreamContainer> stream_;
112 std::string view_id_;
114 DISALLOW_COPY_AND_ASSIGN(MimeHandlerViewGuest);
117 } // namespace extensions
119 #endif // EXTENSIONS_BROWSER_GUEST_VIEW_MIME_HANDLER_VIEW_MIME_HANDLER_VIEW_GUEST_H_