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 "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 Loading... |
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 int route_id, | 166 int32 route_id, |
167 int main_frame_route_id, | 167 int32 main_frame_route_id, |
| 168 int32 main_frame_widget_route_id, |
| 169 int32 surface_id, |
168 WindowContainerType window_container_type, | 170 WindowContainerType window_container_type, |
169 const std::string& frame_name, | 171 const std::string& frame_name, |
170 const GURL& target_url, | 172 const GURL& target_url, |
171 const std::string& partition_id, | 173 const std::string& partition_id, |
172 content::SessionStorageNamespace* session_storage_namespace) override; | 174 content::SessionStorageNamespace* session_storage_namespace) override; |
173 | 175 |
174 // content::NotificationObserver overrides: | 176 // content::NotificationObserver overrides: |
175 void Observe(int type, | 177 void Observe(int type, |
176 const content::NotificationSource& source, | 178 const content::NotificationSource& source, |
177 const content::NotificationDetails& details) override; | 179 const content::NotificationDetails& details) override; |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 bool was_ignored_by_handler) { | 274 bool was_ignored_by_handler) { |
273 if (!render_frame_host->GetParent()) { | 275 if (!render_frame_host->GetParent()) { |
274 LOG(WARNING) << "Failed to load WebContents to enable offline mode."; | 276 LOG(WARNING) << "Failed to load WebContents to enable offline mode."; |
275 OnOfflineInit(false, | 277 OnOfflineInit(false, |
276 DriveFirstRunController::OUTCOME_WEB_CONTENTS_LOAD_FAILED); | 278 DriveFirstRunController::OUTCOME_WEB_CONTENTS_LOAD_FAILED); |
277 } | 279 } |
278 } | 280 } |
279 | 281 |
280 bool DriveWebContentsManager::ShouldCreateWebContents( | 282 bool DriveWebContentsManager::ShouldCreateWebContents( |
281 content::WebContents* web_contents, | 283 content::WebContents* web_contents, |
282 int route_id, | 284 int32 route_id, |
283 int main_frame_route_id, | 285 int32 main_frame_route_id, |
| 286 int32 main_frame_widget_route_id, |
| 287 int32 surface_id, |
284 WindowContainerType window_container_type, | 288 WindowContainerType window_container_type, |
285 const std::string& frame_name, | 289 const std::string& frame_name, |
286 const GURL& target_url, | 290 const GURL& target_url, |
287 const std::string& partition_id, | 291 const std::string& partition_id, |
288 content::SessionStorageNamespace* session_storage_namespace) { | 292 content::SessionStorageNamespace* session_storage_namespace) { |
289 if (window_container_type == WINDOW_CONTAINER_TYPE_NORMAL) | 293 if (window_container_type == WINDOW_CONTAINER_TYPE_NORMAL) |
290 return true; | 294 return true; |
291 | 295 |
292 // Check that the target URL is for the Drive app. | 296 // Check that the target URL is for the Drive app. |
293 const extensions::Extension* extension = | 297 const extensions::Extension* extension = |
294 extensions::ExtensionRegistry::Get(profile_) | 298 extensions::ExtensionRegistry::Get(profile_) |
295 ->enabled_extensions().GetAppByURL(target_url); | 299 ->enabled_extensions().GetAppByURL(target_url); |
296 if (!extension || extension->id() != app_id_) | 300 if (!extension || extension->id() != app_id_) |
297 return true; | 301 return true; |
298 | 302 |
299 // The background contents creation is normally done in Browser, but | 303 // The background contents creation is normally done in Browser, but |
300 // because we're using a detached WebContents, we need to do it ourselves. | 304 // because we're using a detached WebContents, we need to do it ourselves. |
301 BackgroundContentsService* background_contents_service = | 305 BackgroundContentsService* background_contents_service = |
302 BackgroundContentsServiceFactory::GetForProfile(profile_); | 306 BackgroundContentsServiceFactory::GetForProfile(profile_); |
303 | 307 |
304 // Prevent redirection if background contents already exists. | 308 // Prevent redirection if background contents already exists. |
305 if (background_contents_service->GetAppBackgroundContents( | 309 if (background_contents_service->GetAppBackgroundContents( |
306 base::UTF8ToUTF16(app_id_))) { | 310 base::UTF8ToUTF16(app_id_))) { |
307 return false; | 311 return false; |
308 } | 312 } |
309 BackgroundContents* contents = background_contents_service | 313 BackgroundContents* contents = |
310 ->CreateBackgroundContents(content::SiteInstance::Create(profile_), | 314 background_contents_service->CreateBackgroundContents( |
311 route_id, | 315 content::SiteInstance::Create(profile_), route_id, |
312 main_frame_route_id, | 316 main_frame_route_id, main_frame_widget_route_id, surface_id, profile_, |
313 profile_, | 317 frame_name, base::ASCIIToUTF16(app_id_), partition_id, |
314 frame_name, | 318 session_storage_namespace); |
315 base::ASCIIToUTF16(app_id_), | |
316 partition_id, | |
317 session_storage_namespace); | |
318 | 319 |
319 contents->web_contents()->GetController().LoadURL( | 320 contents->web_contents()->GetController().LoadURL( |
320 target_url, | 321 target_url, |
321 content::Referrer(), | 322 content::Referrer(), |
322 ui::PAGE_TRANSITION_LINK, | 323 ui::PAGE_TRANSITION_LINK, |
323 std::string()); | 324 std::string()); |
324 | 325 |
325 // Return false as we already created the WebContents here. | 326 // Return false as we already created the WebContents here. |
326 return false; | 327 return false; |
327 } | 328 } |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
469 resource_bundle.GetImageNamed(IDR_NOTIFICATION_DRIVE), | 470 resource_bundle.GetImageNamed(IDR_NOTIFICATION_DRIVE), |
470 base::UTF8ToUTF16(extension->name()), GURL(), | 471 base::UTF8ToUTF16(extension->name()), GURL(), |
471 message_center::NotifierId(message_center::NotifierId::APPLICATION, | 472 message_center::NotifierId(message_center::NotifierId::APPLICATION, |
472 kDriveHostedAppId), | 473 kDriveHostedAppId), |
473 data, new DriveOfflineNotificationDelegate(profile_))); | 474 data, new DriveOfflineNotificationDelegate(profile_))); |
474 notification->set_priority(message_center::LOW_PRIORITY); | 475 notification->set_priority(message_center::LOW_PRIORITY); |
475 message_center::MessageCenter::Get()->AddNotification(notification.Pass()); | 476 message_center::MessageCenter::Get()->AddNotification(notification.Pass()); |
476 } | 477 } |
477 | 478 |
478 } // namespace chromeos | 479 } // namespace chromeos |
OLD | NEW |