Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: trunk/src/chrome/browser/extensions/api/tabs/ash_panel_contents.cc

Issue 164613002: Revert 251094 "Revert 250826 "Remove Profile dependency from app..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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"
18 #include "content/public/browser/site_instance.h" 19 #include "content/public/browser/site_instance.h"
19 #include "content/public/browser/web_contents.h" 20 #include "content/public/browser/web_contents.h"
20 #include "extensions/common/extension.h" 21 #include "extensions/common/extension.h"
21 #include "ui/gfx/image/image.h" 22 #include "ui/gfx/image/image.h"
22 23
23 using apps::ShellWindow; 24 using apps::ShellWindow;
24 using apps::NativeAppWindow; 25 using apps::NativeAppWindow;
25 26
26 // AshPanelWindowController ---------------------------------------------------- 27 // AshPanelWindowController ----------------------------------------------------
27 28
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 161
161 // AshPanelContents ----------------------------------------------------- 162 // AshPanelContents -----------------------------------------------------
162 163
163 AshPanelContents::AshPanelContents(ShellWindow* host) 164 AshPanelContents::AshPanelContents(ShellWindow* host)
164 : host_(host) { 165 : host_(host) {
165 } 166 }
166 167
167 AshPanelContents::~AshPanelContents() { 168 AshPanelContents::~AshPanelContents() {
168 } 169 }
169 170
170 void AshPanelContents::Initialize(Profile* profile, const GURL& url) { 171 void AshPanelContents::Initialize(content::BrowserContext* context,
172 const GURL& url) {
171 url_ = url; 173 url_ = url;
172 174
173 extension_function_dispatcher_.reset( 175 extension_function_dispatcher_.reset(
174 new ExtensionFunctionDispatcher(profile, this)); 176 new ExtensionFunctionDispatcher(context, this));
175 177
176 web_contents_.reset(content::WebContents::Create( 178 web_contents_.reset(
177 content::WebContents::CreateParams( 179 content::WebContents::Create(content::WebContents::CreateParams(
178 profile, content::SiteInstance::CreateForURL(profile, url_)))); 180 context, content::SiteInstance::CreateForURL(context, url_))));
179 181
180 // Needed to give the web contents a Window ID. Extension APIs expect web 182 // Needed to give the web contents a Window ID. Extension APIs expect web
181 // contents to have a Window ID. Also required for FaviconTabHelper to 183 // contents to have a Window ID. Also required for FaviconTabHelper to
182 // correctly set the window icon and title. 184 // correctly set the window icon and title.
183 SessionTabHelper::CreateForWebContents(web_contents_.get()); 185 SessionTabHelper::CreateForWebContents(web_contents_.get());
184 SessionTabHelper::FromWebContents(web_contents_.get())->SetWindowID( 186 SessionTabHelper::FromWebContents(web_contents_.get())->SetWindowID(
185 host_->session_id()); 187 host_->session_id());
186 188
187 // Responsible for loading favicons for the Launcher, which uses different 189 // Responsible for loading favicons for the Launcher, which uses different
188 // logic than the FaviconTabHelper associated with web_contents_ 190 // logic than the FaviconTabHelper associated with web_contents_
189 // (instantiated in ShellWindow::Init()) 191 // (instantiated in ShellWindow::Init())
190 launcher_favicon_loader_.reset( 192 launcher_favicon_loader_.reset(
191 new LauncherFaviconLoader(this, web_contents_.get())); 193 new LauncherFaviconLoader(this, web_contents_.get()));
192 194
193 content::WebContentsObserver::Observe(web_contents_.get()); 195 content::WebContentsObserver::Observe(web_contents_.get());
194 } 196 }
195 197
196 void AshPanelContents::LoadContents(int32 creator_process_id) { 198 void AshPanelContents::LoadContents(int32 creator_process_id) {
197 // This must be created after the native window has been created. 199 // This must be created after the native window has been created.
198 window_controller_.reset( 200 window_controller_.reset(new AshPanelWindowController(
199 new AshPanelWindowController(host_, host_->profile())); 201 host_, Profile::FromBrowserContext(host_->browser_context())));
200 202
201 web_contents_->GetController().LoadURL( 203 web_contents_->GetController().LoadURL(
202 url_, content::Referrer(), content::PAGE_TRANSITION_LINK, 204 url_, content::Referrer(), content::PAGE_TRANSITION_LINK,
203 std::string()); 205 std::string());
204 } 206 }
205 207
206 void AshPanelContents::NativeWindowChanged(NativeAppWindow* native_app_window) { 208 void AshPanelContents::NativeWindowChanged(NativeAppWindow* native_app_window) {
207 if (window_controller_) 209 if (window_controller_)
208 window_controller_->NativeWindowChanged(); 210 window_controller_->NativeWindowChanged();
209 } 211 }
(...skipping 27 matching lines...) Expand all
237 239
238 content::WebContents* AshPanelContents::GetAssociatedWebContents() const { 240 content::WebContents* AshPanelContents::GetAssociatedWebContents() const {
239 return web_contents_.get(); 241 return web_contents_.get();
240 } 242 }
241 243
242 void AshPanelContents::OnRequest( 244 void AshPanelContents::OnRequest(
243 const ExtensionHostMsg_Request_Params& params) { 245 const ExtensionHostMsg_Request_Params& params) {
244 extension_function_dispatcher_->Dispatch( 246 extension_function_dispatcher_->Dispatch(
245 params, web_contents_->GetRenderViewHost()); 247 params, web_contents_->GetRenderViewHost());
246 } 248 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698