| 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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 // Called when when offline initialization succeeds or fails and schedules | 120 // Called when when offline initialization succeeds or fails and schedules |
| 121 // |RunCompletionCallback|. | 121 // |RunCompletionCallback|. |
| 122 void OnOfflineInit(bool success); | 122 void OnOfflineInit(bool success); |
| 123 | 123 |
| 124 // Runs |completion_callback|. | 124 // Runs |completion_callback|. |
| 125 void RunCompletionCallback(bool success); | 125 void RunCompletionCallback(bool success); |
| 126 | 126 |
| 127 // content::WebContentsObserver overrides: | 127 // content::WebContentsObserver overrides: |
| 128 virtual void DidFailProvisionalLoad( | 128 virtual void DidFailProvisionalLoad( |
| 129 int64 frame_id, | 129 int64 frame_id, |
| 130 const string16& frame_unique_name, | 130 const base::string16& frame_unique_name, |
| 131 bool is_main_frame, | 131 bool is_main_frame, |
| 132 const GURL& validated_url, | 132 const GURL& validated_url, |
| 133 int error_code, | 133 int error_code, |
| 134 const string16& error_description, | 134 const base::string16& error_description, |
| 135 content::RenderViewHost* render_view_host) OVERRIDE; | 135 content::RenderViewHost* render_view_host) OVERRIDE; |
| 136 | 136 |
| 137 virtual void DidFailLoad(int64 frame_id, | 137 virtual void DidFailLoad(int64 frame_id, |
| 138 const GURL& validated_url, | 138 const GURL& validated_url, |
| 139 bool is_main_frame, | 139 bool is_main_frame, |
| 140 int error_code, | 140 int error_code, |
| 141 const string16& error_description, | 141 const base::string16& error_description, |
| 142 content::RenderViewHost* render_view_host) OVERRIDE; | 142 content::RenderViewHost* render_view_host) OVERRIDE; |
| 143 | 143 |
| 144 // content::WebContentsDelegate overrides: | 144 // content::WebContentsDelegate overrides: |
| 145 virtual bool ShouldCreateWebContents( | 145 virtual bool ShouldCreateWebContents( |
| 146 content::WebContents* web_contents, | 146 content::WebContents* web_contents, |
| 147 int route_id, | 147 int route_id, |
| 148 WindowContainerType window_container_type, | 148 WindowContainerType window_container_type, |
| 149 const string16& frame_name, | 149 const base::string16& frame_name, |
| 150 const GURL& target_url, | 150 const GURL& target_url, |
| 151 const std::string& partition_id, | 151 const std::string& partition_id, |
| 152 content::SessionStorageNamespace* session_storage_namespace) OVERRIDE; | 152 content::SessionStorageNamespace* session_storage_namespace) OVERRIDE; |
| 153 | 153 |
| 154 // content::NotificationObserver overrides: | 154 // content::NotificationObserver overrides: |
| 155 virtual void Observe(int type, | 155 virtual void Observe(int type, |
| 156 const content::NotificationSource& source, | 156 const content::NotificationSource& source, |
| 157 const content::NotificationDetails& details) OVERRIDE; | 157 const content::NotificationDetails& details) OVERRIDE; |
| 158 | 158 |
| 159 Profile* profile_; | 159 Profile* profile_; |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 StopLoad(); | 221 StopLoad(); |
| 222 } | 222 } |
| 223 } | 223 } |
| 224 | 224 |
| 225 void DriveWebContentsManager::RunCompletionCallback(bool success) { | 225 void DriveWebContentsManager::RunCompletionCallback(bool success) { |
| 226 completion_callback_.Run(success); | 226 completion_callback_.Run(success); |
| 227 } | 227 } |
| 228 | 228 |
| 229 void DriveWebContentsManager::DidFailProvisionalLoad( | 229 void DriveWebContentsManager::DidFailProvisionalLoad( |
| 230 int64 frame_id, | 230 int64 frame_id, |
| 231 const string16& frame_unique_name, | 231 const base::string16& frame_unique_name, |
| 232 bool is_main_frame, | 232 bool is_main_frame, |
| 233 const GURL& validated_url, | 233 const GURL& validated_url, |
| 234 int error_code, | 234 int error_code, |
| 235 const string16& error_description, | 235 const base::string16& error_description, |
| 236 content::RenderViewHost* render_view_host) { | 236 content::RenderViewHost* render_view_host) { |
| 237 if (is_main_frame) { | 237 if (is_main_frame) { |
| 238 LOG(WARNING) << "Failed to load WebContents to enable offline mode."; | 238 LOG(WARNING) << "Failed to load WebContents to enable offline mode."; |
| 239 OnOfflineInit(false); | 239 OnOfflineInit(false); |
| 240 } | 240 } |
| 241 } | 241 } |
| 242 | 242 |
| 243 void DriveWebContentsManager::DidFailLoad( | 243 void DriveWebContentsManager::DidFailLoad( |
| 244 int64 frame_id, | 244 int64 frame_id, |
| 245 const GURL& validated_url, | 245 const GURL& validated_url, |
| 246 bool is_main_frame, | 246 bool is_main_frame, |
| 247 int error_code, | 247 int error_code, |
| 248 const string16& error_description, | 248 const base::string16& error_description, |
| 249 content::RenderViewHost* render_view_host) { | 249 content::RenderViewHost* render_view_host) { |
| 250 if (is_main_frame) { | 250 if (is_main_frame) { |
| 251 LOG(WARNING) << "Failed to load WebContents to enable offline mode."; | 251 LOG(WARNING) << "Failed to load WebContents to enable offline mode."; |
| 252 OnOfflineInit(false); | 252 OnOfflineInit(false); |
| 253 } | 253 } |
| 254 } | 254 } |
| 255 | 255 |
| 256 bool DriveWebContentsManager::ShouldCreateWebContents( | 256 bool DriveWebContentsManager::ShouldCreateWebContents( |
| 257 content::WebContents* web_contents, | 257 content::WebContents* web_contents, |
| 258 int route_id, | 258 int route_id, |
| 259 WindowContainerType window_container_type, | 259 WindowContainerType window_container_type, |
| 260 const string16& frame_name, | 260 const base::string16& frame_name, |
| 261 const GURL& target_url, | 261 const GURL& target_url, |
| 262 const std::string& partition_id, | 262 const std::string& partition_id, |
| 263 content::SessionStorageNamespace* session_storage_namespace) { | 263 content::SessionStorageNamespace* session_storage_namespace) { |
| 264 | 264 |
| 265 if (window_container_type == WINDOW_CONTAINER_TYPE_NORMAL) | 265 if (window_container_type == WINDOW_CONTAINER_TYPE_NORMAL) |
| 266 return true; | 266 return true; |
| 267 | 267 |
| 268 // Check that the target URL is for the Drive app. | 268 // Check that the target URL is for the Drive app. |
| 269 ExtensionService* service = | 269 ExtensionService* service = |
| 270 extensions::ExtensionSystem::Get(profile_)->extension_service(); | 270 extensions::ExtensionSystem::Get(profile_)->extension_service(); |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 445 base::UTF8ToUTF16(extension->name()), | 445 base::UTF8ToUTF16(extension->name()), |
| 446 message_center::NotifierId(message_center::NotifierId::APPLICATION, | 446 message_center::NotifierId(message_center::NotifierId::APPLICATION, |
| 447 kDriveHostedAppId), | 447 kDriveHostedAppId), |
| 448 data, | 448 data, |
| 449 new DriveOfflineNotificationDelegate())); | 449 new DriveOfflineNotificationDelegate())); |
| 450 notification->set_priority(message_center::LOW_PRIORITY); | 450 notification->set_priority(message_center::LOW_PRIORITY); |
| 451 message_center::MessageCenter::Get()->AddNotification(notification.Pass()); | 451 message_center::MessageCenter::Get()->AddNotification(notification.Pass()); |
| 452 } | 452 } |
| 453 | 453 |
| 454 } // namespace chromeos | 454 } // namespace chromeos |
| OLD | NEW |