Chromium Code Reviews| 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 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 281 continue; | 281 continue; |
| 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. |
|
Steve McKay
2012/09/14 18:57:00
Update the comment here to reflect the additional
Greg Billock
2012/09/14 19:12:28
Done.
| |
| 292 if (default_service.user_date <= 0 && iter->user_date >= 0) { | 292 if (default_service.user_date <= 0 && iter->user_date >= 0) { |
| 293 default_service = *iter; | 293 default_service = *iter; |
| 294 } else if (default_service.url_pattern.match_all_urls() && | 294 } else if (default_service.url_pattern.match_all_urls() && |
| 295 !iter->url_pattern.match_all_urls()) { | 295 !iter->url_pattern.match_all_urls()) { |
| 296 default_service = *iter; | 296 default_service = *iter; |
| 297 } else if (iter->url_pattern < default_service.url_pattern) { | 297 } else if (iter->url_pattern < default_service.url_pattern) { |
| 298 default_service = *iter; | 298 default_service = *iter; |
| 299 } else if (default_service.user_date < iter->user_date) { | |
| 300 default_service = *iter; | |
| 299 } | 301 } |
| 300 } | 302 } |
| 301 | 303 |
| 302 // TODO(hshi): Temporary workaround for http://crbug.com/134197. | 304 // TODO(hshi): Temporary workaround for http://crbug.com/134197. |
| 303 // If no user-set default service is found, use built-in QuickOffice Viewer as | 305 // 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. | 306 // default for MS office files. Remove this once full defaults is in place. |
| 305 if (default_service.user_date <= 0) { | 307 if (default_service.user_date <= 0) { |
| 306 for (size_t i = 0; i < sizeof(kQuickOfficeViewerMimeType) / sizeof(char*); | 308 for (size_t i = 0; i < sizeof(kQuickOfficeViewerMimeType) / sizeof(char*); |
| 307 ++i) { | 309 ++i) { |
| 308 DefaultWebIntentService qoviewer_service; | 310 DefaultWebIntentService qoviewer_service; |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 496 void WebIntentsRegistry::ReleaseQuery(QueryAdapter* query) { | 498 void WebIntentsRegistry::ReleaseQuery(QueryAdapter* query) { |
| 497 QueryVector::iterator it = std::find( | 499 QueryVector::iterator it = std::find( |
| 498 pending_queries_.begin(), pending_queries_.end(), query); | 500 pending_queries_.begin(), pending_queries_.end(), query); |
| 499 if (it != pending_queries_.end()) { | 501 if (it != pending_queries_.end()) { |
| 500 pending_queries_.erase(it); | 502 pending_queries_.erase(it); |
| 501 delete query; | 503 delete query; |
| 502 } else { | 504 } else { |
| 503 NOTREACHED(); | 505 NOTREACHED(); |
| 504 } | 506 } |
| 505 } | 507 } |
| OLD | NEW |