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

Side by Side Diff: chrome/browser/chromeos/first_run/drive_first_run_controller.cc

Issue 2882513005: Propagate opener to BackgroundsContents. (Closed)
Patch Set: Tweaked the comment in DriveWebContentsManager::ShouldCreateWebContents Created 3 years, 6 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
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/chromeos/first_run/drive_first_run_controller.h" 5 #include "chrome/browser/chromeos/first_run/drive_first_run_controller.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "ash/shell.h" 10 #include "ash/shell.h"
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 156
157 void DidFailLoad(content::RenderFrameHost* render_frame_host, 157 void DidFailLoad(content::RenderFrameHost* render_frame_host,
158 const GURL& validated_url, 158 const GURL& validated_url,
159 int error_code, 159 int error_code,
160 const base::string16& error_description, 160 const base::string16& error_description,
161 bool was_ignored_by_handler) override; 161 bool was_ignored_by_handler) override;
162 162
163 // content::WebContentsDelegate overrides: 163 // content::WebContentsDelegate overrides:
164 bool ShouldCreateWebContents( 164 bool ShouldCreateWebContents(
165 content::WebContents* web_contents, 165 content::WebContents* web_contents,
166 content::RenderFrameHost* opener,
166 content::SiteInstance* source_site_instance, 167 content::SiteInstance* source_site_instance,
167 int32_t route_id, 168 int32_t route_id,
168 int32_t main_frame_route_id, 169 int32_t main_frame_route_id,
169 int32_t main_frame_widget_route_id, 170 int32_t main_frame_widget_route_id,
170 content::mojom::WindowContainerType window_container_type, 171 content::mojom::WindowContainerType window_container_type,
171 const GURL& opener_url, 172 const GURL& opener_url,
172 const std::string& frame_name, 173 const std::string& frame_name,
173 const GURL& target_url, 174 const GURL& target_url,
174 const std::string& partition_id, 175 const std::string& partition_id,
175 content::SessionStorageNamespace* session_storage_namespace) override; 176 content::SessionStorageNamespace* session_storage_namespace) override;
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 bool was_ignored_by_handler) { 270 bool was_ignored_by_handler) {
270 if (!render_frame_host->GetParent()) { 271 if (!render_frame_host->GetParent()) {
271 LOG(WARNING) << "Failed to load WebContents to enable offline mode."; 272 LOG(WARNING) << "Failed to load WebContents to enable offline mode.";
272 OnOfflineInit(false, 273 OnOfflineInit(false,
273 DriveFirstRunController::OUTCOME_WEB_CONTENTS_LOAD_FAILED); 274 DriveFirstRunController::OUTCOME_WEB_CONTENTS_LOAD_FAILED);
274 } 275 }
275 } 276 }
276 277
277 bool DriveWebContentsManager::ShouldCreateWebContents( 278 bool DriveWebContentsManager::ShouldCreateWebContents(
278 content::WebContents* web_contents, 279 content::WebContents* web_contents,
280 content::RenderFrameHost* opener,
279 content::SiteInstance* source_site_instance, 281 content::SiteInstance* source_site_instance,
280 int32_t route_id, 282 int32_t route_id,
281 int32_t main_frame_route_id, 283 int32_t main_frame_route_id,
282 int32_t main_frame_widget_route_id, 284 int32_t main_frame_widget_route_id,
283 content::mojom::WindowContainerType window_container_type, 285 content::mojom::WindowContainerType window_container_type,
284 const GURL& opener_url, 286 const GURL& opener_url,
285 const std::string& frame_name, 287 const std::string& frame_name,
286 const GURL& target_url, 288 const GURL& target_url,
287 const std::string& partition_id, 289 const std::string& partition_id,
288 content::SessionStorageNamespace* session_storage_namespace) { 290 content::SessionStorageNamespace* session_storage_namespace) {
(...skipping 10 matching lines...) Expand all
299 // The background contents creation is normally done in Browser, but 301 // The background contents creation is normally done in Browser, but
300 // because we're using a detached WebContents, we need to do it ourselves. 302 // because we're using a detached WebContents, we need to do it ourselves.
301 BackgroundContentsService* background_contents_service = 303 BackgroundContentsService* background_contents_service =
302 BackgroundContentsServiceFactory::GetForProfile(profile_); 304 BackgroundContentsServiceFactory::GetForProfile(profile_);
303 305
304 // Prevent redirection if background contents already exists. 306 // Prevent redirection if background contents already exists.
305 if (background_contents_service->GetAppBackgroundContents( 307 if (background_contents_service->GetAppBackgroundContents(
306 base::UTF8ToUTF16(app_id_))) { 308 base::UTF8ToUTF16(app_id_))) {
307 return false; 309 return false;
308 } 310 }
309 // We are creating a new SiteInstance (and thus a new renderer process) here, 311 // drive_first_run/app/manifest.json sets allow_js_access to false and
310 // so we must not use |route_id|, etc, which are IDs in a different process. 312 // therefore we are creating a new SiteInstance (and thus a new renderer
313 // process) here, so we must use MSG_ROUTING_NONE and we cannot pass the
314 // opener (similarily to how allow_js_access:false is handled in
315 // Browser::MaybeCreateBackgroundContents).
311 BackgroundContents* contents = 316 BackgroundContents* contents =
312 background_contents_service->CreateBackgroundContents( 317 background_contents_service->CreateBackgroundContents(
313 content::SiteInstance::Create(profile_), MSG_ROUTING_NONE, 318 content::SiteInstance::Create(profile_), nullptr, MSG_ROUTING_NONE,
314 MSG_ROUTING_NONE, MSG_ROUTING_NONE, profile_, frame_name, 319 MSG_ROUTING_NONE, MSG_ROUTING_NONE, profile_, frame_name,
315 base::ASCIIToUTF16(app_id_), partition_id, session_storage_namespace); 320 base::ASCIIToUTF16(app_id_), partition_id, session_storage_namespace);
316 321
317 contents->web_contents()->GetController().LoadURL( 322 contents->web_contents()->GetController().LoadURL(
318 target_url, 323 target_url,
319 content::Referrer(), 324 content::Referrer(),
320 ui::PAGE_TRANSITION_LINK, 325 ui::PAGE_TRANSITION_LINK,
321 std::string()); 326 std::string());
322 327
323 // Return false as we already created the WebContents here. 328 // Return false as we already created the WebContents here.
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
469 base::UTF8ToUTF16(extension->name()), GURL(), 474 base::UTF8ToUTF16(extension->name()), GURL(),
470 message_center::NotifierId(message_center::NotifierId::APPLICATION, 475 message_center::NotifierId(message_center::NotifierId::APPLICATION,
471 kDriveHostedAppId), 476 kDriveHostedAppId),
472 data, new DriveOfflineNotificationDelegate(profile_))); 477 data, new DriveOfflineNotificationDelegate(profile_)));
473 notification->set_priority(message_center::LOW_PRIORITY); 478 notification->set_priority(message_center::LOW_PRIORITY);
474 message_center::MessageCenter::Get()->AddNotification( 479 message_center::MessageCenter::Get()->AddNotification(
475 std::move(notification)); 480 std::move(notification));
476 } 481 }
477 482
478 } // namespace chromeos 483 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698