Allow only one bookmark to be added for multiple fast starring
[chromium-blink-merge.git] / extensions / browser / guest_view / mime_handler_view / mime_handler_view_guest.h
blob33ff28ea3bf61d35e2e7fe73f0e5882163eca485
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 "components/guest_view/browser/guest_view.h"
11 namespace content {
12 class WebContents;
13 struct ContextMenuParams;
14 struct StreamInfo;
15 } // namespace content
17 namespace extensions {
18 class MimeHandlerViewGuestDelegate;
20 // A container for a StreamHandle and any other information necessary for a
21 // MimeHandler to handle a resource stream.
22 class StreamContainer {
23 public:
24 StreamContainer(scoped_ptr<content::StreamInfo> stream,
25 int tab_id,
26 bool embedded,
27 const GURL& handler_url,
28 const std::string& extension_id);
29 ~StreamContainer();
31 // Aborts the stream.
32 void Abort(const base::Closure& callback);
34 base::WeakPtr<StreamContainer> GetWeakPtr();
36 const content::StreamInfo* stream_info() const { return stream_.get(); }
37 bool embedded() const { return embedded_; }
38 int tab_id() const { return tab_id_; }
39 GURL handler_url() const { return handler_url_; }
40 std::string extension_id() const { return extension_id_; }
42 private:
43 const scoped_ptr<content::StreamInfo> stream_;
44 const bool embedded_;
45 const int tab_id_;
46 const GURL handler_url_;
47 const std::string extension_id_;
49 base::WeakPtrFactory<StreamContainer> weak_factory_;
52 class MimeHandlerViewGuest :
53 public guest_view::GuestView<MimeHandlerViewGuest> {
54 public:
55 static guest_view::GuestViewBase* Create(
56 content::WebContents* owner_web_contents);
58 static const char Type[];
60 // GuestViewBase implementation.
61 const char* GetAPINamespace() const override;
62 int GetTaskPrefix() const override;
63 void CreateWebContents(const base::DictionaryValue& create_params,
64 const WebContentsCreatedCallback& callback) override;
65 void DidAttachToEmbedder() override;
66 void DidInitialize(const base::DictionaryValue& create_params) override;
67 bool ZoomPropagatesFromEmbedderToGuest() const override;
69 // content::BrowserPluginGuestDelegate implementation
70 bool Find(int request_id,
71 const base::string16& search_text,
72 const blink::WebFindOptions& options) override;
73 bool StopFinding(content::StopFindAction action) override;
75 // WebContentsDelegate implementation.
76 content::WebContents* OpenURLFromTab(
77 content::WebContents* source,
78 const content::OpenURLParams& params) override;
79 bool HandleContextMenu(const content::ContextMenuParams& params) override;
80 bool PreHandleGestureEvent(content::WebContents* source,
81 const blink::WebGestureEvent& event) override;
82 content::JavaScriptDialogManager* GetJavaScriptDialogManager(
83 content::WebContents* source) override;
84 void FindReply(content::WebContents* web_contents,
85 int request_id,
86 int number_of_matches,
87 const gfx::Rect& selection_rect,
88 int active_match_ordinal,
89 bool final_update) override;
90 bool SaveFrame(const GURL& url, const content::Referrer& referrer) override;
92 // content::WebContentsObserver implementation.
93 void DocumentOnLoadCompletedInMainFrame() override;
95 std::string view_id() const { return view_id_; }
96 base::WeakPtr<StreamContainer> GetStream() const;
98 protected:
99 explicit MimeHandlerViewGuest(content::WebContents* owner_web_contents);
100 ~MimeHandlerViewGuest() override;
102 private:
103 scoped_ptr<MimeHandlerViewGuestDelegate> delegate_;
104 scoped_ptr<StreamContainer> stream_;
105 std::string view_id_;
107 DISALLOW_COPY_AND_ASSIGN(MimeHandlerViewGuest);
110 } // namespace extensions
112 #endif // EXTENSIONS_BROWSER_GUEST_VIEW_MIME_HANDLER_VIEW_MIME_HANDLER_VIEW_GUEST_H_