OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "chrome/browser/extensions/api/tabs/ash_panel_contents.h" | 5 #include "chrome/browser/extensions/api/tabs/ash_panel_contents.h" |
6 | 6 |
7 #include "apps/ui/native_app_window.h" | 7 #include "apps/ui/native_app_window.h" |
8 #include "base/values.h" | 8 #include "base/values.h" |
9 #include "chrome/browser/chrome_notification_types.h" | 9 #include "chrome/browser/chrome_notification_types.h" |
10 #include "chrome/browser/extensions/api/tabs/tabs_constants.h" | 10 #include "chrome/browser/extensions/api/tabs/tabs_constants.h" |
11 #include "chrome/browser/extensions/api/tabs/tabs_windows_api.h" | 11 #include "chrome/browser/extensions/api/tabs/tabs_windows_api.h" |
12 #include "chrome/browser/extensions/api/tabs/windows_event_router.h" | 12 #include "chrome/browser/extensions/api/tabs/windows_event_router.h" |
13 #include "chrome/browser/extensions/extension_tab_util.h" | 13 #include "chrome/browser/extensions/extension_tab_util.h" |
14 #include "chrome/browser/extensions/window_controller_list.h" | 14 #include "chrome/browser/extensions/window_controller_list.h" |
15 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
16 #include "chrome/browser/sessions/session_tab_helper.h" | 16 #include "chrome/browser/sessions/session_tab_helper.h" |
17 #include "chrome/common/extensions/extension_messages.h" | 17 #include "chrome/common/extensions/extension_messages.h" |
18 #include "content/public/browser/browser_context.h" | |
19 #include "content/public/browser/site_instance.h" | 18 #include "content/public/browser/site_instance.h" |
20 #include "content/public/browser/web_contents.h" | 19 #include "content/public/browser/web_contents.h" |
21 #include "extensions/common/extension.h" | 20 #include "extensions/common/extension.h" |
22 #include "ui/gfx/image/image.h" | 21 #include "ui/gfx/image/image.h" |
23 | 22 |
24 using apps::ShellWindow; | 23 using apps::ShellWindow; |
25 using apps::NativeAppWindow; | 24 using apps::NativeAppWindow; |
26 | 25 |
27 // AshPanelWindowController ---------------------------------------------------- | 26 // AshPanelWindowController ---------------------------------------------------- |
28 | 27 |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 | 160 |
162 // AshPanelContents ----------------------------------------------------- | 161 // AshPanelContents ----------------------------------------------------- |
163 | 162 |
164 AshPanelContents::AshPanelContents(ShellWindow* host) | 163 AshPanelContents::AshPanelContents(ShellWindow* host) |
165 : host_(host) { | 164 : host_(host) { |
166 } | 165 } |
167 | 166 |
168 AshPanelContents::~AshPanelContents() { | 167 AshPanelContents::~AshPanelContents() { |
169 } | 168 } |
170 | 169 |
171 void AshPanelContents::Initialize(content::BrowserContext* context, | 170 void AshPanelContents::Initialize(Profile* profile, const GURL& url) { |
172 const GURL& url) { | |
173 url_ = url; | 171 url_ = url; |
174 | 172 |
175 extension_function_dispatcher_.reset( | 173 extension_function_dispatcher_.reset( |
176 new ExtensionFunctionDispatcher(context, this)); | 174 new ExtensionFunctionDispatcher(profile, this)); |
177 | 175 |
178 web_contents_.reset( | 176 web_contents_.reset(content::WebContents::Create( |
179 content::WebContents::Create(content::WebContents::CreateParams( | 177 content::WebContents::CreateParams( |
180 context, content::SiteInstance::CreateForURL(context, url_)))); | 178 profile, content::SiteInstance::CreateForURL(profile, url_)))); |
181 | 179 |
182 // Needed to give the web contents a Window ID. Extension APIs expect web | 180 // Needed to give the web contents a Window ID. Extension APIs expect web |
183 // contents to have a Window ID. Also required for FaviconTabHelper to | 181 // contents to have a Window ID. Also required for FaviconTabHelper to |
184 // correctly set the window icon and title. | 182 // correctly set the window icon and title. |
185 SessionTabHelper::CreateForWebContents(web_contents_.get()); | 183 SessionTabHelper::CreateForWebContents(web_contents_.get()); |
186 SessionTabHelper::FromWebContents(web_contents_.get())->SetWindowID( | 184 SessionTabHelper::FromWebContents(web_contents_.get())->SetWindowID( |
187 host_->session_id()); | 185 host_->session_id()); |
188 | 186 |
189 // Responsible for loading favicons for the Launcher, which uses different | 187 // Responsible for loading favicons for the Launcher, which uses different |
190 // logic than the FaviconTabHelper associated with web_contents_ | 188 // logic than the FaviconTabHelper associated with web_contents_ |
191 // (instantiated in ShellWindow::Init()) | 189 // (instantiated in ShellWindow::Init()) |
192 launcher_favicon_loader_.reset( | 190 launcher_favicon_loader_.reset( |
193 new LauncherFaviconLoader(this, web_contents_.get())); | 191 new LauncherFaviconLoader(this, web_contents_.get())); |
194 | 192 |
195 content::WebContentsObserver::Observe(web_contents_.get()); | 193 content::WebContentsObserver::Observe(web_contents_.get()); |
196 } | 194 } |
197 | 195 |
198 void AshPanelContents::LoadContents(int32 creator_process_id) { | 196 void AshPanelContents::LoadContents(int32 creator_process_id) { |
199 // This must be created after the native window has been created. | 197 // This must be created after the native window has been created. |
200 window_controller_.reset(new AshPanelWindowController( | 198 window_controller_.reset( |
201 host_, Profile::FromBrowserContext(host_->browser_context()))); | 199 new AshPanelWindowController(host_, host_->profile())); |
202 | 200 |
203 web_contents_->GetController().LoadURL( | 201 web_contents_->GetController().LoadURL( |
204 url_, content::Referrer(), content::PAGE_TRANSITION_LINK, | 202 url_, content::Referrer(), content::PAGE_TRANSITION_LINK, |
205 std::string()); | 203 std::string()); |
206 } | 204 } |
207 | 205 |
208 void AshPanelContents::NativeWindowChanged(NativeAppWindow* native_app_window) { | 206 void AshPanelContents::NativeWindowChanged(NativeAppWindow* native_app_window) { |
209 if (window_controller_) | 207 if (window_controller_) |
210 window_controller_->NativeWindowChanged(); | 208 window_controller_->NativeWindowChanged(); |
211 } | 209 } |
(...skipping 27 matching lines...) Expand all Loading... |
239 | 237 |
240 content::WebContents* AshPanelContents::GetAssociatedWebContents() const { | 238 content::WebContents* AshPanelContents::GetAssociatedWebContents() const { |
241 return web_contents_.get(); | 239 return web_contents_.get(); |
242 } | 240 } |
243 | 241 |
244 void AshPanelContents::OnRequest( | 242 void AshPanelContents::OnRequest( |
245 const ExtensionHostMsg_Request_Params& params) { | 243 const ExtensionHostMsg_Request_Params& params) { |
246 extension_function_dispatcher_->Dispatch( | 244 extension_function_dispatcher_->Dispatch( |
247 params, web_contents_->GetRenderViewHost()); | 245 params, web_contents_->GetRenderViewHost()); |
248 } | 246 } |
OLD | NEW |