Update broken references to image assets
[chromium-blink-merge.git] / extensions / browser / guest_view / mime_handler_view / mime_handler_view_guest.h
blob5a2b016935883e0d8a91b70e4d2b969a354e26b0
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 ShouldHandleFindRequestsForEmbedder() const override;
68 bool ZoomPropagatesFromEmbedderToGuest() const override;
70 // WebContentsDelegate implementation.
71 content::WebContents* OpenURLFromTab(
72 content::WebContents* source,
73 const content::OpenURLParams& params) override;
74 bool HandleContextMenu(const content::ContextMenuParams& params) override;
75 bool PreHandleGestureEvent(content::WebContents* source,
76 const blink::WebGestureEvent& event) override;
77 content::JavaScriptDialogManager* GetJavaScriptDialogManager(
78 content::WebContents* source) override;
79 void FindReply(content::WebContents* web_contents,
80 int request_id,
81 int number_of_matches,
82 const gfx::Rect& selection_rect,
83 int active_match_ordinal,
84 bool final_update) override;
85 bool SaveFrame(const GURL& url, const content::Referrer& referrer) override;
87 // content::WebContentsObserver implementation.
88 void DocumentOnLoadCompletedInMainFrame() override;
90 std::string view_id() const { return view_id_; }
91 base::WeakPtr<StreamContainer> GetStream() const;
93 protected:
94 explicit MimeHandlerViewGuest(content::WebContents* owner_web_contents);
95 ~MimeHandlerViewGuest() override;
97 private:
98 scoped_ptr<MimeHandlerViewGuestDelegate> delegate_;
99 scoped_ptr<StreamContainer> stream_;
100 std::string view_id_;
102 DISALLOW_COPY_AND_ASSIGN(MimeHandlerViewGuest);
105 } // namespace extensions
107 #endif // EXTENSIONS_BROWSER_GUEST_VIEW_MIME_HANDLER_VIEW_MIME_HANDLER_VIEW_GUEST_H_