| 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/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/common/system/tray/system_tray_delegate.h" | 10 #include "ash/common/system/tray/system_tray_delegate.h" |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 | 158 |
| 159 void DidFailLoad(content::RenderFrameHost* render_frame_host, | 159 void DidFailLoad(content::RenderFrameHost* render_frame_host, |
| 160 const GURL& validated_url, | 160 const GURL& validated_url, |
| 161 int error_code, | 161 int error_code, |
| 162 const base::string16& error_description, | 162 const base::string16& error_description, |
| 163 bool was_ignored_by_handler) override; | 163 bool was_ignored_by_handler) override; |
| 164 | 164 |
| 165 // content::WebContentsDelegate overrides: | 165 // content::WebContentsDelegate overrides: |
| 166 bool ShouldCreateWebContents( | 166 bool ShouldCreateWebContents( |
| 167 content::WebContents* web_contents, | 167 content::WebContents* web_contents, |
| 168 content::SiteInstance* source_site_instance, |
| 168 int32_t route_id, | 169 int32_t route_id, |
| 169 int32_t main_frame_route_id, | 170 int32_t main_frame_route_id, |
| 170 int32_t main_frame_widget_route_id, | 171 int32_t main_frame_widget_route_id, |
| 171 WindowContainerType window_container_type, | 172 WindowContainerType window_container_type, |
| 173 const GURL& opener_url, |
| 172 const std::string& frame_name, | 174 const std::string& frame_name, |
| 173 const GURL& target_url, | 175 const GURL& target_url, |
| 174 const std::string& partition_id, | 176 const std::string& partition_id, |
| 175 content::SessionStorageNamespace* session_storage_namespace) override; | 177 content::SessionStorageNamespace* session_storage_namespace) override; |
| 176 | 178 |
| 177 // content::NotificationObserver overrides: | 179 // content::NotificationObserver overrides: |
| 178 void Observe(int type, | 180 void Observe(int type, |
| 179 const content::NotificationSource& source, | 181 const content::NotificationSource& source, |
| 180 const content::NotificationDetails& details) override; | 182 const content::NotificationDetails& details) override; |
| 181 | 183 |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 bool was_ignored_by_handler) { | 275 bool was_ignored_by_handler) { |
| 274 if (!render_frame_host->GetParent()) { | 276 if (!render_frame_host->GetParent()) { |
| 275 LOG(WARNING) << "Failed to load WebContents to enable offline mode."; | 277 LOG(WARNING) << "Failed to load WebContents to enable offline mode."; |
| 276 OnOfflineInit(false, | 278 OnOfflineInit(false, |
| 277 DriveFirstRunController::OUTCOME_WEB_CONTENTS_LOAD_FAILED); | 279 DriveFirstRunController::OUTCOME_WEB_CONTENTS_LOAD_FAILED); |
| 278 } | 280 } |
| 279 } | 281 } |
| 280 | 282 |
| 281 bool DriveWebContentsManager::ShouldCreateWebContents( | 283 bool DriveWebContentsManager::ShouldCreateWebContents( |
| 282 content::WebContents* web_contents, | 284 content::WebContents* web_contents, |
| 285 content::SiteInstance* source_site_instance, |
| 283 int32_t route_id, | 286 int32_t route_id, |
| 284 int32_t main_frame_route_id, | 287 int32_t main_frame_route_id, |
| 285 int32_t main_frame_widget_route_id, | 288 int32_t main_frame_widget_route_id, |
| 286 WindowContainerType window_container_type, | 289 WindowContainerType window_container_type, |
| 290 const GURL& opener_url, |
| 287 const std::string& frame_name, | 291 const std::string& frame_name, |
| 288 const GURL& target_url, | 292 const GURL& target_url, |
| 289 const std::string& partition_id, | 293 const std::string& partition_id, |
| 290 content::SessionStorageNamespace* session_storage_namespace) { | 294 content::SessionStorageNamespace* session_storage_namespace) { |
| 291 if (window_container_type == WINDOW_CONTAINER_TYPE_NORMAL) | 295 if (window_container_type == WINDOW_CONTAINER_TYPE_NORMAL) |
| 292 return true; | 296 return true; |
| 293 | 297 |
| 294 // Check that the target URL is for the Drive app. | 298 // Check that the target URL is for the Drive app. |
| 295 const extensions::Extension* extension = | 299 const extensions::Extension* extension = |
| 296 extensions::ExtensionRegistry::Get(profile_) | 300 extensions::ExtensionRegistry::Get(profile_) |
| 297 ->enabled_extensions().GetAppByURL(target_url); | 301 ->enabled_extensions().GetAppByURL(target_url); |
| 298 if (!extension || extension->id() != app_id_) | 302 if (!extension || extension->id() != app_id_) |
| 299 return true; | 303 return true; |
| 300 | 304 |
| 301 // The background contents creation is normally done in Browser, but | 305 // The background contents creation is normally done in Browser, but |
| 302 // because we're using a detached WebContents, we need to do it ourselves. | 306 // because we're using a detached WebContents, we need to do it ourselves. |
| 303 BackgroundContentsService* background_contents_service = | 307 BackgroundContentsService* background_contents_service = |
| 304 BackgroundContentsServiceFactory::GetForProfile(profile_); | 308 BackgroundContentsServiceFactory::GetForProfile(profile_); |
| 305 | 309 |
| 306 // Prevent redirection if background contents already exists. | 310 // Prevent redirection if background contents already exists. |
| 307 if (background_contents_service->GetAppBackgroundContents( | 311 if (background_contents_service->GetAppBackgroundContents( |
| 308 base::UTF8ToUTF16(app_id_))) { | 312 base::UTF8ToUTF16(app_id_))) { |
| 309 return false; | 313 return false; |
| 310 } | 314 } |
| 315 // We are creating a new SiteInstance (and thus a new renderer process) here, |
| 316 // so we must not use |route_id|, etc, which are IDs in a different process. |
| 311 BackgroundContents* contents = | 317 BackgroundContents* contents = |
| 312 background_contents_service->CreateBackgroundContents( | 318 background_contents_service->CreateBackgroundContents( |
| 313 content::SiteInstance::Create(profile_), route_id, | 319 content::SiteInstance::Create(profile_), MSG_ROUTING_NONE, |
| 314 main_frame_route_id, main_frame_widget_route_id, profile_, frame_name, | 320 MSG_ROUTING_NONE, MSG_ROUTING_NONE, profile_, frame_name, |
| 315 base::ASCIIToUTF16(app_id_), partition_id, session_storage_namespace); | 321 base::ASCIIToUTF16(app_id_), partition_id, session_storage_namespace); |
| 316 | 322 |
| 317 contents->web_contents()->GetController().LoadURL( | 323 contents->web_contents()->GetController().LoadURL( |
| 318 target_url, | 324 target_url, |
| 319 content::Referrer(), | 325 content::Referrer(), |
| 320 ui::PAGE_TRANSITION_LINK, | 326 ui::PAGE_TRANSITION_LINK, |
| 321 std::string()); | 327 std::string()); |
| 322 | 328 |
| 323 // Return false as we already created the WebContents here. | 329 // Return false as we already created the WebContents here. |
| 324 return false; | 330 return false; |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 469 base::UTF8ToUTF16(extension->name()), GURL(), | 475 base::UTF8ToUTF16(extension->name()), GURL(), |
| 470 message_center::NotifierId(message_center::NotifierId::APPLICATION, | 476 message_center::NotifierId(message_center::NotifierId::APPLICATION, |
| 471 kDriveHostedAppId), | 477 kDriveHostedAppId), |
| 472 data, new DriveOfflineNotificationDelegate(profile_))); | 478 data, new DriveOfflineNotificationDelegate(profile_))); |
| 473 notification->set_priority(message_center::LOW_PRIORITY); | 479 notification->set_priority(message_center::LOW_PRIORITY); |
| 474 message_center::MessageCenter::Get()->AddNotification( | 480 message_center::MessageCenter::Get()->AddNotification( |
| 475 std::move(notification)); | 481 std::move(notification)); |
| 476 } | 482 } |
| 477 | 483 |
| 478 } // namespace chromeos | 484 } // namespace chromeos |
| OLD | NEW |