| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/intents/web_intents_registry.h" | 5 #include "chrome/browser/intents/web_intents_registry.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 } | 282 } |
| 283 const Extension* extension = ExtensionForURL(iter->service_url); | 283 const Extension* extension = ExtensionForURL(iter->service_url); |
| 284 if (extension != NULL && | 284 if (extension != NULL && |
| 285 !extension_service_->IsExtensionEnabled(extension->id())) { | 285 !extension_service_->IsExtensionEnabled(extension->id())) { |
| 286 continue; | 286 continue; |
| 287 } | 287 } |
| 288 | 288 |
| 289 // Found a match. If it is better than default_service, use it. | 289 // Found a match. If it is better than default_service, use it. |
| 290 // Currently the metric is that if the new value is user-set, | 290 // Currently the metric is that if the new value is user-set, |
| 291 // prefer it. If the new value has a more specific pattern, prefer it. | 291 // prefer it. If the new value has a more specific pattern, prefer it. |
| 292 // If the new value has a more recent date, prefer it. |
| 292 if (default_service.user_date <= 0 && iter->user_date >= 0) { | 293 if (default_service.user_date <= 0 && iter->user_date >= 0) { |
| 293 default_service = *iter; | 294 default_service = *iter; |
| 294 } else if (default_service.url_pattern.match_all_urls() && | 295 } else if (default_service.url_pattern.match_all_urls() && |
| 295 !iter->url_pattern.match_all_urls()) { | 296 !iter->url_pattern.match_all_urls()) { |
| 296 default_service = *iter; | 297 default_service = *iter; |
| 297 } else if (iter->url_pattern < default_service.url_pattern) { | 298 } else if (iter->url_pattern < default_service.url_pattern) { |
| 298 default_service = *iter; | 299 default_service = *iter; |
| 300 } else if (default_service.user_date < iter->user_date) { |
| 301 default_service = *iter; |
| 299 } | 302 } |
| 300 } | 303 } |
| 301 | 304 |
| 302 // TODO(hshi): Temporary workaround for http://crbug.com/134197. | 305 // TODO(hshi): Temporary workaround for http://crbug.com/134197. |
| 303 // If no user-set default service is found, use built-in QuickOffice Viewer as | 306 // If no user-set default service is found, use built-in QuickOffice Viewer as |
| 304 // default for MS office files. Remove this once full defaults is in place. | 307 // default for MS office files. Remove this once full defaults is in place. |
| 305 if (default_service.user_date <= 0) { | 308 if (default_service.user_date <= 0) { |
| 306 for (size_t i = 0; i < sizeof(kQuickOfficeViewerMimeType) / sizeof(char*); | 309 for (size_t i = 0; i < sizeof(kQuickOfficeViewerMimeType) / sizeof(char*); |
| 307 ++i) { | 310 ++i) { |
| 308 DefaultWebIntentService qoviewer_service; | 311 DefaultWebIntentService qoviewer_service; |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 496 void WebIntentsRegistry::ReleaseQuery(QueryAdapter* query) { | 499 void WebIntentsRegistry::ReleaseQuery(QueryAdapter* query) { |
| 497 QueryVector::iterator it = std::find( | 500 QueryVector::iterator it = std::find( |
| 498 pending_queries_.begin(), pending_queries_.end(), query); | 501 pending_queries_.begin(), pending_queries_.end(), query); |
| 499 if (it != pending_queries_.end()) { | 502 if (it != pending_queries_.end()) { |
| 500 pending_queries_.erase(it); | 503 pending_queries_.erase(it); |
| 501 delete query; | 504 delete query; |
| 502 } else { | 505 } else { |
| 503 NOTREACHED(); | 506 NOTREACHED(); |
| 504 } | 507 } |
| 505 } | 508 } |
| OLD | NEW |