Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(46)

Side by Side Diff: chrome/browser/intents/web_intents_registry.cc

Issue 10830363: intents: Add conditional web intents dispatch for docs types. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Kill superfluous logging. Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 42
43 typedef base::Callback<void(const WDTypedResult* result)> ResultsHandler; 43 typedef base::Callback<void(const WDTypedResult* result)> ResultsHandler;
44 typedef WebIntentsRegistry::IntentServiceList IntentServiceList; 44 typedef WebIntentsRegistry::IntentServiceList IntentServiceList;
45 45
46 // Compares two mime types for equality. Supports wild cards in both 46 // Compares two mime types for equality. Supports wild cards in both
47 // |type1| and |type2|. Wild cards are of the form '<type>/*' or '*'. 47 // |type1| and |type2|. Wild cards are of the form '<type>/*' or '*'.
48 bool MimeTypesAreEqual(const string16& type1, const string16& type2) { 48 bool MimeTypesAreEqual(const string16& type1, const string16& type2) {
49 // We don't have a MIME matcher that allows patterns on both sides 49 // We don't have a MIME matcher that allows patterns on both sides
50 // Instead, we do two comparisons, treating each type in turn as a 50 // Instead, we do two comparisons, treating each type in turn as a
51 // pattern. If either one matches, we consider this a MIME match. 51 // pattern. If either one matches, we consider this a MIME match.
52 if (net::MatchesMimeType(UTF16ToUTF8(type1), UTF16ToUTF8(type2))) 52 std::string t1 = UTF16ToUTF8(type1);
53 std::string t2 = UTF16ToUTF8(type2);
54 StringToLowerASCII(&t1);
55 StringToLowerASCII(&t2);
56 if (net::MatchesMimeType(t1, t2))
53 return true; 57 return true;
54 return net::MatchesMimeType(UTF16ToUTF8(type2), UTF16ToUTF8(type1)); 58 return net::MatchesMimeType(t2, t1);
55 } 59 }
56 60
57 // Returns true if the passed string is a MIME type. Works by comparing string 61 // Returns true if the passed string is a MIME type. Works by comparing string
58 // prefix to the valid MIME top-level types (and the wildcard type */). 62 // prefix to the valid MIME top-level types (and the wildcard type */).
59 // "*" is also accepted as a valid MIME type. 63 // "*" is also accepted as a valid MIME type.
60 // The passed |type_str| should have no leading or trailing whitespace. 64 // The passed |type_str| should have no leading or trailing whitespace.
61 bool IsMimeType(const string16& type_str) { 65 bool IsMimeType(const string16& type_str) {
62 return net::IsMimeType(UTF16ToUTF8(type_str)); 66 return net::IsMimeType(UTF16ToUTF8(type_str));
63 } 67 }
64 68
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 void WebIntentsRegistry::ReleaseQuery(QueryAdapter* query) { 520 void WebIntentsRegistry::ReleaseQuery(QueryAdapter* query) {
517 QueryVector::iterator it = std::find( 521 QueryVector::iterator it = std::find(
518 pending_queries_.begin(), pending_queries_.end(), query); 522 pending_queries_.begin(), pending_queries_.end(), query);
519 if (it != pending_queries_.end()) { 523 if (it != pending_queries_.end()) {
520 pending_queries_.erase(it); 524 pending_queries_.erase(it);
521 delete query; 525 delete query;
522 } else { 526 } else {
523 NOTREACHED(); 527 NOTREACHED();
524 } 528 }
525 } 529 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698