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 "apps/custom_launcher_page_contents.h" | 5 #include "apps/custom_launcher_page_contents.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "chrome/browser/chrome_notification_types.h" | 9 #include "chrome/browser/chrome_notification_types.h" |
10 #include "chrome/browser/extensions/chrome_extension_web_contents_observer.h" | 10 #include "chrome/browser/extensions/chrome_extension_web_contents_observer.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 scoped_ptr<extensions::AppDelegate> app_delegate, | 23 scoped_ptr<extensions::AppDelegate> app_delegate, |
24 const std::string& extension_id) | 24 const std::string& extension_id) |
25 : app_delegate_(app_delegate.Pass()), extension_id_(extension_id) { | 25 : app_delegate_(app_delegate.Pass()), extension_id_(extension_id) { |
26 } | 26 } |
27 | 27 |
28 CustomLauncherPageContents::~CustomLauncherPageContents() { | 28 CustomLauncherPageContents::~CustomLauncherPageContents() { |
29 } | 29 } |
30 | 30 |
31 void CustomLauncherPageContents::Initialize(content::BrowserContext* context, | 31 void CustomLauncherPageContents::Initialize(content::BrowserContext* context, |
32 const GURL& url) { | 32 const GURL& url) { |
33 extension_function_dispatcher_.reset( | |
34 new extensions::ExtensionFunctionDispatcher(context, this)); | |
35 | |
36 web_contents_.reset( | 33 web_contents_.reset( |
37 content::WebContents::Create(content::WebContents::CreateParams( | 34 content::WebContents::Create(content::WebContents::CreateParams( |
38 context, content::SiteInstance::CreateForURL(context, url)))); | 35 context, content::SiteInstance::CreateForURL(context, url)))); |
39 | 36 |
40 Observe(web_contents()); | |
41 web_contents_->GetMutableRendererPrefs() | 37 web_contents_->GetMutableRendererPrefs() |
42 ->browser_handles_all_top_level_requests = true; | 38 ->browser_handles_all_top_level_requests = true; |
43 web_contents_->GetRenderViewHost()->SyncRendererPrefs(); | 39 web_contents_->GetRenderViewHost()->SyncRendererPrefs(); |
44 | 40 |
45 helper_.reset(new extensions::AppWebContentsHelper( | 41 helper_.reset(new extensions::AppWebContentsHelper( |
46 context, extension_id_, web_contents_.get(), app_delegate_.get())); | 42 context, extension_id_, web_contents_.get(), app_delegate_.get())); |
47 web_contents_->SetDelegate(this); | 43 web_contents_->SetDelegate(this); |
48 | 44 |
49 extensions::SetViewType(web_contents(), extensions::VIEW_TYPE_LAUNCHER_PAGE); | 45 extensions::SetViewType(web_contents(), extensions::VIEW_TYPE_LAUNCHER_PAGE); |
50 | 46 |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 } | 124 } |
129 | 125 |
130 bool CustomLauncherPageContents::CheckMediaAccessPermission( | 126 bool CustomLauncherPageContents::CheckMediaAccessPermission( |
131 content::WebContents* web_contents, | 127 content::WebContents* web_contents, |
132 const GURL& security_origin, | 128 const GURL& security_origin, |
133 content::MediaStreamType type) { | 129 content::MediaStreamType type) { |
134 DCHECK_EQ(web_contents_.get(), web_contents); | 130 DCHECK_EQ(web_contents_.get(), web_contents); |
135 return helper_->CheckMediaAccessPermission(security_origin, type); | 131 return helper_->CheckMediaAccessPermission(security_origin, type); |
136 } | 132 } |
137 | 133 |
138 bool CustomLauncherPageContents::OnMessageReceived( | |
139 const IPC::Message& message) { | |
140 bool handled = true; | |
141 IPC_BEGIN_MESSAGE_MAP(CustomLauncherPageContents, message) | |
142 IPC_MESSAGE_HANDLER(ExtensionHostMsg_Request, OnRequest) | |
143 IPC_MESSAGE_UNHANDLED(handled = false) | |
144 IPC_END_MESSAGE_MAP() | |
145 return handled; | |
146 } | |
147 | |
148 extensions::WindowController* | |
149 CustomLauncherPageContents::GetExtensionWindowController() const { | |
150 return NULL; | |
151 } | |
152 | |
153 content::WebContents* CustomLauncherPageContents::GetAssociatedWebContents() | |
154 const { | |
155 return web_contents(); | |
156 } | |
157 | |
158 void CustomLauncherPageContents::OnRequest( | |
159 const ExtensionHostMsg_Request_Params& params) { | |
160 extension_function_dispatcher_->Dispatch(params, | |
161 web_contents_->GetRenderViewHost()); | |
162 } | |
163 | |
164 } // namespace apps | 134 } // namespace apps |
OLD | NEW |