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 #ifndef CHROME_BROWSER_INTENTS_WEB_INTENTS_UTIL_H_ | 5 #ifndef CHROME_BROWSER_INTENTS_WEB_INTENTS_UTIL_H_ |
6 #define CHROME_BROWSER_INTENTS_WEB_INTENTS_UTIL_H_ | 6 #define CHROME_BROWSER_INTENTS_WEB_INTENTS_UTIL_H_ |
7 | 7 |
8 #include "base/string16.h" | 8 #include "base/string16.h" |
9 | 9 |
10 class Browser; | 10 class Browser; |
11 class Profile; | 11 class Profile; |
12 class PrefService; | 12 class PrefService; |
13 class PrefServiceSyncable; | 13 class PrefRegistrySyncable; |
14 | 14 |
15 namespace web_intents { | 15 namespace web_intents { |
16 | 16 |
17 enum ActionId { | 17 enum ActionId { |
18 ACTION_ID_CUSTOM = 1, // for all unrecognized types | 18 ACTION_ID_CUSTOM = 1, // for all unrecognized types |
19 ACTION_ID_EDIT, | 19 ACTION_ID_EDIT, |
20 ACTION_ID_PICK, | 20 ACTION_ID_PICK, |
21 ACTION_ID_SAVE, | 21 ACTION_ID_SAVE, |
22 ACTION_ID_SHARE, | 22 ACTION_ID_SHARE, |
23 ACTION_ID_SUBSCRIBE, | 23 ACTION_ID_SUBSCRIBE, |
24 ACTION_ID_VIEW, | 24 ACTION_ID_VIEW, |
25 }; | 25 }; |
26 | 26 |
27 // "Recognized" action strings. These are basically the | 27 // "Recognized" action strings. These are basically the |
28 // actions we're reporting via UMA. | 28 // actions we're reporting via UMA. |
29 extern const char kActionEdit[]; | 29 extern const char kActionEdit[]; |
30 extern const char kActionPick[]; | 30 extern const char kActionPick[]; |
31 extern const char kActionSave[]; | 31 extern const char kActionSave[]; |
32 extern const char kActionShare[]; | 32 extern const char kActionShare[]; |
33 extern const char kActionSubscribe[]; | 33 extern const char kActionSubscribe[]; |
34 extern const char kActionView[]; | 34 extern const char kActionView[]; |
35 extern const char kActionCrosEcho[]; | 35 extern const char kActionCrosEcho[]; |
36 | 36 |
37 extern const char kQuickOfficeViewerServiceURL[]; | 37 extern const char kQuickOfficeViewerServiceURL[]; |
38 extern const char kQuickOfficeViewerDevServiceURL[]; | 38 extern const char kQuickOfficeViewerDevServiceURL[]; |
39 | 39 |
40 // Registers the preferences related to Web Intents. | 40 // Registers the preferences related to Web Intents. |
41 void RegisterUserPrefs(PrefServiceSyncable* user_prefs); | 41 void RegisterUserPrefs(PrefRegistrySyncable* registry); |
42 | 42 |
43 // Returns true if WebIntents are enabled in preferences. | 43 // Returns true if WebIntents are enabled in preferences. |
44 bool IsWebIntentsEnabled(PrefService* prefs); | 44 bool IsWebIntentsEnabled(PrefService* prefs); |
45 | 45 |
46 // Returns true if WebIntents are enabled due to various factors. |profile| is | 46 // Returns true if WebIntents are enabled due to various factors. |profile| is |
47 // the Profile to check that WebIntents are enabled for. | 47 // the Profile to check that WebIntents are enabled for. |
48 bool IsWebIntentsEnabledForProfile(Profile* profile); | 48 bool IsWebIntentsEnabledForProfile(Profile* profile); |
49 | 49 |
50 // In a context where we are generating a web intent based on internal events, | 50 // In a context where we are generating a web intent based on internal events, |
51 // or from an extension background page, get the browser in which to show the | 51 // or from an extension background page, get the browser in which to show the |
52 // intent picker to the user. | 52 // intent picker to the user. |
53 Browser* GetBrowserForBackgroundWebIntentDelivery(Profile* profile); | 53 Browser* GetBrowserForBackgroundWebIntentDelivery(Profile* profile); |
54 | 54 |
55 // Returns the recognized action (the one described at | 55 // Returns the recognized action (the one described at |
56 // webintents.org) or an empty string if the action is not recognized. | 56 // webintents.org) or an empty string if the action is not recognized. |
57 bool IsRecognizedAction(const string16& action); | 57 bool IsRecognizedAction(const string16& action); |
58 | 58 |
59 // Returns the action::Id corresponding to |action| or ACTION_ID_CUSTOM | 59 // Returns the action::Id corresponding to |action| or ACTION_ID_CUSTOM |
60 // if |action| is not recognized. | 60 // if |action| is not recognized. |
61 ActionId ToActionId(const string16& action); | 61 ActionId ToActionId(const string16& action); |
62 | 62 |
63 // Returns true if |type1| and |type2| "match". Supports wild cards in both | 63 // Returns true if |type1| and |type2| "match". Supports wild cards in both |
64 // |type1| and |type2|. Wild cards are of the form '<type>/*', '*/*', and '*'. | 64 // |type1| and |type2|. Wild cards are of the form '<type>/*', '*/*', and '*'. |
65 bool MimeTypesMatch(const string16& type1, const string16& type2); | 65 bool MimeTypesMatch(const string16& type1, const string16& type2); |
66 | 66 |
67 } // namespace web_intents | 67 } // namespace web_intents |
68 | 68 |
69 #endif // CHROME_BROWSER_INTENTS_WEB_INTENTS_UTIL_H_ | 69 #endif // CHROME_BROWSER_INTENTS_WEB_INTENTS_UTIL_H_ |
OLD | NEW |