diff options
author | smckay@chromium.org <smckay@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-06 07:42:16 +0000 |
---|---|---|
committer | smckay@chromium.org <smckay@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-06 07:42:16 +0000 |
commit | 54f49713cbac46430d3c9d5ab4e52769079cfccc (patch) | |
tree | 127e2d9ac7e68af2539a4ca26542a5a18e4c3ff5 /webkit | |
parent | affd2f830cfa29c189634e06a9f08e0e28df98e9 (diff) | |
download | chromium_src-54f49713cbac46430d3c9d5ab4e52769079cfccc.zip chromium_src-54f49713cbac46430d3c9d5ab4e52769079cfccc.tar.gz chromium_src-54f49713cbac46430d3c9d5ab4e52769079cfccc.tar.bz2 |
Add basic infrastructure for native (aka "browser builtin") services.
Add skeleton FilePicker service.
BUG=129769
TBR=jhawkins for the gypi file changes.
Review URL: https://chromiumcodereview.appspot.com/11022003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@160563 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r-- | webkit/glue/web_intent_service_data.cc | 9 | ||||
-rw-r--r-- | webkit/glue/web_intent_service_data.h | 5 | ||||
-rw-r--r-- | webkit/glue/web_intent_service_data_unittest.cc | 32 |
3 files changed, 40 insertions, 6 deletions
diff --git a/webkit/glue/web_intent_service_data.cc b/webkit/glue/web_intent_service_data.cc index a9d1a0a..4b69863 100644 --- a/webkit/glue/web_intent_service_data.cc +++ b/webkit/glue/web_intent_service_data.cc @@ -4,6 +4,7 @@ #include <ostream> +#include "base/string_util.h" #include "base/utf_string_conversions.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebIntentServiceInfo.h" #include "webkit/glue/web_intent_service_data.h" @@ -11,6 +12,7 @@ namespace webkit_glue { static const char kIntentsInlineDisposition[] = "inline"; +static const char kIntentsWindowDisposition[] = "window"; WebIntentServiceData::WebIntentServiceData() : disposition(WebIntentServiceData::DISPOSITION_WINDOW) { @@ -52,10 +54,13 @@ bool WebIntentServiceData::operator==(const WebIntentServiceData& other) const { } void WebIntentServiceData::setDisposition(const string16& disp) { - if (disp == ASCIIToUTF16(webkit_glue::kIntentsInlineDisposition)) + if (EqualsASCII(disp, kIntentsInlineDisposition)) disposition = DISPOSITION_INLINE; - else + else if (EqualsASCII(disp, kIntentsWindowDisposition)) disposition = DISPOSITION_WINDOW; + // NOTE: We intentionally do not support setting "native" disposition + // via this method. This keeps non-native services from + // claiming to be native...which is no supported...obviously. } std::ostream& operator<<(::std::ostream& os, diff --git a/webkit/glue/web_intent_service_data.h b/webkit/glue/web_intent_service_data.h index 07e9bde..2a7ad24 100644 --- a/webkit/glue/web_intent_service_data.h +++ b/webkit/glue/web_intent_service_data.h @@ -21,8 +21,9 @@ namespace webkit_glue { struct WEBKIT_GLUE_EXPORT WebIntentServiceData { // An intents disposition determines which context the service is opened in. enum Disposition { - DISPOSITION_WINDOW, // Open service inside a new window. (Default) - DISPOSITION_INLINE, // Open service inside the picker UI window. + DISPOSITION_WINDOW, // Service is presented inside a new tab. (Default) + DISPOSITION_INLINE, // Service is presented inside the picker UI window. + DISPOSITION_NATIVE, // Service supplies it's own native UI in browser. }; WebIntentServiceData(); diff --git a/webkit/glue/web_intent_service_data_unittest.cc b/webkit/glue/web_intent_service_data_unittest.cc index 3eb95b3..6f7ffa9 100644 --- a/webkit/glue/web_intent_service_data_unittest.cc +++ b/webkit/glue/web_intent_service_data_unittest.cc @@ -41,7 +41,6 @@ TEST(WebIntentServiceDataTest, Defaults) { TEST(WebIntentServiceDataTest, ActionServicesEqual) { - // with default disposition... WebIntentServiceData intent( ASCIIToUTF16("http://webintents.org/share"), ASCIIToUTF16("image/png"), @@ -61,7 +60,6 @@ TEST(WebIntentServiceDataTest, ActionServicesEqual) { TEST(WebIntentServiceDataTest, SchemeServicesEqual) { - // with default disposition... WebIntentServiceData intent( string16(), string16(), @@ -79,4 +77,34 @@ TEST(WebIntentServiceDataTest, SchemeServicesEqual) { &intent); } +TEST(WebIntentServiceDataTest, SetDisposition) { + + // Test using the default disposition (window). + WebIntentServiceData intent; + EXPECT_EQ(WebIntentServiceData::DISPOSITION_WINDOW, intent.disposition); + + // Set the disposition to "inline", another supported disposition. + intent.setDisposition(ASCIIToUTF16("inline")); + EXPECT_EQ(WebIntentServiceData::DISPOSITION_INLINE, intent.disposition); + + // "native" is a special internal disposition we use for + // "built-in" services. We don't allow the "native" disposition to be + // set via web-content (which is how this SetDisposition gets called). + // So after trying to set the value to "native" the disposition should + // remain unchanged. + intent.setDisposition(ASCIIToUTF16("native")); + EXPECT_EQ(WebIntentServiceData::DISPOSITION_INLINE, intent.disposition); + + // Unrecognized values are ignored. When trying to set the value to "poodles" + // the disposition should remain unchanged. + intent.setDisposition(ASCIIToUTF16("poodles")); + EXPECT_EQ(WebIntentServiceData::DISPOSITION_INLINE, intent.disposition); + + // Set the value back to "window" to confirm we can set back to + // the default disposition value, and to confirm setting still + // works after our special casing of the "native" and unrecognized values. + intent.setDisposition(ASCIIToUTF16("window")); + EXPECT_EQ(WebIntentServiceData::DISPOSITION_WINDOW, intent.disposition); +} + } // namespace |