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

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

Issue 790423002: Add the main frame routing ID to WebContentsDelegate, use it in BackgroundContents. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: content shell Created 6 years 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 "ash/shell.h" 7 #include "ash/shell.h"
8 #include "ash/system/tray/system_tray_delegate.h" 8 #include "ash/system/tray/system_tray_delegate.h"
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/memory/weak_ptr.h" 10 #include "base/memory/weak_ptr.h"
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 156
157 virtual void DidFailLoad(content::RenderFrameHost* render_frame_host, 157 virtual 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) override; 160 const base::string16& error_description) override;
161 161
162 // content::WebContentsDelegate overrides: 162 // content::WebContentsDelegate overrides:
163 virtual bool ShouldCreateWebContents( 163 virtual bool ShouldCreateWebContents(
164 content::WebContents* web_contents, 164 content::WebContents* web_contents,
165 int route_id, 165 int route_id,
166 int main_frame_route_id,
166 WindowContainerType window_container_type, 167 WindowContainerType window_container_type,
167 const base::string16& frame_name, 168 const base::string16& frame_name,
168 const GURL& target_url, 169 const GURL& target_url,
169 const std::string& partition_id, 170 const std::string& partition_id,
170 content::SessionStorageNamespace* session_storage_namespace) override; 171 content::SessionStorageNamespace* session_storage_namespace) override;
171 172
172 // content::NotificationObserver overrides: 173 // content::NotificationObserver overrides:
173 virtual void Observe(int type, 174 virtual void Observe(int type,
174 const content::NotificationSource& source, 175 const content::NotificationSource& source,
175 const content::NotificationDetails& details) override; 176 const content::NotificationDetails& details) override;
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 if (!render_frame_host->GetParent()) { 270 if (!render_frame_host->GetParent()) {
270 LOG(WARNING) << "Failed to load WebContents to enable offline mode."; 271 LOG(WARNING) << "Failed to load WebContents to enable offline mode.";
271 OnOfflineInit(false, 272 OnOfflineInit(false,
272 DriveFirstRunController::OUTCOME_WEB_CONTENTS_LOAD_FAILED); 273 DriveFirstRunController::OUTCOME_WEB_CONTENTS_LOAD_FAILED);
273 } 274 }
274 } 275 }
275 276
276 bool DriveWebContentsManager::ShouldCreateWebContents( 277 bool DriveWebContentsManager::ShouldCreateWebContents(
277 content::WebContents* web_contents, 278 content::WebContents* web_contents,
278 int route_id, 279 int route_id,
280 int main_frame_route_id,
279 WindowContainerType window_container_type, 281 WindowContainerType window_container_type,
280 const base::string16& frame_name, 282 const base::string16& frame_name,
281 const GURL& target_url, 283 const GURL& target_url,
282 const std::string& partition_id, 284 const std::string& partition_id,
283 content::SessionStorageNamespace* session_storage_namespace) { 285 content::SessionStorageNamespace* session_storage_namespace) {
284 286
285 if (window_container_type == WINDOW_CONTAINER_TYPE_NORMAL) 287 if (window_container_type == WINDOW_CONTAINER_TYPE_NORMAL)
286 return true; 288 return true;
287 289
288 // Check that the target URL is for the Drive app. 290 // Check that the target URL is for the Drive app.
289 const extensions::Extension* extension = 291 const extensions::Extension* extension =
290 extensions::ExtensionRegistry::Get(profile_) 292 extensions::ExtensionRegistry::Get(profile_)
291 ->enabled_extensions().GetAppByURL(target_url); 293 ->enabled_extensions().GetAppByURL(target_url);
292 if (!extension || extension->id() != app_id_) 294 if (!extension || extension->id() != app_id_)
293 return true; 295 return true;
294 296
295 // The background contents creation is normally done in Browser, but 297 // The background contents creation is normally done in Browser, but
296 // because we're using a detached WebContents, we need to do it ourselves. 298 // because we're using a detached WebContents, we need to do it ourselves.
297 BackgroundContentsService* background_contents_service = 299 BackgroundContentsService* background_contents_service =
298 BackgroundContentsServiceFactory::GetForProfile(profile_); 300 BackgroundContentsServiceFactory::GetForProfile(profile_);
299 301
300 // Prevent redirection if background contents already exists. 302 // Prevent redirection if background contents already exists.
301 if (background_contents_service->GetAppBackgroundContents( 303 if (background_contents_service->GetAppBackgroundContents(
302 base::UTF8ToUTF16(app_id_))) { 304 base::UTF8ToUTF16(app_id_))) {
303 return false; 305 return false;
304 } 306 }
305 BackgroundContents* contents = background_contents_service 307 BackgroundContents* contents = background_contents_service
306 ->CreateBackgroundContents(content::SiteInstance::Create(profile_), 308 ->CreateBackgroundContents(content::SiteInstance::Create(profile_),
307 route_id, 309 route_id,
310 main_frame_route_id,
308 profile_, 311 profile_,
309 frame_name, 312 frame_name,
310 base::ASCIIToUTF16(app_id_), 313 base::ASCIIToUTF16(app_id_),
311 partition_id, 314 partition_id,
312 session_storage_namespace); 315 session_storage_namespace);
313 316
314 contents->web_contents()->GetController().LoadURL( 317 contents->web_contents()->GetController().LoadURL(
315 target_url, 318 target_url,
316 content::Referrer(), 319 content::Referrer(),
317 ui::PAGE_TRANSITION_LINK, 320 ui::PAGE_TRANSITION_LINK,
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 base::UTF8ToUTF16(extension->name()), 469 base::UTF8ToUTF16(extension->name()),
467 message_center::NotifierId(message_center::NotifierId::APPLICATION, 470 message_center::NotifierId(message_center::NotifierId::APPLICATION,
468 kDriveHostedAppId), 471 kDriveHostedAppId),
469 data, 472 data,
470 new DriveOfflineNotificationDelegate(profile_))); 473 new DriveOfflineNotificationDelegate(profile_)));
471 notification->set_priority(message_center::LOW_PRIORITY); 474 notification->set_priority(message_center::LOW_PRIORITY);
472 message_center::MessageCenter::Get()->AddNotification(notification.Pass()); 475 message_center::MessageCenter::Get()->AddNotification(notification.Pass());
473 } 476 }
474 477
475 } // namespace chromeos 478 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/background/background_contents_service.cc ('k') | chrome/browser/prerender/prerender_contents.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698