| 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" |
| 11 #include "base/callback.h" | 11 #include "base/callback.h" |
| 12 #include "base/string_util.h" | 12 #include "base/string_util.h" |
| 13 #include "base/string16.h" | 13 #include "base/string16.h" |
| 14 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
| 15 #include "chrome/browser/intents/default_web_intent_service.h" | 15 #include "chrome/browser/intents/default_web_intent_service.h" |
| 16 #include "chrome/browser/intents/native_services.h" | 16 #include "chrome/browser/intents/native_services.h" |
| 17 #include "chrome/browser/intents/web_intents_util.h" | 17 #include "chrome/browser/intents/web_intents_util.h" |
| 18 #include "chrome/browser/webdata/web_data_service.h" | 18 #include "chrome/browser/webdata/web_data_service.h" |
| 19 #include "chrome/common/extensions/extension.h" | 19 #include "chrome/common/extensions/extension.h" |
| 20 #include "chrome/common/extensions/extension_set.h" | 20 #include "chrome/common/extensions/extension_set.h" |
| 21 #include "chrome/common/extensions/web_intents_handler.h" |
| 21 #include "googleurl/src/gurl.h" | 22 #include "googleurl/src/gurl.h" |
| 22 #include "net/base/mime_util.h" | 23 #include "net/base/mime_util.h" |
| 23 | 24 |
| 24 using extensions::Extension; | 25 using extensions::Extension; |
| 25 using net::IsMimeType; | 26 using net::IsMimeType; |
| 26 | 27 |
| 27 namespace { | 28 namespace { |
| 28 | 29 |
| 29 // TODO(hshi): Temporary workaround for http://crbug.com/134197. | 30 // TODO(hshi): Temporary workaround for http://crbug.com/134197. |
| 30 // If no user-set default service is found, use built-in QuickOffice Viewer as | 31 // If no user-set default service is found, use built-in QuickOffice Viewer as |
| (...skipping 17 matching lines...) Expand all Loading... |
| 48 return (IsMimeType(UTF16ToUTF8(type1)) && IsMimeType(UTF16ToUTF8(type2))) | 49 return (IsMimeType(UTF16ToUTF8(type1)) && IsMimeType(UTF16ToUTF8(type2))) |
| 49 ? web_intents::MimeTypesMatch(type1, type2) | 50 ? web_intents::MimeTypesMatch(type1, type2) |
| 50 : type1 == type2; | 51 : type1 == type2; |
| 51 } | 52 } |
| 52 | 53 |
| 53 // Adds any intent services of |extension| that match |action| to | 54 // Adds any intent services of |extension| that match |action| to |
| 54 // |matching_services|. | 55 // |matching_services|. |
| 55 void AddMatchingServicesForExtension(const Extension& extension, | 56 void AddMatchingServicesForExtension(const Extension& extension, |
| 56 const string16& action, | 57 const string16& action, |
| 57 IntentServiceList* matching_services) { | 58 IntentServiceList* matching_services) { |
| 58 const IntentServiceList& services = extension.intents_services(); | 59 const IntentServiceList& services = |
| 60 extensions::WebIntentsInfo::GetIntentsServices(&extension); |
| 59 for (IntentServiceList::const_iterator i = services.begin(); | 61 for (IntentServiceList::const_iterator i = services.begin(); |
| 60 i != services.end(); ++i) { | 62 i != services.end(); ++i) { |
| 61 if (action.empty() || action == i->action) | 63 if (action.empty() || action == i->action) |
| 62 matching_services->push_back(*i); | 64 matching_services->push_back(*i); |
| 63 } | 65 } |
| 64 } | 66 } |
| 65 | 67 |
| 66 // Removes all services from |matching_services| that do not match |type|. | 68 // Removes all services from |matching_services| that do not match |type|. |
| 67 // Wildcards are supported, of the form '<type>/*' or '*'. | 69 // Wildcards are supported, of the form '<type>/*' or '*'. |
| 68 void FilterServicesByType(const string16& type, | 70 void FilterServicesByType(const string16& type, |
| (...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 517 void WebIntentsRegistry::ReleaseQuery(QueryAdapter* query) { | 519 void WebIntentsRegistry::ReleaseQuery(QueryAdapter* query) { |
| 518 QueryVector::iterator it = std::find( | 520 QueryVector::iterator it = std::find( |
| 519 pending_queries_.begin(), pending_queries_.end(), query); | 521 pending_queries_.begin(), pending_queries_.end(), query); |
| 520 if (it != pending_queries_.end()) { | 522 if (it != pending_queries_.end()) { |
| 521 pending_queries_.erase(it); | 523 pending_queries_.erase(it); |
| 522 delete query; | 524 delete query; |
| 523 } else { | 525 } else { |
| 524 NOTREACHED(); | 526 NOTREACHED(); |
| 525 } | 527 } |
| 526 } | 528 } |
| OLD | NEW |