OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "extensions/browser/guest_view/mime_handler_view/mime_handler_view_gues t.h" | 5 #include "extensions/browser/guest_view/mime_handler_view/mime_handler_view_gues t.h" |
6 | 6 |
7 #include "base/strings/stringprintf.h" | 7 #include "base/strings/stringprintf.h" |
8 #include "content/public/browser/browser_thread.h" | 8 #include "content/public/browser/browser_thread.h" |
9 #include "content/public/browser/render_process_host.h" | 9 #include "content/public/browser/render_process_host.h" |
10 #include "content/public/common/url_constants.h" | 10 #include "content/public/common/url_constants.h" |
11 #include "extensions/browser/api/extensions_api_client.h" | |
11 #include "extensions/browser/guest_view/guest_view_constants.h" | 12 #include "extensions/browser/guest_view/guest_view_constants.h" |
12 #include "extensions/browser/guest_view/guest_view_manager.h" | 13 #include "extensions/browser/guest_view/guest_view_manager.h" |
13 #include "extensions/browser/guest_view/mime_handler_view/mime_handler_view_cons tants.h" | 14 #include "extensions/browser/guest_view/mime_handler_view/mime_handler_view_cons tants.h" |
15 #include "extensions/browser/guest_view/mime_handler_view/mime_handler_view_gues t_delegate.h" | |
14 #include "extensions/common/feature_switch.h" | 16 #include "extensions/common/feature_switch.h" |
15 #include "extensions/strings/grit/extensions_strings.h" | 17 #include "extensions/strings/grit/extensions_strings.h" |
16 #include "net/base/url_util.h" | 18 #include "net/base/url_util.h" |
17 | 19 |
18 using content::WebContents; | 20 using content::WebContents; |
19 | 21 |
20 namespace extensions { | 22 namespace extensions { |
21 | 23 |
22 // static | 24 // static |
23 const char MimeHandlerViewGuest::Type[] = "mimehandler"; | 25 const char MimeHandlerViewGuest::Type[] = "mimehandler"; |
24 | 26 |
25 // static | 27 // static |
26 GuestViewBase* MimeHandlerViewGuest::Create( | 28 GuestViewBase* MimeHandlerViewGuest::Create( |
27 content::BrowserContext* browser_context, | 29 content::BrowserContext* browser_context, |
28 int guest_instance_id) { | 30 int guest_instance_id) { |
29 if (!extensions::FeatureSwitch::mime_handler_view()->IsEnabled()) | 31 if (!extensions::FeatureSwitch::mime_handler_view()->IsEnabled()) |
30 return NULL; | 32 return NULL; |
31 | 33 |
32 return new MimeHandlerViewGuest(browser_context, guest_instance_id); | 34 return new MimeHandlerViewGuest(browser_context, guest_instance_id); |
33 } | 35 } |
34 | 36 |
35 MimeHandlerViewGuest::MimeHandlerViewGuest( | 37 MimeHandlerViewGuest::MimeHandlerViewGuest( |
36 content::BrowserContext* browser_context, | 38 content::BrowserContext* browser_context, |
37 int guest_instance_id) | 39 int guest_instance_id) |
38 : GuestView<MimeHandlerViewGuest>(browser_context, guest_instance_id) { | 40 : GuestView<MimeHandlerViewGuest>(browser_context, guest_instance_id), |
41 delegate_( | |
42 ExtensionsAPIClient::Get()->CreateMimeHandlerViewGuestDelegate()) { | |
Fady Samuel
2014/09/09 14:30:29
Perhaps we can pass in "this" into "CreateMimeHand
lazyboy
2014/09/09 15:49:33
Done.
| |
39 } | 43 } |
40 | 44 |
41 MimeHandlerViewGuest::~MimeHandlerViewGuest() { | 45 MimeHandlerViewGuest::~MimeHandlerViewGuest() { |
42 } | 46 } |
43 | 47 |
44 const char* MimeHandlerViewGuest::GetAPINamespace() const { | 48 const char* MimeHandlerViewGuest::GetAPINamespace() const { |
45 return "mimeHandlerViewGuestInternal"; | 49 return "mimeHandlerViewGuestInternal"; |
46 } | 50 } |
47 | 51 |
48 int MimeHandlerViewGuest::GetTaskPrefix() const { | 52 int MimeHandlerViewGuest::GetTaskPrefix() const { |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
87 std::string src; | 91 std::string src; |
88 DCHECK(attach_params()->GetString(mime_handler_view::kSrc, &src) && | 92 DCHECK(attach_params()->GetString(mime_handler_view::kSrc, &src) && |
89 !src.empty()); | 93 !src.empty()); |
90 web_contents()->GetController().LoadURL( | 94 web_contents()->GetController().LoadURL( |
91 GURL(src), | 95 GURL(src), |
92 content::Referrer(), | 96 content::Referrer(), |
93 content::PAGE_TRANSITION_AUTO_TOPLEVEL, | 97 content::PAGE_TRANSITION_AUTO_TOPLEVEL, |
94 std::string()); | 98 std::string()); |
95 } | 99 } |
96 | 100 |
101 void MimeHandlerViewGuest::DidInitialize() { | |
102 if (delegate_) | |
103 delegate_->AttachHelpers(web_contents()); | |
Fady Samuel
2014/09/09 14:30:29
If the delegate_ knows about this, then we don't n
lazyboy
2014/09/09 15:49:33
Done.
| |
104 } | |
105 | |
97 } // namespace extensions | 106 } // namespace extensions |
OLD | NEW |