summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/chromeos/extensions/external_filesystem_apitest.cc13
-rw-r--r--chrome/browser/chromeos/extensions/file_browser_private_api.cc112
-rw-r--r--chrome/browser/chromeos/extensions/file_browser_private_api.h7
-rw-r--r--chrome/browser/content_settings/content_settings_default_provider.cc6
-rw-r--r--chrome/browser/content_settings/content_settings_policy_provider.cc1
-rw-r--r--chrome/browser/content_settings/content_settings_utils.cc1
-rw-r--r--chrome/browser/content_settings/host_content_settings_map.cc8
-rw-r--r--chrome/browser/content_settings/host_content_settings_map_unittest.cc8
-rw-r--r--chrome/browser/download/chrome_download_manager_delegate.cc131
-rw-r--r--chrome/browser/download/chrome_download_manager_delegate.h9
-rw-r--r--chrome/browser/extensions/api/app_runtime/app_runtime_api.cc104
-rw-r--r--chrome/browser/extensions/api/app_runtime/app_runtime_api.h23
-rw-r--r--chrome/browser/extensions/extension_host.cc24
-rw-r--r--chrome/browser/extensions/extension_host.h4
-rw-r--r--chrome/browser/extensions/extension_special_storage_policy.cc41
-rw-r--r--chrome/browser/extensions/extension_special_storage_policy.h1
-rw-r--r--chrome/browser/extensions/extension_special_storage_policy_unittest.cc54
-rw-r--r--chrome/browser/extensions/platform_app_browsertest.cc83
-rw-r--r--chrome/browser/extensions/platform_app_launcher.cc160
-rw-r--r--chrome/browser/extensions/platform_app_launcher.h12
-rw-r--r--chrome/browser/extensions/web_intent_callbacks.cc128
-rw-r--r--chrome/browser/extensions/web_intent_callbacks.h84
-rw-r--r--chrome/browser/extensions/web_intents_parser.cc32
-rw-r--r--chrome/browser/extensions/web_intents_parser.h37
-rw-r--r--chrome/browser/intents/OWNERS4
-rw-r--r--chrome/browser/intents/cws_intents_registry.cc235
-rw-r--r--chrome/browser/intents/cws_intents_registry.h89
-rw-r--r--chrome/browser/intents/cws_intents_registry_factory.cc40
-rw-r--r--chrome/browser/intents/cws_intents_registry_factory.h42
-rw-r--r--chrome/browser/intents/cws_intents_registry_unittest.cc275
-rw-r--r--chrome/browser/intents/default_web_intent_service.cc47
-rw-r--r--chrome/browser/intents/default_web_intent_service.h61
-rw-r--r--chrome/browser/intents/default_web_intent_service_unittest.cc61
-rw-r--r--chrome/browser/intents/intent_service_host.h57
-rw-r--r--chrome/browser/intents/native_services.cc68
-rw-r--r--chrome/browser/intents/native_services.h104
-rw-r--r--chrome/browser/intents/native_services_browsertest.cc182
-rw-r--r--chrome/browser/intents/native_services_unittest.cc66
-rw-r--r--chrome/browser/intents/register_intent_handler_infobar_delegate.cc121
-rw-r--r--chrome/browser/intents/register_intent_handler_infobar_delegate.h87
-rw-r--r--chrome/browser/intents/register_intent_handler_infobar_delegate_unittest.cc79
-rw-r--r--chrome/browser/intents/web_intents_registry.cc528
-rw-r--r--chrome/browser/intents/web_intents_registry.h180
-rw-r--r--chrome/browser/intents/web_intents_registry_factory.cc46
-rw-r--r--chrome/browser/intents/web_intents_registry_factory.h42
-rw-r--r--chrome/browser/intents/web_intents_registry_unittest.cc807
-rw-r--r--chrome/browser/intents/web_intents_reporting.cc167
-rw-r--r--chrome/browser/intents/web_intents_reporting.h135
-rw-r--r--chrome/browser/intents/web_intents_reporting_unittest.cc48
-rw-r--r--chrome/browser/intents/web_intents_util.cc111
-rw-r--r--chrome/browser/intents/web_intents_util.h69
-rw-r--r--chrome/browser/intents/web_intents_util_stub.cc26
-rw-r--r--chrome/browser/intents/web_intents_util_unittest.cc95
-rw-r--r--chrome/browser/prefs/browser_prefs.cc5
-rw-r--r--chrome/browser/profiles/profile_dependency_manager.cc8
-rw-r--r--chrome/browser/ui/browser.cc73
-rw-r--r--chrome/browser/ui/browser.h13
-rw-r--r--chrome/browser/ui/browser_commands.cc2
-rw-r--r--chrome/browser/ui/browser_tab_contents.cc4
-rw-r--r--chrome/browser/ui/cocoa/content_settings/content_setting_bubble_cocoa.mm1
-rw-r--r--chrome/browser/ui/cocoa/content_settings/content_setting_bubble_cocoa_unittest.mm1
-rw-r--r--chrome/browser/ui/cocoa/intents/web_intent_picker_cocoa.mm13
-rw-r--r--chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h14
-rw-r--r--chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.mm37
-rw-r--r--chrome/browser/ui/cocoa/location_bar/web_intents_button_decoration.h65
-rw-r--r--chrome/browser/ui/cocoa/location_bar/web_intents_button_decoration.mm251
-rw-r--r--chrome/browser/ui/cocoa/location_bar/web_intents_button_decoration_unittest.mm58
-rw-r--r--chrome/browser/ui/extensions/shell_window.cc22
-rw-r--r--chrome/browser/ui/extensions/shell_window.h3
-rw-r--r--chrome/browser/ui/gtk/location_bar_view_gtk.cc100
-rw-r--r--chrome/browser/ui/gtk/location_bar_view_gtk.h9
-rw-r--r--chrome/browser/ui/gtk/web_intent_picker_gtk.cc880
-rw-r--r--chrome/browser/ui/gtk/web_intent_picker_gtk.h196
-rw-r--r--chrome/browser/ui/intents/OWNERS4
-rw-r--r--chrome/browser/ui/intents/native_file_picker_service.cc194
-rw-r--r--chrome/browser/ui/intents/web_intent_icon_loader.cc159
-rw-r--r--chrome/browser/ui/intents/web_intent_icon_loader.h62
-rw-r--r--chrome/browser/ui/intents/web_intent_inline_disposition_delegate.cc136
-rw-r--r--chrome/browser/ui/intents/web_intent_inline_disposition_delegate.h85
-rw-r--r--chrome/browser/ui/intents/web_intent_inline_disposition_delegate_unittest.cc59
-rw-r--r--chrome/browser/ui/intents/web_intent_picker.cc87
-rw-r--r--chrome/browser/ui/intents/web_intent_picker.h130
-rw-r--r--chrome/browser/ui/intents/web_intent_picker_controller.cc972
-rw-r--r--chrome/browser/ui/intents/web_intent_picker_controller.h349
-rw-r--r--chrome/browser/ui/intents/web_intent_picker_controller_browsertest.cc806
-rw-r--r--chrome/browser/ui/intents/web_intent_picker_delegate.h68
-rw-r--r--chrome/browser/ui/intents/web_intent_picker_delegate_mock.cc11
-rw-r--r--chrome/browser/ui/intents/web_intent_picker_delegate_mock.h33
-rw-r--r--chrome/browser/ui/intents/web_intent_picker_model.cc287
-rw-r--r--chrome/browser/ui/intents/web_intent_picker_model.h259
-rw-r--r--chrome/browser/ui/intents/web_intent_picker_model_observer.h33
-rw-r--r--chrome/browser/ui/intents/web_intent_picker_model_unittest.cc236
-rw-r--r--chrome/browser/ui/intents/web_intent_picker_unittest.cc59
-rw-r--r--chrome/browser/ui/omnibox/location_bar.h5
-rw-r--r--chrome/browser/ui/toolbar/action_box_button_controller.cc103
-rw-r--r--chrome/browser/ui/toolbar/action_box_button_controller.h11
-rw-r--r--chrome/browser/ui/views/external_tab_container_win.cc19
-rw-r--r--chrome/browser/ui/views/external_tab_container_win.h13
-rw-r--r--chrome/browser/ui/views/location_bar/location_bar_view.cc31
-rw-r--r--chrome/browser/ui/views/location_bar/location_bar_view.h9
-rw-r--r--chrome/browser/ui/views/location_bar/web_intents_button_view.cc64
-rw-r--r--chrome/browser/ui/views/location_bar/web_intents_button_view.h34
-rw-r--r--chrome/browser/ui/views/web_intent_picker_views.cc1601
-rw-r--r--chrome/browser/ui/webui/options/content_settings_handler.cc10
-rw-r--r--chrome/browser/webdata/web_data_service.cc161
-rw-r--r--chrome/browser/webdata/web_database.cc6
-rw-r--r--chrome/browser/webdata/web_database.h4
-rw-r--r--chrome/browser/webdata/web_intents_table.cc213
-rw-r--r--chrome/browser/webdata/web_intents_table.h55
-rw-r--r--chrome/chrome_browser.gypi30
-rw-r--r--chrome/chrome_browser_extensions.gypi4
-rw-r--r--chrome/chrome_browser_ui.gypi36
-rw-r--r--chrome/chrome_tests.gypi12
-rw-r--r--chrome/chrome_tests_unit.gypi18
-rw-r--r--chrome/common/content_settings_types.h1
-rw-r--r--chrome/common/extensions/api/app_runtime.idl43
-rw-r--r--chrome/common/pref_names.cc5
-rw-r--r--chrome/common/pref_names.h4
-rw-r--r--chrome/test/base/test_location_bar.h3
-rw-r--r--chrome/test/data/extensions/api_test/filebrowser_component/intent.html10
-rw-r--r--content/browser/intents/OWNERS4
-rw-r--r--content/browser/intents/intent_injector.cc130
-rw-r--r--content/browser/intents/intent_injector.h91
-rw-r--r--content/browser/intents/intent_injector_unittest.cc110
-rw-r--r--content/browser/intents/internal_web_intents_dispatcher.cc67
-rw-r--r--content/browser/intents/internal_web_intents_dispatcher.h74
-rw-r--r--content/browser/intents/internal_web_intents_dispatcher_unittest.cc76
-rw-r--r--content/browser/intents/web_intents_dispatcher_impl.cc90
-rw-r--r--content/browser/intents/web_intents_dispatcher_impl.h65
-rw-r--r--content/browser/web_contents/web_contents_impl.cc30
-rw-r--r--content/browser/web_contents/web_contents_impl.h11
-rw-r--r--content/common/content_message_generator.h1
-rw-r--r--content/common/intents_messages.h81
-rw-r--r--content/content_browser.gypi12
-rw-r--r--content/content_common.gypi1
-rw-r--r--content/content_renderer.gypi8
-rw-r--r--content/content_tests.gypi14
-rw-r--r--content/public/browser/web_contents_delegate.cc10
-rw-r--r--content/public/browser/web_contents_delegate.h20
-rw-r--r--content/public/browser/web_intents_dispatcher.h73
-rw-r--r--content/renderer/render_view_browsertest.cc28
-rw-r--r--content/renderer/render_view_impl.cc55
-rw-r--r--content/renderer/render_view_impl.h10
-rw-r--r--content/renderer/web_intents_host.cc258
-rw-r--r--content/renderer/web_intents_host.h103
-rw-r--r--content/renderer/web_intents_host_browsertest.cc123
-rw-r--r--content/shell/webkit_test_runner.cc12
-rw-r--r--content/shell/webkit_test_runner.h9
148 files changed, 19 insertions, 14791 deletions
diff --git a/chrome/browser/chromeos/extensions/external_filesystem_apitest.cc b/chrome/browser/chromeos/extensions/external_filesystem_apitest.cc
index e4e1c53..7f52b58 100644
--- a/chrome/browser/chromeos/extensions/external_filesystem_apitest.cc
+++ b/chrome/browser/chromeos/extensions/external_filesystem_apitest.cc
@@ -267,19 +267,6 @@ IN_PROC_BROWSER_TEST_F(FileSystemExtensionApiTest, FileBrowserTestLazy) {
<< message_;
}
-#if defined(ENABLE_WEB_INTENTS)
-IN_PROC_BROWSER_TEST_F(FileSystemExtensionApiTest, FileBrowserWebIntentTest) {
- // Create a test file inside the ScopedTempDir.
- base::FilePath test_file = mount_point_dir_.AppendASCII("text_file.xul");
- CreateFileWithContent(test_file, kTestFileContent);
-
- ASSERT_TRUE(RunFileBrowserHandlerTest("intent.html#/tmp/text_file.xul",
- "filebrowser_component",
- "webintent_handler"))
- << message_;
-}
-#endif
-
IN_PROC_BROWSER_TEST_F(FileSystemExtensionApiTest, FileBrowserTestWrite) {
ASSERT_TRUE(RunFileBrowserHandlerTest("write.html",
"filebrowser_component",
diff --git a/chrome/browser/chromeos/extensions/file_browser_private_api.cc b/chrome/browser/chromeos/extensions/file_browser_private_api.cc
index a9fee5f..85c4c2c 100644
--- a/chrome/browser/chromeos/extensions/file_browser_private_api.cc
+++ b/chrome/browser/chromeos/extensions/file_browser_private_api.cc
@@ -49,7 +49,6 @@
#include "chrome/browser/google_apis/gdata_wapi_parser.h"
#include "chrome/browser/google_apis/operation_registry.h"
#include "chrome/browser/google_apis/time_util.h"
-#include "chrome/browser/intents/web_intents_util.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_window.h"
@@ -59,7 +58,6 @@
#include "chrome/common/extensions/extension_constants.h"
#include "chrome/common/extensions/extension_icon_set.h"
#include "chrome/common/extensions/extension_manifest_constants.h"
-#include "chrome/common/extensions/web_intents_handler.h"
#include "chrome/common/pref_names.h"
#include "chromeos/disks/disk_mount_manager.h"
#include "content/public/browser/child_process_security_policy.h"
@@ -82,7 +80,6 @@
#include "webkit/fileapi/file_system_types.h"
#include "webkit/fileapi/file_system_url.h"
#include "webkit/fileapi/file_system_util.h"
-#include "webkit/glue/web_intent_service_data.h"
#include "ui/webui/web_ui_util.h"
using extensions::app_file_handler_util::FindFileHandlersForMimeTypes;
@@ -282,48 +279,6 @@ GURL FindPreferredIcon(const InstalledApp::IconList& icons,
return result;
}
-#if defined(ENABLE_WEB_INTENTS)
-// Finds the title of the given Web Intents |action|, if the passed extension
-// supports this action for all specified |mime_types|. Returns true and
-// provides the |title| as output on success.
-bool FindTitleForActionWithTypes(
- const Extension* extension,
- const std::string& action,
- const std::set<std::string>& mime_types,
- std::string* title) {
- DCHECK(!mime_types.empty());
- std::set<std::string> pending(mime_types.begin(), mime_types.end());
- std::string found_title;
-
- for (std::vector<webkit_glue::WebIntentServiceData>::const_iterator data =
- extensions::WebIntentsInfo::GetIntentsServices(extension).begin();
- data != extensions::WebIntentsInfo::GetIntentsServices(extension).end();
- ++data) {
- if (pending.empty())
- break;
-
- if (UTF16ToUTF8(data->action) != action)
- continue;
-
- std::set<std::string>::iterator pending_iter = pending.begin();
- while (pending_iter != pending.end()) {
- std::set<std::string>::iterator current = pending_iter++;
- if (net::MatchesMimeType(UTF16ToUTF8(data->type), *current))
- pending.erase(current);
- }
- if (found_title.empty())
- found_title = UTF16ToUTF8(data->title);
- }
-
- // Not all mime-types have been found.
- if (!pending.empty())
- return false;
-
- *title = found_title;
- return true;
-}
-#endif // defined(ENABLE_WEB_INTENTS)
-
// Retrieves total and remaining available size on |mount_path|.
void GetSizeStatsOnFileThread(const std::string& mount_path,
size_t* total_size_kb,
@@ -999,60 +954,6 @@ bool GetFileTasksFileBrowserFunction::FindAppTasks(
return true;
}
-#if defined(ENABLE_WEB_INTENTS)
-// Find Web Intent platform apps that support the View task, and add them to
-// the |result_list|. These will be marked as kTaskWebIntent.
-bool GetFileTasksFileBrowserFunction::FindWebIntentTasks(
- const std::vector<base::FilePath>& file_paths,
- ListValue* result_list) {
- DCHECK(!file_paths.empty());
- ExtensionService* service = profile_->GetExtensionService();
- if (!service)
- return false;
-
- std::set<std::string> mime_types;
- GetMimeTypesForFileURLs(file_paths, &mime_types);
-
- for (ExtensionSet::const_iterator iter = service->extensions()->begin();
- iter != service->extensions()->end();
- ++iter) {
- const Extension* extension = *iter;
-
- // We don't support using hosted apps to open files.
- if (!extension->is_platform_app())
- continue;
-
- if (profile_->IsOffTheRecord() &&
- !service->IsIncognitoEnabled(extension->id()))
- continue;
-
- std::string title;
- if (!FindTitleForActionWithTypes(
- extension, web_intents::kActionView, mime_types, &title))
- continue;
-
- DictionaryValue* task = new DictionaryValue;
- std::string task_id = file_handler_util::MakeTaskID(extension->id(),
- file_handler_util::kTaskWebIntent, web_intents::kActionView);
- task->SetString("taskId", task_id);
- task->SetString("title", title);
- task->SetBoolean("isDefault", false);
-
- GURL best_icon = extension->GetIconURL(kPreferredIconSize,
- ExtensionIconSet::MATCH_BIGGER);
- if (!best_icon.is_empty())
- task->SetString("iconUrl", best_icon.spec());
- else
- task->SetString("iconUrl", kDefaultIcon);
-
- task->SetBoolean("driveApp", false);
- result_list->Append(task);
- }
-
- return true;
-}
-#endif // defined(ENABLE_WEB_INTENTS)
-
bool GetFileTasksFileBrowserFunction::RunImpl() {
// First argument is the list of files to get tasks for.
ListValue* files_list = NULL;
@@ -1161,20 +1062,13 @@ bool GetFileTasksFileBrowserFunction::RunImpl() {
result_list->Append(task);
}
- // Take the union of platform app file handlers, Web Intents that platform
- // apps may accept, and all previous Drive and extension tasks. As above, we
- // know there aren't duplicates because they're entirely different kinds of
+ // Take the union of platform app file handlers, and all previous Drive
+ // and extension tasks. As above, we know there aren't duplicates because
+ // they're entirely different kinds of
// tasks.
if (!FindAppTasks(file_paths, result_list))
return false;
-#if defined(ENABLE_WEB_INTENTS)
- // TODO(benwells): remove the web intents tasks once we no longer support
- // them.
- if (!FindWebIntentTasks(file_paths, result_list))
- return false;
-#endif
-
if (VLOG_IS_ON(1)) {
std::string result_json;
base::JSONWriter::WriteWithOptions(
diff --git a/chrome/browser/chromeos/extensions/file_browser_private_api.h b/chrome/browser/chromeos/extensions/file_browser_private_api.h
index 1e9dae7..8450fde 100644
--- a/chrome/browser/chromeos/extensions/file_browser_private_api.h
+++ b/chrome/browser/chromeos/extensions/file_browser_private_api.h
@@ -199,13 +199,6 @@ class GetFileTasksFileBrowserFunction : public AsyncExtensionFunction {
ListValue* result_list,
bool* default_already_set);
-#if defined(ENABLE_WEB_INTENTS)
- // Find the list of Web Intent tasks that can be used with the given file
- // types, appending them to the |result_list|.
- bool FindWebIntentTasks(const std::vector<base::FilePath>& file_paths,
- ListValue* result_list);
-#endif
-
// Find the list of app file handlers that can be used with the given file
// types, appending them to the |result_list|.
bool FindAppTasks(const std::vector<base::FilePath>& file_paths,
diff --git a/chrome/browser/content_settings/content_settings_default_provider.cc b/chrome/browser/content_settings/content_settings_default_provider.cc
index 5651955..8133505 100644
--- a/chrome/browser/content_settings/content_settings_default_provider.cc
+++ b/chrome/browser/content_settings/content_settings_default_provider.cc
@@ -40,7 +40,6 @@ const ContentSetting kDefaultSettings[] = {
CONTENT_SETTING_BLOCK, // CONTENT_SETTINGS_TYPE_POPUPS
CONTENT_SETTING_ASK, // CONTENT_SETTINGS_TYPE_GEOLOCATION
CONTENT_SETTING_ASK, // CONTENT_SETTINGS_TYPE_NOTIFICATIONS
- CONTENT_SETTING_ASK, // CONTENT_SETTINGS_TYPE_INTENTS
CONTENT_SETTING_DEFAULT, // CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE
CONTENT_SETTING_ASK, // CONTENT_SETTINGS_TYPE_FULLSCREEN
CONTENT_SETTING_ASK, // CONTENT_SETTINGS_TYPE_MOUSELOCK
@@ -146,11 +145,6 @@ DefaultProvider::DefaultProvider(PrefService* prefs, bool incognito)
default_settings_[CONTENT_SETTINGS_TYPE_NOTIFICATIONS].get()),
CONTENT_SETTING_NUM_SETTINGS);
UMA_HISTOGRAM_ENUMERATION(
- "ContentSettings.DefaultHandlersSetting",
- ValueToContentSetting(
- default_settings_[CONTENT_SETTINGS_TYPE_INTENTS].get()),
- CONTENT_SETTING_NUM_SETTINGS);
- UMA_HISTOGRAM_ENUMERATION(
"ContentSettings.DefaultMouseCursorSetting",
ValueToContentSetting(
default_settings_[CONTENT_SETTINGS_TYPE_MOUSELOCK].get()),
diff --git a/chrome/browser/content_settings/content_settings_policy_provider.cc b/chrome/browser/content_settings/content_settings_policy_provider.cc
index 0687d6a..1d8f31a 100644
--- a/chrome/browser/content_settings/content_settings_policy_provider.cc
+++ b/chrome/browser/content_settings/content_settings_policy_provider.cc
@@ -33,7 +33,6 @@ const char* kPrefToManageType[] = {
prefs::kManagedDefaultPopupsSetting,
prefs::kManagedDefaultGeolocationSetting,
prefs::kManagedDefaultNotificationsSetting,
- NULL, // No policy for default value of content type intents
NULL, // No policy for default value of content type auto-select-certificate
NULL, // No policy for default value of fullscreen requests
NULL, // No policy for default value of mouse lock requests
diff --git a/chrome/browser/content_settings/content_settings_utils.cc b/chrome/browser/content_settings/content_settings_utils.cc
index 31c6ba0..6534526 100644
--- a/chrome/browser/content_settings/content_settings_utils.cc
+++ b/chrome/browser/content_settings/content_settings_utils.cc
@@ -30,7 +30,6 @@ const char* kTypeNames[] = {
"popups",
"geolocation",
"notifications",
- "intents",
"auto-select-certificate",
"fullscreen",
"mouselock",
diff --git a/chrome/browser/content_settings/host_content_settings_map.cc b/chrome/browser/content_settings/host_content_settings_map.cc
index f4ed324..01b150d7 100644
--- a/chrome/browser/content_settings/host_content_settings_map.cc
+++ b/chrome/browser/content_settings/host_content_settings_map.cc
@@ -22,7 +22,6 @@
#include "chrome/browser/content_settings/content_settings_rule.h"
#include "chrome/browser/content_settings/content_settings_utils.h"
#include "chrome/browser/extensions/extension_service.h"
-#include "chrome/browser/intents/web_intents_util.h"
#include "chrome/browser/prefs/pref_registry_syncable.h"
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/common/chrome_notification_types.h"
@@ -335,12 +334,6 @@ bool HostContentSettingsMap::IsSettingAllowedForType(
PrefService* prefs,
ContentSetting setting,
ContentSettingsType content_type) {
- // Intents content settings are hidden behind a switch for now.
- if (content_type == CONTENT_SETTINGS_TYPE_INTENTS) {
- if (!web_intents::IsWebIntentsEnabled(prefs))
- return false;
- }
-
// We don't yet support stored content settings for mixed scripting.
if (content_type == CONTENT_SETTINGS_TYPE_MIXEDSCRIPT)
return false;
@@ -369,7 +362,6 @@ bool HostContentSettingsMap::IsSettingAllowedForType(
case CONTENT_SETTINGS_TYPE_PLUGINS:
case CONTENT_SETTINGS_TYPE_GEOLOCATION:
case CONTENT_SETTINGS_TYPE_NOTIFICATIONS:
- case CONTENT_SETTINGS_TYPE_INTENTS:
case CONTENT_SETTINGS_TYPE_MOUSELOCK:
case CONTENT_SETTINGS_TYPE_MEDIASTREAM:
case CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC:
diff --git a/chrome/browser/content_settings/host_content_settings_map_unittest.cc b/chrome/browser/content_settings/host_content_settings_map_unittest.cc
index 646d3c1..5d19b03 100644
--- a/chrome/browser/content_settings/host_content_settings_map_unittest.cc
+++ b/chrome/browser/content_settings/host_content_settings_map_unittest.cc
@@ -143,9 +143,6 @@ TEST_F(HostContentSettingsMapTest, IndividualSettings) {
host, host, CONTENT_SETTINGS_TYPE_NOTIFICATIONS, ""));
EXPECT_EQ(CONTENT_SETTING_ASK,
host_content_settings_map->GetContentSetting(
- host, host, CONTENT_SETTINGS_TYPE_INTENTS, ""));
- EXPECT_EQ(CONTENT_SETTING_ASK,
- host_content_settings_map->GetContentSetting(
host, host, CONTENT_SETTINGS_TYPE_FULLSCREEN, ""));
EXPECT_EQ(CONTENT_SETTING_ASK,
host_content_settings_map->GetContentSetting(
@@ -609,9 +606,6 @@ TEST_F(HostContentSettingsMapTest, NestedSettings) {
host, host, CONTENT_SETTINGS_TYPE_NOTIFICATIONS, ""));
EXPECT_EQ(CONTENT_SETTING_ASK,
host_content_settings_map->GetContentSetting(
- host, host, CONTENT_SETTINGS_TYPE_INTENTS, ""));
- EXPECT_EQ(CONTENT_SETTING_ASK,
- host_content_settings_map->GetContentSetting(
host, host, CONTENT_SETTINGS_TYPE_FULLSCREEN, ""));
EXPECT_EQ(CONTENT_SETTING_ASK,
host_content_settings_map->GetContentSetting(
@@ -1041,8 +1035,6 @@ TEST_F(HostContentSettingsMapTest, ShouldAllowAllContent) {
extension, extension, CONTENT_SETTINGS_TYPE_COOKIES));
EXPECT_FALSE(host_content_settings_map->ShouldAllowAllContent(
extension, extension, CONTENT_SETTINGS_TYPE_PLUGINS));
- EXPECT_TRUE(host_content_settings_map->ShouldAllowAllContent(
- extension, extension, CONTENT_SETTINGS_TYPE_INTENTS));
EXPECT_FALSE(host_content_settings_map->ShouldAllowAllContent(
extension, http_host, CONTENT_SETTINGS_TYPE_COOKIES));
}
diff --git a/chrome/browser/download/chrome_download_manager_delegate.cc b/chrome/browser/download/chrome_download_manager_delegate.cc
index dcfbfd1..cdd91fd 100644
--- a/chrome/browser/download/chrome_download_manager_delegate.cc
+++ b/chrome/browser/download/chrome_download_manager_delegate.cc
@@ -32,7 +32,6 @@
#include "chrome/browser/extensions/extension_system.h"
#include "chrome/browser/history/history_service.h"
#include "chrome/browser/history/history_service_factory.h"
-#include "chrome/browser/intents/web_intents_util.h"
#include "chrome/browser/platform_util.h"
#include "chrome/browser/prefs/pref_registry_syncable.h"
#include "chrome/browser/prefs/pref_service.h"
@@ -50,12 +49,9 @@
#include "content/public/browser/notification_source.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_delegate.h"
-#include "content/public/browser/web_intents_dispatcher.h"
#include "grit/generated_resources.h"
#include "net/base/net_util.h"
#include "ui/base/l10n/l10n_util.h"
-#include "webkit/glue/web_intent_data.h"
-#include "webkit/glue/web_intent_reply_data.h"
#if !defined(OS_ANDROID)
#include "chrome/browser/ui/browser.h"
@@ -83,11 +79,6 @@ namespace {
// a download item.
static const char safe_browsing_id[] = "Safe Browsing ID";
-// String pointer used to set the local file extension to be used when a
-// download is going to be dispatched with web intents.
-static const base::FilePath::CharType kWebIntentsFileExtension[] =
- FILE_PATH_LITERAL(".webintents");
-
// The state of a safebrowsing check.
class SafeBrowsingState : public DownloadCompletionBlocker {
public:
@@ -133,20 +124,6 @@ void GenerateFileNameFromRequest(const DownloadItem& download_item,
default_file_name);
}
-// Needed to give PostTask a void closure in OnWebIntentDispatchCompleted.
-void DeleteFile(const base::FilePath& file_path) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
- file_util::Delete(file_path, false);
-}
-
-// Called when the web intents dispatch has completed. Deletes the |file_path|.
-void OnWebIntentDispatchCompleted(
- const base::FilePath& file_path,
- webkit_glue::WebIntentReplyType intent_reply) {
- BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE,
- base::Bind(&DeleteFile, file_path));
-}
-
typedef base::Callback<void(bool)> VisitedBeforeCallback;
// Condenses the results from HistoryService::GetVisibleVisitCountToHost() to a
@@ -392,107 +369,9 @@ bool ChromeDownloadManagerDelegate::ShouldOpenDownload(
return false;
}
-#if defined(ENABLE_WEB_INTENTS)
- if (ShouldOpenWithWebIntents(item)) {
- OpenWithWebIntent(item);
- callback.Run(true);
- return false;
- }
-#endif
-
return true;
}
-#if defined(ENABLE_WEB_INTENTS)
-bool ChromeDownloadManagerDelegate::ShouldOpenWithWebIntents(
- const DownloadItem* item) {
- if (!web_intents::IsWebIntentsEnabledForProfile(profile_))
- return false;
-
- if ((item->GetWebContents() && !item->GetWebContents()->GetDelegate()) &&
- !web_intents::GetBrowserForBackgroundWebIntentDelivery(profile_)) {
- return false;
- }
- if (!item->GetForcedFilePath().empty())
- return false;
- if (item->GetTargetDisposition() == DownloadItem::TARGET_DISPOSITION_PROMPT)
- return false;
-
-#if !defined(OS_CHROMEOS)
- std::string mime_type = item->GetMimeType();
-
- // If QuickOffice extension is installed, and we're not on ChromeOS,use web
- // intents to handle the downloaded file.
- const char kQuickOfficeExtensionId[] = "gbkeegbaiigmenfmjfclcdgdpimamgkj";
- const char kQuickOfficeDevExtensionId[] = "ionpfmkccalenbmnddpbmocokhaknphg";
- ExtensionServiceInterface* extension_service =
- extensions::ExtensionSystem::Get(profile_)->extension_service();
-
- bool use_quickoffice = false;
- if (extension_service &&
- extension_service->GetInstalledExtension(kQuickOfficeExtensionId) &&
- extension_service->IsExtensionEnabled(kQuickOfficeExtensionId))
- use_quickoffice = true;
-
- if (extension_service &&
- extension_service->GetInstalledExtension(kQuickOfficeDevExtensionId) &&
- extension_service->IsExtensionEnabled(kQuickOfficeDevExtensionId))
- use_quickoffice = true;
-
- if (use_quickoffice) {
- if (mime_type == "application/msword" ||
- mime_type == "application/vnd.ms-powerpoint" ||
- mime_type == "application/vnd.ms-excel" ||
- mime_type == "application/vnd.openxmlformats-officedocument."
- "wordprocessingml.document" ||
- mime_type == "application/vnd.openxmlformats-officedocument."
- "presentationml.presentation" ||
- mime_type == "application/vnd.openxmlformats-officedocument."
- "spreadsheetml.sheet") {
- return true;
- }
- }
-#endif // !defined(OS_CHROMEOS)
-
- return false;
-}
-
-void ChromeDownloadManagerDelegate::OpenWithWebIntent(
- const DownloadItem* item) {
- webkit_glue::WebIntentData intent_data(
- ASCIIToUTF16("http://webintents.org/view"),
- ASCIIToUTF16(item->GetMimeType()),
- item->GetFullPath(),
- item->GetReceivedBytes());
-
- // RCH specifies that the receiver gets the url, but with Web Intents
- // it isn't really needed.
- intent_data.extra_data.insert(make_pair(
- ASCIIToUTF16("url"), ASCIIToUTF16(item->GetURL().spec())));
-
- // Pass the downloaded filename to the service app as the name hint.
- intent_data.extra_data.insert(
- make_pair(ASCIIToUTF16("filename"),
- item->GetFileNameToReportUser().LossyDisplayName()));
-
- content::WebIntentsDispatcher* dispatcher =
- content::WebIntentsDispatcher::Create(intent_data);
- dispatcher->RegisterReplyNotification(
- base::Bind(&OnWebIntentDispatchCompleted, item->GetFullPath()));
-
- content::WebContentsDelegate* delegate = NULL;
-#if !defined(OS_ANDROID)
- if (item->GetWebContents() && item->GetWebContents()->GetDelegate()) {
- delegate = item->GetWebContents()->GetDelegate();
- } else {
- delegate = web_intents::GetBrowserForBackgroundWebIntentDelivery(profile_);
- }
-#endif // !defined(OS_ANDROID)
- DCHECK(delegate);
- delegate->WebIntentDispatch(NULL, dispatcher);
-}
-#endif
-
bool ChromeDownloadManagerDelegate::GenerateFileHash() {
#if defined(FULL_SAFE_BROWSING)
return profile_->GetPrefs()->GetBoolean(prefs::kSafeBrowsingEnabled) &&
@@ -788,16 +667,6 @@ void ChromeDownloadManagerDelegate::CheckVisitedReferrerBeforeDone(
suggested_path = download->GetForcedFilePath();
}
-#if defined(ENABLE_WEB_INTENTS)
- // If we will open the file with a web intents dispatch,
- // give it a name that will not allow the OS to open it using usual
- // associated apps.
- if (ShouldOpenWithWebIntents(download)) {
- download->SetDisplayName(suggested_path.BaseName());
- suggested_path = suggested_path.AddExtension(kWebIntentsFileExtension);
- }
-#endif
-
// If the download hasn't already been marked dangerous (could be
// DANGEROUS_URL), check if it is a dangerous file.
if (danger_type == content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS) {
diff --git a/chrome/browser/download/chrome_download_manager_delegate.h b/chrome/browser/download/chrome_download_manager_delegate.h
index ff64439..2014069 100644
--- a/chrome/browser/download/chrome_download_manager_delegate.h
+++ b/chrome/browser/download/chrome_download_manager_delegate.h
@@ -208,15 +208,6 @@ class ChromeDownloadManagerDelegate
content::DownloadDangerType danger_type,
const base::FilePath& target_path);
-#if defined(ENABLE_WEB_INTENTS)
- // Check policy of whether we should open this download with a web intents
- // dispatch.
- bool ShouldOpenWithWebIntents(const content::DownloadItem* item);
-
- // Open the given item with a web intent dispatch.
- void OpenWithWebIntent(const content::DownloadItem* item);
-#endif
-
// Internal gateways for ShouldCompleteDownload().
bool IsDownloadReadyForCompletion(
content::DownloadItem* item,
diff --git a/chrome/browser/extensions/api/app_runtime/app_runtime_api.cc b/chrome/browser/extensions/api/app_runtime/app_runtime_api.cc
index d5180e8..ff70376 100644
--- a/chrome/browser/extensions/api/app_runtime/app_runtime_api.cc
+++ b/chrome/browser/extensions/api/app_runtime/app_runtime_api.cc
@@ -11,27 +11,18 @@
#include "base/values.h"
#include "chrome/browser/extensions/event_router.h"
#include "chrome/browser/extensions/extension_system.h"
-#include "chrome/browser/extensions/web_intent_callbacks.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/extensions/extension.h"
#include "content/public/browser/web_contents.h"
-#include "content/public/browser/web_intents_dispatcher.h"
#include "googleurl/src/gurl.h"
-#include "webkit/glue/web_intent_data.h"
namespace extensions {
namespace {
-const char kIntentIdKey[] = "intentId";
-const char kIntentSuccessKey[] = "success";
-const char kIntentDataKey[] = "data";
const char kOnLaunchedEvent[] = "app.runtime.onLaunched";
const char kOnRestartedEvent[] = "app.runtime.onRestarted";
-const char kCallbackNotFoundError[] =
- "WebIntent callback not found; perhaps already responded to";
-
void DispatchOnLaunchedEventImpl(const std::string& extension_id,
scoped_ptr<base::ListValue> args,
Profile* profile) {
@@ -72,7 +63,7 @@ void AppEventRouter::DispatchOnRestartedEvent(
// static.
void AppEventRouter::DispatchOnLaunchedEventWithFileEntry(
- Profile* profile, const Extension* extension, const string16& action,
+ Profile* profile, const Extension* extension,
const std::string& handler_id, const std::string& mime_type,
const std::string& file_system_id, const std::string& base_name) {
scoped_ptr<ListValue> args(new ListValue());
@@ -89,97 +80,4 @@ void AppEventRouter::DispatchOnLaunchedEventWithFileEntry(
DispatchOnLaunchedEventImpl(extension->id(), args.Pass(), profile);
}
-// static.
-void AppEventRouter::DispatchOnLaunchedEventWithWebIntent(
- Profile* profile, const Extension* extension,
- content::WebIntentsDispatcher* intents_dispatcher,
- content::WebContents* source) {
-#if defined(ENABLE_WEB_INTENTS)
- webkit_glue::WebIntentData web_intent_data = intents_dispatcher->GetIntent();
- scoped_ptr<ListValue> args(new ListValue());
- DictionaryValue* launch_data = new DictionaryValue();
- DictionaryValue* intent = new DictionaryValue();
- intent->SetString("action", UTF16ToUTF8(web_intent_data.action));
- intent->SetString("type", UTF16ToUTF8(web_intent_data.type));
- launch_data->Set("intent", intent);
- args->Append(launch_data);
- DictionaryValue* intent_data;
- switch (web_intent_data.data_type) {
- case webkit_glue::WebIntentData::SERIALIZED:
- intent_data = new DictionaryValue();
- intent_data->SetString("format", "serialized");
- intent_data->SetString("data", UTF16ToUTF8(web_intent_data.data));
- // NOTE: This second argument is dropped before being dispatched to the
- // client code.
- args->Append(intent_data);
- break;
- case webkit_glue::WebIntentData::UNSERIALIZED:
- args->Append(Value::CreateNullValue());
- intent->SetString("data", UTF16ToUTF8(web_intent_data.unserialized_data));
- break;
- case webkit_glue::WebIntentData::BLOB:
- intent_data = new DictionaryValue();
- intent_data->SetString("format", "blob");
- intent_data->SetString("blobFileName", web_intent_data.blob_file.value());
- intent_data->SetString("blobLength",
- base::Int64ToString(web_intent_data.blob_length));
- // NOTE: This second argument is dropped before being dispatched to the
- // client code.
- args->Append(intent_data);
- break;
- case webkit_glue::WebIntentData::FILESYSTEM:
- intent_data = new DictionaryValue();
- intent_data->SetString("format", "filesystem");
- intent_data->SetString("fileSystemId", web_intent_data.filesystem_id);
- intent_data->SetString("baseName", web_intent_data.root_name);
- args->Append(intent_data);
- break;
- default:
- NOTREACHED();
- break;
- }
- DCHECK(args->GetSize() == 2); // intent_id must be our third argument.
- WebIntentCallbacks* callbacks = WebIntentCallbacks::Get(profile);
- int intent_id =
- callbacks->RegisterCallback(extension, intents_dispatcher, source);
- args->Append(base::Value::CreateIntegerValue(intent_id));
- DispatchOnLaunchedEventImpl(extension->id(), args.Pass(), profile);
-#endif
-}
-
-bool AppRuntimePostIntentResponseFunction::RunImpl() {
-#if defined(ENABLE_WEB_INTENTS)
- DictionaryValue* details = NULL;
- EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(0, &details));
-
- int intent_id = 0;
- EXTENSION_FUNCTION_VALIDATE(details->GetInteger(kIntentIdKey, &intent_id));
-
- WebIntentCallbacks* callbacks = WebIntentCallbacks::Get(profile());
- content::WebIntentsDispatcher* intents_dispatcher =
- callbacks->RetrieveCallback(GetExtension(), intent_id);
- if (!intents_dispatcher) {
- error_ = kCallbackNotFoundError;
- return false;
- }
-
- webkit_glue::WebIntentReplyType reply_type =
- webkit_glue::WEB_INTENT_REPLY_FAILURE;
- bool success;
- EXTENSION_FUNCTION_VALIDATE(details->GetBoolean(kIntentSuccessKey, &success));
- if (success)
- reply_type = webkit_glue::WEB_INTENT_REPLY_SUCCESS;
-
- std::string data;
- EXTENSION_FUNCTION_VALIDATE(details->GetString(kIntentDataKey, &data));
-
- intents_dispatcher->SendReply(webkit_glue::WebIntentReply(
- reply_type, UTF8ToUTF16(data)));
-
- return true;
-#else
- return false;
-#endif
-}
-
} // namespace extensions
diff --git a/chrome/browser/extensions/api/app_runtime/app_runtime_api.h b/chrome/browser/extensions/api/app_runtime/app_runtime_api.h
index 0611c49..84ade63 100644
--- a/chrome/browser/extensions/api/app_runtime/app_runtime_api.h
+++ b/chrome/browser/extensions/api/app_runtime/app_runtime_api.h
@@ -12,7 +12,6 @@ class Profile;
namespace content {
class WebContents;
-class WebIntentsDispatcher;
}
namespace extensions {
@@ -28,11 +27,11 @@ class AppEventRouter {
static void DispatchOnRestartedEvent(Profile* profile,
const Extension* extension);
+ // TODO(benwells): Update this comment, it is out of date.
// Dispatches the onLaunched event to the given app, providing launch data of
// the form:
// {
// "intent" : {
- // "action" : |action|,
// "type" : "chrome-extension://fileentry",
// "data" : a FileEntry,
// "postResults" : a null function,
@@ -46,30 +45,10 @@ class AppEventRouter {
static void DispatchOnLaunchedEventWithFileEntry(
Profile* profile,
const Extension* extension,
- const string16& action,
const std::string& handler_id,
const std::string& mime_type,
const std::string& file_system_id,
const std::string& base_name);
-
- // Dispatches the onLaunched event to the app implemented by |extension|
- // running in |profile|. The event parameter launchData will have a field
- // called intent, populated by |web_intent_data|.
- static void DispatchOnLaunchedEventWithWebIntent(
- Profile* profile,
- const Extension* extension,
- content::WebIntentsDispatcher* intents_dispatcher,
- content::WebContents* source);
-};
-
-class AppRuntimePostIntentResponseFunction : public SyncExtensionFunction {
- public:
- DECLARE_EXTENSION_FUNCTION("app.runtime.postIntentResponse",
- APP_RUNTIME_POSTINTENTRESPONSE)
-
- protected:
- virtual ~AppRuntimePostIntentResponseFunction() {}
- virtual bool RunImpl() OVERRIDE;
};
} // namespace extensions
diff --git a/chrome/browser/extensions/extension_host.cc b/chrome/browser/extensions/extension_host.cc
index 99c8da6..334054f 100644
--- a/chrome/browser/extensions/extension_host.cc
+++ b/chrome/browser/extensions/extension_host.cc
@@ -21,7 +21,6 @@
#include "chrome/browser/extensions/extension_tab_util.h"
#include "chrome/browser/extensions/window_controller.h"
#include "chrome/browser/file_select_helper.h"
-#include "chrome/browser/intents/web_intents_util.h"
#include "chrome/browser/media/media_capture_devices_dispatcher.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/app_modal_dialogs/javascript_dialog_manager.h"
@@ -48,7 +47,6 @@
#include "content/public/browser/site_instance.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_view.h"
-#include "content/public/browser/web_intents_dispatcher.h"
#include "grit/browser_resources.h"
#include "grit/chromium_strings.h"
#include "grit/generated_resources.h"
@@ -424,28 +422,6 @@ void ExtensionHost::OnStartDownload(
OnStartDownload(source, download);
}
-void ExtensionHost::WebIntentDispatch(
- content::WebContents* web_contents,
- content::WebIntentsDispatcher* intents_dispatcher) {
-#if !defined(OS_ANDROID)
- scoped_ptr<content::WebIntentsDispatcher> dispatcher(intents_dispatcher);
-
- Browser* browser = view() ? view()->browser()
- : chrome::FindBrowserWithWebContents(web_contents);
-
- // For background scripts/pages, there will be no view(). In this case, we
- // want to treat the intent as a browser-initiated one and deliver it into the
- // current browser. It probably came from a context menu click or similar.
- if (!browser)
- browser = web_intents::GetBrowserForBackgroundWebIntentDelivery(profile());
-
- if (browser) {
- static_cast<WebContentsDelegate*>(browser)->
- WebIntentDispatch(NULL, dispatcher.release());
- }
-#endif
-}
-
void ExtensionHost::WillRunJavaScriptDialog() {
ExtensionProcessManager* pm =
ExtensionSystem::Get(profile_)->process_manager();
diff --git a/chrome/browser/extensions/extension_host.h b/chrome/browser/extensions/extension_host.h
index d9ff3ca..cea7f1c 100644
--- a/chrome/browser/extensions/extension_host.h
+++ b/chrome/browser/extensions/extension_host.h
@@ -36,7 +36,6 @@ namespace content {
class RenderProcessHost;
class RenderWidgetHostView;
class SiteInstance;
-class WebIntentsDispatcher;
}
namespace extensions {
@@ -168,9 +167,6 @@ class ExtensionHost : public content::WebContentsDelegate,
virtual void CloseContents(content::WebContents* contents) OVERRIDE;
virtual void OnStartDownload(content::WebContents* source,
content::DownloadItem* download) OVERRIDE;
- virtual void WebIntentDispatch(
- content::WebContents* web_contents,
- content::WebIntentsDispatcher* intents_dispatcher) OVERRIDE;
virtual void RequestMediaAccessPermission(
content::WebContents* web_contents,
const content::MediaStreamRequest& request,
diff --git a/chrome/browser/extensions/extension_special_storage_policy.cc b/chrome/browser/extensions/extension_special_storage_policy.cc
index e035ff1..e239641 100644
--- a/chrome/browser/extensions/extension_special_storage_policy.cc
+++ b/chrome/browser/extensions/extension_special_storage_policy.cc
@@ -9,39 +9,16 @@
#include "base/stl_util.h"
#include "base/utf_string_conversions.h"
#include "chrome/browser/content_settings/cookie_settings.h"
-#include "chrome/browser/intents/web_intents_util.h"
#include "chrome/common/content_settings.h"
#include "chrome/common/content_settings_types.h"
#include "chrome/common/extensions/extension.h"
-#include "chrome/common/extensions/web_intents_handler.h"
#include "chrome/common/url_constants.h"
#include "content/public/browser/browser_thread.h"
#include "extensions/common/constants.h"
-#include "webkit/glue/web_intent_service_data.h"
using content::BrowserThread;
using extensions::APIPermission;
-namespace {
-
-// Does the specified extension support the passed Web Intent, |action|?
-bool ExtensionSupportsIntentAction(
- const extensions::Extension* extension,
- const std::string& action) {
-#if defined(ENABLE_WEB_INTENTS)
- for (std::vector<webkit_glue::WebIntentServiceData>::const_iterator i =
- extensions::WebIntentsInfo::GetIntentsServices(extension).begin();
- i != extensions::WebIntentsInfo::GetIntentsServices(extension).end();
- ++i) {
- if (UTF16ToUTF8(i->action) == action)
- return true;
- }
-#endif
- return false;
-}
-
-} // namespace
-
ExtensionSpecialStoragePolicy::ExtensionSpecialStoragePolicy(
CookieSettings* cookie_settings)
: cookie_settings_(cookie_settings) {}
@@ -88,8 +65,7 @@ bool ExtensionSpecialStoragePolicy::HasSessionOnlyOrigins() {
bool ExtensionSpecialStoragePolicy::IsFileHandler(
const std::string& extension_id) {
base::AutoLock locker(lock_);
- return web_intent_extensions_.ContainsExtension(extension_id) ||
- file_handler_extensions_.ContainsExtension(extension_id);
+ return file_handler_extensions_.ContainsExtension(extension_id);
}
bool ExtensionSpecialStoragePolicy::NeedsProtection(
@@ -106,14 +82,11 @@ const ExtensionSet* ExtensionSpecialStoragePolicy::ExtensionsProtectingOrigin(
void ExtensionSpecialStoragePolicy::GrantRightsForExtension(
const extensions::Extension* extension) {
DCHECK(extension);
- const bool supports_intent_view = ExtensionSupportsIntentAction(
- extension, web_intents::kActionView);
if (!NeedsProtection(extension) &&
!extension->HasAPIPermission(
APIPermission::kUnlimitedStorage) &&
!extension->HasAPIPermission(
- APIPermission::kFileBrowserHandler) &&
- !supports_intent_view) {
+ APIPermission::kFileBrowserHandler)) {
return;
}
{
@@ -128,8 +101,6 @@ void ExtensionSpecialStoragePolicy::GrantRightsForExtension(
if (extension->HasAPIPermission(
APIPermission::kFileBrowserHandler))
file_handler_extensions_.Add(extension);
- if (supports_intent_view)
- web_intent_extensions_.Add(extension);
}
NotifyChanged();
}
@@ -137,14 +108,11 @@ void ExtensionSpecialStoragePolicy::GrantRightsForExtension(
void ExtensionSpecialStoragePolicy::RevokeRightsForExtension(
const extensions::Extension* extension) {
DCHECK(extension);
- const bool supports_intent_view = ExtensionSupportsIntentAction(
- extension, web_intents::kActionView);
if (!NeedsProtection(extension) &&
!extension->HasAPIPermission(
APIPermission::kUnlimitedStorage) &&
!extension->HasAPIPermission(
- APIPermission::kFileBrowserHandler) &&
- !supports_intent_view) {
+ APIPermission::kFileBrowserHandler)) {
return;
}
{
@@ -157,8 +125,6 @@ void ExtensionSpecialStoragePolicy::RevokeRightsForExtension(
unlimited_extensions_.Remove(extension);
if (extension->HasAPIPermission(APIPermission::kFileBrowserHandler))
file_handler_extensions_.Remove(extension);
- if (supports_intent_view)
- web_intent_extensions_.Remove(extension);
}
NotifyChanged();
}
@@ -170,7 +136,6 @@ void ExtensionSpecialStoragePolicy::RevokeRightsForAllExtensions() {
installed_apps_.Clear();
unlimited_extensions_.Clear();
file_handler_extensions_.Clear();
- web_intent_extensions_.Clear();
}
NotifyChanged();
}
diff --git a/chrome/browser/extensions/extension_special_storage_policy.h b/chrome/browser/extensions/extension_special_storage_policy.h
index 7a7a2c1..54f0119 100644
--- a/chrome/browser/extensions/extension_special_storage_policy.h
+++ b/chrome/browser/extensions/extension_special_storage_policy.h
@@ -79,7 +79,6 @@ class ExtensionSpecialStoragePolicy : public quota::SpecialStoragePolicy {
SpecialCollection installed_apps_;
SpecialCollection unlimited_extensions_;
SpecialCollection file_handler_extensions_;
- SpecialCollection web_intent_extensions_;
scoped_refptr<CookieSettings> cookie_settings_;
};
diff --git a/chrome/browser/extensions/extension_special_storage_policy_unittest.cc b/chrome/browser/extensions/extension_special_storage_policy_unittest.cc
index 5220587..62cd4f1 100644
--- a/chrome/browser/extensions/extension_special_storage_policy_unittest.cc
+++ b/chrome/browser/extensions/extension_special_storage_policy_unittest.cc
@@ -12,7 +12,6 @@
#include "chrome/common/extensions/extension_manifest_constants.h"
#include "chrome/common/extensions/manifest.h"
#include "chrome/common/extensions/manifest_handler.h"
-#include "chrome/common/extensions/web_intents_handler.h"
#include "chrome/test/base/testing_profile.h"
#include "content/public/test/test_browser_thread.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -27,11 +26,6 @@ class ExtensionSpecialStoragePolicyTest : public testing::Test {
public:
virtual void SetUp() {
policy_ = new ExtensionSpecialStoragePolicy(NULL);
-#if defined(ENABLE_WEB_INTENTS)
- extensions::ManifestHandler::Register(
- keys::kIntents,
- make_linked_ptr(new extensions::WebIntentsHandler));
-#endif
}
protected:
@@ -134,42 +128,6 @@ class ExtensionSpecialStoragePolicyTest : public testing::Test {
return handler_app;
}
-#if defined(ENABLE_WEB_INTENTS)
- scoped_refptr<Extension> CreateWebIntentViewApp() {
-#if defined(OS_WIN)
- base::FilePath path(FILE_PATH_LITERAL("c:\\bar"));
-#elif defined(OS_POSIX)
- base::FilePath path(FILE_PATH_LITERAL("/bar"));
-#endif
- DictionaryValue manifest;
- manifest.SetString(keys::kName, "WebIntent");
- manifest.SetString(keys::kVersion, "1");
- manifest.SetString(keys::kLaunchWebURL, "http://explicit/unlimited/start");
-
- ListValue* view_intent_types = new ListValue;
- view_intent_types->Append(Value::CreateStringValue("text/plain"));
-
- DictionaryValue* view_intent = new DictionaryValue;
- view_intent->SetString(keys::kIntentTitle, "Test Intent");
- view_intent->Set(keys::kIntentType, view_intent_types);
-
- ListValue* view_intent_list = new ListValue;
- view_intent_list->Append(view_intent);
-
- DictionaryValue* intents = new DictionaryValue;
- intents->SetWithoutPathExpansion("http://webintents.org/view",
- view_intent_list);
- manifest.Set(keys::kIntents, intents);
-
- std::string error;
- scoped_refptr<Extension> intent_app = Extension::Create(
- path, Manifest::INVALID_LOCATION, manifest,
- Extension::NO_FLAGS, &error);
- EXPECT_TRUE(intent_app.get()) << error;
- return intent_app;
- }
-#endif
-
// Verifies that the set of extensions protecting |url| is *exactly* equal to
// |expected_extensions|. Pass in an empty set to verify that an origin is not
// protected.
@@ -291,18 +249,6 @@ TEST_F(ExtensionSpecialStoragePolicyTest, OverlappingApps) {
ExpectProtectedBy(empty_set, GURL("https://bar.wildcards/"));
}
-TEST_F(ExtensionSpecialStoragePolicyTest, WebIntentViewApp) {
-#if defined(ENABLE_WEB_INTENTS)
- scoped_refptr<Extension> intent_app(CreateWebIntentViewApp());
-
- policy_->GrantRightsForExtension(intent_app);
- EXPECT_TRUE(policy_->IsFileHandler(intent_app->id()));
-
- policy_->RevokeRightsForExtension(intent_app);
- EXPECT_FALSE(policy_->IsFileHandler(intent_app->id()));
-#endif
-}
-
TEST_F(ExtensionSpecialStoragePolicyTest, HasSessionOnlyOrigins) {
MessageLoop message_loop;
content::TestBrowserThread ui_thread(BrowserThread::UI, &message_loop);
diff --git a/chrome/browser/extensions/platform_app_browsertest.cc b/chrome/browser/extensions/platform_app_browsertest.cc
index 1b2fe67..c4c6731 100644
--- a/chrome/browser/extensions/platform_app_browsertest.cc
+++ b/chrome/browser/extensions/platform_app_browsertest.cc
@@ -34,10 +34,8 @@
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/render_widget_host_view.h"
#include "content/public/browser/web_contents_view.h"
-#include "content/public/browser/web_intents_dispatcher.h"
#include "content/public/test/test_utils.h"
#include "googleurl/src/gurl.h"
-#include "webkit/glue/web_intent_data.h"
using content::WebContents;
@@ -67,54 +65,6 @@ class PlatformAppContextMenu : public RenderViewContextMenu {
virtual void PlatformCancel() OVERRIDE {}
};
-#if defined(ENABLE_WEB_INTENTS)
-// State holder for the LaunchReply test. This provides an WebIntentsDispatcher
-// that will, when used to launch a Web Intent, will return its reply via this
-// class. The result may then be waited on via WaitUntilReply().
-class LaunchReplyHandler {
- public:
- explicit LaunchReplyHandler(webkit_glue::WebIntentData& data)
- : data_(data),
- replied_(false),
- weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {
- intents_dispatcher_ = content::WebIntentsDispatcher::Create(data);
- intents_dispatcher_->RegisterReplyNotification(base::Bind(
- &LaunchReplyHandler::OnReply, weak_ptr_factory_.GetWeakPtr()));
- }
-
- content::WebIntentsDispatcher* intents_dispatcher() {
- return intents_dispatcher_;
- }
-
- // Waits until a reply to this Web Intent is provided via the
- // WebIntentsDispatcher.
- bool WaitUntilReply() {
- if (replied_)
- return true;
- waiting_ = true;
- content::RunMessageLoop();
- waiting_ = false;
- return replied_;
- }
-
- private:
- void OnReply(webkit_glue::WebIntentReplyType reply) {
- // Note that the ReplyNotification registered on WebIntentsDispatcher does
- // not include the result data: this is reserved for the source page (which
- // we don't care about).
- replied_ = true;
- if (waiting_)
- MessageLoopForUI::current()->Quit();
- }
-
- webkit_glue::WebIntentData data_;
- bool replied_;
- bool waiting_;
- content::WebIntentsDispatcher* intents_dispatcher_;
- base::WeakPtrFactory<LaunchReplyHandler> weak_ptr_factory_;
-};
-#endif
-
// This class keeps track of tabs as they are added to the browser. It will be
// "done" (i.e. won't block on Wait()) once |observations| tabs have been added.
class TabsAddedNotificationObserver
@@ -163,39 +113,6 @@ IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, OnLaunchedEvent) {
ASSERT_TRUE(RunPlatformAppTest("platform_apps/launch")) << message_;
}
-#if defined(ENABLE_WEB_INTENTS)
-// Tests that platform apps can reply to "launch" events that contain a Web
-// Intent. This test does not test the mechanics of invoking a Web Intent
-// from a source page, and short-circuits to LaunchPlatformAppWithWebIntent.
-IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, LaunchReply) {
- base::FilePath path =
- test_data_dir_.AppendASCII("platform_apps/launch_reply");
- const extensions::Extension* extension = LoadExtension(path);
- ASSERT_TRUE(extension) << "Failed to load extension.";
-
- webkit_glue::WebIntentData data(
- UTF8ToUTF16("http://webintents.org/view"),
- UTF8ToUTF16("text/plain"),
- UTF8ToUTF16("irrelevant unserialized string data"));
- LaunchReplyHandler handler(data);
-
- // Navigate to a boring page: we don't care what it is, but we require some
- // source WebContents to launch the Web Intent "from".
- ui_test_utils::NavigateToURL(browser(), GURL("about:blank"));
- WebContents* web_contents =
- browser()->tab_strip_model()->GetActiveWebContents();
- ASSERT_TRUE(web_contents);
-
- extensions::LaunchPlatformAppWithWebIntent(
- browser()->profile(),
- extension,
- handler.intents_dispatcher(),
- web_contents);
-
- ASSERT_TRUE(handler.WaitUntilReply());
-}
-#endif
-
// Tests that platform apps cannot use certain disabled window properties, but
// can override them and then use them.
IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, DisabledWindowProperties) {
diff --git a/chrome/browser/extensions/platform_app_launcher.cc b/chrome/browser/extensions/platform_app_launcher.cc
index 3c9d93d..8527476 100644
--- a/chrome/browser/extensions/platform_app_launcher.cc
+++ b/chrome/browser/extensions/platform_app_launcher.cc
@@ -17,22 +17,17 @@
#include "chrome/browser/extensions/extension_process_manager.h"
#include "chrome/browser/extensions/extension_system.h"
#include "chrome/browser/extensions/lazy_background_task_queue.h"
-#include "chrome/browser/intents/web_intents_util.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/extensions/extension.h"
#include "chrome/common/extensions/extension_messages.h"
-#include "chrome/common/extensions/web_intents_handler.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/child_process_security_policy.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/web_contents.h"
-#include "content/public/browser/web_intents_dispatcher.h"
#include "net/base/mime_util.h"
#include "net/base/net_util.h"
#include "webkit/fileapi/file_system_types.h"
#include "webkit/fileapi/isolated_context.h"
-#include "webkit/glue/web_intent_data.h"
-#include "webkit/glue/web_intent_service_data.h"
using content::BrowserThread;
using extensions::app_file_handler_util::FileHandlerForId;
@@ -153,10 +148,7 @@ class PlatformAppPathLauncher
}
void LaunchWithMimeType(const std::string& mime_type) {
- // Find the intent service or file handler from the platform app for the
- // file being opened.
- bool found_service = false;
-
+ // Find file handler from the platform app for the file being opened.
const FileHandlerInfo* handler = NULL;
if (!handler_id_.empty())
handler = FileHandlerForId(*extension_, handler_id_);
@@ -169,28 +161,10 @@ class PlatformAppPathLauncher
LaunchWithNoLaunchData();
return;
}
- found_service = !!handler;
-
- // TODO(benwells): remove this once we no longer support the "intents"
- // syntax in platform app manifests.
- if (!found_service) {
-#if defined(ENABLE_WEB_INTENTS)
- std::vector<webkit_glue::WebIntentServiceData> services =
- extensions::WebIntentsInfo::GetIntentsServices(extension_);
- for (size_t i = 0; i < services.size(); i++) {
- std::string service_type_ascii = UTF16ToASCII(services[i].type);
- if (services[i].action == ASCIIToUTF16(web_intents::kActionView) &&
- net::MatchesMimeType(service_type_ascii, mime_type)) {
- found_service = true;
- break;
- }
- }
-#endif
- }
- // If this app doesn't have an intent that supports the file, launch with
- // no launch data.
- if (!found_service) {
+ // If this app doesn't have a file handler that supports the file, launch
+ // with no launch data.
+ if (!handler) {
LOG(WARNING) << "Extension does not provide a valid file handler for "
<< file_path_.value();
LaunchWithNoLaunchData();
@@ -249,8 +223,8 @@ class PlatformAppPathLauncher
policy->GrantReadFileSystem(renderer_id, filesystem_id);
AppEventRouter::DispatchOnLaunchedEventWithFileEntry(
- profile_, extension_, ASCIIToUTF16(web_intents::kActionView),
- handler_id_, mime_type, filesystem_id, registered_name);
+ profile_, extension_, handler_id_, mime_type, filesystem_id,
+ registered_name);
}
// The profile the app should be run in.
@@ -265,115 +239,6 @@ class PlatformAppPathLauncher
DISALLOW_COPY_AND_ASSIGN(PlatformAppPathLauncher);
};
-#if defined(ENABLE_WEB_INTENTS)
-// Class to handle launching of platform apps with WebIntent data.
-// An instance of this class is created for each launch. The lifetime of these
-// instances is managed by reference counted pointers. As long as an instance
-// has outstanding tasks on a message queue it will be retained; once all
-// outstanding tasks are completed it will be deleted.
-class PlatformAppWebIntentLauncher
- : public base::RefCountedThreadSafe<PlatformAppWebIntentLauncher> {
- public:
- PlatformAppWebIntentLauncher(
- Profile* profile,
- const Extension* extension,
- content::WebIntentsDispatcher* intents_dispatcher,
- content::WebContents* source)
- : profile_(profile),
- extension_(extension),
- intents_dispatcher_(intents_dispatcher),
- source_(source),
- data_(intents_dispatcher->GetIntent()) {}
-
- void Launch() {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- if (data_.data_type != webkit_glue::WebIntentData::BLOB &&
- data_.data_type != webkit_glue::WebIntentData::FILESYSTEM) {
- InternalLaunch();
- return;
- }
-
- // Access needs to be granted to the file or filesystem for the process
- // associated with the extension. To do this the ExtensionHost is needed.
- // This might not be available, or it might be in the process of being
- // unloaded, in which case the lazy background task queue is used to load
- // he extension and then call back to us.
- LazyBackgroundTaskQueue* queue =
- ExtensionSystem::Get(profile_)->lazy_background_task_queue();
- if (queue->ShouldEnqueueTask(profile_, extension_)) {
- queue->AddPendingTask(profile_, extension_->id(), base::Bind(
- &PlatformAppWebIntentLauncher::GrantAccessToFileAndLaunch,
- this));
- return;
- }
- ExtensionProcessManager* process_manager =
- ExtensionSystem::Get(profile_)->process_manager();
- ExtensionHost* host =
- process_manager->GetBackgroundHostForExtension(extension_->id());
- DCHECK(host);
- GrantAccessToFileAndLaunch(host);
- }
-
- private:
- friend class base::RefCountedThreadSafe<PlatformAppWebIntentLauncher>;
-
- virtual ~PlatformAppWebIntentLauncher() {}
-
- void GrantAccessToFileAndLaunch(ExtensionHost* host) {
- // If there was an error loading the app page, |host| will be NULL.
- if (!host) {
- LOG(ERROR) << "Could not load app page for " << extension_->id();
- return;
- }
-
- content::ChildProcessSecurityPolicy* policy =
- content::ChildProcessSecurityPolicy::GetInstance();
- int renderer_id = host->render_process_host()->GetID();
-
- if (data_.data_type == webkit_glue::WebIntentData::BLOB) {
- // Granting read file permission to allow reading file content.
- // If the renderer already has permission to read these paths, it is not
- // regranted, as this would overwrite any other permissions which the
- // renderer may already have.
- if (!policy->CanReadFile(renderer_id, data_.blob_file))
- policy->GrantReadFile(renderer_id, data_.blob_file);
- } else if (data_.data_type == webkit_glue::WebIntentData::FILESYSTEM) {
- // Grant read filesystem and read directory permission to allow reading
- // any part of the specified filesystem.
- base::FilePath path;
- const bool valid =
- fileapi::IsolatedContext::GetInstance()->GetRegisteredPath(
- data_.filesystem_id, &path);
- DCHECK(valid);
- if (!policy->CanReadFile(renderer_id, path))
- policy->GrantReadFile(renderer_id, path);
- policy->GrantReadFileSystem(renderer_id, data_.filesystem_id);
- } else {
- NOTREACHED();
- }
- InternalLaunch();
- }
-
- void InternalLaunch() {
- AppEventRouter::DispatchOnLaunchedEventWithWebIntent(
- profile_, extension_, intents_dispatcher_, source_);
- }
-
- // The profile the app should be run in.
- Profile* profile_;
- // The extension providing the app.
- const Extension* extension_;
- // The dispatcher so that platform apps can respond to this intent.
- content::WebIntentsDispatcher* intents_dispatcher_;
- // The source of this intent.
- content::WebContents* source_;
- // The WebIntent data from the dispatcher.
- const webkit_glue::WebIntentData data_;
-
- DISALLOW_COPY_AND_ASSIGN(PlatformAppWebIntentLauncher);
-};
-#endif
-
} // namespace
void LaunchPlatformApp(Profile* profile,
@@ -410,17 +275,4 @@ void LaunchPlatformAppWithFileHandler(Profile* profile,
launcher->LaunchWithHandler(handler_id);
}
-#if defined(ENABLE_WEB_INTENTS)
-void LaunchPlatformAppWithWebIntent(
- Profile* profile,
- const Extension* extension,
- content::WebIntentsDispatcher* intents_dispatcher,
- content::WebContents* source) {
- scoped_refptr<PlatformAppWebIntentLauncher> launcher =
- new PlatformAppWebIntentLauncher(
- profile, extension, intents_dispatcher, source);
- launcher->Launch();
-}
-#endif
-
} // namespace extensions
diff --git a/chrome/browser/extensions/platform_app_launcher.h b/chrome/browser/extensions/platform_app_launcher.h
index ae9cfa5..c301c45 100644
--- a/chrome/browser/extensions/platform_app_launcher.h
+++ b/chrome/browser/extensions/platform_app_launcher.h
@@ -16,7 +16,6 @@ class FilePath;
namespace content {
class WebContents;
-class WebIntentsDispatcher;
}
namespace extensions {
@@ -45,17 +44,6 @@ void LaunchPlatformAppWithFileHandler(Profile* profile,
const std::string& handler_id,
const base::FilePath& file_path);
-#if defined(ENABLE_WEB_INTENTS)
-// Launches the platform app |extension| with the supplied web intent. Creates
-// appropriate launch data for the |web_intent_data| field present. |extension|
-// and |profile| must not be NULL.
-void LaunchPlatformAppWithWebIntent(
- Profile* profile,
- const Extension* extension,
- content::WebIntentsDispatcher* intents_dispatcher,
- content::WebContents* source);
-#endif
-
} // namespace extensions
#endif // CHROME_BROWSER_EXTENSIONS_PLATFORM_APP_LAUNCHER_H_
diff --git a/chrome/browser/extensions/web_intent_callbacks.cc b/chrome/browser/extensions/web_intent_callbacks.cc
deleted file mode 100644
index 38708b4..0000000
--- a/chrome/browser/extensions/web_intent_callbacks.cc
+++ /dev/null
@@ -1,128 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "base/stringprintf.h"
-#include "chrome/browser/extensions/web_intent_callbacks.h"
-#include "chrome/browser/profiles/profile_dependency_manager.h"
-#include "chrome/common/extensions/extension.h"
-#include "content/public/browser/web_contents.h"
-#include "content/public/browser/web_contents_observer.h"
-#include "content/public/browser/web_intents_dispatcher.h"
-
-namespace {
-
-// Get the key for use inside the internal pending WebIntentCallbacks map.
-std::string GetKey(const extensions::Extension* extension, int id) {
- return StringPrintf("%s/%d", extension->id().c_str(), id);
-}
-
-} // namespace
-
-namespace extensions {
-
-// SourceObserver is a subclass of WebContentsObserver that is instantiated
-// on RegisterCallback to wait for the source WebContents to be destroyed.
-// If it is destroyed, this automatically clears the callback from pending_.
-class WebIntentCallbacks::SourceObserver : content::WebContentsObserver {
- public:
- SourceObserver(content::WebContents* web_contents,
- WebIntentCallbacks* callbacks,
- const std::string& key)
- : content::WebContentsObserver(web_contents),
- callbacks_(callbacks),
- key_(key) {}
- virtual ~SourceObserver() {}
-
- // Implement WebContentsObserver
- virtual void WebContentsDestroyed(content::WebContents* web_contents)
- OVERRIDE {
- content::WebIntentsDispatcher* dispatcher =
- callbacks_->GetAndClear(key_);
- if (dispatcher)
- delete dispatcher;
-
- delete this;
- }
-
- private:
- WebIntentCallbacks* callbacks_;
- const std::string key_;
-};
-
-WebIntentCallbacks::WebIntentCallbacks() : last_id_(0) {}
-
-WebIntentCallbacks::~WebIntentCallbacks() {}
-
-// static
-WebIntentCallbacks* WebIntentCallbacks::Get(Profile* profile) {
- return Factory::GetForProfile(profile);
-}
-
-int WebIntentCallbacks::RegisterCallback(
- const Extension* extension,
- content::WebIntentsDispatcher* dispatcher,
- content::WebContents* source) {
- int id = ++last_id_;
- std::string key = GetKey(extension, id);
- pending_[key] = dispatcher;
-
- // TODO(thorogood): We should also listen for extension suspend events, and
- // clear the relevant callback (i.e., the handler of this intent)
-
- // TODO(thorogood): The source window may actually be a ShellWindow of a
- // platform app. In this case, we should not wait for its destruction:
- // rather, we should be listening to platform app suspend events.
-
- // Listen to when the source WebContent is destroyed. This object is self-
- // deleting on this event.
- DCHECK(source);
- new SourceObserver(source, this, key);
-
- return id;
-}
-
-content::WebIntentsDispatcher* WebIntentCallbacks::RetrieveCallback(
- const Extension* extension, int id) {
- std::string key = GetKey(extension, id);
- return GetAndClear(key);
-}
-
-content::WebIntentsDispatcher* WebIntentCallbacks::GetAndClear(
- const std::string& key) {
- if (!pending_.count(key))
- return NULL;
-
- content::WebIntentsDispatcher* dispatcher = pending_[key];
- pending_.erase(key);
- return dispatcher;
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// Factory boilerplate
-
-// static
-WebIntentCallbacks* WebIntentCallbacks::Factory::GetForProfile(
- Profile* profile) {
- return static_cast<WebIntentCallbacks*>(
- GetInstance()->GetServiceForProfile(profile, true));
-}
-
-WebIntentCallbacks::Factory* WebIntentCallbacks::Factory::GetInstance() {
- return Singleton<WebIntentCallbacks::Factory>::get();
-}
-
-WebIntentCallbacks::Factory::Factory()
- : ProfileKeyedServiceFactory("WebIntentCallbacks",
- ProfileDependencyManager::GetInstance()) {
-}
-
-WebIntentCallbacks::Factory::~Factory() {
-}
-
-ProfileKeyedService* WebIntentCallbacks::Factory::BuildServiceInstanceFor(
- Profile* profile) const {
- return new WebIntentCallbacks();
-}
-
-} // namespace extensions
diff --git a/chrome/browser/extensions/web_intent_callbacks.h b/chrome/browser/extensions/web_intent_callbacks.h
deleted file mode 100644
index 067d825..0000000
--- a/chrome/browser/extensions/web_intent_callbacks.h
+++ /dev/null
@@ -1,84 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_EXTENSIONS_WEB_INTENT_CALLBACKS_H_
-#define CHROME_BROWSER_EXTENSIONS_WEB_INTENT_CALLBACKS_H_
-
-#include "base/memory/singleton.h"
-#include "chrome/browser/profiles/profile_keyed_service.h"
-#include "chrome/browser/profiles/profile_keyed_service_factory.h"
-
-class Profile;
-
-namespace content {
-class WebContents;
-class WebIntentsDispatcher;
-}
-
-namespace extensions {
-class Extension;
-
-// The WebIntentCallbacks class tracks the pending callbacks for web intents
-// that have been delivered to packaged apps (i.e., new-style apps containing
-// shell windows), for a particular profile.
-class WebIntentCallbacks : public ProfileKeyedService {
- public:
- WebIntentCallbacks();
- virtual ~WebIntentCallbacks();
-
- // Returns the instance for the given profile. This is a convenience wrapper
- // around WebIntentCallbacks::Factory::GetForProfile.
- static WebIntentCallbacks* Get(Profile* profile);
-
- // Registers the callback for the Web Intent we're about to dispatch to the
- // given extension. Returns an identifier that should later be dispatched to
- // RetrieveCallback in order to invoke the callback registered here.
- // This transfers ownership of WebIntentsDispatcher to this class.
- int RegisterCallback(const Extension* extension,
- content::WebIntentsDispatcher* dispatcher,
- content::WebContents* source);
-
- // Retrieves the callback for the given identifier, for a response from the
- // specified extension. This will clear the callback. If there is no callback
- // registered under this identifier, then this will return NULL. This
- // transfers ownership of WebIntentsDispatcher to the caller.
- content::WebIntentsDispatcher* RetrieveCallback(const Extension* extension,
- int intent_id);
-
- private:
- typedef std::map<std::string, content::WebIntentsDispatcher*> CallbackMap;
-
- class Factory : public ProfileKeyedServiceFactory {
- public:
- static WebIntentCallbacks* GetForProfile(Profile* profile);
-
- static Factory* GetInstance();
- private:
- friend struct DefaultSingletonTraits<Factory>;
-
- Factory();
- virtual ~Factory();
-
- // ProfileKeyedServiceFactory
- virtual ProfileKeyedService* BuildServiceInstanceFor(
- Profile* profile) const OVERRIDE;
- };
-
- // Private method to get and clear the dispatcher for the given string key.
- // If there is no dispatcher available, this will return NULL. Otherwise, this
- // transfers ownership of the WebIntentsDispatcher to the caller.
- content::WebIntentsDispatcher* GetAndClear(const std::string& key);
-
- class SourceObserver;
-
- // Used as an incrementing ID for callback keys.
- int last_id_;
-
- // Stores all pending callbacks sent to platform apps.
- CallbackMap pending_;
-};
-
-} // namespace extensions
-
-#endif // CHROME_BROWSER_EXTENSIONS_WEB_INTENT_CALLBACKS_H_
diff --git a/chrome/browser/extensions/web_intents_parser.cc b/chrome/browser/extensions/web_intents_parser.cc
deleted file mode 100644
index 26be0a9..0000000
--- a/chrome/browser/extensions/web_intents_parser.cc
+++ /dev/null
@@ -1,32 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/extensions/web_intents_parser.h"
-
-#include "base/lazy_instance.h"
-#include "chrome/browser/profiles/profile.h"
-#include "chrome/common/extensions/extension_manifest_constants.h"
-#include "chrome/common/extensions/manifest_handler.h"
-#include "chrome/common/extensions/web_intents_handler.h"
-
-namespace extensions {
-
-WebIntentsParser::WebIntentsParser(Profile* profile) {
- ManifestHandler::Register(extension_manifest_keys::kIntents,
- make_linked_ptr(new WebIntentsHandler));
-}
-
-WebIntentsParser::~WebIntentsParser() {
-}
-
-static base::LazyInstance<ProfileKeyedAPIFactory<WebIntentsParser> >
-g_factory = LAZY_INSTANCE_INITIALIZER;
-
-// static
-ProfileKeyedAPIFactory<WebIntentsParser>*
- WebIntentsParser::GetFactoryInstance() {
- return &g_factory.Get();
-}
-
-} // namespace extensions
diff --git a/chrome/browser/extensions/web_intents_parser.h b/chrome/browser/extensions/web_intents_parser.h
deleted file mode 100644
index bb99ab3..0000000
--- a/chrome/browser/extensions/web_intents_parser.h
+++ /dev/null
@@ -1,37 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_EXTENSIONS_WEB_INTENTS_PARSER_H_
-#define CHROME_BROWSER_EXTENSIONS_WEB_INTENTS_PARSER_H_
-
-#include "base/basictypes.h"
-#include "chrome/browser/extensions/api/profile_keyed_api_factory.h"
-
-class Profile;
-
-namespace extensions {
-
-class WebIntentsParser : public ProfileKeyedAPI {
- public:
- explicit WebIntentsParser(Profile* profile);
- virtual ~WebIntentsParser();
-
- // ProfileKeyedAPI implementation.
- static ProfileKeyedAPIFactory<WebIntentsParser>* GetFactoryInstance();
-
- private:
- friend class ProfileKeyedAPIFactory<WebIntentsParser>;
-
- // ProfileKeyedAPI implementation.
- static const char* service_name() {
- return "WebIntentsParser";
- }
- static const bool kServiceIsNULLWhileTesting = true;
-
- DISALLOW_COPY_AND_ASSIGN(WebIntentsParser);
-};
-
-} // namespace extensions
-
-#endif // CHROME_BROWSER_EXTENSIONS_WEB_INTENTS_PARSER_H_
diff --git a/chrome/browser/intents/OWNERS b/chrome/browser/intents/OWNERS
deleted file mode 100644
index 39a4139..0000000
--- a/chrome/browser/intents/OWNERS
+++ /dev/null
@@ -1,4 +0,0 @@
-gbillock@chromium.org
-groby@chromium.org
-jhawkins@chromium.org
-smckay@chromium.org \ No newline at end of file
diff --git a/chrome/browser/intents/cws_intents_registry.cc b/chrome/browser/intents/cws_intents_registry.cc
deleted file mode 100644
index 4211499..0000000
--- a/chrome/browser/intents/cws_intents_registry.cc
+++ /dev/null
@@ -1,235 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/intents/cws_intents_registry.h"
-
-#include "base/callback.h"
-#include "base/json/json_string_value_serializer.h"
-#include "base/memory/scoped_ptr.h"
-#include "base/stl_util.h"
-#include "base/string16.h"
-#include "base/utf_string_conversions.h"
-#include "chrome/common/extensions/extension_l10n_util.h"
-#include "chrome/common/extensions/message_bundle.h"
-#include "chrome/browser/net/chrome_url_request_context.h"
-#include "chrome/browser/webdata/web_data_service.h"
-#include "google_apis/google_api_keys.h"
-#include "net/base/load_flags.h"
-#include "net/base/mime_util.h"
-#include "net/base/url_util.h"
-#include "net/url_request/url_fetcher.h"
-
-namespace {
-
-// Limit for the number of suggestions we fix from CWS. Ideally, the registry
-// simply get all of them, but there is a) chunking on the CWS side, and b)
-// there is a cost with suggestions fetched. (Network overhead for favicons,
-// roundtrips to registry to check if installed).
-//
-// Since the picker limits the number of suggestions displayed to 5, 15 means
-// the suggestion list only has the potential to be shorter than that once the
-// user has at least 10 installed handlers for the particular action/type.
-//
-// TODO(groby): Adopt number of suggestions dynamically so the picker can
-// always display 5 suggestions unless there are less than 5 viable extensions
-// in the CWS.
-const char kMaxSuggestions[] = "15";
-
-// URL for CWS intents API.
-const char kCWSIntentServiceURL[] =
- "https://www.googleapis.com/chromewebstore/v1.1b/items/intent";
-
-// Determines if a string is a candidate for localization.
-bool ShouldLocalize(const std::string& value) {
- std::string::size_type index = 0;
- index = value.find(extensions::MessageBundle::kMessageBegin);
- if (index == std::string::npos)
- return false;
-
- index = value.find(extensions::MessageBundle::kMessageEnd, index);
- return (index != std::string::npos);
-}
-
-// Parses a JSON |response| from the CWS into a list of suggested extensions,
-// stored in |intents|. |intents| must not be NULL.
-void ParseResponse(const std::string& response,
- CWSIntentsRegistry::IntentExtensionList* intents) {
- std::string error;
- scoped_ptr<Value> parsed_response;
- JSONStringValueSerializer serializer(response);
- parsed_response.reset(serializer.Deserialize(NULL, &error));
- if (parsed_response.get() == NULL)
- return;
-
- DictionaryValue* response_dict = NULL;
- if (!parsed_response->GetAsDictionary(&response_dict) || !response_dict)
- return;
-
- ListValue* items;
- if (!response_dict->GetList("items", &items))
- return;
-
- for (ListValue::const_iterator iter(items->begin());
- iter != items->end(); ++iter) {
- DictionaryValue* item = static_cast<DictionaryValue*>(*iter);
-
- // All fields are mandatory - skip this result if any field isn't found.
- CWSIntentsRegistry::IntentExtensionInfo info;
- if (!item->GetString("id", &info.id))
- continue;
-
- if (!item->GetInteger("num_ratings", &info.num_ratings))
- continue;
-
- if (!item->GetDouble("average_rating", &info.average_rating))
- continue;
-
- if (!item->GetString("manifest", &info.manifest))
- continue;
-
- std::string manifest_utf8 = UTF16ToUTF8(info.manifest);
- JSONStringValueSerializer manifest_serializer(manifest_utf8);
- scoped_ptr<Value> manifest_value;
- manifest_value.reset(manifest_serializer.Deserialize(NULL, &error));
- if (manifest_value.get() == NULL)
- continue;
-
- DictionaryValue* manifest_dict;
- if (!manifest_value->GetAsDictionary(&manifest_dict) ||
- !manifest_dict->GetString("name", &info.name))
- continue;
-
- string16 url_string;
- if (!item->GetString("icon_url", &url_string))
- continue;
- info.icon_url = GURL(url_string);
-
- // Need to parse CWS reply, since it is not pre-l10n'd.
- ListValue* all_locales = NULL;
- if (ShouldLocalize(UTF16ToUTF8(info.name)) &&
- item->GetList("locale_data", &all_locales)) {
- std::map<std::string, std::string> localized_title;
-
- for (ListValue::const_iterator locale_iter(all_locales->begin());
- locale_iter != all_locales->end(); ++locale_iter) {
- DictionaryValue* locale = static_cast<DictionaryValue*>(*locale_iter);
-
- std::string locale_id, title;
- if (!locale->GetString("locale_string", &locale_id) ||
- !locale->GetString("title", &title))
- continue;
-
- localized_title[locale_id] = title;
- }
-
- std::vector<std::string> valid_locales;
- extension_l10n_util::GetAllFallbackLocales(
- extension_l10n_util::CurrentLocaleOrDefault(),
- "all",
- &valid_locales);
- for (std::vector<std::string>::iterator iter = valid_locales.begin();
- iter != valid_locales.end(); ++iter) {
- if (localized_title.count(*iter)) {
- info.name = UTF8ToUTF16(localized_title[*iter]);
- break;
- }
- }
- }
-
- intents->push_back(info);
- }
-}
-
-} // namespace
-
-// Internal object representing all data associated with a single query.
-struct CWSIntentsRegistry::IntentsQuery {
- IntentsQuery();
- ~IntentsQuery();
-
- // Underlying URL request query.
- scoped_ptr<net::URLFetcher> url_fetcher;
-
- // The callback - invoked on completed retrieval.
- ResultsCallback callback;
-};
-
-CWSIntentsRegistry::IntentsQuery::IntentsQuery() {
-}
-
-CWSIntentsRegistry::IntentsQuery::~IntentsQuery() {
-}
-
-CWSIntentsRegistry::IntentExtensionInfo::IntentExtensionInfo()
- : num_ratings(0),
- average_rating(0) {
-}
-
-CWSIntentsRegistry::IntentExtensionInfo::~IntentExtensionInfo() {
-}
-
-CWSIntentsRegistry::CWSIntentsRegistry(net::URLRequestContextGetter* context)
- : request_context_(context) {
-}
-
-CWSIntentsRegistry::~CWSIntentsRegistry() {
- // Cancel all pending queries, since we can't handle them any more.
- STLDeleteValues(&queries_);
-}
-
-void CWSIntentsRegistry::OnURLFetchComplete(const net::URLFetcher* source) {
- DCHECK(source);
-
- URLFetcherHandle handle = reinterpret_cast<URLFetcherHandle>(source);
- QueryMap::iterator it = queries_.find(handle);
- DCHECK(it != queries_.end());
- scoped_ptr<IntentsQuery> query(it->second);
- DCHECK(query.get() != NULL);
- queries_.erase(it);
-
- std::string response;
- source->GetResponseAsString(&response);
-
- // TODO(groby): Do we really only accept 200, or any 2xx codes?
- IntentExtensionList intents;
- if (source->GetResponseCode() == 200)
- ParseResponse(response, &intents);
-
- if (!query->callback.is_null())
- query->callback.Run(intents);
-}
-
-void CWSIntentsRegistry::GetIntentServices(const string16& action,
- const string16& mimetype,
- const ResultsCallback& cb) {
- scoped_ptr<IntentsQuery> query(new IntentsQuery);
- query->callback = cb;
- query->url_fetcher.reset(net::URLFetcher::Create(
- 0, BuildQueryURL(action,mimetype), net::URLFetcher::GET, this));
-
- if (query->url_fetcher.get() == NULL)
- return;
-
- query->url_fetcher->SetRequestContext(request_context_);
- query->url_fetcher->SetLoadFlags(
- net::LOAD_DO_NOT_SEND_COOKIES | net::LOAD_DO_NOT_SAVE_COOKIES);
-
- URLFetcherHandle handle = reinterpret_cast<URLFetcherHandle>(
- query->url_fetcher.get());
- queries_[handle] = query.release();
- queries_[handle]->url_fetcher->Start();
-}
-
-// static
-GURL CWSIntentsRegistry::BuildQueryURL(const string16& action,
- const string16& type) {
- GURL request(kCWSIntentServiceURL);
- request = net::AppendQueryParameter(request, "intent", UTF16ToUTF8(action));
- request = net::AppendQueryParameter(request, "mime_types", UTF16ToUTF8(type));
- request = net::AppendQueryParameter(request, "start_index", "0");
- request = net::AppendQueryParameter(request, "num_results", kMaxSuggestions);
- request = net::AppendQueryParameter(request, "key", google_apis::GetAPIKey());
-
- return request;
-}
diff --git a/chrome/browser/intents/cws_intents_registry.h b/chrome/browser/intents/cws_intents_registry.h
deleted file mode 100644
index 004de37..0000000
--- a/chrome/browser/intents/cws_intents_registry.h
+++ /dev/null
@@ -1,89 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_INTENTS_CWS_INTENTS_REGISTRY_H_
-#define CHROME_BROWSER_INTENTS_CWS_INTENTS_REGISTRY_H_
-
-#include <vector>
-
-#include "base/callback_forward.h"
-#include "base/gtest_prod_util.h"
-#include "base/hash_tables.h"
-#include "base/memory/ref_counted.h"
-#include "chrome/browser/profiles/profile_keyed_service.h"
-#include "googleurl/src/gurl.h"
-#include "net/url_request/url_fetcher_delegate.h"
-
-namespace net {
-class URLRequestContextGetter;
-}
-
-class CWSIntentsRegistryForTest;
-
-// Handles storing and retrieving of web intents in the web database.
-// The registry provides filtering logic to retrieve specific types of intents.
-class CWSIntentsRegistry : public ProfileKeyedService,
- public net::URLFetcherDelegate {
- public:
- // Data returned from CWS for a single service.
- struct IntentExtensionInfo {
- IntentExtensionInfo();
- ~IntentExtensionInfo();
-
- std::string id; // The id of the extension.
- string16 name; // The name of the extension.
- int num_ratings; // Number of ratings in CWS store.
- double average_rating; // The average CWS rating.
- string16 manifest; // The containing extension's manifest info.
- GURL icon_url; // Where to retrieve an icon for this service.
- };
-
- // List of Intent extensions, as returned by GetIntentServices's |callback|
- typedef std::vector<IntentExtensionInfo> IntentExtensionList;
- // Callback to return results from GetIntentServices upon completion.
- typedef base::Callback<void(const IntentExtensionList&)> ResultsCallback;
-
- // Requests all intent services matching |action| and |mimetype|.
- // |mimetype| must conform to definition as outlined for
- // WebIntentsRegistry::GetIntentServices.
- // |callback| will be invoked upon retrieving results from CWS, returning
- // a list of matching Intent extensions.
- void GetIntentServices(const string16& action,
- const string16& mimetype,
- const ResultsCallback& callback);
-
- // Build a REST query URL to retrieve intent info from CWS.
- static GURL BuildQueryURL(const string16& action, const string16& type);
-
- private:
- // Make sure that only CWSIntentsRegistryFactory can create an instance of
- // CWSIntentsRegistry.
- friend class CWSIntentsRegistryFactory;
- friend class ::CWSIntentsRegistryForTest;
-
- struct IntentsQuery;
-
- // This is an opaque version of URLFetcher*, so we can use it as a hash key.
- typedef intptr_t URLFetcherHandle;
-
- // Maps URL fetchers to queries. IntentsQuery objects are owned by the map.
- typedef base::hash_map<URLFetcherHandle, IntentsQuery*> QueryMap;
-
- // |context| is a profile-dependent URL request context. Must not be NULL.
- explicit CWSIntentsRegistry(net::URLRequestContextGetter* context);
- virtual ~CWSIntentsRegistry();
-
- // net::URLFetcherDelegate implementation.
- virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE;
-
- // Map for all in-flight web data requests/intent queries.
- QueryMap queries_;
-
- // Request context for any CWS requests.
- scoped_refptr<net::URLRequestContextGetter> request_context_;
-
- DISALLOW_COPY_AND_ASSIGN(CWSIntentsRegistry);
-};
-
-#endif // CHROME_BROWSER_INTENTS_CWS_INTENTS_REGISTRY_H_
diff --git a/chrome/browser/intents/cws_intents_registry_factory.cc b/chrome/browser/intents/cws_intents_registry_factory.cc
deleted file mode 100644
index 1e9a907..0000000
--- a/chrome/browser/intents/cws_intents_registry_factory.cc
+++ /dev/null
@@ -1,40 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-
-#include "chrome/browser/intents/cws_intents_registry.h"
-#include "chrome/browser/intents/cws_intents_registry_factory.h"
-#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/profiles/profile_dependency_manager.h"
-
-// static
-CWSIntentsRegistry* CWSIntentsRegistryFactory::GetForProfile(Profile* profile) {
- return static_cast<CWSIntentsRegistry*>(
- GetInstance()->GetServiceForProfile(profile, true));
-}
-
-CWSIntentsRegistryFactory::CWSIntentsRegistryFactory()
- : ProfileKeyedServiceFactory("CWSIntentsRegistry",
- ProfileDependencyManager::GetInstance()) {
-}
-
-CWSIntentsRegistryFactory::~CWSIntentsRegistryFactory() {
-}
-
-// static
-CWSIntentsRegistryFactory* CWSIntentsRegistryFactory::GetInstance() {
- return Singleton<CWSIntentsRegistryFactory>::get();
-}
-
-ProfileKeyedService* CWSIntentsRegistryFactory::BuildServiceInstanceFor(
- Profile* profile) const {
- CWSIntentsRegistry* registry = new CWSIntentsRegistry(
- profile->GetRequestContext());
- return registry;
-}
-
-bool CWSIntentsRegistryFactory::ServiceRedirectedInIncognito() const {
- // TODO(groby): Do we have CWS access in incognito?
- return false;
-}
diff --git a/chrome/browser/intents/cws_intents_registry_factory.h b/chrome/browser/intents/cws_intents_registry_factory.h
deleted file mode 100644
index 5007c0f..0000000
--- a/chrome/browser/intents/cws_intents_registry_factory.h
+++ /dev/null
@@ -1,42 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_INTENTS_CWS_INTENTS_REGISTRY_FACTORY_H_
-#define CHROME_BROWSER_INTENTS_CWS_INTENTS_REGISTRY_FACTORY_H_
-
-#include "base/basictypes.h"
-#include "base/compiler_specific.h"
-#include "base/memory/singleton.h"
-#include "chrome/browser/profiles/profile_keyed_service_factory.h"
-
-class CWSIntentsRegistry;
-class Profile;
-
-// Singleton that owns all CWSIntentsRegistry objects and associates each with
-// their respective profile. Listens for the profile's destruction notification
-// and cleans up the associated CWSIntentsRegistry.
-class CWSIntentsRegistryFactory : public ProfileKeyedServiceFactory {
- public:
- // Returns a weak pointer to the WebIntentsRegistry that provides intent
- // registration for |profile|.
- static CWSIntentsRegistry* GetForProfile(Profile* profile);
-
- // Returns the singleton instance of the WebIntentsRegistryFactory.
- static CWSIntentsRegistryFactory* GetInstance();
-
- private:
- friend struct DefaultSingletonTraits<CWSIntentsRegistryFactory>;
-
- CWSIntentsRegistryFactory();
- virtual ~CWSIntentsRegistryFactory();
-
- // ProfileKeyedServiceFactory implementation.
- virtual ProfileKeyedService* BuildServiceInstanceFor(
- Profile* profile) const OVERRIDE;
- virtual bool ServiceRedirectedInIncognito() const OVERRIDE;
-
- DISALLOW_COPY_AND_ASSIGN(CWSIntentsRegistryFactory);
-};
-
-#endif // CHROME_BROWSER_INTENTS_CWS_INTENTS_REGISTRY_FACTORY_H_
diff --git a/chrome/browser/intents/cws_intents_registry_unittest.cc b/chrome/browser/intents/cws_intents_registry_unittest.cc
deleted file mode 100644
index bc09576..0000000
--- a/chrome/browser/intents/cws_intents_registry_unittest.cc
+++ /dev/null
@@ -1,275 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/intents/cws_intents_registry.h"
-
-#include "base/bind.h"
-#include "base/bind_helpers.h"
-#include "base/message_loop.h"
-#include "base/utf_string_conversions.h"
-#include "chrome/common/extensions/extension_l10n_util.h"
-#include "net/url_request/test_url_fetcher_factory.h"
-#include "net/url_request/url_request_test_util.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-// Create a CWSIntentsRegistry proxy for testing purposes.
-// Needs to be non-anonymous so it can be friended.
-class CWSIntentsRegistryForTest {
-public:
- CWSIntentsRegistryForTest() : registry_(NULL) {}
- ~CWSIntentsRegistryForTest() { delete registry_; }
-
- void reset(net::URLRequestContextGetter* context) {
- delete registry_;
- registry_ = new CWSIntentsRegistry(context);
- }
-
- CWSIntentsRegistry* operator->() { return registry_; }
-
-private:
- CWSIntentsRegistry* registry_;
-};
-
-namespace {
-
-const char kCWSResponseInvalid[] =
- "{\"error\":{"
- "\"errors\":[{"
- "\"domain\":\"global\","
- "\"reason\":\"invalid\","
- "\"message\":\"Invalid mimetype:foo\"}],"
- "\"code\":400,"
- "\"message\":\"Invalid mimetype:foo\"}}\"";
-
-const char kCWSResponseValid[] =
- "{\"kind\":\"chromewebstore#itemList\","
- " \"total_items\":1,"
- " \"start_index\":0,"
- " \"items\":[ "
- " {\"kind\":\"chromewebstore#item\","
- " \"id\":\"nhkckhebbbncbkefhcpcgepcgfaclehe\","
- " \"type\":\"APPLICATION\","
- " \"num_ratings\":0,"
- " \"average_rating\":0.0,"
- " \"manifest\":\"{\\n\\\"update_url\\\":\\"
- "\"http://0.tbhome_staging.dserver.download-qa.td.borg.google.com/"
- "service/update2/crx\\\",\\n \\\"name\\\": \\\"Sidd's Intent App\\\""
- ",\\n \\\"description\\\": \\\"Do stuff\\\",\\n \\\"version\\\": "
- "\\\"1.2.19\\\",\\n \\\"app\\\": {\\n \\\"urls\\\": [ \\n ],"
- "\\n \\\"launch\\\": {\\n \\\"web_url\\\": \\"
- "\"http://siddharthasaha.net/\\\"\\n }\\n },\\n \\\"icons\\\": "
- "{\\n \\\"128\\\": \\\"icon128.png\\\"\\n },\\n \\\"permissions\\\":"
- " [\\n \\\"unlimitedStorage\\\",\\n \\\"notifications\\\"\\n ],\\n"
- " \\\"intents\\\": {\\n \\\"http://webintents.org/edit\\\" : {\\n "
- "\\\"type\\\" : [\\\"image/png\\\", \\\"image/jpg\\\"],\\n \\\"path\\"
- "\" : \\\"//services/edit\\\",\\n \\\"title\\\" : "
- "\\\"Sample Editing Intent\\\",\\n \\\"disposition\\\" : \\\"inline\\"
- "\"\\n },\\n \\\"http://webintents.org/share\\\" : "
- "{\\n \\\"type\\\" : [\\\"text/plain\\\", \\\"image/jpg\\\"],"
- "\\n \\\"path\\\" : \\\"//services/share\\\",\\n \\\"title\\\" : "
- "\\\"Sample sharing Intent\\\",\\n \\\"disposition\\\" : "
- "\\\"inline\\\"\\n }\\n }\\n}\\n\","
- " \"family_safe\":true,"
- " \"icon_url\":\"http://qa-lighthouse.sandbox.google.com/image/"
- "QzPnRCYCBbBGI99ZkGxkp-NNJ488IkkiTyCgynFEeDTJHcw4tHl3csmjTQ\"}]}";
-
-const char kCWSResponseValidL10n[] =
- "{\"kind\":\"chromewebstore#itemList\","
- " \"total_items\":1,"
- " \"start_index\":0,"
- " \"items\":[ "
- " {\"kind\":\"chromewebstore#item\","
- " \"id\":\"nhkckhebbbncbkefhcpcgepcgfaclehe\","
- " \"type\":\"APPLICATION\","
- " \"num_ratings\":0,"
- " \"average_rating\":0.0,"
- " \"manifest\":\"{\\n\\\"update_url\\\":\\"
- "\"http://0.tbhome_staging.dserver.download-qa.td.borg.google.com/"
- "service/update2/crx\\\",\\n \\\"name\\\": \\\"__MSG_name__\\\""
- ",\\n \\\"description\\\": \\\"Do stuff\\\",\\n \\\"version\\\": "
- "\\\"1.2.19\\\",\\n \\\"app\\\": {\\n \\\"urls\\\": [ \\n ],"
- "\\n \\\"launch\\\": {\\n \\\"web_url\\\": \\"
- "\"http://siddharthasaha.net/\\\"\\n }\\n },\\n \\\"icons\\\": "
- "{\\n \\\"128\\\": \\\"icon128.png\\\"\\n },\\n \\\"permissions\\\":"
- " [\\n \\\"unlimitedStorage\\\",\\n \\\"notifications\\\"\\n ],\\n"
- " \\\"intents\\\": {\\n \\\"http://webintents.org/edit\\\" : {\\n "
- "\\\"type\\\" : [\\\"image/png\\\", \\\"image/jpg\\\"],\\n \\\"path\\"
- "\" : \\\"//services/edit\\\",\\n \\\"title\\\" : "
- "\\\"Sample Editing Intent\\\",\\n \\\"disposition\\\" : \\\"inline\\"
- "\"\\n },\\n \\\"http://webintents.org/share\\\" : "
- "{\\n \\\"type\\\" : [\\\"text/plain\\\", \\\"image/jpg\\\"],"
- "\\n \\\"path\\\" : \\\"//services/share\\\",\\n \\\"title\\\" : "
- "\\\"Sample sharing Intent\\\",\\n \\\"disposition\\\" : "
- "\\\"inline\\\"\\n }\\n }\\n}\\n\","
- " \"family_safe\":true,"
- " \"icon_url\":\"http://qa-lighthouse.sandbox.google.com/image/"
- "QzPnRCYCBbBGI99ZkGxkp-NNJ488IkkiTyCgynFEeDTJHcw4tHl3csmjTQ\","
- "\"locale_data\": [";
-
-const char kCWSResponseValidL10nPostfix[] =
-"]}]}";
-
-const char kLocaleDataEn[] =
- "{"
- " \"locale_string\": \"en\","
- " \"title\": \"Localized EN\""
- "}";
-
-const char kLocaleDataDe[] =
- "{"
- " \"locale_string\": \"de\","
- " \"title\": \"Localized DE\""
- "}";
-
-const char kLocaleDataAll[] =
- "{"
- " \"locale_string\": \"all\","
- " \"title\": \"Localized ALL\""
- "}";
-
-const char kValidIconURL[] =
- "http://qa-lighthouse.sandbox.google.com/image/"
- "QzPnRCYCBbBGI99ZkGxkp-NNJ488IkkiTyCgynFEeDTJHcw4tHl3csmjTQ";
-
-const char kValidManifest[] =
- "{\n\"update_url\":\"http://0.tbhome_staging.dserver.download-qa.td.borg."
- "google.com/service/update2/crx\",\n \"name\": \"Sidd's Intent App\",\n"
- " \"description\": \"Do stuff\",\n \"version\": \"1.2.19\",\n \"app\":"
- " {\n \"urls\": [ \n ],\n \"launch\": {\n \"web_url\":"
- " \"http://siddharthasaha.net/\"\n }\n },\n \"icons\": {\n "
- "\"128\": \"icon128.png\"\n },\n \"permissions\": [\n "
- "\"unlimitedStorage\",\n \"notifications\"\n ],\n \"intents\": "
- "{\n \"http://webintents.org/edit\" : {\n \"type\" : ["
- "\"image/png\", \"image/jpg\"],\n \"path\" : \"//services/edit\",\n"
- " \"title\" : \"Sample Editing Intent\",\n \"disposition\" : "
- "\"inline\"\n },\n \"http://webintents.org/share\" : {\n "
- "\"type\" : [\"text/plain\", \"image/jpg\"],\n \"path\" : "
- "\"//services/share\",\n \"title\" : \"Sample sharing Intent\",\n"
- " \"disposition\" : \"inline\"\n }\n }\n}\n";
-
-const char kEditAction[] = "http://webintents.org/edit";
-const char kImagePngType[] = "image/png";
-
-class CWSIntentsRegistryTest : public testing::Test {
- public:
- virtual void SetUp() {
- scoped_refptr<net::TestURLRequestContextGetter> context_getter(
- new net::TestURLRequestContextGetter(ui_loop_.message_loop_proxy()));
- registry_.reset(context_getter);
- }
-
- virtual void TearDown() {
- // Pump messages posted by the main thread.
- ui_loop_.RunUntilIdle();
- }
-
- CWSIntentsRegistry::IntentExtensionList WaitForResults() {
- ui_loop_.RunUntilIdle();
- return extensions_;
- }
-
- void Callback(const CWSIntentsRegistry::IntentExtensionList& extensions) {
- extensions_ = extensions;
- }
-
- void RunRequest(const std::string& action, const std::string& mime,
- const std::string& response) {
- extensions_.clear();
-
- net::FakeURLFetcherFactory test_factory;
- test_factory.SetFakeResponse(
- CWSIntentsRegistry::BuildQueryURL(
- ASCIIToUTF16(action),ASCIIToUTF16(mime)).spec(),
- response, true);
-
- registry_->GetIntentServices(ASCIIToUTF16(action),
- ASCIIToUTF16(mime),
- base::Bind(&CWSIntentsRegistryTest::Callback,
- base::Unretained(this)));
- WaitForResults();
- }
-
-
- protected:
- // UI loop MUST be declared first, (and thus destroyed last) to allow posted
- // DeleteSoon() for e.g.TestURLRequestContextGetter.
- MessageLoop ui_loop_;
- CWSIntentsRegistryForTest registry_;
- CWSIntentsRegistry::IntentExtensionList extensions_;
-};
-
-} // namespace
-
-TEST_F(CWSIntentsRegistryTest, ValidQuery) {
- RunRequest(kEditAction, kImagePngType,kCWSResponseValid);
- ASSERT_EQ(1UL, extensions_.size());
-
- EXPECT_EQ(0, extensions_[0].num_ratings);
- EXPECT_EQ(0.0, extensions_[0].average_rating);
- EXPECT_EQ(std::string(kValidManifest), UTF16ToUTF8(extensions_[0].manifest));
- EXPECT_EQ(std::string("nhkckhebbbncbkefhcpcgepcgfaclehe"), extensions_[0].id);
- EXPECT_EQ(std::string("Sidd's Intent App"),
- UTF16ToUTF8(extensions_[0].name));
- EXPECT_EQ(std::string(kValidIconURL), extensions_[0].icon_url.spec());
-}
-
-TEST_F(CWSIntentsRegistryTest, InvalidQuery) {
- RunRequest("foo", "foo",kCWSResponseInvalid);
- EXPECT_EQ(0UL, extensions_.size());
-}
-
-TEST_F(CWSIntentsRegistryTest, BuildQueryURL) {
- const std::string kExpectedURL = "https://www.googleapis.com"
- "/chromewebstore/v1.1b/items/intent"
- "?intent=action&mime_types=mime%2Ftype&start_index=0&num_results=15";
- GURL url = CWSIntentsRegistry::BuildQueryURL(ASCIIToUTF16("action"),
- ASCIIToUTF16("mime/type"));
-
- EXPECT_EQ(kExpectedURL, url.spec().substr(0, kExpectedURL.size()));
-}
-
-// Test for match to the application locale - i.e. if running in "en",
-// registry will use locale_data for "en" key, with or without "all"
-// locale_data present.
-TEST_F(CWSIntentsRegistryTest, LocalizeMatchingLocale) {
- extension_l10n_util::ScopedLocaleForTest restoreLocaleOnExit;
-
- std::string response = kCWSResponseValidL10n;
- response += kLocaleDataEn + std::string(",");
- response += kLocaleDataAll + std::string(",");
- response += kLocaleDataDe;
- response += kCWSResponseValidL10nPostfix;
-
- // Picks the proper locale_data based on application locale.
- extension_l10n_util::SetProcessLocale("en");
- RunRequest(kEditAction, kImagePngType, response);
- ASSERT_EQ(1UL, extensions_.size());
- EXPECT_EQ(std::string("Localized EN"),
- UTF16ToUTF8(extensions_[0].name));
-
- extension_l10n_util::SetProcessLocale("de");
- RunRequest(kEditAction, kImagePngType, response);
- ASSERT_EQ(1UL, extensions_.size());
- EXPECT_EQ(std::string("Localized DE"),
- UTF16ToUTF8(extensions_[0].name));
-
- // Falls back to locale_data for "All" if unknown application locale.
- extension_l10n_util::SetProcessLocale("fr");
- RunRequest(kEditAction, kImagePngType, std::string(kCWSResponseValidL10n) +
- kLocaleDataAll + kCWSResponseValidL10nPostfix);
- ASSERT_EQ(1UL, extensions_.size());
- EXPECT_EQ(std::string("Localized ALL"),
- UTF16ToUTF8(extensions_[0].name));
-
- // Keeps original content if unknown application locale and no "all"
- // localization data exists.
- response = kCWSResponseValidL10n;
- response += kLocaleDataEn;
- response += kCWSResponseValidL10nPostfix;
- extension_l10n_util::SetProcessLocale("de");
- RunRequest(kEditAction, kImagePngType, response);
- ASSERT_EQ(1UL, extensions_.size());
- EXPECT_EQ(std::string("__MSG_name__"),
- UTF16ToUTF8(extensions_[0].name));
-}
diff --git a/chrome/browser/intents/default_web_intent_service.cc b/chrome/browser/intents/default_web_intent_service.cc
deleted file mode 100644
index 9f369edd..0000000
--- a/chrome/browser/intents/default_web_intent_service.cc
+++ /dev/null
@@ -1,47 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/intents/default_web_intent_service.h"
-#include "base/string_util.h"
-
-DefaultWebIntentService::DefaultWebIntentService()
- : url_pattern(URLPattern::SCHEME_ALL, URLPattern::kAllUrlsPattern),
- user_date(-1),
- suppression(0) {}
-
-DefaultWebIntentService::DefaultWebIntentService(
- const string16& srv_action,
- const string16& srv_type,
- const std::string& srv_service_url)
- : action(srv_action), type(srv_type),
- url_pattern(URLPattern::SCHEME_ALL, URLPattern::kAllUrlsPattern),
- user_date(-1), suppression(0), service_url(srv_service_url) {}
-
-DefaultWebIntentService::DefaultWebIntentService(
- const string16& srv_scheme,
- const std::string& srv_service_url)
- : scheme(srv_scheme),
- url_pattern(URLPattern::SCHEME_ALL, URLPattern::kAllUrlsPattern),
- user_date(-1), suppression(0), service_url(srv_service_url) {}
-
-DefaultWebIntentService::~DefaultWebIntentService() {}
-
-std::string DefaultWebIntentService::ToString() const {
- return "{action=" + UTF16ToASCII(action)
- + ", type=" + UTF16ToASCII(type)
- + ", service_url=" + service_url
- + ", url_pattern=" + url_pattern.GetAsString()
- + "}";
-}
-
-bool DefaultWebIntentService::operator==(
- const DefaultWebIntentService& other) const {
- return action == other.action &&
- type == other.type &&
- scheme == other.scheme &&
- url_pattern == other.url_pattern &&
- user_date == other.user_date &&
- suppression == other.suppression &&
- service_url == other.service_url;
-}
diff --git a/chrome/browser/intents/default_web_intent_service.h b/chrome/browser/intents/default_web_intent_service.h
deleted file mode 100644
index 191d5c2..0000000
--- a/chrome/browser/intents/default_web_intent_service.h
+++ /dev/null
@@ -1,61 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_INTENTS_DEFAULT_WEB_INTENT_SERVICE_H_
-#define CHROME_BROWSER_INTENTS_DEFAULT_WEB_INTENT_SERVICE_H_
-
-#include <string>
-
-#include "base/string16.h"
-#include "extensions/common/url_pattern.h"
-
-// Holds data related to a default settings for web intents service
-// selection. Holds data in a row in the web_intents_defaults table.
-// The key for the table is the |action|, |type|, and |url_pattern|.
-// These describe the action and type of the web intent for which the
-// default is set, and the url prefix (if any) of source pages for
-// which the default applies. The main actionable value is the URL
-// of the service or extension page handling the intent. The |user_date|
-// and |suppression| fields are provided for more intricate post-fetch
-// decisions about whether to use a particular default service.
-struct DefaultWebIntentService {
-
- // Intents are matched to services using two defferent matching
- // strategies.
- // 1) |action| + |type|. Examples:
- // action = "webintents.org/share", type = "mydomain.com/mytype"
- // action = "intents.w3c.org/action/view", type = "image/png"
- // 2) |scheme| e.g., "mailto", or "web+poodle".
- // Type for intent service matching. This can be any arbitray type,
- // including commonly recognized types such as mime-types.
- string16 action;
- string16 type;
- string16 scheme;
-
- URLPattern url_pattern;
-
- // |user_date| holds the offset time when a user set the default.
- // If the user did not set the default explicitly, is <= 0.
- int user_date;
-
- // Currently unused.
- int64 suppression;
-
- std::string service_url;
-
- DefaultWebIntentService();
- DefaultWebIntentService(
- const string16& action,
- const string16& type,
- const std::string& service_url);
- DefaultWebIntentService(
- const string16& scheme,
- const std::string& service_url);
- ~DefaultWebIntentService();
-
- std::string ToString() const;
- bool operator==(const DefaultWebIntentService& other) const;
-};
-
-#endif // CHROME_BROWSER_INTENTS_DEFAULT_WEB_INTENT_SERVICE_H_
diff --git a/chrome/browser/intents/default_web_intent_service_unittest.cc b/chrome/browser/intents/default_web_intent_service_unittest.cc
deleted file mode 100644
index 9478e96..0000000
--- a/chrome/browser/intents/default_web_intent_service_unittest.cc
+++ /dev/null
@@ -1,61 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include <string>
-
-#include "base/utf_string_conversions.h"
-#include "chrome/browser/intents/default_web_intent_service.h"
-#include "extensions/common/url_pattern.h"
-#include "googleurl/src/gurl.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-namespace {
-
-const char kEmptyString[] = "";
-const char kShareAction[] = "http://webintents.org/share";
-const char kPngType[] = "image/png";
-const char kMailToScheme[] = "mailto";
-const char kQuackService[] = "http://ducknet.com/quack";
-const URLPattern all_pattern(
- URLPattern::SCHEME_ALL, URLPattern::kAllUrlsPattern);
-
-TEST(DefaultWebIntentServiceTest, Defaults) {
- DefaultWebIntentService service;
-
- EXPECT_EQ(string16(), service.action);
- EXPECT_EQ(string16(), service.type);
- EXPECT_EQ(string16(), service.scheme);
- EXPECT_EQ(all_pattern, service.url_pattern);
- EXPECT_EQ(-1, service.user_date);
- EXPECT_EQ(0, service.suppression);
- EXPECT_EQ("", service.service_url);
-}
-
-TEST(DefaultWebIntentServiceTest, ActionServicesEqual) {
- DefaultWebIntentService actual(
- ASCIIToUTF16(kShareAction),
- ASCIIToUTF16(kPngType),
- kQuackService);
-
- DefaultWebIntentService expected;
- expected.action = ASCIIToUTF16(kShareAction);
- expected.type = ASCIIToUTF16(kPngType);
- expected.service_url = kQuackService;
-
- EXPECT_EQ(expected, actual);
-}
-
-TEST(DefaultWebIntentServiceTest, SchemeServicesEqual) {
- DefaultWebIntentService actual(
- ASCIIToUTF16(kMailToScheme),
- kQuackService);
-
- DefaultWebIntentService expected;
- expected.scheme = ASCIIToUTF16(kMailToScheme);
- expected.service_url = kQuackService;
-
- EXPECT_EQ(expected, actual);
-}
-
-} // namespace
diff --git a/chrome/browser/intents/intent_service_host.h b/chrome/browser/intents/intent_service_host.h
deleted file mode 100644
index 63d3570..0000000
--- a/chrome/browser/intents/intent_service_host.h
+++ /dev/null
@@ -1,57 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_INTENTS_INTENT_SERVICE_HOST_H_
-#define CHROME_BROWSER_INTENTS_INTENT_SERVICE_HOST_H_
-
-namespace content {
-class WebIntentsDispatcher;
-}
-
-namespace web_intents {
-
-// Interface for web intent "services" that act as handlers for
-// web intents invoked by client code or other means. "services" can
-// be implemented in a variety of means across different "host" environments
-// Examples:
-// * In another tab, where the tab hosts a web page that services the
-// intent.
-// * In the Chrome browser where a file picker can be used to select
-// a file from disk in response to a "pick" action.
-// * In the underlying OS where a native application could be used
-// to handle an intent.
-//
-// A "service" is selected by policy, based on a heuristic including:
-// user selection, system defaults, declaration as an "explicit" intent
-// by client code, and other means. This selection process is managed
-// by WebInentPickerController.
-//
-// A service, once selected, is responsible for responding to an intent.
-// The "intent" is presented to the service as an instance of
-// WebIntentsDispatcher. The dispatcher provides access to the intent data
-// in the form of a webkit_glue::WebIntentData. The dispatcher also provides
-// the service a means of responding to the intent.
-//
-// A service instance is owned by WebIntentPickerController. Its lifetime is a
-// subset of the life of an intent. It will be created immediately prior
-// to calling HandleIntent, and destroyed immediately after SendReply
-// is called.
-//
-// For details see content::WebIntentsDispatcher and webkit_glue::WebIntentData
-class IntentServiceHost {
- public:
- virtual ~IntentServiceHost() {}
-
- // A service is responsible for replying to the dispatcher in all
- // circumstances, including when the user has canceled the operation,
- // or the action was terminated without user intervention. In each of
- // these cases the correct webkit_glue::WebIntentReplyType should
- // be chosen and a response should be delivered to the dispatcher
- // via SendReply(webkit_glue::WebIntentReply).
- virtual void HandleIntent(content::WebIntentsDispatcher* dispatcher) = 0;
-};
-
-} // namespace web_intents
-
-#endif // CHROME_BROWSER_INTENTS_INTENT_SERVICE_HOST_H_
diff --git a/chrome/browser/intents/native_services.cc b/chrome/browser/intents/native_services.cc
deleted file mode 100644
index 70ed674..0000000
--- a/chrome/browser/intents/native_services.cc
+++ /dev/null
@@ -1,68 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Native services are implemented with UI code necessitating portions
-// of native_services.h to be defined in
-// chrome/browser/ui/intents/native_file_picker_service.cc
-
-#include "base/command_line.h"
-#include "base/logging.h"
-#include "base/string16.h"
-#include "base/string_util.h"
-#include "base/utf_string_conversions.h"
-#include "chrome/browser/intents/native_services.h"
-#include "chrome/browser/intents/web_intents_util.h"
-#include "chrome/common/chrome_switches.h"
-#include "googleurl/src/gurl.h"
-#include "webkit/glue/web_intent_service_data.h"
-
-namespace web_intents {
-
-const char kNativeFilePickerUrl[] = "chrome-intents-native://file-picker";
-
-NativeServiceRegistry::NativeServiceRegistry() {}
-NativeServiceRegistry::~NativeServiceRegistry() {}
-
-void NativeServiceRegistry::GetSupportedServices(
- const string16& action,
- IntentServiceList* services) {
- if (!CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kWebIntentsNativeServicesEnabled))
- return;
-
-#if !defined(ANDROID)
- if (EqualsASCII(action, kActionPick)) {
- // File picker registrations.
- webkit_glue::WebIntentServiceData service(
- ASCIIToUTF16(kActionPick),
- ASCIIToUTF16("*/*"), // Handle any MIME-type.
- // This is an action/type based service, so we supply an empty scheme.
- string16(),
- GURL(kNativeFilePickerUrl),
- FilePickerFactory::GetServiceTitle());
- service.disposition = webkit_glue::WebIntentServiceData::DISPOSITION_NATIVE;
-
- services->push_back(service);
- }
-#endif
-}
-
-NativeServiceFactory::NativeServiceFactory() {}
-NativeServiceFactory::~NativeServiceFactory() {}
-
-IntentServiceHost* NativeServiceFactory::CreateServiceInstance(
- const GURL& service_url,
- const webkit_glue::WebIntentData& intent,
- content::WebContents* web_contents) {
-
-#if !defined(ANDROID)
- if (service_url.spec() == kNativeFilePickerUrl) {
- return FilePickerFactory::CreateServiceInstance(intent, web_contents);
- }
-#endif
-
- return NULL; // Couldn't create an instance.
-}
-
-} // namespace web_intents
diff --git a/chrome/browser/intents/native_services.h b/chrome/browser/intents/native_services.h
deleted file mode 100644
index 1691a19..0000000
--- a/chrome/browser/intents/native_services.h
+++ /dev/null
@@ -1,104 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_INTENTS_NATIVE_SERVICES_H_
-#define CHROME_BROWSER_INTENTS_NATIVE_SERVICES_H_
-
-#include <string>
-#include <vector>
-#include "base/basictypes.h"
-#include "base/string16.h"
-
-class GURL;
-
-namespace content {
-class WebContents;
-class WebIntentsDispatcher;
-}
-
-namespace webkit_glue {
-struct WebIntentData;
-struct WebIntentServiceData;
-}
-
-namespace web_intents {
-
-class IntentServiceHost;
-
-// Service URL for the file picker hosted by the Chrome browser.
-extern const char kNativeFilePickerUrl[];
-
-#if !defined(ANDROID)
-// Factory capable of producing a native file picker IntentServiceHost,
-// as well as producing registration information about the service. Instances
-// of this class can be obtained via NativeServiceFactory and should not
-// otherwise be instantiated directly.
-class FilePickerFactory {
- public:
- // Returns a localized title for the file picker.
- static string16 GetServiceTitle();
-
- // Returns a new IntentServiceHost for processing the given intent data in the
- // context of the given web contents. The intent must be of action type
- // "pick".
- static IntentServiceHost* CreateServiceInstance(
- const webkit_glue::WebIntentData& intent,
- content::WebContents* web_contents);
-
- private:
- DISALLOW_IMPLICIT_CONSTRUCTORS(FilePickerFactory);
-};
-#endif
-
-// Supplier of information about services hosted by Chrome itself
-// (as opposed to web services). Each service registration produced
-// by this class will have a WebIntentServiceData::DISPOSITION_NATIVE
-// disposition. This value can be used at runtime to determine when a service
-// can be instantiated by our sibling class NativeServiceFactory.
-// Instances of this class are currently stateless and fairly light weight.
-// Any two instances can be assumed to have the same information.
-class NativeServiceRegistry {
- public:
- typedef std::vector<webkit_glue::WebIntentServiceData> IntentServiceList;
- NativeServiceRegistry();
- ~NativeServiceRegistry();
-
- // Populates |services| with all supported IntentServiceHosts
- // capable of handling |action|.
- void GetSupportedServices(
- const string16& action,
- IntentServiceList* services);
-
- private:
- DISALLOW_COPY_AND_ASSIGN(NativeServiceRegistry);
-};
-
-// Factory for services hosted by Chrome itself (as opposed to web services).
-// When implementing a new native service this is where you add support
-// for creating an instance.
-// Only services reported by NativeServiceRegistry.GetSupportedServices,
-// specifically those having a WebIntentServiceData::DISPOSITION_NATIVE
-// disposition, are instantiatable via this class.
-// Instances of this class are currently stateless and fairly light weight.
-// Any two instances can be assumed to have the same capabilities.
-class NativeServiceFactory {
- public:
- NativeServiceFactory();
- ~NativeServiceFactory();
-
- // Returns a new IntentServiceHost for processing the given intent data in the
- // context of the given web contents. Callers assume ownership of the
- // instance.
- IntentServiceHost* CreateServiceInstance(
- const GURL& url,
- const webkit_glue::WebIntentData& intent,
- content::WebContents* web_contents);
-
- private:
- DISALLOW_COPY_AND_ASSIGN(NativeServiceFactory);
-};
-
-} // namespace web_intents
-
-#endif // CHROME_BROWSER_INTENTS_NATIVE_SERVICES_H_
diff --git a/chrome/browser/intents/native_services_browsertest.cc b/chrome/browser/intents/native_services_browsertest.cc
deleted file mode 100644
index e8442c64..0000000
--- a/chrome/browser/intents/native_services_browsertest.cc
+++ /dev/null
@@ -1,182 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include <algorithm>
-#include <iterator>
-#include <string>
-
-#include "base/command_line.h"
-#include "base/file_path.h"
-#include "base/path_service.h"
-#include "base/string_util.h"
-#include "base/utf_string_conversions.h"
-#include "base/memory/scoped_ptr.h"
-#include "content/public/browser/browser_thread.h"
-#include "chrome/browser/intents/intent_service_host.h"
-#include "chrome/browser/intents/native_services.h"
-#include "chrome/browser/intents/web_intents_util.h"
-#include "chrome/browser/ui/browser.h"
-#include "chrome/browser/ui/tabs/tab_strip_model.h"
-#include "chrome/common/chrome_paths.h"
-#include "chrome/common/chrome_switches.h"
-#include "chrome/test/base/in_process_browser_test.h"
-#include "chrome/test/base/ui_test_utils.h"
-#include "content/public/browser/web_contents.h"
-#include "content/public/browser/web_intents_dispatcher.h"
-#include "testing/gtest/include/gtest/gtest.h"
-#include "ui/shell_dialogs/select_file_dialog_factory.h"
-#include "webkit/glue/web_intent_data.h"
-#include "webkit/glue/web_intent_reply_data.h"
-#include "webkit/glue/web_intent_service_data.h"
-
-using content::BrowserThread;
-
-namespace {
-
-const std::string kPoodlePath = "/home/poodles/skippy.png";
-const int64 kTestFileSize = 193;
-
-base::FilePath CreateTestFile() {
- base::FilePath file;
- PathService::Get(chrome::DIR_TEST_DATA, &file);
- file = file.AppendASCII("web_intents").AppendASCII("test.png");
- return file;
-}
-
-class TestIntentsDispatcher : public content::WebIntentsDispatcher {
- public:
- TestIntentsDispatcher() {
- intent_.action = ASCIIToUTF16(web_intents::kActionPick);
- intent_.type = ASCIIToUTF16("image/*");
- }
-
- virtual const webkit_glue::WebIntentData& GetIntent() OVERRIDE {
- return intent_;
- }
-
- virtual void DispatchIntent(content::WebContents* web_contents) OVERRIDE {}
- virtual void ResetDispatch() OVERRIDE {}
-
- virtual void SendReply(const webkit_glue::WebIntentReply& reply) OVERRIDE {
- reply_.reset(new webkit_glue::WebIntentReply(reply));
- }
-
- virtual void RegisterReplyNotification(
- const base::Callback<void(webkit_glue::WebIntentReplyType)>&) OVERRIDE {
- }
-
- webkit_glue::WebIntentData intent_;
- scoped_ptr<webkit_glue::WebIntentReply> reply_;
-};
-
-class FakeSelectFileDialog : public ui::SelectFileDialog {
- public:
- FakeSelectFileDialog(
- Listener* listener, ui::SelectFilePolicy* policy, bool should_succeed)
- : SelectFileDialog(listener, policy), should_succeed_(should_succeed),
- test_file_(CreateTestFile()) {
- }
- virtual bool IsRunning(gfx::NativeWindow parent_window) const OVERRIDE {
- return false;
- }
- virtual void ListenerDestroyed() OVERRIDE {}
- virtual bool HasMultipleFileTypeChoicesImpl() OVERRIDE {
- return false;
- }
-
- protected:
- virtual void SelectFileImpl(
- Type type,
- const string16& title,
- const base::FilePath& default_path,
- const FileTypeInfo* file_types,
- int file_type_index,
- const base::FilePath::StringType& default_extension,
- gfx::NativeWindow owning_window,
- void* params) OVERRIDE {
- if (should_succeed_)
- listener_->FileSelected(test_file_, kTestFileSize, params);
- else
- listener_->FileSelectionCanceled(params);
- }
-
- private:
- bool should_succeed_;
- base::FilePath test_file_;
- DISALLOW_COPY_AND_ASSIGN(FakeSelectFileDialog);
-};
-
-class TestSelectFileDialogFactory : public ui::SelectFileDialogFactory {
- public:
- virtual ui::SelectFileDialog* Create(
- ui::SelectFileDialog::Listener* listener,
- ui::SelectFilePolicy* policy) OVERRIDE {
- return new FakeSelectFileDialog(listener, policy, should_succeed_);
- }
- bool should_succeed_;
-};
-
-class NativeServicesBrowserTest : public InProcessBrowserTest {
- protected:
- virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
- // We start the test server now instead of in
- // SetUpInProcessBrowserTestFixture so that we can get its port number.
- ASSERT_TRUE(test_server()->Start());
-
- command_line->AppendSwitch(switches::kWebIntentsNativeServicesEnabled);
- test_file_ = CreateTestFile();
- }
-
- virtual void SetUpOnMainThread() OVERRIDE {
- dispatcher_.reset(new TestIntentsDispatcher());
- factory_.reset(new TestSelectFileDialogFactory());
- ui::SelectFileDialog::SetFactory(factory_.get());
- }
-
- void DispatchIntent(bool should_succeed) {
- factory_->should_succeed_ = should_succeed;
-
- content::WebContents* tab =
- browser()->tab_strip_model()->GetActiveWebContents();
-
- web_intents::NativeServiceFactory factory;
- GURL url(web_intents::kNativeFilePickerUrl);
- scoped_ptr<web_intents::IntentServiceHost> service(
- factory.CreateServiceInstance(url, dispatcher_->intent_, tab));
- service->HandleIntent(dispatcher_.get());
-
- // Reads of file size are done on the FILE thread, then posted
- // back to the UI thread. So these are necessary for the
- // should_succeed case and noop for the !should_succeed
- content::RunAllPendingInMessageLoop(BrowserThread::FILE);
- content::RunAllPendingInMessageLoop(BrowserThread::UI);
- }
-
- scoped_ptr<TestIntentsDispatcher> dispatcher_;
- scoped_ptr<TestSelectFileDialogFactory> factory_;
- base::FilePath test_file_;
-};
-
-IN_PROC_BROWSER_TEST_F(NativeServicesBrowserTest, PickFileSelected) {
- DispatchIntent(true);
- ASSERT_TRUE(dispatcher_->reply_);
- EXPECT_EQ(
- webkit_glue::WebIntentReply(
- webkit_glue::WEB_INTENT_REPLY_SUCCESS,
- test_file_,
- kTestFileSize),
- *dispatcher_->reply_.get());
-}
-
-IN_PROC_BROWSER_TEST_F(NativeServicesBrowserTest, PickFileCancelled) {
- DispatchIntent(false);
- ASSERT_TRUE(dispatcher_->reply_);
- EXPECT_EQ(
- webkit_glue::WebIntentReply(
- webkit_glue::WEB_INTENT_REPLY_FAILURE,
- string16()),
- *dispatcher_->reply_.get());
-}
-
-} // namespace
diff --git a/chrome/browser/intents/native_services_unittest.cc b/chrome/browser/intents/native_services_unittest.cc
deleted file mode 100644
index 7cc57d0..0000000
--- a/chrome/browser/intents/native_services_unittest.cc
+++ /dev/null
@@ -1,66 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include <string>
-#include <vector>
-
-#include "base/command_line.h"
-#include "base/utf_string_conversions.h"
-#include "chrome/browser/intents/native_services.h"
-#include "chrome/browser/intents/web_intents_util.h"
-#include "chrome/common/chrome_switches.h"
-#include "extensions/common/url_pattern.h"
-#include "googleurl/src/gurl.h"
-#include "testing/gtest/include/gtest/gtest.h"
-#include "webkit/glue/web_intent_service_data.h"
-
-namespace {
-
-using web_intents::NativeServiceRegistry;
-
-TEST(NativeServiceRegistryTest, GetSupportedServices) {
-#if !defined(ANDROID)
- CommandLine::ForCurrentProcess()->AppendSwitch(
- switches::kWebIntentsNativeServicesEnabled);
-
- NativeServiceRegistry::IntentServiceList services;
- NativeServiceRegistry registry;
- typedef NativeServiceRegistry::IntentServiceList::const_iterator Iter;
-
- registry.GetSupportedServices(ASCIIToUTF16("dothedew"), &services);
-
- ASSERT_EQ(0U, services.size());
- for (Iter it = services.begin(); it != services.end(); ++it) {
- ADD_FAILURE() << "Unexpected handler for Dew: " << *it;
- }
-
- registry.GetSupportedServices(
- ASCIIToUTF16(web_intents::kActionPick), &services);
-
- EXPECT_EQ(1U, services.size());
- if (services.size() == 1) {
- // Verify the service returned is for "pick".
- EXPECT_EQ(ASCIIToUTF16(web_intents::kActionPick), services[0].action);
- EXPECT_EQ(GURL(web_intents::kNativeFilePickerUrl), services[0].service_url);
- } else {
- for (Iter it = services.begin(); it != services.end(); ++it) {
- ADD_FAILURE() << "Too many services for pick action: " << *it;
- }
- }
-#endif
-}
-
-TEST(NativeServiceRegistryTest, GetSupportedServicesDisabled) {
-#if !defined(ANDROID)
- NativeServiceRegistry::IntentServiceList services;
- NativeServiceRegistry registry;
-
- registry.GetSupportedServices(
- ASCIIToUTF16(web_intents::kActionPick), &services);
-
- ASSERT_EQ(0U, services.size());
-#endif
-}
-
-} // namespace
diff --git a/chrome/browser/intents/register_intent_handler_infobar_delegate.cc b/chrome/browser/intents/register_intent_handler_infobar_delegate.cc
deleted file mode 100644
index 5892d7f..0000000
--- a/chrome/browser/intents/register_intent_handler_infobar_delegate.cc
+++ /dev/null
@@ -1,121 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/intents/register_intent_handler_infobar_delegate.h"
-
-#include "base/bind.h"
-#include "base/bind_helpers.h"
-#include "base/logging.h"
-#include "base/utf_string_conversions.h"
-#include "chrome/browser/api/infobars/infobar_service.h"
-#include "chrome/browser/favicon/favicon_service.h"
-#include "chrome/browser/favicon/favicon_service_factory.h"
-#include "chrome/browser/intents/web_intents_registry.h"
-#include "chrome/browser/intents/web_intents_registry_factory.h"
-#include "chrome/browser/intents/web_intents_util.h"
-#include "chrome/browser/profiles/profile.h"
-#include "content/public/browser/web_contents.h"
-#include "grit/generated_resources.h"
-#include "ui/base/l10n/l10n_util.h"
-
-
-// static
-void RegisterIntentHandlerInfoBarDelegate::Create(
- content::WebContents* web_contents,
- const webkit_glue::WebIntentServiceData& data) {
- Profile* profile =
- Profile::FromBrowserContext(web_contents->GetBrowserContext());
- if (profile->IsOffTheRecord())
- return;
-
- if (!web_intents::IsWebIntentsEnabledForProfile(profile))
- return;
-
- FaviconService* favicon_service = FaviconServiceFactory::GetForProfile(
- profile, Profile::EXPLICIT_ACCESS);
-
- WebIntentsRegistry* registry =
- WebIntentsRegistryFactory::GetForProfile(profile);
- registry->IntentServiceExists(
- data, base::Bind(
- &CreateContinuation,
- base::Unretained(InfoBarService::FromWebContents(web_contents)),
- registry,
- data,
- favicon_service,
- web_contents->GetURL()));
-}
-
-InfoBarDelegate::Type
- RegisterIntentHandlerInfoBarDelegate::GetInfoBarType() const {
- return PAGE_ACTION_TYPE;
-}
-
-string16 RegisterIntentHandlerInfoBarDelegate::GetMessageText() const {
- return l10n_util::GetStringFUTF16(
- IDS_REGISTER_INTENT_HANDLER_CONFIRM,
- service_.title,
- UTF8ToUTF16(service_.service_url.host()));
-}
-
-string16 RegisterIntentHandlerInfoBarDelegate::GetButtonLabel(
- InfoBarButton button) const {
- if (button == BUTTON_OK) {
- return l10n_util::GetStringFUTF16(IDS_REGISTER_INTENT_HANDLER_ACCEPT,
- UTF8ToUTF16(service_.service_url.host()));
- }
-
- DCHECK(button == BUTTON_CANCEL);
- return l10n_util::GetStringUTF16(IDS_REGISTER_INTENT_HANDLER_DENY);
-}
-
-bool RegisterIntentHandlerInfoBarDelegate::Accept() {
- registry_->RegisterIntentService(service_);
-
- // Register a temporary FavIcon in case we never visited the provider page.
- if (favicon_service_ && origin_url_ != service_.service_url)
- favicon_service_->CloneFavicon(origin_url_, service_.service_url);
-
- return true;
-}
-
-string16 RegisterIntentHandlerInfoBarDelegate::GetLinkText() const {
- return l10n_util::GetStringUTF16(IDS_LEARN_MORE);
-}
-
-bool RegisterIntentHandlerInfoBarDelegate::LinkClicked(
- WindowOpenDisposition disposition) {
- // TODO(jhawkins): Open the Web Intents Help Center article once it is
- // written.
- // TODO(jhawkins): Add associated bug for the article here.
- return false;
-}
-
-RegisterIntentHandlerInfoBarDelegate::RegisterIntentHandlerInfoBarDelegate(
- InfoBarService* infobar_service,
- WebIntentsRegistry* registry,
- const webkit_glue::WebIntentServiceData& service,
- FaviconService* favicon_service,
- const GURL& origin_url)
- : ConfirmInfoBarDelegate(infobar_service),
- registry_(registry),
- service_(service),
- favicon_service_(favicon_service),
- origin_url_(origin_url) {
-}
-
-// static
-void RegisterIntentHandlerInfoBarDelegate::CreateContinuation(
- InfoBarService* infobar_service,
- WebIntentsRegistry* registry,
- const webkit_glue::WebIntentServiceData& service,
- FaviconService* favicon_service,
- const GURL& origin_url,
- bool provider_exists) {
- if (!provider_exists) {
- infobar_service->AddInfoBar(scoped_ptr<InfoBarDelegate>(
- new RegisterIntentHandlerInfoBarDelegate(
- infobar_service, registry, service, favicon_service, origin_url)));
- }
-}
diff --git a/chrome/browser/intents/register_intent_handler_infobar_delegate.h b/chrome/browser/intents/register_intent_handler_infobar_delegate.h
deleted file mode 100644
index 9fcb197..0000000
--- a/chrome/browser/intents/register_intent_handler_infobar_delegate.h
+++ /dev/null
@@ -1,87 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_INTENTS_REGISTER_INTENT_HANDLER_INFOBAR_DELEGATE_H_
-#define CHROME_BROWSER_INTENTS_REGISTER_INTENT_HANDLER_INFOBAR_DELEGATE_H_
-
-#include "base/basictypes.h"
-#include "base/string16.h"
-#include "chrome/browser/api/infobars/confirm_infobar_delegate.h"
-#include "webkit/glue/web_intent_service_data.h"
-
-#if defined(UNIT_TEST)
-#include "base/memory/scoped_ptr.h"
-#endif
-
-class WebIntentsRegistry;
-class FaviconService;
-class GURL;
-namespace content {
-class WebContents;
-}
-
-// The InfoBar used to request permission for a site to be registered as an
-// Intent handler.
-class RegisterIntentHandlerInfoBarDelegate : public ConfirmInfoBarDelegate {
- public:
- // Checks whether the intent service specified by |data| exists. If not, and
- // |web_contents| is in a non-incognito, web-intents-enabled profile, creates
- // a register intent handler delegate and adds it to the InfoBarService for
- // |web_contents|.
- static void Create(content::WebContents* web_contents,
- const webkit_glue::WebIntentServiceData& data);
-
-#if defined(UNIT_TEST)
- static scoped_ptr<RegisterIntentHandlerInfoBarDelegate> Create(
- WebIntentsRegistry* registry,
- const webkit_glue::WebIntentServiceData& data) {
- return scoped_ptr<RegisterIntentHandlerInfoBarDelegate>(
- new RegisterIntentHandlerInfoBarDelegate(NULL, registry, data, NULL,
- GURL()));
- }
-#endif
-
- // ConfirmInfoBarDelegate implementation.
- virtual Type GetInfoBarType() const OVERRIDE;
- virtual string16 GetMessageText() const OVERRIDE;
- virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE;
- virtual bool Accept() OVERRIDE;
- virtual string16 GetLinkText() const OVERRIDE;
- virtual bool LinkClicked(WindowOpenDisposition disposition) OVERRIDE;
-
- private:
- RegisterIntentHandlerInfoBarDelegate(
- InfoBarService* infobar_service,
- WebIntentsRegistry* registry,
- const webkit_glue::WebIntentServiceData& service,
- FaviconService* favicon_service,
- const GURL& origin_url);
-
- // Finishes the work of Create(). This is called back from the
- // WebIntentsRegistry once it determines whether the requested intent service
- // exists.
- static void CreateContinuation(
- InfoBarService* infobar_service,
- WebIntentsRegistry* registry,
- const webkit_glue::WebIntentServiceData& service,
- FaviconService* favicon_service,
- const GURL& origin_url,
- bool provider_exists);
-
- // The web intents registry to use. Weak pointer.
- WebIntentsRegistry* registry_;
-
- // The cached intent service data bundle passed up from the renderer.
- webkit_glue::WebIntentServiceData service_;
-
- // The favicon service to use. Weak pointer.
- FaviconService* favicon_service_;
-
- // The URL of the page the service was originally registered from.
- GURL origin_url_;
-
- DISALLOW_COPY_AND_ASSIGN(RegisterIntentHandlerInfoBarDelegate);
-};
-
-#endif // CHROME_BROWSER_INTENTS_REGISTER_INTENT_HANDLER_INFOBAR_DELEGATE_H_
diff --git a/chrome/browser/intents/register_intent_handler_infobar_delegate_unittest.cc b/chrome/browser/intents/register_intent_handler_infobar_delegate_unittest.cc
deleted file mode 100644
index 3b3d5f3..0000000
--- a/chrome/browser/intents/register_intent_handler_infobar_delegate_unittest.cc
+++ /dev/null
@@ -1,79 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "base/synchronization/waitable_event.h"
-#include "base/utf_string_conversions.h"
-#include "chrome/browser/intents/register_intent_handler_infobar_delegate.h"
-#include "chrome/browser/intents/web_intents_registry.h"
-#include "chrome/browser/intents/web_intents_registry_factory.h"
-#include "chrome/test/base/chrome_render_view_host_test_harness.h"
-#include "chrome/test/base/testing_profile.h"
-#include "content/public/test/test_browser_thread.h"
-#include "testing/gmock/include/gmock/gmock.h"
-#include "testing/gtest/include/gtest/gtest.h"
-#include "webkit/glue/web_intent_service_data.h"
-
-using content::BrowserThread;
-
-namespace {
-
-class MockWebIntentsRegistry : public WebIntentsRegistry {
- public:
- MOCK_METHOD1(RegisterIntentService,
- void(const webkit_glue::WebIntentServiceData&));
-};
-
-ProfileKeyedService* BuildMockWebIntentsRegistry(Profile* profile) {
- return new MockWebIntentsRegistry;
-}
-
-MockWebIntentsRegistry* BuildForProfile(Profile* profile) {
- return static_cast<MockWebIntentsRegistry*>(
- WebIntentsRegistryFactory::GetInstance()->SetTestingFactoryAndUse(
- profile, BuildMockWebIntentsRegistry));
-}
-
-class RegisterIntentHandlerInfoBarDelegateTest
- : public ChromeRenderViewHostTestHarness {
- protected:
- RegisterIntentHandlerInfoBarDelegateTest()
- : ui_thread_(BrowserThread::UI, MessageLoopForUI::current()),
- db_thread_(BrowserThread::DB, MessageLoopForUI::current()) {}
-
- virtual void SetUp() {
- ChromeRenderViewHostTestHarness::SetUp();
-
- profile()->CreateWebDataService();
- web_intents_registry_ = BuildForProfile(profile());
- }
-
- virtual void TearDown() {
- web_intents_registry_ = NULL;
-
- ChromeRenderViewHostTestHarness::TearDown();
- }
-
- MockWebIntentsRegistry* web_intents_registry_;
-
- private:
- content::TestBrowserThread ui_thread_;
- content::TestBrowserThread db_thread_;
-
- DISALLOW_COPY_AND_ASSIGN(RegisterIntentHandlerInfoBarDelegateTest);
-};
-
-TEST_F(RegisterIntentHandlerInfoBarDelegateTest, Accept) {
- webkit_glue::WebIntentServiceData service;
- service.service_url = GURL("google.com");
- service.action = ASCIIToUTF16("http://webintents.org/share");
- service.type = ASCIIToUTF16("text/url");
- scoped_ptr<RegisterIntentHandlerInfoBarDelegate> infobar_delegate(
- RegisterIntentHandlerInfoBarDelegate::Create(web_intents_registry_,
- service));
-
- EXPECT_CALL(*web_intents_registry_, RegisterIntentService(service));
- infobar_delegate->Accept();
-}
-
-} // namespace
diff --git a/chrome/browser/intents/web_intents_registry.cc b/chrome/browser/intents/web_intents_registry.cc
deleted file mode 100644
index f2663b5..0000000
--- a/chrome/browser/intents/web_intents_registry.cc
+++ /dev/null
@@ -1,528 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/intents/web_intents_registry.h"
-
-#include <algorithm>
-
-#include "base/bind.h"
-#include "base/bind_helpers.h"
-#include "base/callback.h"
-#include "base/string_util.h"
-#include "base/string16.h"
-#include "base/utf_string_conversions.h"
-#include "chrome/browser/intents/default_web_intent_service.h"
-#include "chrome/browser/intents/native_services.h"
-#include "chrome/browser/intents/web_intents_util.h"
-#include "chrome/browser/webdata/web_data_service.h"
-#include "chrome/common/extensions/extension.h"
-#include "chrome/common/extensions/extension_set.h"
-#include "chrome/common/extensions/web_intents_handler.h"
-#include "googleurl/src/gurl.h"
-#include "net/base/mime_util.h"
-
-using extensions::Extension;
-using net::IsMimeType;
-
-namespace {
-
-// TODO(hshi): Temporary workaround for http://crbug.com/134197.
-// If no user-set default service is found, use built-in QuickOffice Viewer as
-// default for MS office files. Remove this once full defaults is in place.
-const char* kQuickOfficeViewerMimeType[] = {
- "application/msword",
- "application/vnd.ms-powerpoint",
- "application/vnd.ms-excel",
- "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
- "application/vnd.openxmlformats-officedocument.presentationml.presentation",
- "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
-};
-
-typedef base::Callback<void(const WDTypedResult* result)> ResultsHandler;
-typedef WebIntentsRegistry::IntentServiceList IntentServiceList;
-
-// Compares two web intents type specifiers to see if there is a match.
-// First checks if both are MIME types. If so, uses MatchesMimeType.
-// If not, uses exact string equality.
-bool WebIntentsTypesMatch(const string16& type1, const string16& type2) {
- return (IsMimeType(UTF16ToUTF8(type1)) && IsMimeType(UTF16ToUTF8(type2)))
- ? web_intents::MimeTypesMatch(type1, type2)
- : type1 == type2;
-}
-
-// Adds any intent services of |extension| that match |action| to
-// |matching_services|.
-void AddMatchingServicesForExtension(const Extension& extension,
- const string16& action,
- IntentServiceList* matching_services) {
- const IntentServiceList& services =
- extensions::WebIntentsInfo::GetIntentsServices(&extension);
- for (IntentServiceList::const_iterator i = services.begin();
- i != services.end(); ++i) {
- if (action.empty() || action == i->action)
- matching_services->push_back(*i);
- }
-}
-
-// Removes all services from |matching_services| that do not match |type|.
-// Wildcards are supported, of the form '<type>/*' or '*'.
-void FilterServicesByType(const string16& type,
- IntentServiceList* matching_services) {
- // Filter out all services not matching the query type.
- IntentServiceList::iterator iter(matching_services->begin());
- while (iter != matching_services->end()) {
- if (WebIntentsTypesMatch(iter->type, type))
- ++iter;
- else
- iter = matching_services->erase(iter);
- }
-}
-
-// Callback for existence checks. Converts a callback for a list of services
-// into a callback that returns true if the list contains a specific service.
-void ExistenceCallback(const webkit_glue::WebIntentServiceData& service,
- const base::Callback<void(bool)>& callback,
- const WDTypedResult* result) {
-
- WebIntentsRegistry::IntentServiceList list = static_cast<
- const WDResult<IntentServiceList>*>(result)->GetValue();
-
- for (WebIntentsRegistry::IntentServiceList::const_iterator i = list.begin();
- i != list.end(); ++i) {
- if (*i == service) {
- callback.Run(true);
- return;
- }
- }
-
- callback.Run(false);
-}
-
-// Functor object for intent ordering.
-struct IntentOrdering {
- // Implements StrictWeakOrdering for intents, based on intent-equivalence.
- // Order by |service_url|, |action|, |title|, and |disposition| in order.
- bool operator()(const webkit_glue::WebIntentServiceData& lhs,
- const webkit_glue::WebIntentServiceData& rhs) {
- if (lhs.service_url != rhs.service_url)
- return lhs.service_url < rhs.service_url;
-
- if (lhs.action != rhs.action)
- return lhs.action < rhs.action;
-
- if (lhs.title != rhs.title)
- return lhs.title < rhs.title;
-
- if (lhs.disposition != rhs.disposition)
- return lhs.disposition < rhs.disposition;
-
- // At this point, we consider intents to be equal, even if |type| differs.
- return false;
- }
-};
-
-// Two intents are equivalent iff all fields except |type| are equal.
-bool IntentsAreEquivalent(const webkit_glue::WebIntentServiceData& lhs,
- const webkit_glue::WebIntentServiceData& rhs) {
- return !((lhs.service_url != rhs.service_url) ||
- (lhs.action != rhs.action) ||
- (lhs.title != rhs.title) ||
- (lhs.disposition != rhs.disposition));
-}
-
-} // namespace
-
-using webkit_glue::WebIntentServiceData;
-
-// Internal object containing arguments to be used in post processing
-// WDS results.
-struct WebIntentsRegistry::QueryParams {
-
- // The particular action to filter for while searching through extensions.
- // If |action_| is empty, return all extension-provided services.
- string16 action_;
-
- // The MIME type that was requested for this service query.
- // Suppports wild cards.
- string16 type_;
-
- // The url of the invoking page.
- GURL url_;
-
- // Create a new QueryParams for all intent services or for existence checks.
- QueryParams() : type_(ASCIIToUTF16("*")) {}
-
- QueryParams(const string16& action, const string16& type)
- : action_(action), type_(type) {}
-
- // Create a new QueryParams for default services.
- QueryParams(const string16& action, const string16& type, const GURL& url)
- : action_(action), type_(type), url_(url) {}
-};
-
-// Internal object adapting the WDS consumer interface to base::Bind
-// callback way of doing business.
-class WebIntentsRegistry::QueryAdapter : public WebDataServiceConsumer {
-
- public:
- // Underlying data query.
- WebDataService::Handle query_handle_;
-
- // Create a new QueryAdapter that delegates results to |handler|.
- QueryAdapter(WebIntentsRegistry* registry, const ResultsHandler& handler)
- : registry_(registry), handler_(handler) {
- registry_->TrackQuery(this);
- }
-
- virtual void OnWebDataServiceRequestDone(
- WebDataService::Handle h,
- const WDTypedResult* result) OVERRIDE {
-
- handler_.Run(result);
- registry_->ReleaseQuery(this);
- }
-
- private:
- // Handle so we can call back into the WebIntentsRegistry when
- // processing query results. The registry is guaranteed to be
- // valid for the life of this object. We do not own this object.
- WebIntentsRegistry* registry_;
-
- // The callback for this particular query.
- ResultsHandler handler_;
-};
-
-WebIntentsRegistry::WebIntentsRegistry() {
- native_services_.reset(new web_intents::NativeServiceRegistry());
-}
-
-WebIntentsRegistry::~WebIntentsRegistry() {
-
- // Cancel all pending queries, since we can't handle them any more.
- for (QueryVector::iterator it = pending_queries_.begin();
- it != pending_queries_.end(); ++it) {
- QueryAdapter* query = *it;
- wds_->CancelRequest(query->query_handle_);
- delete query;
- }
-}
-
-void WebIntentsRegistry::Initialize(
- scoped_refptr<WebDataService> wds,
- ExtensionServiceInterface* extension_service) {
- wds_ = wds;
- extension_service_ = extension_service;
-}
-
-void WebIntentsRegistry::OnWebIntentsResultReceived(
- const QueryParams& params,
- const QueryCallback& callback,
- const WDTypedResult* result) {
- DCHECK(result);
- DCHECK(result->GetType() == WEB_INTENTS_RESULT);
-
- IntentServiceList matching_services = static_cast<
- const WDResult<IntentServiceList>*>(result)->GetValue();
-
- // Loop over all services in all extensions, collect ones
- // matching the query.
- if (extension_service_) {
- const ExtensionSet* extensions = extension_service_->extensions();
- if (extensions) {
- for (ExtensionSet::const_iterator i(extensions->begin());
- i != extensions->end(); ++i) {
- AddMatchingServicesForExtension(**i, params.action_,
- &matching_services);
- }
- }
- }
-
- // add native services.
- native_services_->GetSupportedServices(params.action_, &matching_services);
-
- // Filter out all services not matching the query type.
- FilterServicesByType(params.type_, &matching_services);
-
- // Collapse intents that are equivalent for all but |type|.
- CollapseIntents(&matching_services);
-
- callback.Run(matching_services);
-}
-
-void WebIntentsRegistry::OnAllDefaultIntentServicesReceived(
- const DefaultIntentServicesCallback& callback,
- const WDTypedResult* result) {
- DCHECK(result);
- DCHECK(result->GetType() == WEB_INTENTS_DEFAULTS_RESULT);
-
- const std::vector<DefaultWebIntentService> services = static_cast<
- const WDResult<std::vector<DefaultWebIntentService> >*>(result)->
- GetValue();
-
- callback.Run(services);
-}
-
-void WebIntentsRegistry::OnWebIntentsDefaultsResultReceived(
- const QueryParams& params,
- const DefaultQueryCallback& callback,
- const WDTypedResult* result) {
- DCHECK(result);
- DCHECK(result->GetType() == WEB_INTENTS_DEFAULTS_RESULT);
-
- std::vector<DefaultWebIntentService> services = static_cast<
- const WDResult<std::vector<DefaultWebIntentService> >*>(result)->
- GetValue();
-
- DefaultWebIntentService default_service;
- std::vector<DefaultWebIntentService>::iterator iter(services.begin());
- for (; iter != services.end(); ++iter) {
- if (!WebIntentsTypesMatch(iter->type, params.type_)) {
- continue;
- }
- if (!iter->url_pattern.MatchesURL(params.url_)) {
- continue;
- }
- const Extension* extension = ExtensionForURL(iter->service_url);
- if (extension != NULL &&
- !extension_service_->IsExtensionEnabled(extension->id())) {
- continue;
- }
-
- // Found a match. If it is better than default_service, use it.
- // Currently the metric is that if the new value is user-set,
- // prefer it. If the new value has a more specific pattern, prefer it.
- // If the new value has a more recent date, prefer it.
- if (default_service.user_date <= 0 && iter->user_date >= 0) {
- default_service = *iter;
- } else if (default_service.url_pattern.match_all_urls() &&
- !iter->url_pattern.match_all_urls()) {
- default_service = *iter;
- } else if (iter->url_pattern < default_service.url_pattern) {
- default_service = *iter;
- } else if (default_service.user_date < iter->user_date) {
- default_service = *iter;
- }
- }
-
- // If QuickOffice is the default for this, recompute defaults.
- if (default_service.service_url
- == web_intents::kQuickOfficeViewerServiceURL ||
- default_service.service_url
- == web_intents::kQuickOfficeViewerDevServiceURL) {
- default_service.user_date = -1;
- }
-
- // TODO(hshi): Temporary workaround for http://crbug.com/134197.
- // If no user-set default service is found, use built-in QuickOffice Viewer as
- // default for MS office files. Remove this once full defaults is in place.
-
- if (default_service.user_date <= 0) {
- const char kQuickOfficeDevExtensionId[] =
- "ionpfmkccalenbmnddpbmocokhaknphg";
- std::string service_url = web_intents::kQuickOfficeViewerServiceURL;
- if (extension_service_->GetInstalledExtension(kQuickOfficeDevExtensionId) &&
- extension_service_->IsExtensionEnabled(kQuickOfficeDevExtensionId)) {
- service_url = web_intents::kQuickOfficeViewerDevServiceURL;
- }
-
- for (size_t i = 0; i < sizeof(kQuickOfficeViewerMimeType) / sizeof(char*);
- ++i) {
- DefaultWebIntentService qoviewer_service;
- qoviewer_service.action = ASCIIToUTF16(web_intents::kActionView);
- qoviewer_service.type = ASCIIToUTF16(kQuickOfficeViewerMimeType[i]);
- qoviewer_service.service_url = service_url;
- if (WebIntentsTypesMatch(qoviewer_service.type, params.type_)) {
- default_service = qoviewer_service;
- break;
- }
- }
- }
-
- callback.Run(default_service);
-}
-
-void WebIntentsRegistry::GetIntentServices(
- const string16& action, const string16& type,
- const QueryCallback& callback) {
- DCHECK(wds_.get());
- DCHECK(!callback.is_null());
-
- const QueryParams params(action, type);
- const ResultsHandler handler = base::Bind(
- &WebIntentsRegistry::OnWebIntentsResultReceived,
- base::Unretained(this),
- params,
- callback);
-
- QueryAdapter* query = new QueryAdapter(this, handler);
- query->query_handle_ = wds_->GetWebIntentServicesForAction(action, query);
-}
-
-void WebIntentsRegistry::GetAllIntentServices(
- const QueryCallback& callback) {
- DCHECK(wds_.get());
- DCHECK(!callback.is_null());
-
- const QueryParams params;
- const ResultsHandler handler = base::Bind(
- &WebIntentsRegistry::OnWebIntentsResultReceived,
- base::Unretained(this),
- params,
- callback);
-
- QueryAdapter* query = new QueryAdapter(this, handler);
- query->query_handle_ = wds_->GetAllWebIntentServices(query);
-}
-
-void WebIntentsRegistry::GetAllDefaultIntentServices(
- const DefaultIntentServicesCallback& callback) {
- DCHECK(!callback.is_null());
-
- ResultsHandler handler = base::Bind(
- &WebIntentsRegistry::OnAllDefaultIntentServicesReceived,
- base::Unretained(this),
- callback);
-
- QueryAdapter* query = new QueryAdapter(this, handler);
- query->query_handle_ =
- wds_->GetAllDefaultWebIntentServices(query);
-}
-
-void WebIntentsRegistry::IntentServiceExists(
- const WebIntentServiceData& service,
- const base::Callback<void(bool)>& callback) {
- DCHECK(!callback.is_null());
-
- ResultsHandler handler = base::Bind(
- &ExistenceCallback,
- service,
- callback);
-
- QueryAdapter* query = new QueryAdapter(this, handler);
- query->query_handle_ = wds_->GetWebIntentServicesForURL(
- UTF8ToUTF16(service.service_url.spec()), query);
-}
-
-void WebIntentsRegistry::GetIntentServicesForExtensionFilter(
- const string16& action,
- const string16& type,
- const std::string& extension_id,
- IntentServiceList* services) {
- if (extension_service_) {
- const Extension* extension =
- extension_service_->GetExtensionById(extension_id, false);
- AddMatchingServicesForExtension(*extension,
- action,
- services);
- FilterServicesByType(type, services);
- }
-}
-
-void WebIntentsRegistry::RegisterDefaultIntentService(
- const DefaultWebIntentService& default_service) {
- DCHECK(wds_.get());
- wds_->AddDefaultWebIntentService(default_service);
-}
-
-void WebIntentsRegistry::UnregisterDefaultIntentService(
- const DefaultWebIntentService& default_service) {
- DCHECK(wds_.get());
- wds_->RemoveDefaultWebIntentService(default_service);
-}
-
-void WebIntentsRegistry::UnregisterServiceDefaults(const GURL& service_url) {
- DCHECK(wds_.get());
- wds_->RemoveWebIntentServiceDefaults(service_url);
-}
-
-void WebIntentsRegistry::GetDefaultIntentService(
- const string16& action,
- const string16& type,
- const GURL& invoking_url,
- const DefaultQueryCallback& callback) {
- DCHECK(!callback.is_null());
-
- const QueryParams params(action, type);
-
- ResultsHandler handler = base::Bind(
- &WebIntentsRegistry::OnWebIntentsDefaultsResultReceived,
- base::Unretained(this),
- params,
- callback);
-
- QueryAdapter* query = new QueryAdapter(this, handler);
- query->query_handle_ =
- wds_->GetDefaultWebIntentServicesForAction(action, query);
-}
-
-void WebIntentsRegistry::RegisterIntentService(
- const WebIntentServiceData& service) {
- DCHECK(wds_.get());
- wds_->AddWebIntentService(service);
-}
-
-void WebIntentsRegistry::UnregisterIntentService(
- const WebIntentServiceData& service) {
- DCHECK(wds_.get());
- wds_->RemoveWebIntentService(service);
-}
-
-void WebIntentsRegistry::CollapseIntents(IntentServiceList* services) {
- DCHECK(services);
-
- // No need to do anything for no services/single service.
- if (services->size() < 2)
- return;
-
- // Sort so that intents that can be collapsed must be adjacent.
- std::sort(services->begin(), services->end(), IntentOrdering());
-
- // Combine adjacent services if they are equivalent.
- IntentServiceList::iterator write_iter = services->begin();
- IntentServiceList::iterator read_iter = write_iter + 1;
- while (read_iter != services->end()) {
- if (IntentsAreEquivalent(*write_iter, *read_iter)) {
- // If the two intents are equivalent, join types and collapse.
- write_iter->type += ASCIIToUTF16(",") + read_iter->type;
- } else {
- // Otherwise, keep both intents.
- ++write_iter;
- if (write_iter != read_iter)
- *write_iter = *read_iter;
- }
- ++read_iter;
- }
-
- // Cut off everything after the last intent copied to the list.
- if (++write_iter != services->end())
- services->erase(write_iter, services->end());
-}
-
-const Extension* WebIntentsRegistry::ExtensionForURL(const std::string& url) {
- const ExtensionSet* extensions = extension_service_->extensions();
- if (!extensions)
- return NULL;
-
- // Use the unsafe ExtensionURLInfo constructor: we don't care if the extension
- // is running or not.
- GURL gurl(url);
- ExtensionURLInfo info(gurl);
- return extensions->GetExtensionOrAppByURL(info);
-}
-
-void WebIntentsRegistry::TrackQuery(QueryAdapter* query) {
- DCHECK(query);
- pending_queries_.push_back(query);
-}
-
-void WebIntentsRegistry::ReleaseQuery(QueryAdapter* query) {
- QueryVector::iterator it = std::find(
- pending_queries_.begin(), pending_queries_.end(), query);
- if (it != pending_queries_.end()) {
- pending_queries_.erase(it);
- delete query;
- } else {
- NOTREACHED();
- }
-}
diff --git a/chrome/browser/intents/web_intents_registry.h b/chrome/browser/intents/web_intents_registry.h
deleted file mode 100644
index b5a20e2..0000000
--- a/chrome/browser/intents/web_intents_registry.h
+++ /dev/null
@@ -1,180 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_INTENTS_WEB_INTENTS_REGISTRY_H_
-#define CHROME_BROWSER_INTENTS_WEB_INTENTS_REGISTRY_H_
-
-#include "base/callback_forward.h"
-#include "base/hash_tables.h"
-#include "base/memory/ref_counted.h"
-#include "chrome/browser/extensions/extension_service.h"
-#include "chrome/browser/profiles/profile_keyed_service.h"
-#include "chrome/browser/webdata/web_data_service.h"
-#include "webkit/glue/web_intent_service_data.h"
-
-struct DefaultWebIntentService;
-
-namespace extensions {
-class Extension;
-}
-
-namespace web_intents {
-class NativeServiceRegistry;
-}
-
-// Handles storing and retrieving of web intents services in the web database.
-// The registry provides filtering logic to retrieve specific types of services.
-class WebIntentsRegistry : public ProfileKeyedService {
- public:
- typedef std::vector<webkit_glue::WebIntentServiceData> IntentServiceList;
- typedef std::vector<DefaultWebIntentService> DefaultIntentServiceList;
-
- // Callback used by callers to accept results of a query for
- // a list of |WebIntentServiceData|.
- typedef base::Callback<void(const IntentServiceList&)>
- QueryCallback;
-
- // Callback used by callers to accept results of a query for
- // a list of |DefaultWebIntentService|.
- typedef base::Callback<void(const DefaultIntentServiceList&)>
- DefaultIntentServicesCallback;
-
- // Callback used by callers to accept results of a query for
- // a |DefaultWebIntentService|.
- typedef base::Callback<void(const DefaultWebIntentService&)>
- DefaultQueryCallback;
-
- // Initializes, binds to a valid WebDataService.
- void Initialize(scoped_refptr<WebDataService> wds,
- ExtensionServiceInterface* extension_service);
-
- // Registers a service.
- virtual void RegisterIntentService(
- const webkit_glue::WebIntentServiceData& service);
-
- // Removes a service from the registry.
- void UnregisterIntentService(
- const webkit_glue::WebIntentServiceData& service);
-
- // Requests all services matching |action| and |type|.
- // |type| can contain wildcards, i.e. "image/*" or "*".
- // |callback| must not be null.
- void GetIntentServices(const string16& action,
- const string16& type,
- const QueryCallback& callback);
-
- // Requests all services.
- // |callback| must not be null.
- void GetAllIntentServices(const QueryCallback& callback);
-
- // Requests all default services.
- // |callback| must not be null.
- void GetAllDefaultIntentServices(
- const DefaultIntentServicesCallback& callback);
-
- // Tests for the existence of the given |service|. Calls the
- // provided |callback| with true if it exists, false if it does not.
- // Checks for |service| equality with ==.
- // |callback| must not be null.
- void IntentServiceExists(
- const webkit_glue::WebIntentServiceData& service,
- const base::Callback<void(bool)>& callback);
-
- // Requests all extension services matching |action|, |type| and
- // |extension_id|.
- // |type| must conform to definition as outlined for GetIntentServices.
- // |callback| must not be null.
- void GetIntentServicesForExtensionFilter(const string16& action,
- const string16& type,
- const std::string& extension_id,
- IntentServiceList* services);
-
- // Record the given default service entry.
- virtual void RegisterDefaultIntentService(
- const DefaultWebIntentService& default_service);
-
- // Delete the given default service entry. Deletes entries matching
- // the |action|, |type|, and |url_pattern| of |default_service|.
- virtual void UnregisterDefaultIntentService(
- const DefaultWebIntentService& default_service);
-
- // Delete all default service entries associated with |service_url|.
- virtual void UnregisterServiceDefaults(const GURL& service_url);
-
- // Requests the best default intent service for the given invocation
- // parameters.
- // |callback| must not be null.
- void GetDefaultIntentService(const string16& action,
- const string16& type,
- const GURL& invoking_url,
- const DefaultQueryCallback& callback);
-
- protected:
- // Make sure that only WebIntentsRegistryFactory can create an instance of
- // WebIntentsRegistry.
- friend class WebIntentsRegistryFactory;
- friend class WebIntentsRegistryTest;
- FRIEND_TEST_ALL_PREFIXES(WebIntentsRegistryTest, CollapseIntents);
-
- WebIntentsRegistry();
- virtual ~WebIntentsRegistry();
-
- // Collapses a list of IntentServices by joining intents that have identical
- // service URLs, actions, and mime types.
- // |services| is the list of intent services to be collapsed when passed in
- // and will be modified with the new list in-place.
- void CollapseIntents(IntentServiceList* services);
-
- private:
- struct QueryParams;
- class QueryAdapter;
- typedef std::vector<QueryAdapter*> QueryVector;
-
- // Handles services loaded
- void OnWebIntentsResultReceived(
- const QueryParams& params,
- const QueryCallback& callback,
- const WDTypedResult* result);
-
- // Handles default services loaded, supplying an unfiltered list
- // to the callback.
- void OnAllDefaultIntentServicesReceived(
- const DefaultIntentServicesCallback& callback,
- const WDTypedResult* result);
-
- // Handles default services loaded
- void OnWebIntentsDefaultsResultReceived(
- const QueryParams& params,
- const DefaultQueryCallback& callback,
- const WDTypedResult* result);
-
- const extensions::Extension* ExtensionForURL(const std::string& url);
-
- // Adds a query to the list of pending queries.
- void TrackQuery(QueryAdapter* query);
-
- // Takes ownership of a query. This removes a query from the list
- // of pending queries.
- void ReleaseQuery(QueryAdapter* query);
-
- // Map for all in-flight web data requests/intent queries.
- QueryVector pending_queries_;
-
- // Local reference to Web Data Service.
- scoped_refptr<WebDataService> wds_;
-
- // Local reference to the ExtensionService.
- // Shutdown/cleanup is handled by ProfileImpl. We are guaranteed that any
- // ProfileKeyedService will be shut down before data on ProfileImpl is
- // destroyed (i.e. |extension_service_|), so |extension_service_| is valid
- // for the lifetime of the WebIntentsRegistry object.
- ExtensionServiceInterface* extension_service_;
-
- // Registry used to obtain list of supported native services.
- scoped_ptr<web_intents::NativeServiceRegistry> native_services_;
-
- DISALLOW_COPY_AND_ASSIGN(WebIntentsRegistry);
-};
-
-#endif // CHROME_BROWSER_INTENTS_WEB_INTENTS_REGISTRY_H_
diff --git a/chrome/browser/intents/web_intents_registry_factory.cc b/chrome/browser/intents/web_intents_registry_factory.cc
deleted file mode 100644
index 376f3d6..0000000
--- a/chrome/browser/intents/web_intents_registry_factory.cc
+++ /dev/null
@@ -1,46 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/intents/web_intents_registry_factory.h"
-
-#include "base/memory/singleton.h"
-#include "chrome/browser/extensions/extension_system_factory.h"
-#include "chrome/browser/intents/web_intents_registry.h"
-#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/profiles/profile_dependency_manager.h"
-#include "chrome/browser/webdata/web_data_service_factory.h"
-
-// static
-WebIntentsRegistry* WebIntentsRegistryFactory::GetForProfile(Profile* profile) {
- return static_cast<WebIntentsRegistry*>(
- GetInstance()->GetServiceForProfile(profile, true));
-}
-
-WebIntentsRegistryFactory::WebIntentsRegistryFactory()
- : ProfileKeyedServiceFactory("WebIntentsRegistry",
- ProfileDependencyManager::GetInstance()) {
- DependsOn(WebDataServiceFactory::GetInstance());
- DependsOn(extensions::ExtensionSystemFactory::GetInstance());
-}
-
-WebIntentsRegistryFactory::~WebIntentsRegistryFactory() {
-}
-
-// static
-WebIntentsRegistryFactory* WebIntentsRegistryFactory::GetInstance() {
- return Singleton<WebIntentsRegistryFactory>::get();
-}
-
-ProfileKeyedService* WebIntentsRegistryFactory::BuildServiceInstanceFor(
- Profile* profile) const {
- WebIntentsRegistry* registry = new WebIntentsRegistry;
- registry->Initialize(WebDataServiceFactory::GetForProfile(
- profile, Profile::EXPLICIT_ACCESS),
- profile->GetExtensionService());
- return registry;
-}
-
-bool WebIntentsRegistryFactory::ServiceRedirectedInIncognito() const {
- return false;
-}
diff --git a/chrome/browser/intents/web_intents_registry_factory.h b/chrome/browser/intents/web_intents_registry_factory.h
deleted file mode 100644
index d130d31..0000000
--- a/chrome/browser/intents/web_intents_registry_factory.h
+++ /dev/null
@@ -1,42 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_INTENTS_WEB_INTENTS_REGISTRY_FACTORY_H_
-#define CHROME_BROWSER_INTENTS_WEB_INTENTS_REGISTRY_FACTORY_H_
-
-#include "base/basictypes.h"
-#include "base/compiler_specific.h"
-#include "chrome/browser/profiles/profile_keyed_service_factory.h"
-
-class Profile;
-class WebIntentsRegistry;
-template <typename T> struct DefaultSingletonTraits;
-
-// Singleton that owns all WebIntentsRegistrys and associates them with
-// Profiles. Listens for the Profile's destruction notification and cleans up
-// the associated WebIntentsRegistry.
-class WebIntentsRegistryFactory : public ProfileKeyedServiceFactory {
- public:
- // Returns the WebIntentsRegistry that provides intent registration for
- // |profile|. Ownership stays with this factory object.
- static WebIntentsRegistry* GetForProfile(Profile* profile);
-
- // Returns the singleton instance of the WebIntentsRegistryFactory.
- static WebIntentsRegistryFactory* GetInstance();
-
- private:
- friend struct DefaultSingletonTraits<WebIntentsRegistryFactory>;
-
- WebIntentsRegistryFactory();
- virtual ~WebIntentsRegistryFactory();
-
- // ProfileKeyedServiceFactory implementation.
- virtual ProfileKeyedService* BuildServiceInstanceFor(
- Profile* profile) const OVERRIDE;
- virtual bool ServiceRedirectedInIncognito() const OVERRIDE;
-
- DISALLOW_COPY_AND_ASSIGN(WebIntentsRegistryFactory);
-};
-
-#endif // CHROME_BROWSER_INTENTS_WEB_INTENTS_REGISTRY_FACTORY_H_
diff --git a/chrome/browser/intents/web_intents_registry_unittest.cc b/chrome/browser/intents/web_intents_registry_unittest.cc
deleted file mode 100644
index 921108a..0000000
--- a/chrome/browser/intents/web_intents_registry_unittest.cc
+++ /dev/null
@@ -1,807 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "base/bind.h"
-#include "base/file_util.h"
-#include "base/files/scoped_temp_dir.h"
-#include "base/json/json_file_value_serializer.h"
-#include "base/message_loop.h"
-#include "base/path_service.h"
-#include "base/synchronization/waitable_event.h"
-#include "base/utf_string_conversions.h"
-#include "chrome/browser/extensions/test_extension_service.h"
-#include "chrome/browser/intents/default_web_intent_service.h"
-#include "chrome/browser/intents/web_intents_registry.h"
-#include "chrome/browser/webdata/web_data_service.h"
-#include "chrome/common/chrome_paths.h"
-#include "chrome/common/extensions/extension.h"
-#include "chrome/common/extensions/extension_manifest_constants.h"
-#include "chrome/common/extensions/extension_set.h"
-#include "chrome/common/extensions/manifest.h"
-#include "chrome/common/extensions/manifest_handler.h"
-#include "chrome/common/extensions/web_intents_handler.h"
-#include "content/public/test/test_browser_thread.h"
-#include "testing/gmock/include/gmock/gmock.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-using content::BrowserThread;
-using extensions::Extension;
-using extensions::Manifest;
-using webkit_glue::WebIntentServiceData;
-
-class MockExtensionService: public TestExtensionService {
- public:
- virtual ~MockExtensionService() {}
- MOCK_CONST_METHOD0(extensions, const ExtensionSet*());
- MOCK_CONST_METHOD2(GetExtensionById,
- const Extension*(const std::string&, bool));
- MOCK_CONST_METHOD1(GetInstalledExtension,
- const Extension*(const std::string& id));
-};
-
-namespace {
-
-// TODO(groby): Unify loading functions with extension_manifest_unittest code.
-DictionaryValue* LoadManifestFile(const base::FilePath& path,
- std::string* error) {
- EXPECT_TRUE(file_util::PathExists(path));
- JSONFileValueSerializer serializer(path);
- return static_cast<DictionaryValue*>(serializer.Deserialize(NULL, error));
-}
-
-scoped_refptr<Extension> LoadExtensionWithLocation(
- const std::string& name,
- Manifest::Location location,
- std::string* error) {
- base::FilePath path;
- PathService::Get(chrome::DIR_TEST_DATA, &path);
- path = path.AppendASCII("extensions")
- .AppendASCII("manifest_tests")
- .AppendASCII(name.c_str());
- scoped_ptr<DictionaryValue> value(LoadManifestFile(path, error));
- if (!value.get())
- return NULL;
- return Extension::Create(path.DirName(),
- location,
- *value,
- Extension::NO_FLAGS,
- Extension::GenerateIdForPath(path),
- error);
-}
-
-scoped_refptr<Extension> LoadExtension(const std::string& name,
- std::string* error) {
- return LoadExtensionWithLocation(name, Manifest::INTERNAL, error);
-}
-
-scoped_refptr<Extension> LoadAndExpectSuccess(const std::string& name) {
- std::string error;
- scoped_refptr<Extension> extension = LoadExtension(name, &error);
- EXPECT_TRUE(extension) << name;
- EXPECT_EQ("", error) << name;
- return extension;
-}
-
-} // namespace
-
-class WebIntentsRegistryTest : public testing::Test {
- public:
- WebIntentsRegistryTest()
- : ui_thread_(BrowserThread::UI, &message_loop_),
- db_thread_(BrowserThread::DB) {}
-
- protected:
- virtual void SetUp() {
- db_thread_.Start();
- wds_ = new WebDataService();
- ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
- wds_->Init(temp_dir_.path());
- registry_.Initialize(wds_, &extension_service_);
- EXPECT_CALL(extension_service_, extensions()).
- WillRepeatedly(testing::Return(&extensions_));
- EXPECT_CALL(extension_service_, GetExtensionById(testing::_, testing::_)).
- WillRepeatedly(
- testing::Invoke(this, &WebIntentsRegistryTest::GetExtensionById));
- extensions::ManifestHandler::Register(
- extension_manifest_keys::kIntents,
- make_linked_ptr(new extensions::WebIntentsHandler));
- }
-
- virtual void TearDown() {
- // Clear all references to wds to force it destruction.
- wds_->ShutdownOnUIThread();
- wds_ = NULL;
-
- // Schedule another task on the DB thread to notify us that it's safe to
- // carry on with the test.
- base::WaitableEvent done(false, false);
- BrowserThread::PostTask(BrowserThread::DB, FROM_HERE,
- base::Bind(&base::WaitableEvent::Signal,
- base::Unretained(&done)));
- done.Wait();
- db_thread_.Stop();
- MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure());
- MessageLoop::current()->Run();
- }
-
- const Extension* GetExtensionById(const std::string& extension_id,
- testing::Unused) {
- for (ExtensionSet::const_iterator iter = extensions_.begin();
- iter != extensions_.end(); ++iter) {
- if ((*iter)->id() == extension_id)
- return &**iter;
- }
-
- return NULL;
- }
-
- MessageLoopForUI message_loop_;
- content::TestBrowserThread ui_thread_;
- content::TestBrowserThread db_thread_;
- scoped_refptr<WebDataService> wds_;
- MockExtensionService extension_service_;
- ExtensionSet extensions_;
- WebIntentsRegistry registry_;
- base::ScopedTempDir temp_dir_;
-};
-
-// Base consumer for WebIntentsRegistry results.
-class TestConsumer {
- public:
- // Wait for the UI message loop to terminate - happens when OnIntesQueryDone
- // is invoked.
- void WaitForData() {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- MessageLoop::current()->Run();
- }
-};
-
-// Consumer of service lists. Stores result data and
-// terminates UI thread when callback is invoked.
-class ServiceListConsumer : public TestConsumer {
- public:
- void Accept(
- const std::vector<webkit_glue::WebIntentServiceData>& services) {
- services_ = services;
-
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- MessageLoop::current()->Quit();
- }
-
- bool ResultsContain(const webkit_glue::WebIntentServiceData& service) {
- for (size_t i = 0; i < services_.size(); ++i) {
- if (services_[i] == service)
- return true;
- }
- return false;
- }
-
- // Result data from callback.
- std::vector<webkit_glue::WebIntentServiceData> services_;
-};
-
-// Consume or defaultservice lists. Stores result data and
-// terminates UI thread when callback is invoked.
-class DefaultServiceListConsumer : public TestConsumer {
- public:
- void Accept(const std::vector<DefaultWebIntentService>& services) {
- services_ = services;
-
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- MessageLoop::current()->Quit();
- }
-
- bool ResultsContain(const DefaultWebIntentService& service) {
- for (size_t i = 0; i < services_.size(); ++i) {
- if (services_[i] == service)
- return true;
- }
- return false;
- }
-
- // Result data from callback.
- std::vector<DefaultWebIntentService> services_;
-};
-
-// Consumer of a default service. Stores result data and
-// terminates UI thread when callback is invoked.
-class DefaultServiceConsumer : public TestConsumer {
- public:
- void Accept(
- const DefaultWebIntentService& default_service) {
- service_ = default_service;
-
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- MessageLoop::current()->Quit();
- }
-
- // Result default data from callback.
- DefaultWebIntentService service_;
-};
-
-TEST_F(WebIntentsRegistryTest, BasicTests) {
- webkit_glue::WebIntentServiceData service;
- service.service_url = GURL("http://google.com");
- service.action = ASCIIToUTF16("share");
- service.type = ASCIIToUTF16("image/*");
- service.title = ASCIIToUTF16("Google's Sharing Service");
-
- registry_.RegisterIntentService(service);
-
- service.type = ASCIIToUTF16("video/*");
- service.title = ASCIIToUTF16("Second Service");
- registry_.RegisterIntentService(service);
-
- service.action = ASCIIToUTF16("search");
- registry_.RegisterIntentService(service);
-
- ServiceListConsumer consumer;
- registry_.GetIntentServices(ASCIIToUTF16("share"), ASCIIToUTF16("*"),
- base::Bind(&ServiceListConsumer::Accept,
- base::Unretained(&consumer)));
- consumer.WaitForData();
- EXPECT_EQ(2U, consumer.services_.size());
-
- registry_.GetIntentServices(ASCIIToUTF16("search"), ASCIIToUTF16("*"),
- base::Bind(&ServiceListConsumer::Accept,
- base::Unretained(&consumer)));
- consumer.WaitForData();
- EXPECT_EQ(1U, consumer.services_.size());
-
- service.action = ASCIIToUTF16("share");
- service.type = ASCIIToUTF16("image/*");
- registry_.UnregisterIntentService(service);
-
- registry_.GetIntentServices(ASCIIToUTF16("share"), ASCIIToUTF16("*"),
- base::Bind(&ServiceListConsumer::Accept,
- base::Unretained(&consumer)));
- consumer.WaitForData();
- EXPECT_EQ(1U, consumer.services_.size());
-}
-
-TEST_F(WebIntentsRegistryTest, GetIntentServicesForExtensionFilter) {
- scoped_refptr<Extension> share_extension(
- LoadAndExpectSuccess("intent_valid.json"));
- scoped_refptr<Extension> edit_extension(
- LoadAndExpectSuccess("intent_valid_2.json"));
- extensions_.Insert(share_extension);
- extensions_.Insert(edit_extension);
- ASSERT_EQ(2U, extensions_.size());
-
- WebIntentsRegistry::IntentServiceList services;
- registry_.GetIntentServicesForExtensionFilter(
- ASCIIToUTF16("http://webintents.org/edit"),
- ASCIIToUTF16("image/*"),
- edit_extension->id(),
- &services);
- ASSERT_EQ(1U, services.size());
-
- EXPECT_EQ(edit_extension->url().spec() + "services/edit",
- services[0].service_url.spec());
-}
-
-TEST_F(WebIntentsRegistryTest, GetAllIntents) {
- webkit_glue::WebIntentServiceData service;
- service.service_url = GURL("http://google.com");
- service.action = ASCIIToUTF16("share");
- service.type = ASCIIToUTF16("image/*");
- service.title = ASCIIToUTF16("Google's Sharing Service");
- registry_.RegisterIntentService(service);
-
- service.action = ASCIIToUTF16("search");
- registry_.RegisterIntentService(service);
-
- ServiceListConsumer consumer;
- registry_.GetAllIntentServices(base::Bind(&ServiceListConsumer::Accept,
- base::Unretained(&consumer)));
- consumer.WaitForData();
- ASSERT_EQ(2U, consumer.services_.size());
-
- if (consumer.services_[0].action != ASCIIToUTF16("share"))
- std::swap(consumer.services_[0], consumer.services_[1]);
-
- service.action = ASCIIToUTF16("share");
- EXPECT_EQ(service, consumer.services_[0]);
-
- service.action = ASCIIToUTF16("search");
- EXPECT_EQ(service, consumer.services_[1]);
-}
-
-TEST_F(WebIntentsRegistryTest, GetExtensionIntents) {
- extensions_.Insert(LoadAndExpectSuccess("intent_valid.json"));
- extensions_.Insert(LoadAndExpectSuccess("intent_valid_2.json"));
- ASSERT_EQ(2U, extensions_.size());
-
- ServiceListConsumer consumer;
- registry_.GetAllIntentServices(base::Bind(&ServiceListConsumer::Accept,
- base::Unretained(&consumer)));
- consumer.WaitForData();
- ASSERT_EQ(2U, consumer.services_.size());
-}
-
-TEST_F(WebIntentsRegistryTest, GetSomeExtensionIntents) {
- extensions_.Insert(LoadAndExpectSuccess("intent_valid.json"));
- extensions_.Insert(LoadAndExpectSuccess("intent_valid_2.json"));
- ASSERT_EQ(2U, extensions_.size());
-
- ServiceListConsumer consumer;
- registry_.GetIntentServices(ASCIIToUTF16("http://webintents.org/edit"),
- ASCIIToUTF16("*"),
- base::Bind(&ServiceListConsumer::Accept,
- base::Unretained(&consumer)));
- consumer.WaitForData();
- ASSERT_EQ(1U, consumer.services_.size());
-}
-
-TEST_F(WebIntentsRegistryTest, GetIntentsFromMixedSources) {
- extensions_.Insert(LoadAndExpectSuccess("intent_valid.json"));
- extensions_.Insert(LoadAndExpectSuccess("intent_valid_2.json"));
- ASSERT_EQ(2U, extensions_.size());
-
- webkit_glue::WebIntentServiceData service;
- service.service_url = GURL("http://somewhere.com/intent/edit.html");
- service.action = ASCIIToUTF16("http://webintents.org/edit");
- service.type = ASCIIToUTF16("image/*");
- service.title = ASCIIToUTF16("Image Editing Service");
- registry_.RegisterIntentService(service);
-
- ServiceListConsumer consumer;
- registry_.GetIntentServices(
- ASCIIToUTF16("http://webintents.org/edit"), ASCIIToUTF16("*"),
- base::Bind(&ServiceListConsumer::Accept,
- base::Unretained(&consumer)));
- consumer.WaitForData();
- ASSERT_EQ(2U, consumer.services_.size());
-
- registry_.GetIntentServices(ASCIIToUTF16("http://webintents.org/share"),
- ASCIIToUTF16("*"),
- base::Bind(&ServiceListConsumer::Accept,
- base::Unretained(&consumer)));
- consumer.WaitForData();
- ASSERT_EQ(1U, consumer.services_.size());
-}
-
-TEST_F(WebIntentsRegistryTest, GetIntentsWithMimeAndLiteralMatching) {
- WebIntentServiceData services[] = {
- WebIntentServiceData(ASCIIToUTF16("http://webintents.org/share"),
- ASCIIToUTF16("image/*"),
- string16(),
- GURL("http://elsewhere.com/intent/share.html"),
- ASCIIToUTF16("Image Sharing Service")),
- WebIntentServiceData(ASCIIToUTF16("http://webintents.org/share"),
- ASCIIToUTF16("image/jpeg"),
- string16(),
- GURL("http://somewhere.com/intent/share.html"),
- ASCIIToUTF16("Specific Image Editing Service")),
- WebIntentServiceData(ASCIIToUTF16("http://webintents.org/share"),
- ASCIIToUTF16("text/uri-list"),
- string16(),
- GURL("http://somewhere.com/intent/share.html"),
- ASCIIToUTF16("Text Link Sharing Service")),
- WebIntentServiceData(ASCIIToUTF16("http://webintents.org/share"),
- ASCIIToUTF16("text/plain"),
- string16(),
- GURL("http://somewhere2.com/intent/share.html"),
- ASCIIToUTF16("Text Sharing Service")),
- WebIntentServiceData(ASCIIToUTF16("http://webintents.org/share"),
- ASCIIToUTF16("elsewhere"),
- string16(),
- GURL("http://elsewhere.com/intent/share.html"),
- ASCIIToUTF16("Text Sharing Service")),
- WebIntentServiceData(ASCIIToUTF16("http://webintents.org/share"),
- ASCIIToUTF16("somewhere"),
- string16(),
- GURL("http://somewhere.com/intent/share.html"),
- ASCIIToUTF16("Text Sharing Service")),
- WebIntentServiceData(ASCIIToUTF16("http://webintents.org/share"),
- ASCIIToUTF16("nota/*"),
- string16(),
- GURL("http://somewhere.com/intent/share.html"),
- ASCIIToUTF16("Text Sharing Service")),
- WebIntentServiceData(ASCIIToUTF16("http://webintents.org/share"),
- ASCIIToUTF16("*nomime"),
- string16(),
- GURL("http://somewhere.com/intent/share.html"),
- ASCIIToUTF16("Text Sharing Service")),
- WebIntentServiceData(ASCIIToUTF16("http://webintents.org/share"),
- ASCIIToUTF16("*/nomime"),
- string16(),
- GURL("http://somewhere.com/intent/share.html"),
- ASCIIToUTF16("Text Sharing Service")),
- WebIntentServiceData(ASCIIToUTF16("http://webintents.org/share"),
- ASCIIToUTF16("*/*nomime"),
- string16(),
- GURL("http://somewhere.com/intent/share.html"),
- ASCIIToUTF16("Text Sharing Service")),
- WebIntentServiceData(ASCIIToUTF16("http://webintents.org/share"),
- ASCIIToUTF16("*/*/nomime"),
- string16(),
- GURL("http://somewhere.com/intent/share.html"),
- ASCIIToUTF16("Text Sharing Service")),
- WebIntentServiceData(ASCIIToUTF16("http://webintents.org/share"),
- ASCIIToUTF16("nomime/*"),
- string16(),
- GURL("http://somewhere.com/intent/share.html"),
- ASCIIToUTF16("Text Sharing Service")),
- WebIntentServiceData(ASCIIToUTF16("http://webintents.org/share"),
- ASCIIToUTF16("x-type/*"),
- string16(),
- GURL("http://somewhere.com/intent/share.html"),
- ASCIIToUTF16("Text Sharing Service")),
- WebIntentServiceData(ASCIIToUTF16("http://webintents.org/share"),
- ASCIIToUTF16("x-/*"), // actually a string literal
- string16(),
- GURL("http://somewhere.com/intent/share.html"),
- ASCIIToUTF16("Text Sharing Service"))
- };
- registry_.RegisterIntentService(services[0]);
- registry_.RegisterIntentService(services[1]);
- registry_.RegisterIntentService(services[2]);
- registry_.RegisterIntentService(services[3]);
- registry_.RegisterIntentService(services[4]);
- registry_.RegisterIntentService(services[5]);
- registry_.RegisterIntentService(services[6]);
- registry_.RegisterIntentService(services[7]);
- registry_.RegisterIntentService(services[8]);
- registry_.RegisterIntentService(services[9]);
- registry_.RegisterIntentService(services[10]);
- registry_.RegisterIntentService(services[11]);
- registry_.RegisterIntentService(services[12]);
- registry_.RegisterIntentService(services[13]);
-
- ServiceListConsumer consumer;
-
- // Test specific match on both sides.
- registry_.GetIntentServices(ASCIIToUTF16("http://webintents.org/share"),
- ASCIIToUTF16("text/uri-list"),
- base::Bind(&ServiceListConsumer::Accept,
- base::Unretained(&consumer)));
- consumer.WaitForData();
- ASSERT_EQ(1U, consumer.services_.size());
- EXPECT_EQ(services[2], consumer.services_[0]);
-
- // Test specific query, wildcard registration.
- registry_.GetIntentServices(ASCIIToUTF16("http://webintents.org/share"),
- ASCIIToUTF16("image/png"),
- base::Bind(&ServiceListConsumer::Accept,
- base::Unretained(&consumer)));
- consumer.WaitForData();
- ASSERT_EQ(1U, consumer.services_.size());
- EXPECT_EQ(services[0], consumer.services_[0]);
-
- // Test wildcard query, specific registration.
- registry_.GetIntentServices(ASCIIToUTF16("http://webintents.org/share"),
- ASCIIToUTF16("text/*"),
- base::Bind(&ServiceListConsumer::Accept,
- base::Unretained(&consumer)));
- consumer.WaitForData();
- ASSERT_EQ(2U, consumer.services_.size());
- EXPECT_EQ(services[2], consumer.services_[0]);
- EXPECT_EQ(services[3], consumer.services_[1]);
-
- // Test wildcard query, wildcard registration.
- registry_.GetIntentServices(ASCIIToUTF16("http://webintents.org/share"),
- ASCIIToUTF16("image/*"),
- base::Bind(&ServiceListConsumer::Accept,
- base::Unretained(&consumer)));
- consumer.WaitForData();
- ASSERT_EQ(2U, consumer.services_.size());
- EXPECT_EQ(services[0], consumer.services_[0]);
- EXPECT_EQ(services[1], consumer.services_[1]);
-
- // Test "catch-all" query.
- registry_.GetIntentServices(ASCIIToUTF16("http://webintents.org/share"),
- ASCIIToUTF16("*"),
- base::Bind(&ServiceListConsumer::Accept,
- base::Unretained(&consumer)));
- consumer.WaitForData();
- ASSERT_EQ(5U, consumer.services_.size());
- EXPECT_TRUE(consumer.ResultsContain(services[0]));
- EXPECT_TRUE(consumer.ResultsContain(services[1]));
- EXPECT_TRUE(consumer.ResultsContain(services[2]));
- EXPECT_TRUE(consumer.ResultsContain(services[3]));
- EXPECT_TRUE(consumer.ResultsContain(services[12]));
-
- // Test retrieve string literal match.
- registry_.GetIntentServices(
- ASCIIToUTF16("http://webintents.org/share"), ASCIIToUTF16("elsewhere"),
- base::Bind(&ServiceListConsumer::Accept,
- base::Unretained(&consumer)));
- consumer.WaitForData();
- ASSERT_EQ(1U, consumer.services_.size());
- EXPECT_EQ(services[4], consumer.services_[0]);
-
- // Test retrieve MIME-looking type but actually isn't
- // doesn't wildcard match.
- registry_.GetIntentServices(
- ASCIIToUTF16("http://webintents.org/share"),
- ASCIIToUTF16("nota/mimetype"),
- base::Bind(&ServiceListConsumer::Accept,
- base::Unretained(&consumer)));
- consumer.WaitForData();
- ASSERT_EQ(0U, consumer.services_.size());
-
- // Also a MIME-ish type that actually isn't.
- registry_.GetIntentServices(
- ASCIIToUTF16("http://webintents.org/share"),
- ASCIIToUTF16("x-/mimetype"),
- base::Bind(&ServiceListConsumer::Accept,
- base::Unretained(&consumer)));
- consumer.WaitForData();
- ASSERT_EQ(0U, consumer.services_.size());
-
- // Extension MIME type will match wildcard.
- registry_.GetIntentServices(
- ASCIIToUTF16("http://webintents.org/share"),
- ASCIIToUTF16("x-type/mimetype"),
- base::Bind(&ServiceListConsumer::Accept,
- base::Unretained(&consumer)));
- consumer.WaitForData();
- ASSERT_EQ(1U, consumer.services_.size());
-}
-
-TEST_F(WebIntentsRegistryTest, TestGetAllDefaultIntentServices) {
- DefaultWebIntentService s0;
- s0.action = ASCIIToUTF16("share");
- s0.type = ASCIIToUTF16("text/*");
- // Values here are just dummies to test for preservation.
- s0.user_date = 1;
- s0.suppression = 4;
- s0.service_url = "service_url";
- registry_.RegisterDefaultIntentService(s0);
-
- DefaultWebIntentService s1;
- s1.action = ASCIIToUTF16("pick");
- s1.type = ASCIIToUTF16("image/*");
- // Values here are just dummies to test for preservation.
- s1.user_date = 1;
- s1.suppression = 4;
- s1.service_url = "service_url";
- registry_.RegisterDefaultIntentService(s1);
-
- DefaultWebIntentService s2;
- s2.action = ASCIIToUTF16("save");
- s2.type = ASCIIToUTF16("application/*");
- // Values here are just dummies to test for preservation.
- s2.user_date = 1;
- s2.suppression = 4;
- s2.service_url = "service_url";
- registry_.RegisterDefaultIntentService(s2);
-
- DefaultServiceListConsumer consumer;
-
- registry_.GetAllDefaultIntentServices(
- base::Bind(&DefaultServiceListConsumer::Accept,
- base::Unretained(&consumer)));
-
- consumer.WaitForData();
-
- EXPECT_TRUE(consumer.ResultsContain(s0));
- EXPECT_TRUE(consumer.ResultsContain(s1));
- EXPECT_TRUE(consumer.ResultsContain(s2));
-}
-
-TEST_F(WebIntentsRegistryTest, TestGetDefaults) {
- // Ignore QO-default related calls.
- EXPECT_CALL(extension_service_, GetInstalledExtension(testing::_)).
- WillRepeatedly(testing::ReturnNull());
-
- DefaultWebIntentService default_service;
- default_service.action = ASCIIToUTF16("share");
- default_service.type = ASCIIToUTF16("text/*");
- // Values here are just dummies to test for preservation.
- default_service.user_date = 1;
- default_service.suppression = 4;
- default_service.service_url = "service_url";
- registry_.RegisterDefaultIntentService(default_service);
-
- DefaultServiceConsumer consumer;
-
- // Test we can retrieve default entries by action.
- registry_.GetDefaultIntentService(
- ASCIIToUTF16("share"), ASCIIToUTF16("text/plain"),
- GURL("http://www.google.com/"),
- base::Bind(&DefaultServiceConsumer::Accept,
- base::Unretained(&consumer)));
-
- consumer.WaitForData();
-
- EXPECT_EQ("service_url", consumer.service_.service_url);
- EXPECT_EQ(1, consumer.service_.user_date);
- EXPECT_EQ(4, consumer.service_.suppression);
-
- // Can get for wildcard.
- consumer.service_ = DefaultWebIntentService();
- registry_.GetDefaultIntentService(
- ASCIIToUTF16("share"),
- ASCIIToUTF16("text/*"),
- GURL("http://www.google.com/"),
- base::Bind(&DefaultServiceConsumer::Accept,
- base::Unretained(&consumer)));
- consumer.WaitForData();
- EXPECT_EQ("service_url", consumer.service_.service_url);
- EXPECT_EQ(1, consumer.service_.user_date);
- EXPECT_EQ(4, consumer.service_.suppression);
-
- // Test that no action match means we don't retrieve any
- // default entries.
- consumer.service_ = DefaultWebIntentService();
- ASSERT_EQ("", consumer.service_.service_url);
- registry_.GetDefaultIntentService(
- ASCIIToUTF16("no-share"), ASCIIToUTF16("text/plain"),
- GURL("http://www.google.com/"),
- base::Bind(&DefaultServiceConsumer::Accept,
- base::Unretained(&consumer)));
-
- consumer.WaitForData();
-
- EXPECT_EQ("", consumer.service_.service_url);
-
- // Test that no type match means we don't retrieve any
- // default entries (they get filtered out).
- consumer.service_ = DefaultWebIntentService();
- ASSERT_EQ("", consumer.service_.service_url);
- registry_.GetDefaultIntentService(
- ASCIIToUTF16("share"), ASCIIToUTF16("image/plain"),
- GURL("http://www.google.com/"),
- base::Bind(&DefaultServiceConsumer::Accept,
- base::Unretained(&consumer)));
-
- consumer.WaitForData();
-
- EXPECT_EQ("", consumer.service_.service_url);
-
- // Check that a string-literal type won't match.
- consumer.service_ = DefaultWebIntentService();
- ASSERT_EQ("", consumer.service_.service_url);
- registry_.GetDefaultIntentService(
- ASCIIToUTF16("share"),
- ASCIIToUTF16("literal"),
- GURL("http://www.google.com/"),
- base::Bind(&DefaultServiceConsumer::Accept,
- base::Unretained(&consumer)));
-
- consumer.WaitForData();
-
- EXPECT_EQ("", consumer.service_.service_url);
-}
-
-// Verify that collapsing equivalent intents works properly.
-TEST_F(WebIntentsRegistryTest, CollapseIntents) {
- WebIntentsRegistry::IntentServiceList services;
-
- // Add two intents with identical |service_url|, |title|, and |action|.
- services.push_back(
- WebIntentServiceData(ASCIIToUTF16("http://webintents.org/share"),
- ASCIIToUTF16("image/png"),
- string16(),
- GURL("http://somewhere.com/intent/share.html"),
- ASCIIToUTF16("Image Sharing Service")));
- services.push_back(
- WebIntentServiceData(ASCIIToUTF16("http://webintents.org/share"),
- ASCIIToUTF16("image/jpg"),
- string16(),
- GURL("http://somewhere.com/intent/share.html"),
- ASCIIToUTF16("Image Sharing Service")));
- // Service that differs in disposition.
- services.push_back(
- WebIntentServiceData(ASCIIToUTF16("http://webintents.org/share"),
- ASCIIToUTF16("image/png"),
- string16(),
- GURL("http://somewhere.com/intent/share.html"),
- ASCIIToUTF16("Image Sharing Service")));
- ASSERT_EQ(WebIntentServiceData::DISPOSITION_WINDOW,
- services.back().disposition);
- services.back().disposition = WebIntentServiceData::DISPOSITION_INLINE;
- // Service that differs in title.
- services.push_back(
- WebIntentServiceData(ASCIIToUTF16("http://webintents.org/share"),
- ASCIIToUTF16("image/png"),
- string16(),
- GURL("http://somewhere.com/intent/share.html"),
- ASCIIToUTF16("Sharing Service")));
- // Service that differs in |action|.
- services.push_back(
- WebIntentServiceData(ASCIIToUTF16("http://webintents.org/share-old"),
- ASCIIToUTF16("image/png"),
- string16(),
- GURL("http://somewhere.com/intent/share.html"),
- ASCIIToUTF16("Image Sharing Service")));
- // Service that differs in |service_url|.
- services.push_back(
- WebIntentServiceData(ASCIIToUTF16("http://webintents.org/share"),
- ASCIIToUTF16("image/png"),
- string16(),
- GURL("http://zoo.com/share.html"),
- ASCIIToUTF16("Image Sharing Service")));
-
- // Only the first two services should be collapsed.
- registry_.CollapseIntents(&services);
- ASSERT_EQ(5UL, services.size());
-
- // Joined services have their mime types combined
- EXPECT_EQ(ASCIIToUTF16("image/png,image/jpg"), services[0].type);
-
- // Verify the remaining services via distinguishing characteristics.
- EXPECT_EQ(WebIntentServiceData::DISPOSITION_INLINE, services[1].disposition);
- EXPECT_EQ(ASCIIToUTF16("Sharing Service"), services[2].title);
- EXPECT_EQ(ASCIIToUTF16("http://webintents.org/share-old"),
- services[3].action);
- EXPECT_EQ(GURL("http://zoo.com/share.html").spec(),
- services[4].service_url.spec());
-}
-
-// Verify that GetIntentServices collapses equivalent intents.
-TEST_F(WebIntentsRegistryTest, GetIntentsCollapsesEquivalentIntents) {
- WebIntentServiceData services[] = {
- WebIntentServiceData(ASCIIToUTF16("http://webintents.org/share"),
- ASCIIToUTF16("image/png"),
- string16(),
- GURL("http://somewhere.com/intent/share.html"),
- ASCIIToUTF16("Image Sharing Service")),
- WebIntentServiceData(ASCIIToUTF16("http://webintents.org/share"),
- ASCIIToUTF16("image/jpg"),
- string16(),
- GURL("http://somewhere.com/intent/share.html"),
- ASCIIToUTF16("Image Sharing Service"))
- };
- registry_.RegisterIntentService(services[0]);
- registry_.RegisterIntentService(services[1]);
-
- ServiceListConsumer consumer;
- registry_.GetIntentServices(ASCIIToUTF16("http://webintents.org/share"),
- ASCIIToUTF16("image/*"),
- base::Bind(&ServiceListConsumer::Accept,
- base::Unretained(&consumer)));
-
- consumer.WaitForData();
- ASSERT_EQ(1U, consumer.services_.size());
- EXPECT_EQ(ASCIIToUTF16("image/png,image/jpg"), consumer.services_[0].type);
-}
-
-TEST_F(WebIntentsRegistryTest, UnregisterDefaultIntentServicesForServiceURL) {
-
- const GURL service_url_0("http://jibfest.com/dozer");
- const GURL service_url_1("http://kittyfizzer.com/fizz");
-
- DefaultWebIntentService s0;
- s0.action = ASCIIToUTF16("share");
- s0.type = ASCIIToUTF16("text/*");
- // Values here are just dummies to test for preservation.
- s0.user_date = 1;
- s0.suppression = 4;
- s0.service_url = service_url_0.spec();
- registry_.RegisterDefaultIntentService(s0);
-
- DefaultWebIntentService s1;
- s1.action = ASCIIToUTF16("whack");
- s1.type = ASCIIToUTF16("text/*");
- // Values here are just dummies to test for preservation.
- s1.user_date = 1;
- s1.suppression = 4;
- s1.service_url = service_url_1.spec();
- registry_.RegisterDefaultIntentService(s1);
-
- DefaultServiceListConsumer consumer;
-
- registry_.GetAllDefaultIntentServices(
- base::Bind(&DefaultServiceListConsumer::Accept,
- base::Unretained(&consumer)));
-
- consumer.WaitForData();
-
- ASSERT_EQ(2U, consumer.services_.size());
-
- registry_.UnregisterServiceDefaults(service_url_0);
- MessageLoop::current()->RunUntilIdle();
-
- registry_.GetAllDefaultIntentServices(
- base::Bind(&DefaultServiceListConsumer::Accept,
- base::Unretained(&consumer)));
-
- consumer.WaitForData();
-
- ASSERT_EQ(1U, consumer.services_.size());
- EXPECT_EQ(service_url_1.spec(), consumer.services_[0].service_url);
-}
diff --git a/chrome/browser/intents/web_intents_reporting.cc b/chrome/browser/intents/web_intents_reporting.cc
deleted file mode 100644
index c780724..0000000
--- a/chrome/browser/intents/web_intents_reporting.cc
+++ /dev/null
@@ -1,167 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "web_intents_reporting.h"
-
-#include "base/metrics/histogram.h"
-#include "base/string_util.h"
-#include "chrome/browser/intents/web_intents_util.h"
-#include "net/base/mime_util.h"
-#include "webkit/glue/web_intent_data.h"
-
-namespace web_intents {
-namespace {
-
-struct TypeMapping {
- const char* name;
- const TypeId id;
-};
-
-const TypeMapping kTypeMap[] = {
- { "application", TYPE_ID_APPLICATION },
- { "audio", TYPE_ID_AUDIO },
- { "example", TYPE_ID_EXAMPLE },
- { "image", TYPE_ID_IMAGE },
- { "message", TYPE_ID_MESSAGE },
- { "model", TYPE_ID_MODEL },
- { "multipart", TYPE_ID_MULTIPART },
- { "text", TYPE_ID_TEXT },
- { "video", TYPE_ID_VIDEO },
-};
-
-// The number of buckets for the histogram of the duration of time spent in a
-// service.
-const int kServiceActiveTimeNumBuckets = 10;
-
-// The lower bound on the tracked duration of time spent in a service.
-// This bound is in seconds.
-const int kServiceActiveDurationMinSeconds = 1;
-
-// The upper bound on the tracked duration of time spent in a service.
-// This bound is in seconds.
-const int kServiceActiveDurationMaxSeconds = 3600;
-
-// UMA bucket range for custom histograms.
-//
-// TODO(rouslan): Remove this once we've migrated to sparse histograms. See
-// http://crbug.com/153891 before changing anything.
-std::vector<int> GetUmaBucketsCustomRange() {
- // Please update these numbers if you add more actions or types.
- const int kNumActions = 7;
- const int kNumTypes = 10;
- std::vector<int> range;
- for (int i = 1; i <= kNumActions; i++) {
- for (int j = 1; j <= kNumTypes; j++) {
- range.push_back(i << 8 | j);
- }
- }
- return range;
-}
-
-// Returns the ActionMapping for |action| if one exists, or NULL.
-TypeId ToTypeId(const string16& type) {
- const std::string iana_type = net::GetIANAMediaType(UTF16ToASCII(type));
- for (size_t i = 0; i < arraysize(kTypeMap); ++i) {
- if (iana_type == kTypeMap[i].name) {
- return kTypeMap[i].id;
- }
- }
- return TYPE_ID_CUSTOM;
-}
-
-// Records the number of services installed at the time the picker
-// is shown to the user. Drops the size into one of several buckets.
-void RecordInstalledServiceCount(const UMABucket bucket, size_t installed) {
- if (installed == 0) {
- UMA_HISTOGRAM_CUSTOM_ENUMERATION("WebIntents.Service.NumInstalled.0.v0",
- bucket, GetUmaBucketsCustomRange());
- } else if (installed >= 1 && installed <= 4) {
- UMA_HISTOGRAM_CUSTOM_ENUMERATION("WebIntents.Service.NumInstalled.1-4.v0",
- bucket, GetUmaBucketsCustomRange());
- } else if (installed >= 5 && installed <= 8) {
- UMA_HISTOGRAM_CUSTOM_ENUMERATION("WebIntents.Service.NumInstalled.5-8.v0",
- bucket, GetUmaBucketsCustomRange());
- } else {
- UMA_HISTOGRAM_CUSTOM_ENUMERATION("WebIntents.Service.NumInstalled.9+.v0",
- bucket, GetUmaBucketsCustomRange());
- }
-}
-
-} // namespace
-
-UMABucket ToUMABucket(const string16& action, const string16& type) {
- ActionId action_id = ToActionId(action);
- TypeId type_id = ToTypeId(type);
- short bucket_id = (action_id << 8) | type_id;
- DCHECK(bucket_id > 256);
- return static_cast<UMABucket>(bucket_id);
-}
-
-void RecordIntentsDispatchDisabled() {
- UMA_HISTOGRAM_COUNTS("WebIntents.DispatchDisabled", 1);
-}
-
-void RecordIntentDispatchRequested() {
- UMA_HISTOGRAM_COUNTS("WebIntents.Dispatch", 1);
-}
-
-void RecordIntentDispatched(const UMABucket bucket) {
- UMA_HISTOGRAM_CUSTOM_ENUMERATION("WebIntents.IntentDispatched.v0",
- bucket, GetUmaBucketsCustomRange());
-}
-
-void RecordPickerShow(const UMABucket bucket, size_t installed) {
- UMA_HISTOGRAM_CUSTOM_ENUMERATION("WebIntents.Picker.Show.v0",
- bucket, GetUmaBucketsCustomRange());
- RecordInstalledServiceCount(bucket, installed);
-}
-
-void RecordPickerCancel(const UMABucket bucket) {
- UMA_HISTOGRAM_CUSTOM_ENUMERATION("WebIntents.Picker.Cancel.v0",
- bucket, GetUmaBucketsCustomRange());
-}
-
-void RecordServiceInvoke(const UMABucket bucket) {
- UMA_HISTOGRAM_CUSTOM_ENUMERATION("WebIntents.Service.Invoked.v0",
- bucket, GetUmaBucketsCustomRange());
-}
-
-void RecordChooseAnotherService(const UMABucket bucket) {
- UMA_HISTOGRAM_CUSTOM_ENUMERATION("WebIntents.Service.ChooseAnother.v0",
- bucket, GetUmaBucketsCustomRange());
-}
-
-void RecordCWSExtensionInstalled(const UMABucket bucket) {
- UMA_HISTOGRAM_CUSTOM_ENUMERATION("WebIntents.Service.CWSInstall.v0",
- bucket, GetUmaBucketsCustomRange());
-}
-
-void RecordServiceActiveDuration(
- webkit_glue::WebIntentReplyType reply_type,
- const base::TimeDelta& duration) {
- switch (reply_type) {
- case webkit_glue::WEB_INTENT_REPLY_SUCCESS:
- UMA_HISTOGRAM_CUSTOM_TIMES("WebIntents.Service.ActiveDuration.Success",
- duration,
- base::TimeDelta::FromSeconds(kServiceActiveDurationMinSeconds),
- base::TimeDelta::FromSeconds(kServiceActiveDurationMaxSeconds),
- kServiceActiveTimeNumBuckets);
- break;
- case webkit_glue::WEB_INTENT_REPLY_INVALID:
- case webkit_glue::WEB_INTENT_REPLY_FAILURE:
- case webkit_glue::WEB_INTENT_PICKER_CANCELLED:
- case webkit_glue::WEB_INTENT_SERVICE_CONTENTS_CLOSED:
- UMA_HISTOGRAM_CUSTOM_TIMES("WebIntents.Service.ActiveDuration.Failure",
- duration,
- base::TimeDelta::FromSeconds(kServiceActiveDurationMinSeconds),
- base::TimeDelta::FromSeconds(kServiceActiveDurationMaxSeconds),
- kServiceActiveTimeNumBuckets);
- break;
- default:
- NOTREACHED();
- break;
- }
-}
-
-} // namespace web_intents
diff --git a/chrome/browser/intents/web_intents_reporting.h b/chrome/browser/intents/web_intents_reporting.h
deleted file mode 100644
index afcd391..0000000
--- a/chrome/browser/intents/web_intents_reporting.h
+++ /dev/null
@@ -1,135 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_INTENTS_WEB_INTENTS_REPORTING_H_
-#define CHROME_BROWSER_INTENTS_WEB_INTENTS_REPORTING_H_
-
-#include "base/string16.h"
-#include "chrome/browser/intents/web_intents_util.h"
-#include "webkit/glue/web_intent_reply_data.h"
-
-namespace base {
-class TimeDelta;
-}
-
-namespace webkit_glue {
-struct WebIntentData;
-}
-
-namespace web_intents {
-
-// primarily an implementation detail, but declared in this scope
-// so they can be used in generating bucket ids
-enum TypeId {
- TYPE_ID_CUSTOM = 1,
- TYPE_ID_APPLICATION,
- TYPE_ID_AUDIO,
- TYPE_ID_EXAMPLE,
- TYPE_ID_IMAGE,
- TYPE_ID_MESSAGE,
- TYPE_ID_MODEL,
- TYPE_ID_MULTIPART,
- TYPE_ID_TEXT,
- TYPE_ID_VIDEO,
-};
-
-#define INTENT_UMA_BUCKET(ACTION, TYPE) \
- (ACTION_ID_##ACTION << 8) | TYPE_ID_##TYPE
-
-// UMA buckets for reporting the Web Intent action and type.
-enum UMABucket {
- BUCKET_CUSTOM_CUSTOM = INTENT_UMA_BUCKET(CUSTOM, CUSTOM),
- BUCKET_CUSTOM_APPLICATION = INTENT_UMA_BUCKET(CUSTOM, APPLICATION),
- BUCKET_CUSTOM_AUDIO = INTENT_UMA_BUCKET(CUSTOM, AUDIO),
- BUCKET_CUSTOM_EXAMPLE = INTENT_UMA_BUCKET(CUSTOM, EXAMPLE),
- BUCKET_CUSTOM_IMAGE = INTENT_UMA_BUCKET(CUSTOM, IMAGE),
- BUCKET_CUSTOM_MESSAGE = INTENT_UMA_BUCKET(CUSTOM, MESSAGE),
- BUCKET_CUSTOM_MODEL = INTENT_UMA_BUCKET(CUSTOM, MODEL),
- BUCKET_CUSTOM_MULTIPART = INTENT_UMA_BUCKET(CUSTOM, MULTIPART),
- BUCKET_CUSTOM_TEXT = INTENT_UMA_BUCKET(CUSTOM, TEXT),
- BUCKET_CUSTOM_VIDEO = INTENT_UMA_BUCKET(CUSTOM, VIDEO),
- BUCKET_EDIT_CUSTOM = INTENT_UMA_BUCKET(EDIT, CUSTOM),
- BUCKET_EDIT_APPLICATION = INTENT_UMA_BUCKET(EDIT, APPLICATION),
- BUCKET_EDIT_AUDIO = INTENT_UMA_BUCKET(EDIT, AUDIO),
- BUCKET_EDIT_EXAMPLE = INTENT_UMA_BUCKET(EDIT, EXAMPLE),
- BUCKET_EDIT_IMAGE = INTENT_UMA_BUCKET(EDIT, IMAGE),
- BUCKET_EDIT_MESSAGE = INTENT_UMA_BUCKET(EDIT, MESSAGE),
- BUCKET_EDIT_MODEL = INTENT_UMA_BUCKET(EDIT, MODEL),
- BUCKET_EDIT_MULTIPART = INTENT_UMA_BUCKET(EDIT, MULTIPART),
- BUCKET_EDIT_TEXT = INTENT_UMA_BUCKET(EDIT, TEXT),
- BUCKET_EDIT_VIDEO = INTENT_UMA_BUCKET(EDIT, VIDEO),
- BUCKET_PICK_CUSTOM = INTENT_UMA_BUCKET(PICK, CUSTOM),
- BUCKET_PICK_APPLICATION = INTENT_UMA_BUCKET(PICK, APPLICATION),
- BUCKET_PICK_AUDIO = INTENT_UMA_BUCKET(PICK, AUDIO),
- BUCKET_PICK_EXAMPLE = INTENT_UMA_BUCKET(PICK, EXAMPLE),
- BUCKET_PICK_IMAGE = INTENT_UMA_BUCKET(PICK, IMAGE),
- BUCKET_PICK_MESSAGE = INTENT_UMA_BUCKET(PICK, MESSAGE),
- BUCKET_PICK_MODEL = INTENT_UMA_BUCKET(PICK, MODEL),
- BUCKET_PICK_MULTIPART = INTENT_UMA_BUCKET(PICK, MULTIPART),
- BUCKET_PICK_TEXT = INTENT_UMA_BUCKET(PICK, TEXT),
- BUCKET_PICK_VIDEO = INTENT_UMA_BUCKET(PICK, VIDEO),
- BUCKET_SAVE_CUSTOM = INTENT_UMA_BUCKET(SAVE, CUSTOM),
- BUCKET_SAVE_APPLICATION = INTENT_UMA_BUCKET(SAVE, APPLICATION),
- BUCKET_SAVE_AUDIO = INTENT_UMA_BUCKET(SAVE, AUDIO),
- BUCKET_SAVE_EXAMPLE = INTENT_UMA_BUCKET(SAVE, EXAMPLE),
- BUCKET_SAVE_IMAGE = INTENT_UMA_BUCKET(SAVE, IMAGE),
- BUCKET_SAVE_MESSAGE = INTENT_UMA_BUCKET(SAVE, MESSAGE),
- BUCKET_SAVE_MODEL = INTENT_UMA_BUCKET(SAVE, MODEL),
- BUCKET_SAVE_MULTIPART = INTENT_UMA_BUCKET(SAVE, MULTIPART),
- BUCKET_SAVE_TEXT = INTENT_UMA_BUCKET(SAVE, TEXT),
- BUCKET_SAVE_VIDEO = INTENT_UMA_BUCKET(SAVE, VIDEO),
- BUCKET_SHARE_CUSTOM = INTENT_UMA_BUCKET(SHARE, CUSTOM),
- BUCKET_SHARE_APPLICATION = INTENT_UMA_BUCKET(SHARE, APPLICATION),
- BUCKET_SHARE_AUDIO = INTENT_UMA_BUCKET(SHARE, AUDIO),
- BUCKET_SHARE_EXAMPLE = INTENT_UMA_BUCKET(SHARE, EXAMPLE),
- BUCKET_SHARE_IMAGE = INTENT_UMA_BUCKET(SHARE, IMAGE),
- BUCKET_SHARE_MESSAGE = INTENT_UMA_BUCKET(SHARE, MESSAGE),
- BUCKET_SHARE_MODEL = INTENT_UMA_BUCKET(SHARE, MODEL),
- BUCKET_SHARE_MULTIPART = INTENT_UMA_BUCKET(SHARE, MULTIPART),
- BUCKET_SHARE_TEXT = INTENT_UMA_BUCKET(SHARE, TEXT),
- BUCKET_SHARE_VIDEO = INTENT_UMA_BUCKET(SHARE, VIDEO),
- BUCKET_SUBSCRIBE_CUSTOM = INTENT_UMA_BUCKET(SUBSCRIBE, CUSTOM),
- BUCKET_SUBSCRIBE_APPLICATION = INTENT_UMA_BUCKET(SUBSCRIBE, APPLICATION),
- BUCKET_SUBSCRIBE_AUDIO = INTENT_UMA_BUCKET(SUBSCRIBE, AUDIO),
- BUCKET_SUBSCRIBE_EXAMPLE = INTENT_UMA_BUCKET(SUBSCRIBE, EXAMPLE),
- BUCKET_SUBSCRIBE_IMAGE = INTENT_UMA_BUCKET(SUBSCRIBE, IMAGE),
- BUCKET_SUBSCRIBE_MESSAGE = INTENT_UMA_BUCKET(SUBSCRIBE, MESSAGE),
- BUCKET_SUBSCRIBE_MODEL = INTENT_UMA_BUCKET(SUBSCRIBE, MODEL),
- BUCKET_SUBSCRIBE_MULTIPART = INTENT_UMA_BUCKET(SUBSCRIBE, MULTIPART),
- BUCKET_SUBSCRIBE_TEXT = INTENT_UMA_BUCKET(SUBSCRIBE, TEXT),
- BUCKET_SUBSCRIBE_VIDEO = INTENT_UMA_BUCKET(SUBSCRIBE, VIDEO),
- BUCKET_VIEW_CUSTOM = INTENT_UMA_BUCKET(VIEW, CUSTOM),
- BUCKET_VIEW_APPLICATION = INTENT_UMA_BUCKET(VIEW, APPLICATION),
- BUCKET_VIEW_AUDIO = INTENT_UMA_BUCKET(VIEW, AUDIO),
- BUCKET_VIEW_EXAMPLE = INTENT_UMA_BUCKET(VIEW, EXAMPLE),
- BUCKET_VIEW_IMAGE = INTENT_UMA_BUCKET(VIEW, IMAGE),
- BUCKET_VIEW_MESSAGE = INTENT_UMA_BUCKET(VIEW, MESSAGE),
- BUCKET_VIEW_MODEL = INTENT_UMA_BUCKET(VIEW, MODEL),
- BUCKET_VIEW_MULTIPART = INTENT_UMA_BUCKET(VIEW, MULTIPART),
- BUCKET_VIEW_TEXT = INTENT_UMA_BUCKET(VIEW, TEXT),
- BUCKET_VIEW_VIDEO = INTENT_UMA_BUCKET(VIEW, VIDEO),
-};
-
-#undef INTENT_UMA_BUCKET
-
-UMABucket ToUMABucket(const string16& action, const string16& type);
-void RecordIntentsDispatchDisabled();
-void RecordIntentDispatchRequested();
-void RecordIntentDispatched(const UMABucket bucket);
-
-// Records the fact that the picker was shown and records the
-// number of services installed at the time the picker was shown
-void RecordPickerShow(const UMABucket bucket, size_t installed);
-void RecordPickerCancel(const UMABucket bucket);
-void RecordServiceInvoke(const UMABucket bucket);
-// Records the |duration| of time spent in the service. Uses |reply_type| to
-// distinguish between failed and successful service usage.
-void RecordServiceActiveDuration(
- webkit_glue::WebIntentReplyType reply_type,
- const base::TimeDelta& duration);
-void RecordChooseAnotherService(const UMABucket bucket);
-void RecordCWSExtensionInstalled(const UMABucket bucket);
-} // namespace web_intents
-
-#endif // CHROME_BROWSER_INTENTS_WEB_INTENTS_REPORTING_H_
diff --git a/chrome/browser/intents/web_intents_reporting_unittest.cc b/chrome/browser/intents/web_intents_reporting_unittest.cc
deleted file mode 100644
index 0bcb136..0000000
--- a/chrome/browser/intents/web_intents_reporting_unittest.cc
+++ /dev/null
@@ -1,48 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/intents/web_intents_reporting.h"
-
-#include <vector>
-
-#include "base/metrics/histogram.h"
-#include "base/metrics/statistics_recorder.h"
-#include "base/utf_string_conversions.h"
-#include "chrome/browser/intents/web_intents_util.h"
-#include "chrome/browser/search_engines/search_engine_type.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-namespace web_intents {
-namespace reporting {
-namespace {
-
-const char kCustomAction[] = "jiggle";
-const char kImageType[] = "image/png";
-const char kCustomType[] = "http://a.b/mine";
-
-UMABucket ToBucket(const std::string& action, const std::string& type) {
- return web_intents::ToUMABucket(
- ASCIIToUTF16(action), ASCIIToUTF16(type));
-}
-
-} // namespace
-
-TEST(WebIntentsReportingTest, RecognizedActionAndType) {
- EXPECT_EQ(BUCKET_SHARE_IMAGE, ToBucket(kActionShare, kImageType));
-}
-
-TEST(WebIntentsReportingTest, CustomAction) {
- EXPECT_EQ(BUCKET_CUSTOM_IMAGE, ToBucket(kCustomAction, kImageType));
-}
-
-TEST(WebIntentsReportingTest, CustomType) {
- EXPECT_EQ(BUCKET_EDIT_CUSTOM, ToBucket(kActionEdit, kCustomType));
-}
-
-TEST(WebIntentsReportingTest, CustomActionAndType) {
- EXPECT_EQ(BUCKET_CUSTOM_CUSTOM, ToBucket(kCustomAction, kCustomType));
-}
-
-} // namespace reporting
-} // namespace web_intents
diff --git a/chrome/browser/intents/web_intents_util.cc b/chrome/browser/intents/web_intents_util.cc
deleted file mode 100644
index 0624a10..0000000
--- a/chrome/browser/intents/web_intents_util.cc
+++ /dev/null
@@ -1,111 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/intents/web_intents_util.h"
-
-#include "base/command_line.h"
-#include "base/string_util.h"
-#include "base/utf_string_conversions.h"
-#include "chrome/browser/prefs/pref_registry_syncable.h"
-#include "chrome/browser/prefs/pref_service.h"
-#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/ui/browser.h"
-#include "chrome/browser/ui/browser_finder.h"
-#include "chrome/browser/ui/host_desktop.h"
-#include "chrome/common/chrome_switches.h"
-#include "chrome/common/pref_names.h"
-#include "chrome/common/url_constants.h"
-#include "content/public/common/content_switches.h"
-#include "net/base/mime_util.h"
-
-namespace web_intents {
-namespace {
-
-struct ActionMapping {
- const char* name;
- const ActionId id;
-};
-
-const ActionMapping kActionMap[] = {
- { kActionEdit, ACTION_ID_EDIT },
- { kActionPick, ACTION_ID_PICK },
- { kActionSave, ACTION_ID_SAVE },
- { kActionShare, ACTION_ID_SHARE},
- { kActionSubscribe, ACTION_ID_SUBSCRIBE },
- { kActionView, ACTION_ID_VIEW },
-};
-
-// Returns the ActionMapping for |action| if one exists, or NULL.
-const ActionMapping* FindActionMapping(const string16& action) {
- for (size_t i = 0; i < arraysize(kActionMap); ++i) {
- if (EqualsASCII(action, kActionMap[i].name)) {
- return &kActionMap[i];
- }
- }
- return NULL;
-}
-
-} // namespace
-
-const char kActionEdit[] = "http://webintents.org/edit";
-const char kActionPick[] = "http://webintents.org/pick";
-const char kActionSave[] = "http://webintents.org/save";
-const char kActionShare[] = "http://webintents.org/share";
-const char kActionSubscribe[] = "http://webintents.org/subscribe";
-const char kActionView[] = "http://webintents.org/view";
-const char kActionCrosEcho[] = "https://crosecho.com/startEcho";
-const char kQuickOfficeViewerServiceURL[] =
- "chrome-extension://gbkeegbaiigmenfmjfclcdgdpimamgkj/views/appViewer.html";
-const char kQuickOfficeViewerDevServiceURL[] =
- "chrome-extension://ionpfmkccalenbmnddpbmocokhaknphg/views/appEditor.html";
-
-void RegisterUserPrefs(PrefRegistrySyncable* registry) {
- registry->RegisterBooleanPref(prefs::kWebIntentsEnabled, true,
- PrefRegistrySyncable::SYNCABLE_PREF);
-}
-
-bool IsWebIntentsEnabled(PrefService* prefs) {
- return CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kWebIntentsInvocationEnabled);
-}
-
-bool IsWebIntentsEnabledForProfile(Profile* profile) {
- return IsWebIntentsEnabled(profile->GetPrefs());
-}
-
-Browser* GetBrowserForBackgroundWebIntentDelivery(Profile* profile) {
- Browser* browser = chrome::FindLastActiveWithHostDesktopType(
- chrome::GetActiveDesktop());
- if (browser && profile && browser->profile() != profile)
- return NULL;
- return browser;
-}
-
-bool IsRecognizedAction(const string16& action) {
- const ActionMapping* mapping = FindActionMapping(action);
- return mapping != NULL;
-}
-
-ActionId ToActionId(const string16& action) {
- const ActionMapping* mapping = FindActionMapping(action);
- return mapping != NULL ? mapping->id : ACTION_ID_CUSTOM;
-}
-
-bool MimeTypesMatch(const string16& type1, const string16& type2) {
- // We don't have a MIME matcher that allows patterns on both sides
- // Instead, we do two comparisons, treating each type in turn as a
- // pattern. If either one matches, we consider this a MIME match.
- std::string t1 = UTF16ToUTF8(type1);
- std::string t2 = UTF16ToUTF8(type2);
-
- // If either side is _all_ wildcard, it's a match!
- if (t1 == "*" || t1 == "*/*" || t2 == "*" || t2 == "*/*")
- return true;
-
- StringToLowerASCII(&t1);
- StringToLowerASCII(&t2);
- return (net::MatchesMimeType(t1, t2)) || net::MatchesMimeType(t2, t1);
-}
-
-} // namespace web_intents
diff --git a/chrome/browser/intents/web_intents_util.h b/chrome/browser/intents/web_intents_util.h
deleted file mode 100644
index 2dfa99f..0000000
--- a/chrome/browser/intents/web_intents_util.h
+++ /dev/null
@@ -1,69 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_INTENTS_WEB_INTENTS_UTIL_H_
-#define CHROME_BROWSER_INTENTS_WEB_INTENTS_UTIL_H_
-
-#include "base/string16.h"
-
-class Browser;
-class Profile;
-class PrefService;
-class PrefRegistrySyncable;
-
-namespace web_intents {
-
-enum ActionId {
- ACTION_ID_CUSTOM = 1, // for all unrecognized types
- ACTION_ID_EDIT,
- ACTION_ID_PICK,
- ACTION_ID_SAVE,
- ACTION_ID_SHARE,
- ACTION_ID_SUBSCRIBE,
- ACTION_ID_VIEW,
-};
-
-// "Recognized" action strings. These are basically the
-// actions we're reporting via UMA.
-extern const char kActionEdit[];
-extern const char kActionPick[];
-extern const char kActionSave[];
-extern const char kActionShare[];
-extern const char kActionSubscribe[];
-extern const char kActionView[];
-extern const char kActionCrosEcho[];
-
-extern const char kQuickOfficeViewerServiceURL[];
-extern const char kQuickOfficeViewerDevServiceURL[];
-
-// Registers the preferences related to Web Intents.
-void RegisterUserPrefs(PrefRegistrySyncable* registry);
-
-// Returns true if WebIntents are enabled in preferences.
-bool IsWebIntentsEnabled(PrefService* prefs);
-
-// Returns true if WebIntents are enabled due to various factors. |profile| is
-// the Profile to check that WebIntents are enabled for.
-bool IsWebIntentsEnabledForProfile(Profile* profile);
-
-// In a context where we are generating a web intent based on internal events,
-// or from an extension background page, get the browser in which to show the
-// intent picker to the user.
-Browser* GetBrowserForBackgroundWebIntentDelivery(Profile* profile);
-
-// Returns the recognized action (the one described at
-// webintents.org) or an empty string if the action is not recognized.
-bool IsRecognizedAction(const string16& action);
-
-// Returns the action::Id corresponding to |action| or ACTION_ID_CUSTOM
-// if |action| is not recognized.
-ActionId ToActionId(const string16& action);
-
-// Returns true if |type1| and |type2| "match". Supports wild cards in both
-// |type1| and |type2|. Wild cards are of the form '<type>/*', '*/*', and '*'.
-bool MimeTypesMatch(const string16& type1, const string16& type2);
-
-} // namespace web_intents
-
-#endif // CHROME_BROWSER_INTENTS_WEB_INTENTS_UTIL_H_
diff --git a/chrome/browser/intents/web_intents_util_stub.cc b/chrome/browser/intents/web_intents_util_stub.cc
deleted file mode 100644
index f51fb3a..0000000
--- a/chrome/browser/intents/web_intents_util_stub.cc
+++ /dev/null
@@ -1,26 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Stub implementation of web_intents_util.h to be included in builds
-// where ENABLE_WEB_INTENTS is not defined.
-
-#include "chrome/browser/intents/web_intents_util.h"
-
-namespace web_intents {
-
-const char kActionView[] = "http://webintents.org/view";
-
-bool IsWebIntentsEnabled(PrefService* prefs) {
- return false;
-}
-
-bool IsWebIntentsEnabledForProfile(Profile* profile) {
- return false;
-}
-
-Browser* GetBrowserForBackgroundWebIntentDelivery(Profile* profile) {
- return NULL;
-}
-
-} // namespace web_intents
diff --git a/chrome/browser/intents/web_intents_util_unittest.cc b/chrome/browser/intents/web_intents_util_unittest.cc
deleted file mode 100644
index 931204b..0000000
--- a/chrome/browser/intents/web_intents_util_unittest.cc
+++ /dev/null
@@ -1,95 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/intents/web_intents_util.h"
-
-#include <string>
-
-#include "base/utf_string_conversions.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-namespace web_intents {
-namespace {
-
-bool IsRecognized(const std::string& value) {
- return web_intents::IsRecognizedAction(ASCIIToUTF16(value));
-}
-
-ActionId ToAction(const std::string& value) {
- return web_intents::ToActionId(ASCIIToUTF16(value));
-}
-
-bool TypesMatch(const std::string& a, const std::string& b) {
- return MimeTypesMatch(ASCIIToUTF16(a), ASCIIToUTF16(b));
-}
-
-} // namespace
-
-TEST(WebIntentsUtilTest, IsRecognizedAction) {
- EXPECT_TRUE(IsRecognized(kActionEdit));
- EXPECT_FALSE(IsRecognized("http://webintents.org/eDit")); // case matters
- EXPECT_TRUE(IsRecognized(kActionPick));
- EXPECT_TRUE(IsRecognized(kActionSave));
- EXPECT_TRUE(IsRecognized(kActionShare));
- EXPECT_TRUE(IsRecognized(kActionSubscribe));
- EXPECT_TRUE(IsRecognized(kActionView));
-}
-
-TEST(WebIntentsUtilTest, IsRecognizedActionFailure) {
- EXPECT_FALSE(IsRecognized(std::string(kActionPick) + "lezooka"));
- EXPECT_FALSE(IsRecognized("Chrome LAX"));
- EXPECT_FALSE(IsRecognized("_zoom "));
- EXPECT_FALSE(IsRecognized(" "));
- EXPECT_FALSE(IsRecognized(""));
-}
-
-TEST(WebIntentsUtilTest, ToActionId) {
- EXPECT_EQ(ACTION_ID_EDIT, ToAction(kActionEdit));
- EXPECT_EQ(ACTION_ID_PICK, ToAction(kActionPick));
- EXPECT_EQ(ACTION_ID_SAVE, ToAction(kActionSave));
- EXPECT_EQ(ACTION_ID_SHARE, ToAction(kActionShare));
- EXPECT_EQ(ACTION_ID_SUBSCRIBE, ToAction(kActionSubscribe));
- EXPECT_EQ(ACTION_ID_VIEW, ToAction(kActionView));
-}
-
-TEST(WebIntentsUtilTest, MimeTypesMatchLiteral) {
- EXPECT_TRUE(TypesMatch("image/png", "image/png"));
-
- EXPECT_FALSE(TypesMatch(" image/png", "image/png"));
- EXPECT_FALSE(TypesMatch("image/png", " image/png"));
- EXPECT_FALSE(TypesMatch("image/png ", "image/png"));
- EXPECT_FALSE(TypesMatch("image/png", "image/png "));
- EXPECT_FALSE(TypesMatch("image/jpg", "image/png"));
- EXPECT_FALSE(TypesMatch("image/png", "image/jpg"));
-}
-
-TEST(WebIntentsUtilTest, MimeTypesMatchWildCards) {
- EXPECT_TRUE(TypesMatch("*", "*"));
- EXPECT_TRUE(TypesMatch("*", "*/*"));
- EXPECT_TRUE(TypesMatch("*/*", "*"));
- EXPECT_TRUE(TypesMatch("*/*", "*/*"));
- EXPECT_TRUE(TypesMatch("*", "image/png"));
- EXPECT_TRUE(TypesMatch("image/png", "*"));
- EXPECT_TRUE(TypesMatch("*/*", "image/png"));
- EXPECT_TRUE(TypesMatch("image/png", "*/*"));
-
- EXPECT_FALSE(TypesMatch(" */*", "image/png"));
- EXPECT_FALSE(TypesMatch("*/* ", "image/png"));
- EXPECT_FALSE(TypesMatch("**", "image/png"));
-}
-
-TEST(WebIntentsUtilTest, MimeTypesMatchParameters) {
- EXPECT_TRUE(TypesMatch("*", "video/*;single=true"));
- EXPECT_TRUE(TypesMatch("*/*", "video/mpg;single=true"));
- EXPECT_TRUE(TypesMatch("video/*", "video/mpg;single=true"));
- EXPECT_TRUE(TypesMatch("video/mpg", "video/mpg;single=true"));
- EXPECT_TRUE(TypesMatch("video/mpg;single=true", "video/mpg;single=true"));
- EXPECT_TRUE(TypesMatch("video/mpg;a=b;single=true",
- "video/mpg;single=true;a=b"));
- EXPECT_FALSE(TypesMatch("video/mpg;a=b;single=true",
- "video/mpg;single=false;a=b"));
- EXPECT_FALSE(TypesMatch("video/mpg;single=true", "video/mpg;single=false"));
-}
-
-} // namepsace web_intents
diff --git a/chrome/browser/prefs/browser_prefs.cc b/chrome/browser/prefs/browser_prefs.cc
index 8c5be3a4..e1722f0 100644
--- a/chrome/browser/prefs/browser_prefs.cc
+++ b/chrome/browser/prefs/browser_prefs.cc
@@ -28,7 +28,6 @@
#include "chrome/browser/geolocation/geolocation_prefs.h"
#include "chrome/browser/google/google_url_tracker.h"
#include "chrome/browser/google/google_url_tracker_factory.h"
-#include "chrome/browser/intents/web_intents_util.h"
#include "chrome/browser/intranet_redirect_detector.h"
#include "chrome/browser/managed_mode/managed_mode.h"
#include "chrome/browser/managed_mode/managed_user_service.h"
@@ -290,10 +289,6 @@ void RegisterUserPrefs(PrefService* user_prefs,
DesktopNotificationService::RegisterUserPrefs(registry);
#endif
-#if defined(ENABLE_WEB_INTENTS)
- web_intents::RegisterUserPrefs(registry);
-#endif
-
#if defined(TOOLKIT_VIEWS)
RegisterInvertBubbleUserPrefs(registry);
#elif defined(TOOLKIT_GTK)
diff --git a/chrome/browser/profiles/profile_dependency_manager.cc b/chrome/browser/profiles/profile_dependency_manager.cc
index 1ada8d0..85ec0f4c4 100644
--- a/chrome/browser/profiles/profile_dependency_manager.cc
+++ b/chrome/browser/profiles/profile_dependency_manager.cc
@@ -44,13 +44,11 @@
#include "chrome/browser/extensions/extension_system_factory.h"
#include "chrome/browser/extensions/manifest_url_parser.h"
#include "chrome/browser/extensions/web_accessible_resources_parser.h"
-#include "chrome/browser/extensions/web_intents_parser.h"
#include "chrome/browser/favicon/favicon_service_factory.h"
#include "chrome/browser/geolocation/chrome_geolocation_permission_context_factory.h"
#include "chrome/browser/google/google_url_tracker_factory.h"
#include "chrome/browser/history/history_service_factory.h"
#include "chrome/browser/history/shortcuts_backend_factory.h"
-#include "chrome/browser/intents/web_intents_registry_factory.h"
#include "chrome/browser/media_gallery/media_galleries_preferences_factory.h"
#include "chrome/browser/notifications/desktop_notification_service_factory.h"
#include "chrome/browser/password_manager/password_store_factory.h"
@@ -296,9 +294,6 @@ void ProfileDependencyManager::AssertFactoriesBuilt() {
extensions::TabsWindowsAPI::GetFactoryInstance();
extensions::TtsAPI::GetFactoryInstance();
extensions::WebAccessibleResourcesParser::GetFactoryInstance();
-#if defined(ENABLE_WEB_INTENTS)
- extensions::WebIntentsParser::GetFactoryInstance();
-#endif
extensions::WebNavigationAPI::GetFactoryInstance();
#endif
FaviconServiceFactory::GetInstance();
@@ -353,9 +348,6 @@ void ProfileDependencyManager::AssertFactoriesBuilt() {
TokenServiceFactory::GetInstance();
UserStyleSheetWatcherFactory::GetInstance();
WebDataServiceFactory::GetInstance();
-#if defined(ENABLE_WEB_INTENTS)
- WebIntentsRegistryFactory::GetInstance();
-#endif
built_factories_ = true;
}
diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc
index a117a38..1572543 100644
--- a/chrome/browser/ui/browser.cc
+++ b/chrome/browser/ui/browser.cc
@@ -58,9 +58,6 @@
#include "chrome/browser/file_select_helper.h"
#include "chrome/browser/first_run/first_run.h"
#include "chrome/browser/google/google_url_tracker.h"
-#include "chrome/browser/intents/register_intent_handler_infobar_delegate.h"
-#include "chrome/browser/intents/web_intents_reporting.h"
-#include "chrome/browser/intents/web_intents_util.h"
#include "chrome/browser/lifetime/application_lifetime.h"
#include "chrome/browser/net/url_fixer_upper.h"
#include "chrome/browser/notifications/notification_ui_manager.h"
@@ -116,7 +113,6 @@
#include "chrome/browser/ui/global_error/global_error.h"
#include "chrome/browser/ui/global_error/global_error_service.h"
#include "chrome/browser/ui/global_error/global_error_service_factory.h"
-#include "chrome/browser/ui/intents/web_intent_picker_controller.h"
#include "chrome/browser/ui/media_stream_infobar_delegate.h"
#include "chrome/browser/ui/omnibox/location_bar.h"
#include "chrome/browser/ui/screen_capture_infobar_delegate.h"
@@ -171,7 +167,6 @@
#include "content/public/browser/user_metrics.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_view.h"
-#include "content/public/browser/web_intents_dispatcher.h"
#include "content/public/common/content_restriction.h"
#include "content/public/common/content_switches.h"
#include "content/public/common/page_zoom.h"
@@ -189,8 +184,6 @@
#include "ui/base/window_open_disposition.h"
#include "ui/gfx/point.h"
#include "ui/shell_dialogs/selected_file_info.h"
-#include "webkit/glue/web_intent_data.h"
-#include "webkit/glue/web_intent_service_data.h"
#include "webkit/glue/webkit_glue.h"
#include "webkit/plugins/webplugininfo.h"
@@ -1596,72 +1589,6 @@ void Browser::RegisterProtocolHandler(WebContents* web_contents,
web_contents, protocol, url, title, user_gesture, window());
}
-#if defined(ENABLE_WEB_INTENTS)
-void Browser::RegisterIntentHandler(
- WebContents* web_contents,
- const webkit_glue::WebIntentServiceData& data,
- bool user_gesture) {
- RegisterIntentHandlerInfoBarDelegate::Create(web_contents, data);
-}
-
-void Browser::WebIntentDispatch(
- WebContents* web_contents,
- content::WebIntentsDispatcher* intents_dispatcher) {
- if (!web_intents::IsWebIntentsEnabledForProfile(profile_)) {
- web_intents::RecordIntentsDispatchDisabled();
- delete intents_dispatcher;
- return;
- }
-
- // Make sure the requester is coming from an extension/app page.
- // Internal dispatches set |web_contents| to NULL.
-#if !defined(OS_CHROMEOS)
- if (web_contents &&
- !CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kWebIntentsInvocationEnabled)) {
- ExtensionService* extensions_service =
- extensions::ExtensionSystem::Get(profile_)->extension_service();
- if (!extensions_service ||
- extensions_service->extensions()->GetExtensionOrAppByURL(
- ExtensionURLInfo(web_contents->GetURL())) == NULL) {
- web_intents::RecordIntentsDispatchDisabled();
- intents_dispatcher->SendReply(webkit_glue::WebIntentReply(
- webkit_glue::WEB_INTENT_REPLY_FAILURE,
- ASCIIToUTF16("Intents may only be invoked from extensions/apps.")));
- return;
- }
- }
-#else
- // ChromeOS currently uses a couple specific intent actions.
- // TODO(gbillock): delete this when we find good alternatives for those uses.
- if (intents_dispatcher->GetIntent().action !=
- ASCIIToUTF16(web_intents::kActionCrosEcho) &&
- intents_dispatcher->GetIntent().action !=
- ASCIIToUTF16(web_intents::kActionView)) {
- web_intents::RecordIntentsDispatchDisabled();
- intents_dispatcher->SendReply(webkit_glue::WebIntentReply(
- webkit_glue::WEB_INTENT_REPLY_FAILURE,
- ASCIIToUTF16("Intents may only be invoked from extensions/apps.")));
- return;
- }
-#endif
-
- web_intents::RecordIntentDispatchRequested();
-
- if (!web_contents) {
- // Intent is system-caused and the picker will show over the currently
- // active web contents.
- web_contents = tab_strip_model_->GetActiveWebContents();
- }
- WebIntentPickerController* web_intent_picker_controller =
- WebIntentPickerController::FromWebContents(web_contents);
- web_intent_picker_controller->SetIntentsDispatcher(intents_dispatcher);
- web_intent_picker_controller->ShowDialog(
- intents_dispatcher->GetIntent().action,
- intents_dispatcher->GetIntent().type);
-}
-#endif
-
void Browser::UpdatePreferredSize(WebContents* source,
const gfx::Size& pref_size) {
window_->UpdatePreferredSize(source, pref_size);
diff --git a/chrome/browser/ui/browser.h b/chrome/browser/ui/browser.h
index 69c602b..416921b 100644
--- a/chrome/browser/ui/browser.h
+++ b/chrome/browser/ui/browser.h
@@ -92,10 +92,6 @@ struct SelectedFileInfo;
class WebDialogDelegate;
}
-namespace webkit_glue {
-struct WebIntentServiceData;
-}
-
class Browser : public TabStripModelObserver,
public content::WebContentsDelegate,
public CoreTabHelperDelegate,
@@ -616,15 +612,6 @@ class Browser : public TabStripModelObserver,
const GURL& url,
const string16& title,
bool user_gesture) OVERRIDE;
-#if defined(ENABLE_WEB_INTENTS)
- virtual void RegisterIntentHandler(
- content::WebContents* web_contents,
- const webkit_glue::WebIntentServiceData& data,
- bool user_gesture) OVERRIDE;
- virtual void WebIntentDispatch(
- content::WebContents* web_contents,
- content::WebIntentsDispatcher* intents_dispatcher) OVERRIDE;
-#endif
virtual void UpdatePreferredSize(content::WebContents* source,
const gfx::Size& pref_size) OVERRIDE;
virtual void ResizeDueToAutoResize(content::WebContents* source,
diff --git a/chrome/browser/ui/browser_commands.cc b/chrome/browser/ui/browser_commands.cc
index 21b9648..492d8c3 100644
--- a/chrome/browser/ui/browser_commands.cc
+++ b/chrome/browser/ui/browser_commands.cc
@@ -65,14 +65,12 @@
#include "content/public/browser/user_metrics.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_view.h"
-#include "content/public/browser/web_intents_dispatcher.h"
#include "content/public/common/content_client.h"
#include "content/public/common/content_restriction.h"
#include "content/public/common/renderer_preferences.h"
#include "content/public/common/url_constants.h"
#include "net/base/escape.h"
#include "webkit/glue/glue_serialize.h"
-#include "webkit/glue/web_intent_data.h"
#include "webkit/user_agent/user_agent_util.h"
#if defined(OS_MACOSX)
diff --git a/chrome/browser/ui/browser_tab_contents.cc b/chrome/browser/ui/browser_tab_contents.cc
index 23a9a66..2d08b1b 100644
--- a/chrome/browser/ui/browser_tab_contents.cc
+++ b/chrome/browser/ui/browser_tab_contents.cc
@@ -36,7 +36,6 @@
#include "chrome/browser/ui/bookmarks/bookmark_tab_helper.h"
#include "chrome/browser/ui/find_bar/find_tab_helper.h"
#include "chrome/browser/ui/hung_plugin_tab_helper.h"
-#include "chrome/browser/ui/intents/web_intent_picker_controller.h"
#include "chrome/browser/ui/pdf/pdf_tab_helper.h"
#include "chrome/browser/ui/prefs/prefs_tab_helper.h"
#include "chrome/browser/ui/sad_tab_helper.h"
@@ -153,9 +152,6 @@ void BrowserTabContents::AttachTabHelpers(WebContents* web_contents) {
ThreeDAPIObserver::CreateForWebContents(web_contents);
ThumbnailTabHelper::CreateForWebContents(web_contents);
TranslateTabHelper::CreateForWebContents(web_contents);
-#if defined(ENABLE_WEB_INTENTS)
- WebIntentPickerController::CreateForWebContents(web_contents);
-#endif
ZoomController::CreateForWebContents(web_contents);
#if defined(ENABLE_AUTOMATION)
diff --git a/chrome/browser/ui/cocoa/content_settings/content_setting_bubble_cocoa.mm b/chrome/browser/ui/cocoa/content_settings/content_setting_bubble_cocoa.mm
index d4ad48c..5e856a1 100644
--- a/chrome/browser/ui/cocoa/content_settings/content_setting_bubble_cocoa.mm
+++ b/chrome/browser/ui/cocoa/content_settings/content_setting_bubble_cocoa.mm
@@ -140,7 +140,6 @@ NSTextField* LabelWithFrame(NSString* text, const NSRect& frame) {
// These content types have no bubble:
case CONTENT_SETTINGS_TYPE_DEFAULT:
case CONTENT_SETTINGS_TYPE_NOTIFICATIONS:
- case CONTENT_SETTINGS_TYPE_INTENTS:
case CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE:
case CONTENT_SETTINGS_TYPE_FULLSCREEN:
case CONTENT_SETTINGS_TYPE_MOUSELOCK:
diff --git a/chrome/browser/ui/cocoa/content_settings/content_setting_bubble_cocoa_unittest.mm b/chrome/browser/ui/cocoa/content_settings/content_setting_bubble_cocoa_unittest.mm
index d95395b..4213c57 100644
--- a/chrome/browser/ui/cocoa/content_settings/content_setting_bubble_cocoa_unittest.mm
+++ b/chrome/browser/ui/cocoa/content_settings/content_setting_bubble_cocoa_unittest.mm
@@ -58,7 +58,6 @@ ContentSettingBubbleControllerTest::~ContentSettingBubbleControllerTest() {
TEST_F(ContentSettingBubbleControllerTest, Init) {
for (int i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) {
if (i == CONTENT_SETTINGS_TYPE_NOTIFICATIONS ||
- i == CONTENT_SETTINGS_TYPE_INTENTS ||
i == CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE ||
i == CONTENT_SETTINGS_TYPE_FULLSCREEN ||
i == CONTENT_SETTINGS_TYPE_MOUSELOCK ||
diff --git a/chrome/browser/ui/cocoa/intents/web_intent_picker_cocoa.mm b/chrome/browser/ui/cocoa/intents/web_intent_picker_cocoa.mm
deleted file mode 100644
index 1f048ec..0000000
--- a/chrome/browser/ui/cocoa/intents/web_intent_picker_cocoa.mm
+++ /dev/null
@@ -1,13 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/ui/intents/web_intent_picker.h"
-
-// static
-WebIntentPicker* WebIntentPicker::Create(content::WebContents* web_contents,
- WebIntentPickerDelegate* delegate,
- WebIntentPickerModel* model) {
- NOTIMPLEMENTED();
- return NULL;
-}
diff --git a/chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h b/chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h
index e445aad..2b2fe27 100644
--- a/chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h
+++ b/chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h
@@ -38,7 +38,6 @@ class SelectedKeywordDecoration;
class SeparatorDecoration;
class StarDecoration;
class ToolbarModel;
-class WebIntentsButtonDecoration;
class ZoomDecoration;
// A C++ bridge class that represents the location bar UI element to
@@ -70,9 +69,6 @@ class LocationBarViewMac : public LocationBar,
virtual void UpdateContentSettingsIcons() OVERRIDE;
virtual void UpdatePageActions() OVERRIDE;
virtual void InvalidatePageActions() OVERRIDE;
-#if defined(ENABLE_WEB_INTENTS)
- virtual void UpdateWebIntentsButton() OVERRIDE;
-#endif
virtual void UpdateOpenPDFInReaderPrompt() OVERRIDE;
virtual void SaveStateToContents(content::WebContents* contents) OVERRIDE;
virtual void Revert() OVERRIDE;
@@ -207,10 +203,6 @@ class LocationBarViewMac : public LocationBar,
// tab contents state.
bool RefreshContentSettingsDecorations();
- // Updates visibility of the web intents button decoration based on the
- // current tab contents state.
- void RefreshWebIntentsButtonDecoration();
-
void ShowFirstRunBubbleInternal();
// Checks if the bookmark star should be enabled or not.
@@ -280,12 +272,6 @@ class LocationBarViewMac : public LocationBar,
// Keyword hint decoration displayed on the right-hand side.
scoped_ptr<KeywordHintDecoration> keyword_hint_decoration_;
-#if defined(ENABLE_WEB_INTENTS)
- // A decoration that shows the web intents "use another service" button
- // on the right.
- scoped_ptr<WebIntentsButtonDecoration> web_intents_button_decoration_;
-#endif
-
Profile* profile_;
Browser* browser_;
diff --git a/chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.mm b/chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.mm
index 61d5895..77b7b2b 100644
--- a/chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.mm
+++ b/chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.mm
@@ -44,12 +44,10 @@
#import "chrome/browser/ui/cocoa/location_bar/selected_keyword_decoration.h"
#import "chrome/browser/ui/cocoa/location_bar/separator_decoration.h"
#import "chrome/browser/ui/cocoa/location_bar/star_decoration.h"
-#import "chrome/browser/ui/cocoa/location_bar/web_intents_button_decoration.h"
#import "chrome/browser/ui/cocoa/location_bar/zoom_decoration.h"
#import "chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.h"
#include "chrome/browser/ui/content_settings/content_setting_bubble_model.h"
#include "chrome/browser/ui/content_settings/content_setting_image_model.h"
-#include "chrome/browser/ui/intents/web_intent_picker_controller.h"
#include "chrome/browser/ui/omnibox/alternate_nav_url_fetcher.h"
#include "chrome/browser/ui/omnibox/location_bar_util.h"
#import "chrome/browser/ui/omnibox/omnibox_popup_model.h"
@@ -108,10 +106,6 @@ LocationBarViewMac::LocationBarViewMac(
zoom_decoration_(new ZoomDecoration(toolbar_model)),
keyword_hint_decoration_(
new KeywordHintDecoration(OmniboxViewMac::GetFieldFont())),
-#if defined(ENABLE_WEB_INTENTS)
- web_intents_button_decoration_(
- new WebIntentsButtonDecoration(this, OmniboxViewMac::GetFieldFont())),
-#endif
profile_(profile),
browser_(browser),
toolbar_model_(toolbar_model),
@@ -130,14 +124,6 @@ LocationBarViewMac::LocationBarViewMac(
new ContentSettingDecoration(type, this, profile_));
}
-#if defined(ENABLE_WEB_INTENTS)
- ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
- web_intents_button_decoration_->SetButtonImages(
- rb.GetNativeImageNamed(IDR_OMNIBOX_WI_BUBBLE_BACKGROUND_L).ToNSImage(),
- rb.GetNativeImageNamed(IDR_OMNIBOX_WI_BUBBLE_BACKGROUND_C).ToNSImage(),
- rb.GetNativeImageNamed(IDR_OMNIBOX_WI_BUBBLE_BACKGROUND_R).ToNSImage());
-#endif
-
registrar_.Add(this,
chrome::NOTIFICATION_EXTENSION_PAGE_ACTION_VISIBILITY_CHANGED,
content::NotificationService::AllSources());
@@ -246,12 +232,6 @@ void LocationBarViewMac::InvalidatePageActions() {
}
}
-#if defined(ENABLE_WEB_INTENTS)
-void LocationBarViewMac::UpdateWebIntentsButton() {
- RefreshWebIntentsButtonDecoration();
-}
-#endif
-
void LocationBarViewMac::UpdateOpenPDFInReaderPrompt() {
// Not implemented on Mac.
}
@@ -269,7 +249,6 @@ void LocationBarViewMac::Update(const WebContents* contents,
UpdateZoomDecoration();
RefreshPageActionDecorations();
RefreshContentSettingsDecorations();
- RefreshWebIntentsButtonDecoration();
// OmniboxView restores state if the tab is non-NULL.
omnibox_view_->Update(should_restore_state ? contents : NULL);
OnChanged();
@@ -672,18 +651,6 @@ void LocationBarViewMac::RefreshPageActionDecorations() {
}
}
-void LocationBarViewMac::RefreshWebIntentsButtonDecoration() {
-#if defined(ENABLE_WEB_INTENTS)
- WebContents* web_contents = GetWebContents();
- if (!web_contents) {
- web_intents_button_decoration_->SetVisible(false);
- return;
- }
-
- web_intents_button_decoration_->Update(web_contents);
-#endif
-}
-
// TODO(shess): This function should over time grow to closely match
// the views Layout() function.
void LocationBarViewMac::Layout() {
@@ -713,10 +680,6 @@ void LocationBarViewMac::Layout() {
[cell addRightDecoration:keyword_hint_decoration_.get()];
-#if defined(ENABLE_WEB_INTENTS)
- [cell addRightDecoration:web_intents_button_decoration_.get()];
-#endif
-
[cell addRightDecoration:separator_decoration_.get()];
[cell addRightDecoration:search_token_decoration_.get()];
diff --git a/chrome/browser/ui/cocoa/location_bar/web_intents_button_decoration.h b/chrome/browser/ui/cocoa/location_bar/web_intents_button_decoration.h
deleted file mode 100644
index 437e41b..0000000
--- a/chrome/browser/ui/cocoa/location_bar/web_intents_button_decoration.h
+++ /dev/null
@@ -1,65 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_UI_COCOA_LOCATION_BAR_WEB_INTENTS_BUTTON_DECORATION_H_
-#define CHROME_BROWSER_UI_COCOA_LOCATION_BAR_WEB_INTENTS_BUTTON_DECORATION_H_
-
-#include <string>
-
-#import <Cocoa/Cocoa.h>
-
-#include "base/memory/scoped_nsobject.h"
-#include "base/string16.h"
-#include "chrome/browser/ui/cocoa/location_bar/bubble_decoration.h"
-
-class LocationBarViewMac;
-@class WebIntentsButtonAnimationState;
-
-namespace content {
-class WebContents;
-}
-
-class WebIntentsButtonDecoration : public BubbleDecoration {
- public:
- WebIntentsButtonDecoration(LocationBarViewMac* owner, NSFont* font);
- virtual ~WebIntentsButtonDecoration();
-
- // Set the background images to be used for the button.
- void SetButtonImages(NSImage* left, NSImage* center, NSImage* right);
-
- // LocationBarDecoration
- virtual bool AcceptsMousePress() OVERRIDE;
- virtual bool OnMousePressed(NSRect frame) OVERRIDE;
- virtual CGFloat GetWidthForSpace(CGFloat width, CGFloat text_width) OVERRIDE;
- virtual void DrawInFrame(NSRect frame, NSView* control_view) OVERRIDE;
-
- // Optionally display the web intents button.
- void Update(content::WebContents* web_contents);
-
- // Called from internal animator.
- virtual void AnimationTimerFired();
-
- private:
- friend class WebIntentsButtonDecorationTest;
-
- // Returns an attributed string with the animated text.
- scoped_nsobject<NSAttributedString> CreateAnimatedText();
-
- // Measure the width of the animated text.
- CGFloat MeasureTextWidth();
-
- LocationBarViewMac* owner_; // weak
-
- // Used when the decoration has animated text.
- scoped_nsobject<WebIntentsButtonAnimationState> animation_;
- CGFloat text_width_;
- scoped_nsobject<NSAttributedString> animated_text_;
- scoped_nsobject<NSImage> left_image_;
- scoped_nsobject<NSImage> center_image_;
- scoped_nsobject<NSImage> right_image_;
-
- DISALLOW_COPY_AND_ASSIGN(WebIntentsButtonDecoration);
-};
-
-#endif // CHROME_BROWSER_UI_COCOA_LOCATION_BAR_WEB_INTENTS_BUTTON_DECORATION_H_
diff --git a/chrome/browser/ui/cocoa/location_bar/web_intents_button_decoration.mm b/chrome/browser/ui/cocoa/location_bar/web_intents_button_decoration.mm
deleted file mode 100644
index ff69696..0000000
--- a/chrome/browser/ui/cocoa/location_bar/web_intents_button_decoration.mm
+++ /dev/null
@@ -1,251 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#import "chrome/browser/ui/cocoa/location_bar/web_intents_button_decoration.h"
-
-#include "base/utf_string_conversions.h"
-#include "chrome/browser/ui/browser_tabstrip.h"
-#import "chrome/browser/ui/cocoa/last_active_browser_cocoa.h"
-#import "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h"
-#import "chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.h"
-#include "chrome/browser/ui/omnibox/location_bar_util.h"
-#include "chrome/browser/ui/intents/web_intent_picker_controller.h"
-#include "grit/generated_resources.h"
-#include "grit/theme_resources.h"
-#include "ui/base/l10n/l10n_util_mac.h"
-#include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h"
-
-namespace {
-
-// Duration of animation, 150 ms.
-const NSTimeInterval kAnimationDurationS = 0.15;
-
-// Interval of the animation timer, 60Hz.
-const NSTimeInterval kAnimationIntervalS = 1.0 / 60.0;
-
-const CGFloat kTextMarginPadding = 4;
-const CGFloat kIconMarginPadding = 2;
-const CGFloat kBorderPadding = 3;
-
-// During animation, the text opens to full width.
-enum AnimationState {
- kNoAnimation,
- kOpening,
- kOpen
-};
-
-} // namespace
-
-// An ObjC class that handles the multiple states of the text animation and
-// bridges NSTimer calls back to the WebIntentsButtonDecoration that owns it.
-// Should be lazily instantiated to only exist when the decoration requires
-// animation.
-// NOTE: One could make this class more generic, but this class only exists
-// because CoreAnimation cannot be used (there are no views to work with).
-@interface WebIntentsButtonAnimationState : NSObject {
- @private
- WebIntentsButtonDecoration* owner_; // Weak, owns this.
- double progress_; // Counter, [0..1], with animation progress.
- NSTimer* timer_; // Animation timer. Owned by the run loop.
-}
-
-// [0..1], the current progress of the animation. -animationState will return
-// |kNoAnimation| when progress is <= 0 or >= 1. Useful when state is
-// |kOpening| as a multiplier for displaying width. Don't use
-// to track state transitions, use -animationState instead.
-@property (readonly, nonatomic) double progress;
-
-// Designated initializer. |owner| must not be nil. Animation timer will start
-// as soon as the object is created.
-- (id)initWithOwner:(WebIntentsButtonDecoration*)owner;
-
-// Returns the current animation state based on how much time has elapsed.
-- (AnimationState)animationState;
-
-// Call when |owner| is going away or the animation needs to be stopped.
-// Ensures that any dangling references are cleared. Can be called multiple
-// times.
-- (void)stopAnimation;
-
-@end
-
-@implementation WebIntentsButtonAnimationState
-
-@synthesize progress = progress_;
-
-- (id)initWithOwner:(WebIntentsButtonDecoration*)owner {
- if ((self = [super init])) {
- owner_ = owner;
- timer_ = [NSTimer scheduledTimerWithTimeInterval:kAnimationIntervalS
- target:self
- selector:@selector(timerFired:)
- userInfo:nil
- repeats:YES];
- }
- return self;
-}
-
-- (void)dealloc {
- DCHECK(!timer_);
- [super dealloc];
-}
-
-// Clear weak references and stop the timer.
-- (void)stopAnimation {
- owner_ = nil;
- [timer_ invalidate];
- timer_ = nil;
-}
-
-// Returns the current state based on how much time has elapsed.
-- (AnimationState)animationState {
- if (progress_ <= 0.0)
- return kNoAnimation;
- if (progress_ <= 1.0)
- return kOpening;
- return kOpen;
-}
-
-- (void)timerFired:(NSTimer*)timer {
- // Increment animation progress, normalized to [0..1].
- // TODO(gbillock): Note this is brittle. Switch to ui/base/animation.
- progress_ += kAnimationIntervalS / kAnimationDurationS;
- progress_ = std::min(progress_, 1.0);
- owner_->AnimationTimerFired();
- // Stop timer if it has reached the end of its life.
- if (progress_ >= 1.0)
- [self stopAnimation];
-}
-
-@end
-
-WebIntentsButtonDecoration::WebIntentsButtonDecoration(
- LocationBarViewMac* owner, NSFont* font)
- : BubbleDecoration(font),
- owner_(owner),
- text_width_(0.0) {
- NSColor* border_color =
- [NSColor colorWithCalibratedRed:0.63 green:0.63 blue:0.63 alpha:1.0];
- NSColor* background_color =
- [NSColor colorWithCalibratedRed:0.90 green:0.90 blue:0.90 alpha:1.0];
- SetColors(border_color, background_color, [NSColor blackColor]);
-
- SetLabel(l10n_util::GetNSString(IDS_INTENT_PICKER_USE_ANOTHER_SERVICE));
-}
-
-WebIntentsButtonDecoration::~WebIntentsButtonDecoration() {}
-
-void WebIntentsButtonDecoration::SetButtonImages(NSImage* left,
- NSImage* center,
- NSImage* right) {
- left_image_.reset([left retain]);
- center_image_.reset([center retain]);
- right_image_.reset([right retain]);
-}
-
-bool WebIntentsButtonDecoration::AcceptsMousePress() {
- return true;
-}
-
-bool WebIntentsButtonDecoration::OnMousePressed(NSRect frame) {
- content::WebContents* web_contents = owner_->GetWebContents();
- if (!web_contents)
- return true;
-
- WebIntentPickerController::FromWebContents(web_contents)->
- LocationBarPickerButtonClicked();
- return true;
-}
-
-// Override to handle the case where there is text to display during the
-// animation. The width is based on the animator's progress.
-CGFloat WebIntentsButtonDecoration::GetWidthForSpace(CGFloat width,
- CGFloat text_width) {
- if (!animation_)
- return BubbleDecoration::GetWidthForSpace(width, text_width);
-
- AnimationState state = [animation_ animationState];
- CGFloat progress = [animation_ progress];
- // Set the margins, fixed for all animation states.
- CGFloat preferredWidth = 2 * kTextMarginPadding;
- // Add the width of the text based on the state of the animation.
- switch (state) {
- case kNoAnimation:
- return preferredWidth;
- case kOpening:
- return preferredWidth + (text_width_ * progress);
- case kOpen:
- return preferredWidth + text_width_;
- }
-}
-
-void WebIntentsButtonDecoration::DrawInFrame(NSRect frame,
- NSView* control_view) {
- if ([animation_ animationState] != kOpening) {
- BubbleDecoration::DrawInFrame(frame, control_view);
- return;
- }
-
- frame = NSInsetRect(frame, 0.0, kTextYInset);
- NSDrawThreePartImage(frame,
- left_image_.get(),
- center_image_.get(),
- right_image_.get(),
- NO, // NO=horizontal layout
- NSCompositeSourceOver,
- 1.0,
- YES); // use flipped coordinates
-
- // Draw the text, clipped to fit on the right. While handling clipping,
- // NSAttributedString's drawInRect: won't draw a word if it doesn't fit
- // in the bounding box so instead use drawAtPoint: with a manual clip
- // rect.
- gfx::ScopedNSGraphicsContextSaveGState scopedGState;
- NSRectClip(frame);
- NSRect remainder = NSInsetRect(frame, kTextMarginPadding, 0.0);
- // .get() needed to fix compiler warning (confusion with NSImageRep).
- [animated_text_.get() drawAtPoint:remainder.origin];
-}
-
-void WebIntentsButtonDecoration::Update(content::WebContents* web_contents) {
- WebIntentPickerController* intents_controller =
- WebIntentPickerController::FromWebContents(web_contents);
- SetVisible(intents_controller->ShowLocationBarPickerButton());
-
- if (IsVisible()) {
- if (!animation_ &&
- !intents_controller->location_bar_picker_button_indicated()) {
- intents_controller->SetLocationBarPickerButtonIndicated();
- animation_.reset(
- [[WebIntentsButtonAnimationState alloc] initWithOwner:this]);
- animated_text_ = CreateAnimatedText();
- text_width_ = MeasureTextWidth();
- }
- } else {
- [animation_ stopAnimation];
- animation_.reset();
- }
-}
-
-scoped_nsobject<NSAttributedString>
- WebIntentsButtonDecoration::CreateAnimatedText() {
- NSString* text =
- l10n_util::GetNSString(IDS_INTENT_PICKER_USE_ANOTHER_SERVICE);
- return scoped_nsobject<NSAttributedString>(
- [[NSAttributedString alloc] initWithString:text attributes:attributes_]);
-}
-
-CGFloat WebIntentsButtonDecoration::MeasureTextWidth() {
- return [animated_text_ size].width;
-}
-
-void WebIntentsButtonDecoration::AnimationTimerFired() {
- if (owner_)
- owner_->Layout();
- // Even after the animation completes, the |animator_| object should be kept
- // alive to prevent the animation from re-appearing if the page opens
- // additional popups later. The animator will be cleared when the decoration
- // hides, indicating something has changed with the WebContents (probably
- // navigation).
-}
diff --git a/chrome/browser/ui/cocoa/location_bar/web_intents_button_decoration_unittest.mm b/chrome/browser/ui/cocoa/location_bar/web_intents_button_decoration_unittest.mm
deleted file mode 100644
index f4a9ba7..0000000
--- a/chrome/browser/ui/cocoa/location_bar/web_intents_button_decoration_unittest.mm
+++ /dev/null
@@ -1,58 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#import <Cocoa/Cocoa.h>
-
-#import "chrome/browser/ui/cocoa/location_bar/web_intents_button_decoration.h"
-
-#import "chrome/browser/ui/cocoa/cocoa_profile_test.h"
-#include "chrome/browser/ui/intents/web_intent_picker_controller.h"
-#include "content/public/browser/site_instance.h"
-#include "content/public/browser/web_intents_dispatcher.h"
-#include "testing/gtest/include/gtest/gtest.h"
-#include "webkit/glue/web_intent_data.h"
-#include "webkit/glue/web_intent_reply_data.h"
-
-class WebIntentsButtonDecorationTest : public CocoaProfileTest {
- public:
- WebIntentsButtonDecorationTest()
- : decoration_(NULL, [NSFont userFontOfSize:12]) {
- }
-
- void SetWindowDispositionSource(
- WebIntentPickerController* controller,
- content::WebContents* contents,
- content::WebIntentsDispatcher* dispatcher) {
- controller->SetWindowDispositionSource(contents, dispatcher);
- }
-
- WebIntentsButtonDecoration decoration_;
-};
-
-TEST_F(WebIntentsButtonDecorationTest, IdentifiesWebIntentService) {
- scoped_refptr<content::SiteInstance> instance =
- content::SiteInstance::Create(profile());
- content::WebContents::CreateParams create_params(profile(), instance.get());
- scoped_ptr<content::WebContents> contents(content::WebContents::Create(
- create_params));
- WebIntentPickerController::CreateForWebContents(contents.get());
-
- decoration_.Update(contents.get());
- EXPECT_FALSE(decoration_.IsVisible());
-
- webkit_glue::WebIntentData data;
- content::WebIntentsDispatcher* dispatcher =
- content::WebIntentsDispatcher::Create(data);
- WebIntentPickerController* web_intent_picker_controller =
- WebIntentPickerController::FromWebContents(contents.get());
- SetWindowDispositionSource(web_intent_picker_controller,
- contents.get(), dispatcher);
- web_intent_picker_controller->SetLocationBarPickerButtonIndicated();
-
- decoration_.Update(contents.get());
- EXPECT_TRUE(decoration_.IsVisible());
-
- dispatcher->SendReply(webkit_glue::WebIntentReply(
- webkit_glue::WEB_INTENT_REPLY_SUCCESS, string16()));
-}
diff --git a/chrome/browser/ui/extensions/shell_window.cc b/chrome/browser/ui/extensions/shell_window.cc
index cc6972f..e74ac30 100644
--- a/chrome/browser/ui/extensions/shell_window.cc
+++ b/chrome/browser/ui/extensions/shell_window.cc
@@ -15,7 +15,6 @@
#include "chrome/browser/extensions/tab_helper.h"
#include "chrome/browser/favicon/favicon_tab_helper.h"
#include "chrome/browser/file_select_helper.h"
-#include "chrome/browser/intents/web_intents_util.h"
#include "chrome/browser/lifetime/application_lifetime.h"
#include "chrome/browser/media/media_capture_devices_dispatcher.h"
#include "chrome/browser/profiles/profile.h"
@@ -25,7 +24,6 @@
#include "chrome/browser/ui/browser_tabstrip.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/extensions/native_app_window.h"
-#include "chrome/browser/ui/intents/web_intent_picker_controller.h"
#include "chrome/browser/ui/web_contents_modal_dialog_manager.h"
#include "chrome/browser/view_type_utils.h"
#include "chrome/common/chrome_notification_types.h"
@@ -46,7 +44,6 @@
#include "content/public/browser/resource_dispatcher_host.h"
#include "content/public/browser/site_instance.h"
#include "content/public/browser/web_contents.h"
-#include "content/public/browser/web_intents_dispatcher.h"
#include "content/public/common/media_stream_request.h"
#include "content/public/common/renderer_preferences.h"
#include "skia/ext/image_operations.h"
@@ -130,9 +127,6 @@ void ShellWindow::Init(const GURL& url,
profile(), SiteInstance::CreateForURL(profile(), url))));
WebContentsModalDialogManager::CreateForWebContents(web_contents_.get());
FaviconTabHelper::CreateForWebContents(web_contents_.get());
-#if defined(ENABLE_WEB_INTENTS)
- WebIntentPickerController::CreateForWebContents(web_contents_.get());
-#endif
content::WebContentsObserver::Observe(web_contents_.get());
web_contents_->SetDelegate(this);
@@ -499,22 +493,6 @@ bool ShellWindow::ShouldSuppressDialogs() {
return true;
}
-void ShellWindow::WebIntentDispatch(
- content::WebContents* web_contents,
- content::WebIntentsDispatcher* intents_dispatcher) {
-#if defined(ENABLE_WEB_INTENTS)
- if (!web_intents::IsWebIntentsEnabledForProfile(profile_))
- return;
-
- WebIntentPickerController* web_intent_picker_controller =
- WebIntentPickerController::FromWebContents(web_contents_.get());
- web_intent_picker_controller->SetIntentsDispatcher(intents_dispatcher);
- web_intent_picker_controller->ShowDialog(
- intents_dispatcher->GetIntent().action,
- intents_dispatcher->GetIntent().type);
-#endif
-}
-
void ShellWindow::RunFileChooser(WebContents* tab,
const content::FileChooserParams& params) {
FileSelectHelper::RunFileChooser(tab, params);
diff --git a/chrome/browser/ui/extensions/shell_window.h b/chrome/browser/ui/extensions/shell_window.h
index a996ed3..981c725 100644
--- a/chrome/browser/ui/extensions/shell_window.h
+++ b/chrome/browser/ui/extensions/shell_window.h
@@ -139,9 +139,6 @@ class ShellWindow : public content::NotificationObserver,
// content::WebContentsDelegate implementation.
virtual void CloseContents(content::WebContents* contents) OVERRIDE;
virtual bool ShouldSuppressDialogs() OVERRIDE;
- virtual void WebIntentDispatch(
- content::WebContents* web_contents,
- content::WebIntentsDispatcher* intents_dispatcher) OVERRIDE;
virtual void RunFileChooser(
content::WebContents* tab,
const content::FileChooserParams& params) OVERRIDE;
diff --git a/chrome/browser/ui/gtk/location_bar_view_gtk.cc b/chrome/browser/ui/gtk/location_bar_view_gtk.cc
index eb2d8643..f5019da 100644
--- a/chrome/browser/ui/gtk/location_bar_view_gtk.cc
+++ b/chrome/browser/ui/gtk/location_bar_view_gtk.cc
@@ -61,7 +61,6 @@
#include "chrome/browser/ui/gtk/script_bubble_gtk.h"
#include "chrome/browser/ui/gtk/view_id_util.h"
#include "chrome/browser/ui/gtk/zoom_bubble_gtk.h"
-#include "chrome/browser/ui/intents/web_intent_picker_controller.h"
#include "chrome/browser/ui/omnibox/alternate_nav_url_fetcher.h"
#include "chrome/browser/ui/omnibox/location_bar_util.h"
#include "chrome/browser/ui/omnibox/omnibox_edit_model.h"
@@ -148,11 +147,6 @@ const int kContentSettingImageDisplayTime = 3200;
// The time, in ms, of the animation (open and close).
const int kContentSettingImageAnimationTime = 150;
-#if defined(ENABLE_WEB_INTENTS)
-// Animation opening time for web intents button (in ms).
-const int kWebIntentsButtonAnimationTime = 150;
-#endif
-
// Color of border of content setting area (icon/label).
const GdkColor kContentSettingBorderColor = GDK_COLOR_RGB(0xe9, 0xb9, 0x66);
// Colors for the background gradient.
@@ -319,70 +313,6 @@ void ContentSettingImageViewGtk::BubbleClosing(
content_setting_bubble_ = NULL;
}
-#if defined(ENABLE_WEB_INTENTS)
-class WebIntentsButtonViewGtk : public LocationBarViewGtk::PageToolViewGtk {
- public:
- explicit WebIntentsButtonViewGtk(const LocationBarViewGtk* parent)
- : LocationBarViewGtk::PageToolViewGtk(parent) {
- animation_.SetSlideDuration(kWebIntentsButtonAnimationTime);
- }
- virtual ~WebIntentsButtonViewGtk() {}
-
- // PageToolViewGtk
- virtual void Update(WebContents* web_contents) OVERRIDE;
-
- private:
- // PageToolViewGtk
- virtual GdkColor button_border_color() const OVERRIDE;
- virtual GdkColor gradient_top_color() const OVERRIDE;
- virtual GdkColor gradient_bottom_color() const OVERRIDE;
- virtual void OnClick(GtkWidget* sender) OVERRIDE;
-
- DISALLOW_COPY_AND_ASSIGN(WebIntentsButtonViewGtk);
-};
-
-void WebIntentsButtonViewGtk::Update(WebContents* web_contents) {
- WebIntentPickerController* web_intent_picker_controller =
- web_contents ? WebIntentPickerController::FromWebContents(web_contents)
- : NULL;
- if (!web_intent_picker_controller ||
- !web_intent_picker_controller->ShowLocationBarPickerButton()) {
- gtk_widget_hide(widget());
- return;
- }
-
- gtk_widget_set_tooltip_text(widget(),
- l10n_util::GetStringUTF8(IDS_INTENT_PICKER_USE_ANOTHER_SERVICE).c_str());
- gtk_widget_show_all(widget());
-
- gtk_label_set_text(GTK_LABEL(label_.get()),
- l10n_util::GetStringUTF8(IDS_INTENT_PICKER_USE_ANOTHER_SERVICE).c_str());
-
- StartAnimating();
-}
-
-void WebIntentsButtonViewGtk::OnClick(GtkWidget* sender) {
- WebContents* web_contents = parent_->GetWebContents();
- if (!web_contents)
- return;
-
- WebIntentPickerController::FromWebContents(web_contents)->
- LocationBarPickerButtonClicked();
-}
-
-GdkColor WebIntentsButtonViewGtk::button_border_color() const {
- return kGrayBorderColor;
-}
-
-GdkColor WebIntentsButtonViewGtk::gradient_top_color() const {
- return kTopColorGray;
-}
-
-GdkColor WebIntentsButtonViewGtk::gradient_bottom_color() const {
- return kBottomColorGray;
-}
-#endif
-
} // namespace
////////////////////////////////////////////////////////////////////////////////
@@ -405,9 +335,6 @@ LocationBarViewGtk::LocationBarViewGtk(Browser* browser)
drag_icon_(NULL),
enable_location_drag_(false),
security_info_label_(NULL),
-#if defined(ENABLE_WEB_INTENTS)
- web_intents_button_view_(new WebIntentsButtonViewGtk(this)),
-#endif
tab_to_search_alignment_(NULL),
tab_to_search_box_(NULL),
tab_to_search_full_label_(NULL),
@@ -440,9 +367,6 @@ LocationBarViewGtk::~LocationBarViewGtk() {
hbox_.Destroy();
content_setting_hbox_.Destroy();
page_action_hbox_.Destroy();
-#if defined(ENABLE_WEB_INTENTS)
- web_intents_hbox_.Destroy();
-#endif
}
void LocationBarViewGtk::Init(bool popup_window_mode) {
@@ -607,16 +531,6 @@ void LocationBarViewGtk::Init(bool popup_window_mode) {
gtk_box_pack_end(GTK_BOX(hbox_.get()), page_action_hbox_.get(),
FALSE, FALSE, 0);
-#if defined(ENABLE_WEB_INTENTS)
- web_intents_hbox_.Own(gtk_hbox_new(FALSE, InnerPadding()));
- gtk_widget_set_name(web_intents_hbox_.get(),
- "chrome-web-intents-hbox");
- gtk_box_pack_end(GTK_BOX(hbox_.get()), web_intents_hbox_.get(),
- FALSE, FALSE, 0);
- gtk_box_pack_end(GTK_BOX(web_intents_hbox_.get()),
- web_intents_button_view_->widget(), FALSE, FALSE, 0);
-#endif
-
// Now that we've created the widget hierarchy, connect to the main |hbox_|'s
// size-allocate so we can do proper resizing and eliding on
// |security_info_label_|.
@@ -750,9 +664,6 @@ void LocationBarViewGtk::Update(const WebContents* contents) {
UpdateSiteTypeArea();
UpdateContentSettingsIcons();
UpdatePageActions();
-#if defined(ENABLE_WEB_INTENTS)
- UpdateWebIntentsButton();
-#endif
location_entry_->Update(contents);
// The security level (background color) could have changed, etc.
if (theme_service_->UsingNativeTheme()) {
@@ -1044,14 +955,6 @@ void LocationBarViewGtk::InvalidatePageActions() {
}
}
-#if defined(ENABLE_WEB_INTENTS)
-void LocationBarViewGtk::UpdateWebIntentsButton() {
- web_intents_button_view_->Update(GetWebContents());
- gtk_widget_set_visible(web_intents_hbox_.get(),
- web_intents_button_view_->IsVisible());
-}
-#endif
-
void LocationBarViewGtk::UpdateOpenPDFInReaderPrompt() {
// Not implemented on Gtk.
}
@@ -1193,9 +1096,6 @@ void LocationBarViewGtk::Observe(int type,
UpdateStarIcon();
UpdateSiteTypeArea();
UpdateContentSettingsIcons();
-#if defined(ENABLE_WEB_INTENTS)
- UpdateWebIntentsButton();
-#endif
break;
}
diff --git a/chrome/browser/ui/gtk/location_bar_view_gtk.h b/chrome/browser/ui/gtk/location_bar_view_gtk.h
index 6c11375..28ab32e 100644
--- a/chrome/browser/ui/gtk/location_bar_view_gtk.h
+++ b/chrome/browser/ui/gtk/location_bar_view_gtk.h
@@ -140,9 +140,6 @@ class LocationBarViewGtk : public OmniboxEditController,
virtual void UpdateContentSettingsIcons() OVERRIDE;
virtual void UpdatePageActions() OVERRIDE;
virtual void InvalidatePageActions() OVERRIDE;
-#if defined(ENABLE_WEB_INTENTS)
- virtual void UpdateWebIntentsButton() OVERRIDE;
-#endif
virtual void UpdateOpenPDFInReaderPrompt() OVERRIDE;
virtual void SaveStateToContents(content::WebContents* contents) OVERRIDE;
virtual void Revert() OVERRIDE;
@@ -469,12 +466,6 @@ class LocationBarViewGtk : public OmniboxEditController,
ui::OwnedWidgetGtk page_action_hbox_;
ScopedVector<PageActionViewGtk> page_action_views_;
-#if defined(ENABLE_WEB_INTENTS)
- // Control for web intents window disposition picker control.
- ui::OwnedWidgetGtk web_intents_hbox_;
- scoped_ptr<PageToolViewGtk> web_intents_button_view_;
-#endif
-
// The widget that contains our tab hints and the location bar.
GtkWidget* entry_box_;
diff --git a/chrome/browser/ui/gtk/web_intent_picker_gtk.cc b/chrome/browser/ui/gtk/web_intent_picker_gtk.cc
deleted file mode 100644
index 4b1c5f3..0000000
--- a/chrome/browser/ui/gtk/web_intent_picker_gtk.cc
+++ /dev/null
@@ -1,880 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/ui/gtk/web_intent_picker_gtk.h"
-
-#include <algorithm>
-
-#include "base/i18n/rtl.h"
-#include "base/utf_string_conversions.h"
-#include "chrome/browser/favicon/favicon_service.h"
-#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/tab_contents/tab_util.h"
-#include "chrome/browser/ui/browser_finder.h"
-#include "chrome/browser/ui/browser_window.h"
-#include "chrome/browser/ui/gtk/browser_toolbar_gtk.h"
-#include "chrome/browser/ui/gtk/browser_window_gtk.h"
-#include "chrome/browser/ui/gtk/custom_button.h"
-#include "chrome/browser/ui/gtk/event_utils.h"
-#include "chrome/browser/ui/gtk/gtk_chrome_link_button.h"
-#include "chrome/browser/ui/gtk/gtk_theme_service.h"
-#include "chrome/browser/ui/gtk/gtk_util.h"
-#include "chrome/browser/ui/gtk/location_bar_view_gtk.h"
-#include "chrome/browser/ui/gtk/throbber_gtk.h"
-#include "chrome/browser/ui/intents/web_intent_picker_controller.h"
-#include "chrome/browser/ui/intents/web_intent_picker_delegate.h"
-#include "chrome/browser/ui/intents/web_intent_picker_model.h"
-#include "chrome/common/chrome_notification_types.h"
-#include "content/public/browser/notification_source.h"
-#include "content/public/browser/notification_types.h"
-#include "content/public/browser/render_view_host.h"
-#include "content/public/browser/render_widget_host_view.h"
-#include "content/public/browser/web_contents.h"
-#include "content/public/browser/web_contents_view.h"
-#include "googleurl/src/gurl.h"
-#include "grit/chromium_strings.h"
-#include "grit/generated_resources.h"
-#include "grit/google_chrome_strings.h"
-#include "grit/theme_resources.h"
-#include "ui/base/gtk/gtk_hig_constants.h"
-#include "ui/base/gtk/gtk_signal_registrar.h"
-#include "ui/base/l10n/l10n_util.h"
-#include "ui/base/resource/resource_bundle.h"
-#include "ui/base/text/text_elider.h"
-#include "ui/gfx/gtk_util.h"
-#include "ui/gfx/image/image.h"
-
-using content::WebContents;
-
-namespace {
-
-// The pixel size of the header label when using a non-native theme.
-const int kHeaderLabelPixelSize = 15;
-
-// The pixel size of the font of the main content of the dialog.
-const int kMainContentPixelSize = 13;
-
-// Indices of the extension row widgets.
-enum {
- kIconIndex,
- kTitleLinkIndex,
- kStarsIndex,
- kInstallButtonIndex,
-};
-
-GtkThemeService *GetThemeService(WebContents* web_contents) {
- Profile* profile =
- Profile::FromBrowserContext(web_contents->GetBrowserContext());
- return GtkThemeService::GetFrom(profile);
-}
-
-// Set the image of |button| to |pixbuf|.
-void SetServiceButtonImage(GtkWidget* button, GdkPixbuf* pixbuf) {
- gtk_button_set_image(GTK_BUTTON(button), gtk_image_new_from_pixbuf(pixbuf));
- gtk_button_set_image_position(GTK_BUTTON(button), GTK_POS_LEFT);
-}
-
-void SetWidgetFontSizeCallback(GtkWidget* widget, gpointer data) {
- if (GTK_IS_LABEL(widget)) {
- int* size = static_cast<int*>(data);
- gtk_util::ForceFontSizePixels(widget, *size);
- return;
- }
-
- if (GTK_IS_CONTAINER(widget))
- gtk_container_forall(GTK_CONTAINER(widget), SetWidgetFontSizeCallback,
- data);
-}
-
-void SetWidgetFontSize(GtkWidget* widget, int size) {
- gtk_container_forall(GTK_CONTAINER(widget), SetWidgetFontSizeCallback, &size);
-}
-
-// Get the index of the row containing |widget|. Assume the widget is the child
-// of an hbox, which is a child of a vbox. The hbox represents a row, and the
-// vbox the full table.
-size_t GetExtensionWidgetRow(GtkWidget* widget) {
- GtkWidget* hbox = gtk_widget_get_parent(widget);
- DCHECK(hbox);
- GtkWidget* vbox = gtk_widget_get_parent(hbox);
- DCHECK(vbox);
- GList* hbox_list = gtk_container_get_children(GTK_CONTAINER(vbox));
- gint index = g_list_index(hbox_list, hbox);
- DCHECK(index != -1);
- g_list_free(hbox_list);
-
- return index;
-}
-
-// A gtk_container_foreach callback to enable/disable a widget.
-void EnableWidgetCallback(GtkWidget* widget, gpointer data) {
- gtk_widget_set_sensitive(widget, *static_cast<gboolean*>(data));
-}
-
-// Create a new widget displaying |rating| as |kNumStarsPerRating| star images.
-// Rating should be in the range [0, kNumStarsPerRating].
-GtkWidget* CreateStarsWidget(double rating) {
- const int kNumStarsPerRating = 5; // Number of stars in a rating.
- const int kStarSpacing = 1; // Spacing between stars in pixels.
- GtkWidget* hbox = gtk_hbox_new(FALSE, kStarSpacing);
-
- ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
- for (int i = 0; i < kNumStarsPerRating; ++i) {
- GdkPixbuf* star = rb.GetNativeImageNamed(
- WebIntentPicker::GetNthStarImageIdFromCWSRating(rating, i),
- ui::ResourceBundle::RTL_ENABLED).ToGdkPixbuf();
- gtk_box_pack_start(GTK_BOX(hbox), gtk_image_new_from_pixbuf(star),
- FALSE, FALSE, 0);
- }
-
- return hbox;
-}
-
-} // namespace
-
-// Create a new Widget for the "waiting for CWS" display.
-
-class WaitingDialog {
- public:
- explicit WaitingDialog(GtkThemeService* theme_service);
- ~WaitingDialog();
-
- GtkWidget* widget() const { return widget_.get(); }
- private:
- // Initialize the widget.
- void Init();
-
- // The actual GtkWidget
- ui::OwnedWidgetGtk widget_;
-
- // Waiting throbber.
- scoped_ptr<ThrobberGtk> throbber_;
-
- // Weak pointer to theme service.
- GtkThemeService* theme_service_;
-};
-
-WaitingDialog::WaitingDialog(GtkThemeService* theme_service)
- : theme_service_(theme_service) {
- DCHECK(theme_service_);
- Init();
-}
-
-WaitingDialog::~WaitingDialog() {
- widget_.Destroy();
-}
-
-void WaitingDialog::Init() {
- const int kDialogSpacing = 30;
-
- widget_.Own(gtk_vbox_new(FALSE, 0));
- GtkWidget* vbox = widget_.get();
-
- // Create throbber
- ThrobberGtk* throbber = new ThrobberGtk(theme_service_);
- GtkWidget* throbber_alignment = gtk_alignment_new(0.5, 0.5, 0, 0);
- gtk_alignment_set_padding(GTK_ALIGNMENT(throbber_alignment), kDialogSpacing,
- kMainContentPixelSize, 0, 0);
- gtk_container_add(GTK_CONTAINER(throbber_alignment), throbber->widget());
- gtk_box_pack_start(GTK_BOX(vbox), throbber_alignment, TRUE, TRUE, 0);
-
- // Add the message text.
- GtkWidget* message_label = theme_service_->BuildLabel(
- l10n_util::GetStringUTF8(IDS_INTENT_PICKER_WAIT_FOR_CWS).c_str(),
- ui::kGdkBlack);
-
- GtkWidget* label_alignment = gtk_alignment_new(0.5, 0.5, 0, 0);
- gtk_alignment_set_padding(GTK_ALIGNMENT(label_alignment),
- kMainContentPixelSize, kDialogSpacing, 0, 0);
- gtk_container_add(GTK_CONTAINER(label_alignment), message_label);
- gtk_box_pack_start(GTK_BOX(vbox), label_alignment, TRUE, TRUE, 0);
-
- // TODO(groby): use IDR_SPEECH_INPUT_SPINNER. Pending fix for ThrobberGtk.
- // Animate throbber
- throbber->Start();
-}
-
-// static
-WebIntentPicker* WebIntentPicker::Create(WebContents* web_contents,
- WebIntentPickerDelegate* delegate,
- WebIntentPickerModel* model) {
- return new WebIntentPickerGtk(web_contents, delegate, model);
-}
-
-WebIntentPickerGtk::WebIntentPickerGtk(WebContents* web_contents,
- WebIntentPickerDelegate* delegate,
- WebIntentPickerModel* model)
- : web_contents_(web_contents),
- delegate_(delegate),
- model_(model),
- contents_(NULL),
- header_label_(NULL),
- button_vbox_(NULL),
- cws_label_(NULL),
- extensions_vbox_(NULL),
- service_hbox_(NULL),
- window_(NULL) {
- DCHECK(delegate_ != NULL);
-
- model_->set_observer(this);
- InitContents();
- UpdateInstalledServices();
- UpdateCWSLabel();
- UpdateSuggestedExtensions();
-
- GtkThemeService* theme_service = GetThemeService(web_contents);
- registrar_.Add(this, chrome::NOTIFICATION_BROWSER_THEME_CHANGED,
- content::Source<ThemeService>(theme_service));
- theme_service->InitThemesFor(this);
-
- window_ = new ConstrainedWindowGtk(web_contents, this);
-
- if (model_->IsInlineDisposition())
- OnInlineDisposition(string16(), model_->inline_disposition_url());
-}
-
-WebIntentPickerGtk::~WebIntentPickerGtk() {
-}
-
-void WebIntentPickerGtk::Close() {
- window_->CloseWebContentsModalDialog();
- if (inline_disposition_web_contents_.get())
- inline_disposition_web_contents_->OnCloseStarted();
-}
-
-void WebIntentPickerGtk::SetActionString(const string16& action) {
- header_label_text_ = action;
- if (header_label_)
- gtk_label_set_text(GTK_LABEL(header_label_), UTF16ToUTF8(action).c_str());
-}
-
-void WebIntentPickerGtk::OnExtensionInstallSuccess(const std::string& id) {
- RemoveThrobber();
-}
-
-void WebIntentPickerGtk::OnExtensionInstallFailure(const std::string& id) {
- // The throbber has an alignment as its parent, so it must be used instead of
- // the throbber to find the extension row.
- size_t index =
- GetExtensionWidgetRow(gtk_widget_get_parent(throbber_->widget()));
- GList* vbox_list =
- gtk_container_get_children(GTK_CONTAINER(extensions_vbox_));
- GtkWidget* hbox = static_cast<GtkWidget*>(g_list_nth_data(vbox_list, index));
-
- RemoveThrobber();
- gtk_widget_show_all(hbox);
- g_list_free(vbox_list);
- SetWidgetsEnabled(true);
-}
-
-void WebIntentPickerGtk::OnModelChanged(WebIntentPickerModel* model) {
- if (waiting_dialog_.get() && !model->IsWaitingForSuggestions()) {
- waiting_dialog_.reset();
- InitMainContents();
- }
- UpdateInstalledServices();
- UpdateCWSLabel();
- UpdateSuggestedExtensions();
- SetActionString(header_label_text_);
-}
-
-void WebIntentPickerGtk::OnFaviconChanged(WebIntentPickerModel* model,
- size_t index) {
- UpdateInstalledServices();
-}
-
-void WebIntentPickerGtk::OnExtensionIconChanged(
- WebIntentPickerModel* model,
- const std::string& extension_id) {
- UpdateSuggestedExtensions();
-}
-
-void WebIntentPickerGtk::OnInlineDisposition(const string16&,
- const GURL& url) {
- DCHECK(delegate_);
- Profile* profile =
- Profile::FromBrowserContext(web_contents_->GetBrowserContext());
- inline_disposition_web_contents_.reset(
- delegate_->CreateWebContentsForInlineDisposition(profile, url));
- Browser* browser = chrome::FindBrowserWithWebContents(web_contents_);
- inline_disposition_delegate_.reset(
- new WebIntentInlineDispositionDelegate(
- this, inline_disposition_web_contents_.get(), browser));
-
- inline_disposition_web_contents_->GetController().LoadURL(
- url, content::Referrer(), content::PAGE_TRANSITION_AUTO_TOPLEVEL,
- std::string());
-
- // Replace the picker contents with the inline disposition.
- ClearContents();
- gtk_widget_set_size_request(contents_, -1, -1);
- window_->BackgroundColorChanged();
-
- GtkWidget* vbox = gtk_vbox_new(FALSE, 0);
- GtkThemeService* theme_service = GetThemeService(web_contents_);
-
- service_hbox_ = gtk_hbox_new(FALSE, ui::kControlSpacing);
- // TODO(gbillock): Eventually get the service icon button here.
-
- // Intent action label.
- const WebIntentPickerModel::InstalledService* service =
- model_->GetInstalledServiceWithURL(url);
- GtkWidget* action_label = gtk_label_new(UTF16ToUTF8(service->title).c_str());
- gtk_util::ForceFontSizePixels(action_label, kMainContentPixelSize);
- // Hardcode color; don't allow theming.
- gtk_util::SetLabelColor(action_label, &ui::kGdkBlack);
-
- GtkWidget* label_alignment = gtk_alignment_new(0, 0.5f, 0, 0);
- gtk_container_add(GTK_CONTAINER(label_alignment), action_label);
- GtkWidget* indent_label = gtk_util::IndentWidget(label_alignment);
-
- gtk_box_pack_start(GTK_BOX(service_hbox_), indent_label, FALSE, TRUE, 0);
- g_signal_connect(service_hbox_, "destroy", G_CALLBACK(gtk_widget_destroyed),
- &service_hbox_);
-
- // Add link for "choose another service" if other suggestions are available
- // or if more than one (the current) service is installed.
- if (model_->show_use_another_service() &&
- (model_->GetInstalledServiceCount() > 1 ||
- model_->GetSuggestedExtensionCount())) {
- GtkWidget* use_alternate_link = theme_service->BuildChromeLinkButton(
- l10n_util::GetStringUTF8(
- IDS_INTENT_PICKER_USE_ALTERNATE_SERVICE).c_str());
- gtk_chrome_link_button_set_use_gtk_theme(
- GTK_CHROME_LINK_BUTTON(use_alternate_link),
- theme_service->UsingNativeTheme());
- gtk_util::ForceFontSizePixels(
- GTK_CHROME_LINK_BUTTON(use_alternate_link)->label,
- kMainContentPixelSize);
- g_signal_connect(use_alternate_link, "clicked",
- G_CALLBACK(OnChooseAnotherServiceClickThunk), this);
- GtkWidget* link_alignment = gtk_alignment_new(0, 0.5f, 0, 0);
- gtk_container_add(GTK_CONTAINER(link_alignment), use_alternate_link);
- gtk_box_pack_start(GTK_BOX(service_hbox_), link_alignment, TRUE, TRUE, 0);
- }
- AddCloseButton(service_hbox_);
-
- // The header box
- gtk_container_add(GTK_CONTAINER(vbox), service_hbox_);
-
- // hbox for the web contents, so we can have spacing on the borders.
- GtkWidget* alignment = gtk_alignment_new(0.0, 0.0, 1.0, 1.0);
- gtk_alignment_set_padding(
- GTK_ALIGNMENT(alignment), 0, ui::kContentAreaBorder,
- ui::kContentAreaBorder, ui::kContentAreaBorder);
- gfx::NativeView web_contents_widget =
- inline_disposition_web_contents_->GetView()->GetNativeView();
- gtk_container_add(GTK_CONTAINER(alignment), web_contents_widget);
- gtk_container_add(GTK_CONTAINER(vbox), alignment);
- gtk_container_add(GTK_CONTAINER(contents_), vbox);
-
- gfx::Size size = GetMinInlineDispositionSize();
- gtk_widget_set_size_request(web_contents_widget,
- size.width(), size.height());
- gtk_widget_show_all(contents_);
-
- inline_disposition_delegate_->SetRenderViewSizeLimits();
- inline_disposition_web_contents_->GetView()->SetInitialFocus();
- host_signals_.reset(new ui::GtkSignalRegistrar());
- host_signals_->Connect(
- web_contents_->GetRenderViewHost()->GetView()->GetNativeView(),
- "size-allocate",
- G_CALLBACK(OnHostContentsSizeAllocateThunk), this);
-}
-
-void WebIntentPickerGtk::OnInlineDispositionAutoResize(const gfx::Size& size) {
- gfx::NativeView web_contents_widget =
- inline_disposition_web_contents_->GetView()->GetNativeView();
- gtk_widget_set_size_request(web_contents_widget, size.width(), size.height());
-}
-
-gfx::Size WebIntentPickerGtk::GetMaxInlineDispositionSize() {
- gfx::Rect tab_bounds(web_contents_->GetRenderViewHost()->
- GetView()->GetNativeView()->allocation);
- GtkRequisition req = {};
- if (service_hbox_)
- gtk_widget_size_request(service_hbox_, &req);
-
- tab_bounds.Inset(2 * ui::kContentAreaBorder,
- 2 * ui::kContentAreaBorder + req.height);
- return tab_bounds.size();
-}
-
-void WebIntentPickerGtk::OnPendingAsyncCompleted() {
- // Requests to both the WebIntentService and the Chrome Web Store have
- // completed. If there are any services, installed or suggested, there's
- // nothing to do.
- if (model_->GetInstalledServiceCount() ||
- model_->GetSuggestedExtensionCount())
- return;
-
- // If there are no installed or suggested services at this point,
- // inform the user about it.
-
- // Replace the picker contents with dialog box.
- ClearContents();
- GtkWidget* sub_contents = CreateSubContents(contents_);
-
- AddCloseButton(contents_);
- AddTitle(sub_contents);
-
- // Replace the dialog header.
- DCHECK(header_label_);
- gtk_label_set_text(
- GTK_LABEL(header_label_),
- l10n_util::GetStringUTF8(IDS_INTENT_PICKER_NO_SERVICES_TITLE).c_str());
-
- // Add the message text.
- GtkWidget* hbox = gtk_hbox_new(FALSE, 0);
- gtk_box_pack_start(GTK_BOX(sub_contents), hbox, TRUE, TRUE, 0);
- GtkThemeService* theme_service = GetThemeService(web_contents_);
- GtkWidget* no_service_label = theme_service->BuildLabel(
- l10n_util::GetStringUTF8(IDS_INTENT_PICKER_NO_SERVICES).c_str(),
- ui::kGdkBlack);
- gtk_label_set_line_wrap(GTK_LABEL(no_service_label), TRUE);
- gtk_misc_set_alignment(GTK_MISC(no_service_label), 0, 0);
- // Set the label width to the size of |sub_contents|, which we don't have
- // access to yet, by calculating the main content width minus borders.
- gtk_util::SetLabelWidth(no_service_label,
- kWindowMinWidth - 2 * ui::kContentAreaBorder);
- gtk_box_pack_start(GTK_BOX(hbox), no_service_label, TRUE, TRUE, 0);
-
- gtk_widget_show_all(contents_);
-}
-
-void WebIntentPickerGtk::InvalidateDelegate() {
- delegate_ = NULL;
-}
-
-GtkWidget* WebIntentPickerGtk::GetWidgetRoot() {
- return contents_;
-}
-
-GtkWidget* WebIntentPickerGtk::GetFocusWidget() {
- return contents_;
-}
-
-void WebIntentPickerGtk::DeleteDelegate() {
- // The delegate is deleted when the contents widget is destroyed. See
- // OnDestroy.
- if (delegate_)
- delegate_->OnClosing();
-}
-
-bool WebIntentPickerGtk::GetBackgroundColor(GdkColor* color) {
- if (inline_disposition_web_contents_.get()) {
- *color = ui::kGdkWhite;
- return true;
- }
-
- return false;
-}
-
-bool WebIntentPickerGtk::ShouldHaveBorderPadding() const {
- return false;
-}
-
-void WebIntentPickerGtk::Observe(int type,
- const content::NotificationSource& source,
- const content::NotificationDetails& details) {
- DCHECK_EQ(type, chrome::NOTIFICATION_BROWSER_THEME_CHANGED);
- if (header_label_) {
- GtkThemeService* theme_service = GetThemeService(web_contents_);
- if (theme_service->UsingNativeTheme())
- gtk_util::UndoForceFontSize(header_label_);
- else
- gtk_util::ForceFontSizePixels(header_label_, kHeaderLabelPixelSize);
- }
- UpdateInstalledServices();
- UpdateSuggestedExtensions();
-}
-
-void WebIntentPickerGtk::OnDestroy(GtkWidget* button) {
- // Destroy this object when the contents widget is destroyed. It can't be
- // "delete this" because this function happens in a callback.
- MessageLoop::current()->DeleteSoon(FROM_HERE, this);
- model_->set_observer(NULL);
- window_ = NULL;
-}
-
-void WebIntentPickerGtk::OnCloseButtonClick(GtkWidget* button) {
- DCHECK(delegate_);
- delegate_->OnUserCancelledPickerDialog();
-}
-
-void WebIntentPickerGtk::OnExtensionLinkClick(GtkWidget* link) {
- DCHECK(delegate_);
- size_t index = GetExtensionWidgetRow(link);
- const WebIntentPickerModel::SuggestedExtension& extension =
- model_->GetSuggestedExtensionAt(index);
- delegate_->OnExtensionLinkClicked(extension.id,
- event_utils::DispositionForCurrentButtonPressEvent());
-}
-
-void WebIntentPickerGtk::OnExtensionInstallButtonClick(GtkWidget* button) {
- DCHECK(delegate_);
- size_t index = GetExtensionWidgetRow(button);
- const WebIntentPickerModel::SuggestedExtension& extension =
- model_->GetSuggestedExtensionAt(index);
-
- delegate_->OnExtensionInstallRequested(extension.id);
- SetWidgetsEnabled(false);
-
- // Re-enable the clicked extension row.
- GList* vbox_list =
- gtk_container_get_children(GTK_CONTAINER(extensions_vbox_));
- GtkWidget* hbox = static_cast<GtkWidget*>(g_list_nth_data(vbox_list, index));
- gtk_widget_set_sensitive(hbox, TRUE);
-
- // Hide the install button.
- GList* hbox_list = gtk_container_get_children(GTK_CONTAINER(hbox));
- GtkWidget* install_button =
- static_cast<GtkWidget*>(g_list_nth_data(hbox_list, kInstallButtonIndex));
- GtkAllocation allocation;
- gtk_widget_get_allocation(install_button, &allocation);
- gtk_widget_hide(install_button);
- g_list_free(hbox_list);
- g_list_free(vbox_list);
-
- // Show the throbber with the same size as the install button.
- GtkWidget* throbber = AddThrobberToExtensionAt(index);
- gtk_widget_set_size_request(throbber, allocation.width, allocation.height);
- gtk_widget_show_all(throbber);
-}
-
-void WebIntentPickerGtk::OnMoreSuggestionsLinkClick(GtkWidget* link) {
- DCHECK(delegate_);
- delegate_->OnSuggestionsLinkClicked(
- event_utils::DispositionForCurrentButtonPressEvent());
-}
-
-void WebIntentPickerGtk::OnChooseAnotherServiceClick(GtkWidget* link) {
- DCHECK(delegate_);
- delegate_->OnChooseAnotherService();
- ResetContents();
-}
-
-void WebIntentPickerGtk::OnHostContentsSizeAllocate(GtkWidget* widget,
- GdkRectangle* rectangle) {
- if (!inline_disposition_delegate_.get())
- return;
- inline_disposition_delegate_->SetRenderViewSizeLimits();
-}
-
-void WebIntentPickerGtk::OnServiceButtonClick(GtkWidget* button) {
- DCHECK(delegate_);
- GList* button_list = gtk_container_get_children(GTK_CONTAINER(button_vbox_));
- gint index = g_list_index(button_list, button);
- DCHECK(index != -1);
- g_list_free(button_list);
-
- const WebIntentPickerModel::InstalledService& installed_service =
- model_->GetInstalledServiceAt(index);
-
- delegate_->OnServiceChosen(installed_service.url,
- installed_service.disposition,
- WebIntentPickerDelegate::kEnableDefaults);
-}
-
-void WebIntentPickerGtk::InitContents() {
- GtkThemeService* theme_service = GetThemeService(web_contents_);
-
- // Main contents vbox.
- if (!contents_) {
- contents_ = gtk_vbox_new(FALSE, 0);
- g_signal_connect(contents_, "destroy", G_CALLBACK(&OnDestroyThunk), this);
- }
-
- gtk_widget_set_size_request(contents_, kWindowMinWidth, -1);
-
- if (model_ && model_->IsWaitingForSuggestions()) {
- ClearContents();
- AddCloseButton(contents_);
- waiting_dialog_.reset(new WaitingDialog(theme_service));
- gtk_box_pack_start(GTK_BOX(contents_), waiting_dialog_->widget(),
- TRUE, TRUE, 0);
- } else {
- InitMainContents();
- }
-}
-
-void WebIntentPickerGtk::InitMainContents() {
- GtkThemeService* theme_service = GetThemeService(web_contents_);
-
- ClearContents();
-
- AddCloseButton(contents_);
- GtkWidget* sub_contents = CreateSubContents(contents_);
-
- AddTitle(sub_contents);
-
- // Add separation between the installed services list and the app suggestions.
- GtkWidget* button_alignment = gtk_alignment_new(0.5, 0, 0, 0);
- gtk_alignment_set_padding(GTK_ALIGNMENT(button_alignment), 0,
- kMainContentPixelSize * 2, 0, 0);
-
- // Vbox containing all service buttons.
- button_vbox_ = gtk_vbox_new(FALSE, ui::kControlSpacing);
- gtk_container_add(GTK_CONTAINER(button_alignment), button_vbox_);
- gtk_box_pack_start(GTK_BOX(sub_contents), button_alignment, TRUE, TRUE, 0);
-
- // Chrome Web Store label.
- cws_label_ = theme_service->BuildLabel(
- l10n_util::GetStringUTF8(IDS_INTENT_PICKER_GET_MORE_SERVICES).c_str(),
- ui::kGdkBlack);
- gtk_box_pack_start(GTK_BOX(sub_contents), cws_label_, TRUE, TRUE, 0);
- gtk_misc_set_alignment(GTK_MISC(cws_label_), 0, 0);
- gtk_widget_set_no_show_all(cws_label_, TRUE);
-
- // Set the label width to the size of |sub_contents|, which we don't have
- // access to yet, by calculating the main content width minus borders.
- gtk_util::SetLabelWidth(cws_label_,
- kWindowMinWidth - 2 * ui::kContentAreaBorder);
- gtk_util::ForceFontSizePixels(cws_label_, kMainContentPixelSize);
-
- // Suggested extensions vbox.
- extensions_vbox_ = gtk_vbox_new(FALSE, ui::kControlSpacing);
- GtkWidget* indent_extensions = gtk_alignment_new(0.0, 0.5, 1.0, 1.0);
- gtk_alignment_set_padding(GTK_ALIGNMENT(indent_extensions), 0, 0,
- ui::kGroupIndent, ui::kGroupIndent);
- gtk_container_add(GTK_CONTAINER(indent_extensions), extensions_vbox_);
- gtk_widget_set_no_show_all(indent_extensions, TRUE);
- gtk_box_pack_start(GTK_BOX(sub_contents), indent_extensions, TRUE, TRUE, 0);
-
- // CWS 'More Suggestions' link.
- GtkWidget* link_alignment = gtk_alignment_new(0, 0.5f, 0, 0);
- GtkWidget* more_hbox = gtk_hbox_new(FALSE, ui::kControlSpacing);
- ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
- GdkPixbuf* cws_icon =
- rb.GetNativeImageNamed(IDR_WEBSTORE_ICON_16).ToGdkPixbuf();
- gtk_box_pack_start(GTK_BOX(more_hbox), gtk_image_new_from_pixbuf(cws_icon),
- FALSE, FALSE, 0);
- GtkWidget* more_suggestions_link = theme_service->BuildChromeLinkButton(
- l10n_util::GetStringUTF8(IDS_FIND_MORE_INTENT_HANDLER_MESSAGE).c_str());
- gtk_box_pack_start(GTK_BOX(more_hbox), more_suggestions_link,
- FALSE, FALSE, 0);
- gtk_container_add(GTK_CONTAINER(link_alignment), more_hbox);
- gtk_chrome_link_button_set_use_gtk_theme(
- GTK_CHROME_LINK_BUTTON(more_suggestions_link),
- theme_service->UsingNativeTheme());
- gtk_util::ForceFontSizePixels(
- GTK_CHROME_LINK_BUTTON(more_suggestions_link)->label,
- kMainContentPixelSize);
- g_signal_connect(more_suggestions_link, "clicked",
- G_CALLBACK(OnMoreSuggestionsLinkClickThunk), this);
-
- GtkWidget* indent_link = gtk_util::IndentWidget(link_alignment);
- gtk_box_pack_start(GTK_BOX(sub_contents), indent_link, TRUE, TRUE, 0);
-
- // Throbber, which will be added to the hierarchy when necessary.
- throbber_.reset(new ThrobberGtk(theme_service));
-
- gtk_widget_show_all(contents_);
-}
-
-void WebIntentPickerGtk::ClearContents() {
- // Wipe out all currently displayed widgets.
- gtk_util::RemoveAllChildren(contents_);
- header_label_ = NULL;
- button_vbox_ = NULL;
- cws_label_ = NULL;
- extensions_vbox_ = NULL;
-}
-
-void WebIntentPickerGtk::ResetContents() {
- ClearContents();
-
- // Reset potential inline disposition data.
- inline_disposition_web_contents_.reset();
- inline_disposition_delegate_.reset();
- window_->BackgroundColorChanged();
-
- // Re-initialize picker widgets and data.
- InitMainContents();
- UpdateInstalledServices();
- UpdateCWSLabel();
- UpdateSuggestedExtensions();
- SetActionString(header_label_text_);
-
- gtk_widget_show_all(contents_);
-}
-
-GtkWidget* WebIntentPickerGtk::CreateSubContents(GtkWidget* box) {
- GtkWidget* alignment = gtk_alignment_new(0.0, 0.0, 1.0, 1.0);
- gtk_alignment_set_padding(
- GTK_ALIGNMENT(alignment), 0, ui::kContentAreaBorder,
- ui::kContentAreaBorder, ui::kContentAreaBorder);
- gtk_box_pack_end(GTK_BOX(box), alignment, TRUE, TRUE, 0);
-
- GtkWidget* sub_contents = gtk_vbox_new(FALSE, ui::kContentAreaSpacing);
- gtk_container_add(GTK_CONTAINER(alignment), sub_contents);
- return sub_contents;
-}
-
-void WebIntentPickerGtk::AddCloseButton(GtkWidget* containingBox) {
-
- // Hbox containing the close button.
- GtkWidget* close_hbox = gtk_hbox_new(FALSE, 0);
- gtk_box_pack_start(GTK_BOX(containingBox), close_hbox, TRUE, TRUE, 0);
-
- close_button_.reset(
- CustomDrawButton::CloseButton(GetThemeService(web_contents_)));
- g_signal_connect(close_button_->widget(), "clicked",
- G_CALLBACK(OnCloseButtonClickThunk), this);
- gtk_widget_set_can_focus(close_button_->widget(), FALSE);
- gtk_box_pack_end(GTK_BOX(close_hbox), close_button_->widget(),
- FALSE, FALSE, 0);
-}
-
-void WebIntentPickerGtk::AddTitle(GtkWidget* containingBox) {
- // Hbox containing the header label.
- GtkWidget* header_hbox = gtk_hbox_new(FALSE, 0);
- gtk_box_pack_start(GTK_BOX(containingBox), header_hbox, TRUE, TRUE, 0);
-
- // Label text will be set in the call to SetActionString().
- header_label_ = GetThemeService(web_contents_)->BuildLabel(
- std::string(), ui::kGdkBlack);
- gtk_util::ForceFontSizePixels(header_label_, kHeaderLabelPixelSize);
- gtk_box_pack_start(GTK_BOX(header_hbox), header_label_, TRUE, TRUE, 0);
- gtk_misc_set_alignment(GTK_MISC(header_label_), 0, 0);
-}
-
-void WebIntentPickerGtk::UpdateInstalledServices() {
- if (!button_vbox_)
- return;
-
- gtk_util::RemoveAllChildren(button_vbox_);
-
- if (model_->GetInstalledServiceCount() == 0) {
- gtk_widget_hide(gtk_widget_get_parent(button_vbox_));
- return;
- }
-
- for (size_t i = 0; i < model_->GetInstalledServiceCount(); ++i) {
- const WebIntentPickerModel::InstalledService& installed_service =
- model_->GetInstalledServiceAt(i);
-
- GtkWidget* button = gtk_button_new();
- gtk_widget_set_tooltip_text(button, installed_service.url.spec().c_str());
- gtk_button_set_label(GTK_BUTTON(button),
- UTF16ToUTF8(installed_service.title).c_str());
- gtk_button_set_alignment(GTK_BUTTON(button), 0, 0);
-
- gtk_container_add(GTK_CONTAINER(button_vbox_), button);
- g_signal_connect(button, "clicked", G_CALLBACK(OnServiceButtonClickThunk),
- this);
-
- SetServiceButtonImage(button, installed_service.favicon.ToGdkPixbuf());
-
- // Must be called after SetServiceButtonImage as the internal label widget
- // is replaced in that call.
- SetWidgetFontSize(button, kMainContentPixelSize);
- }
-
- gtk_widget_show_all(button_vbox_);
- gtk_widget_show(gtk_widget_get_parent(button_vbox_));
-}
-
-void WebIntentPickerGtk::UpdateCWSLabel() {
- if (!button_vbox_)
- return;
-
- gtk_widget_set_visible(gtk_widget_get_parent(button_vbox_),
- model_->GetInstalledServiceCount() != 0);
-
- std::string label_text = UTF16ToUTF8(model_->GetSuggestionsLinkText());
- gtk_label_set_text(GTK_LABEL(cws_label_), label_text.c_str());
- gtk_widget_set_visible(cws_label_, !label_text.empty());
-}
-
-void WebIntentPickerGtk::UpdateSuggestedExtensions() {
- if (!extensions_vbox_)
- return;
-
- GtkThemeService* theme_service = GetThemeService(web_contents_);
-
- gtk_util::RemoveAllChildren(extensions_vbox_);
-
- if (model_->GetSuggestedExtensionCount() == 0) {
- gtk_widget_hide(gtk_widget_get_parent(extensions_vbox_));
- return;
- }
-
- gtk_widget_show(gtk_widget_get_parent(extensions_vbox_));
-
- for (size_t i = 0; i < model_->GetSuggestedExtensionCount(); ++i) {
- const WebIntentPickerModel::SuggestedExtension& extension =
- model_->GetSuggestedExtensionAt(i);
-
- GtkWidget* hbox = gtk_hbox_new(FALSE, ui::kControlSpacing);
- gtk_box_pack_start(GTK_BOX(extensions_vbox_), hbox, FALSE, FALSE, 0);
-
- // Icon.
- GtkWidget* icon = gtk_image_new_from_pixbuf(extension.icon.ToGdkPixbuf());
- gtk_box_pack_start(GTK_BOX(hbox), icon, FALSE, FALSE, 0);
-
- // Title link.
- string16 elided_title = ui::ElideText(extension.title, gfx::Font(),
- kTitleLinkMaxWidth, ui::ELIDE_AT_END);
- GtkWidget* title_link = theme_service->BuildChromeLinkButton(
- UTF16ToUTF8(elided_title).c_str());
- gtk_chrome_link_button_set_use_gtk_theme(GTK_CHROME_LINK_BUTTON(title_link),
- theme_service->UsingNativeTheme());
- gtk_util::ForceFontSizePixels(GTK_CHROME_LINK_BUTTON(title_link)->label,
- kMainContentPixelSize);
- g_signal_connect(title_link, "clicked",
- G_CALLBACK(OnExtensionLinkClickThunk), this);
- gtk_box_pack_start(GTK_BOX(hbox), title_link, FALSE, FALSE, 0);
-
- // Stars.
- GtkWidget* stars = CreateStarsWidget(extension.average_rating);
- gtk_box_pack_start(GTK_BOX(hbox), stars, FALSE, FALSE, 0);
-
- // Install button.
- GtkWidget* install_button = gtk_button_new();
- gtk_button_set_label(
- GTK_BUTTON(install_button),
- l10n_util::GetStringUTF8(IDS_INTENT_PICKER_INSTALL_EXTENSION).c_str());
- GtkWidget* label = gtk_bin_get_child(GTK_BIN(install_button));
- gtk_util::ForceFontSizePixels(label, kMainContentPixelSize);
- g_signal_connect(install_button, "clicked",
- G_CALLBACK(OnExtensionInstallButtonClickThunk), this);
- gtk_box_pack_end(GTK_BOX(hbox), install_button, FALSE, FALSE, 0);
- }
-
- gtk_widget_show_all(extensions_vbox_);
- gtk_widget_show(gtk_widget_get_parent(extensions_vbox_));
-}
-
-void WebIntentPickerGtk::SetWidgetsEnabled(bool enabled) {
- gboolean data = enabled;
- if (button_vbox_)
- gtk_container_foreach(GTK_CONTAINER(button_vbox_), EnableWidgetCallback,
- &data);
- if (extensions_vbox_)
- gtk_container_foreach(GTK_CONTAINER(extensions_vbox_), EnableWidgetCallback,
- &data);
-}
-
-GtkWidget* WebIntentPickerGtk::AddThrobberToExtensionAt(size_t index) {
- // The throbber should be unparented.
- DCHECK(!gtk_widget_get_parent(throbber_->widget()));
- GList* vbox_list =
- gtk_container_get_children(GTK_CONTAINER(extensions_vbox_));
- GtkWidget* hbox = static_cast<GtkWidget*>(g_list_nth_data(vbox_list, index));
- GtkWidget* alignment = gtk_alignment_new(0.5, 0.5, 0, 0);
- gtk_container_add(GTK_CONTAINER(alignment), throbber_->widget());
- gtk_box_pack_end(GTK_BOX(hbox), alignment, FALSE, FALSE, 0);
- g_list_free(vbox_list);
- throbber_->Start();
- return alignment;
-}
-
-void WebIntentPickerGtk::RemoveThrobber() {
- GtkWidget* alignment = gtk_widget_get_parent(throbber_->widget());
- DCHECK(alignment);
- gtk_container_remove(GTK_CONTAINER(alignment), throbber_->widget());
- gtk_widget_destroy(alignment);
- throbber_->Stop();
-}
diff --git a/chrome/browser/ui/gtk/web_intent_picker_gtk.h b/chrome/browser/ui/gtk/web_intent_picker_gtk.h
deleted file mode 100644
index a7a8816..0000000
--- a/chrome/browser/ui/gtk/web_intent_picker_gtk.h
+++ /dev/null
@@ -1,196 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_UI_GTK_WEB_INTENT_PICKER_GTK_H_
-#define CHROME_BROWSER_UI_GTK_WEB_INTENT_PICKER_GTK_H_
-
-#include <gtk/gtk.h>
-
-#include <vector>
-
-#include "base/basictypes.h"
-#include "base/compiler_specific.h"
-#include "base/memory/scoped_ptr.h"
-#include "chrome/browser/ui/gtk/constrained_window_gtk.h"
-#include "chrome/browser/ui/intents/web_intent_inline_disposition_delegate.h"
-#include "chrome/browser/ui/intents/web_intent_picker.h"
-#include "chrome/browser/ui/intents/web_intent_picker_model_observer.h"
-#include "content/public/browser/notification_observer.h"
-#include "content/public/browser/notification_registrar.h"
-#include "ui/base/gtk/gtk_signal.h"
-#include "ui/base/gtk/owned_widget_gtk.h"
-
-namespace ui {
-class GtkSignalRegistrar;
-}
-
-class CustomDrawButton;
-class GURL;
-class ThrobberGtk;
-class WebIntentPickerDelegate;
-class WaitingDialog;
-
-// GTK implementation of WebIntentPicker.
-class WebIntentPickerGtk : public WebIntentPicker,
- public WebIntentPickerModelObserver,
- public ConstrainedWindowGtkDelegate,
- public content::NotificationObserver {
- public:
- WebIntentPickerGtk(content::WebContents* web_contents,
- WebIntentPickerDelegate* delegate,
- WebIntentPickerModel* model);
- virtual ~WebIntentPickerGtk();
-
- // WebIntentPicker implementation.
- virtual void Close() OVERRIDE;
- virtual void SetActionString(const string16& action) OVERRIDE;
- virtual void OnExtensionInstallSuccess(const std::string& id) OVERRIDE;
- virtual void OnExtensionInstallFailure(const std::string& id) OVERRIDE;
- virtual void OnInlineDispositionAutoResize(const gfx::Size& size) OVERRIDE;
- virtual gfx::Size GetMaxInlineDispositionSize() OVERRIDE;
-
- // WebIntentPickerModelObserver implementation.
- virtual void OnModelChanged(WebIntentPickerModel* model) OVERRIDE;
- virtual void OnFaviconChanged(WebIntentPickerModel* model,
- size_t index) OVERRIDE;
- virtual void OnExtensionIconChanged(WebIntentPickerModel* model,
- const std::string& extension_id) OVERRIDE;
- virtual void OnInlineDisposition(const string16& title,
- const GURL& url) OVERRIDE;
-
- virtual void OnPendingAsyncCompleted() OVERRIDE;
- virtual void InvalidateDelegate() OVERRIDE;
-
- // ConstrainedWindowGtkDelegate implementation.
- virtual GtkWidget* GetWidgetRoot() OVERRIDE;
- virtual GtkWidget* GetFocusWidget() OVERRIDE;
- virtual void DeleteDelegate() OVERRIDE;
- virtual bool GetBackgroundColor(GdkColor* color) OVERRIDE;
- virtual bool ShouldHaveBorderPadding() const OVERRIDE;
-
- // content::NotificationObserver implementation.
- virtual void Observe(int type,
- const content::NotificationSource& source,
- const content::NotificationDetails& details) OVERRIDE;
-
- private:
- // Callback when picker is destroyed.
- CHROMEGTK_CALLBACK_0(WebIntentPickerGtk, void, OnDestroy);
- // Callback when a service button is clicked.
- CHROMEGTK_CALLBACK_0(WebIntentPickerGtk, void, OnServiceButtonClick);
- // Callback when close button is clicked.
- CHROMEGTK_CALLBACK_0(WebIntentPickerGtk, void, OnCloseButtonClick);
- // Callback when suggested extension title link is clicked.
- CHROMEGTK_CALLBACK_0(WebIntentPickerGtk, void, OnExtensionLinkClick);
- // Callback when suggested extension install button is clicked.
- CHROMEGTK_CALLBACK_0(WebIntentPickerGtk, void, OnExtensionInstallButtonClick);
- // Callback when "more suggestions" link is clicked.
- CHROMEGTK_CALLBACK_0(WebIntentPickerGtk, void, OnMoreSuggestionsLinkClick);
- // Callback when "or choose another service" link is clicked.
- CHROMEGTK_CALLBACK_0(WebIntentPickerGtk, void, OnChooseAnotherServiceClick);
- // Callback when the host tab contents size changes.
- CHROMEGTK_CALLBACK_1(WebIntentPickerGtk, void, OnHostContentsSizeAllocate,
- GdkRectangle*);
-
- // Initialize the contents of the picker. After this call, contents_ will be
- // non-NULL.
- void InitContents();
-
- // Initialize the main picker dialog.
- void InitMainContents();
-
- // Clear all contents and reset related variables.
- void ClearContents();
-
- // Reset contents to the initial picker state.
- void ResetContents();
-
- // Create the (inset relative to |box|) container for dialog elements.
- GtkWidget* CreateSubContents(GtkWidget* box);
-
- // Add a close button to dialog contents
- void AddCloseButton(GtkWidget* containingBox);
-
- // Add title to dialog contents
- void AddTitle(GtkWidget* containingBox);
-
- // Update the installed service buttons from |model_|.
- void UpdateInstalledServices();
-
- // Update the Chrome Web Store label from |model_|.
- void UpdateCWSLabel();
-
- // Update the suggested extension table from |model_|.
- void UpdateSuggestedExtensions();
-
- // Enables/disables all service buttons and extension suggestions.
- void SetWidgetsEnabled(bool enabled);
-
- // Adds a throbber to the extension at |index|. Returns the alignment widget
- // containing the throbber.
- GtkWidget* AddThrobberToExtensionAt(size_t index);
-
- // Removes the added throbber.
- void RemoveThrobber();
-
- // A weak pointer to the tab contents on which to display the picker UI.
- content::WebContents* web_contents_;
-
- // A weak pointer to the WebIntentPickerDelegate to notify when the user
- // chooses a service or cancels.
- WebIntentPickerDelegate* delegate_;
-
- // A weak pointer to the picker model.
- WebIntentPickerModel* model_;
-
- // A weak pointer to the widget that contains all other widgets in
- // the picker.
- GtkWidget* contents_;
-
- // A weak pointer to the header label.
- GtkWidget* header_label_;
-
- // The text displayed in the header label.
- string16 header_label_text_;
-
- // A weak pointer to the vbox that contains the buttons used to choose the
- // service.
- GtkWidget* button_vbox_;
-
- // A weak pointer to the Chrome Web Store header label.
- GtkWidget* cws_label_;
-
- // A weak pointer to the suggested extensions vbox.
- GtkWidget* extensions_vbox_;
-
- // This widget holds the header when showing an inline intent handler.
- GtkWidget* service_hbox_;
-
- // A button to close the picker.
- scoped_ptr<CustomDrawButton> close_button_;
-
- // The throbber to display when installing an extension.
- scoped_ptr<ThrobberGtk> throbber_;
-
- scoped_ptr<WaitingDialog> waiting_dialog_;
-
- // A weak pointer to the constrained window.
- ConstrainedWindowGtk* window_;
-
- // The WebContents being displayed in inline disposition.
- scoped_ptr<content::WebContents> inline_disposition_web_contents_;
-
- // content::WebContentsDelegate for the inline disposition dialog.
- scoped_ptr<WebIntentInlineDispositionDelegate> inline_disposition_delegate_;
-
- content::NotificationRegistrar registrar_;
-
- // Used to connect to signals fired on the host tab contents (only used while
- // showing an inline intent handler).
- scoped_ptr<ui::GtkSignalRegistrar> host_signals_;
-
- DISALLOW_COPY_AND_ASSIGN(WebIntentPickerGtk);
-};
-
-#endif // CHROME_BROWSER_UI_GTK_WEB_INTENT_PICKER_GTK_H_
diff --git a/chrome/browser/ui/intents/OWNERS b/chrome/browser/ui/intents/OWNERS
deleted file mode 100644
index 39a4139..0000000
--- a/chrome/browser/ui/intents/OWNERS
+++ /dev/null
@@ -1,4 +0,0 @@
-gbillock@chromium.org
-groby@chromium.org
-jhawkins@chromium.org
-smckay@chromium.org \ No newline at end of file
diff --git a/chrome/browser/ui/intents/native_file_picker_service.cc b/chrome/browser/ui/intents/native_file_picker_service.cc
deleted file mode 100644
index 293f3d4..0000000
--- a/chrome/browser/ui/intents/native_file_picker_service.cc
+++ /dev/null
@@ -1,194 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// This file provides the UI implementation of the classes declared
-// in chrome/browser/intents/native_services.h and partially defined in
-// chrome/browser/intents/native_services.cc.
-
-#include <vector>
-
-#include "base/file_path.h"
-#include "base/file_util.h"
-#include "base/logging.h"
-#include "base/platform_file.h"
-#include "base/string16.h"
-#include "base/utf_string_conversions.h"
-#include "chrome/browser/intents/intent_service_host.h"
-#include "chrome/browser/intents/native_services.h"
-#include "chrome/browser/intents/web_intents_util.h"
-#include "chrome/browser/platform_util.h"
-#include "content/public/browser/browser_thread.h"
-#include "content/public/browser/child_process_security_policy.h"
-#include "content/public/browser/render_process_host.h"
-#include "content/public/browser/web_contents.h"
-#include "content/public/browser/web_intents_dispatcher.h"
-#include "googleurl/src/gurl.h"
-#include "grit/generated_resources.h"
-#include "net/base/mime_util.h"
-#include "ui/base/l10n/l10n_util.h"
-#include "ui/shell_dialogs/select_file_dialog.h"
-#include "ui/shell_dialogs/selected_file_info.h"
-#include "webkit/glue/web_intent_data.h"
-#include "webkit/glue/web_intent_service_data.h"
-
-namespace web_intents {
-namespace {
-
-const int kInvalidFileSize = -1;
-
-// Returns a FileTypeInfo instance representative of |mime_type|.
-ui::SelectFileDialog::FileTypeInfo TypeInfoFromMimeType(
- const std::string& mime_type) {
- ui::SelectFileDialog::FileTypeInfo info;
- info.include_all_files = true;
- info.extensions.resize(1);
- net::GetExtensionsForMimeType(mime_type, &info.extensions.back());
-
- // Provide a "helpful" description when possible.
- int description_id = 0;
- if (mime_type == "image/*") {
- description_id = IDS_IMAGE_FILES;
- } else if (mime_type == "audio/*") {
- description_id = IDS_AUDIO_FILES;
- } else if (mime_type == "video/*") {
- description_id = IDS_VIDEO_FILES;
- }
-
- if (description_id != 0) {
- info.extension_description_overrides.push_back(
- l10n_util::GetStringUTF16(description_id));
- }
-
- return info;
-}
-
-// FilePicker service allowing a native file picker to handle
-// pick + */* intents.
-class NativeFilePickerService
- : public IntentServiceHost, public ui::SelectFileDialog::Listener {
- public:
- explicit NativeFilePickerService(content::WebContents* web_contents);
- virtual ~NativeFilePickerService();
-
- // Reads the length of the file on the FILE thread, then returns
- // the file and the length to the UI thread.
- void ReadFileLength(const base::FilePath& path);
-
- // Handles sending of data back to dispatcher
- void PostDataFileReply(const base::FilePath& path, int64 length);
-
- // Implements IntentServiceHost:
- virtual void HandleIntent(content::WebIntentsDispatcher* dispatcher) OVERRIDE;
-
- // Implements SelectFileDialog::Listener
- virtual void FileSelected(
- const base::FilePath& path, int index, void* params) OVERRIDE;
- virtual void FileSelectionCanceled(void* params) OVERRIDE;
-
- private:
- // The web contents on which the selector will be displayed. Not owned.
- content::WebContents* web_contents_;
-
- // The dispatcher for the current intent. Only set at the time the intent
- // request is delivered to HandleIntent. Not owned.
- content::WebIntentsDispatcher* dispatcher_;
-
- scoped_refptr<ui::SelectFileDialog> dialog_;
-
- DISALLOW_COPY_AND_ASSIGN(NativeFilePickerService);
-};
-
-} // namespace
-
-NativeFilePickerService::NativeFilePickerService(
- content::WebContents* web_contents)
- : web_contents_(web_contents), dispatcher_(NULL) {
-}
-
-NativeFilePickerService::~NativeFilePickerService() {}
-
-void NativeFilePickerService::HandleIntent(
- content::WebIntentsDispatcher* dispatcher) {
- DCHECK(dispatcher);
- dispatcher_ = dispatcher;
-
- dialog_ = ui::SelectFileDialog::Create(this, NULL);
-
- ui::SelectFileDialog::FileTypeInfo type_info =
- TypeInfoFromMimeType(UTF16ToASCII(dispatcher_->GetIntent().type));
-
- dialog_->SelectFile(
- ui::SelectFileDialog::SELECT_OPEN_FILE,
- FilePickerFactory::GetServiceTitle(),
- base::FilePath(FILE_PATH_LITERAL(".")),
- &type_info,
- 1, // Index of which file description to show.
- FILE_PATH_LITERAL(""),
- platform_util::GetTopLevel(web_contents_->GetNativeView()),
- NULL);
-}
-
-void NativeFilePickerService::ReadFileLength(const base::FilePath& path) {
- DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE));
-
- int64 file_size;
- if (!file_util::GetFileSize(path, &file_size))
- file_size = kInvalidFileSize;
-
- content::BrowserThread::PostTask(
- content::BrowserThread::UI, FROM_HERE,
- base::Bind(&NativeFilePickerService::PostDataFileReply,
- base::Unretained(this), path, file_size));
-}
-
-void NativeFilePickerService::PostDataFileReply(
- const base::FilePath& path, int64 length) {
- DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
-
- if (length <= kInvalidFileSize) {
- DLOG(WARNING) << "Unable to determine file size.";
- dispatcher_->SendReply(
- webkit_glue::WebIntentReply(
- webkit_glue::WEB_INTENT_REPLY_FAILURE, string16()));
- return;
- }
-
- content::ChildProcessSecurityPolicy::GetInstance()->GrantReadFile(
- web_contents_->GetRenderProcessHost()->GetID(),
- path);
-
- dispatcher_->SendReply(webkit_glue::WebIntentReply(
- webkit_glue::WEB_INTENT_REPLY_SUCCESS, path, length));
-}
-
-void NativeFilePickerService::FileSelected(
- const base::FilePath& path, int index, void* params) {
- DCHECK(dispatcher_);
- content::BrowserThread::PostTask(
- content::BrowserThread::FILE,
- FROM_HERE,
- base::Bind(
- &NativeFilePickerService::ReadFileLength,
- base::Unretained(this), path));
-}
-
-void NativeFilePickerService::FileSelectionCanceled(void* params) {
- DCHECK(dispatcher_);
- dispatcher_->SendReply(
- webkit_glue::WebIntentReply(
- webkit_glue::WEB_INTENT_REPLY_FAILURE, string16()));
-}
-
-// static
-IntentServiceHost* FilePickerFactory::CreateServiceInstance(
- const webkit_glue::WebIntentData& intent,
- content::WebContents* web_contents) {
- return new NativeFilePickerService(web_contents);
-}
-
-string16 FilePickerFactory::GetServiceTitle() {
- return l10n_util::GetStringUTF16(IDS_WEB_INTENTS_FILE_PICKER_SERVICE_TITLE);
-}
-
-} // namespace web_intents
diff --git a/chrome/browser/ui/intents/web_intent_icon_loader.cc b/chrome/browser/ui/intents/web_intent_icon_loader.cc
deleted file mode 100644
index 6792a14..0000000
--- a/chrome/browser/ui/intents/web_intent_icon_loader.cc
+++ /dev/null
@@ -1,159 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/ui/intents/web_intent_icon_loader.h"
-
-#include "chrome/browser/favicon/favicon_service.h"
-#include "chrome/browser/favicon/favicon_service_factory.h"
-#include "chrome/browser/ui/intents/web_intent_picker_model.h"
-#include "content/public/browser/browser_thread.h"
-#include "net/base/load_flags.h"
-#include "net/url_request/url_fetcher.h"
-#include "net/url_request/url_fetcher_delegate.h"
-#include "skia/ext/image_operations.h"
-#include "ui/gfx/codec/png_codec.h"
-#include "ui/gfx/favicon_size.h"
-
-namespace {
-
-typedef base::Callback<void(const gfx::Image&)>
- ExtensionIconAvailableCallback;
-
-// Decodes an |icon_repsonse| as delivered via URLFetcher. The response should
-// be in PNG format, but is not guaranteed to be. Posts the |callback| task
-// when done.
-void DecodeExtensionIconAndResize(
- scoped_ptr<std::string> icon_response,
- const ExtensionIconAvailableCallback& callback) {
- SkBitmap icon_bitmap;
- if (gfx::PNGCodec::Decode(
- reinterpret_cast<const unsigned char*>(icon_response->data()),
- icon_response->length(),
- &icon_bitmap)) {
- SkBitmap resized_icon = skia::ImageOperations::Resize(
- icon_bitmap,
- skia::ImageOperations::RESIZE_BEST,
- gfx::kFaviconSize, gfx::kFaviconSize);
- gfx::Image icon_image = gfx::Image::CreateFrom1xBitmap(resized_icon);
-
- content::BrowserThread::PostTask(
- content::BrowserThread::UI,
- FROM_HERE,
- base::Bind(callback, icon_image));
- }
-}
-
-// Self-deleting trampoline that forwards A URLFetcher response to a callback.
-class URLFetcherTrampoline : public net::URLFetcherDelegate {
- public:
- typedef base::Callback<void(const net::URLFetcher* source)>
- ForwardingCallback;
-
- explicit URLFetcherTrampoline(const ForwardingCallback& callback)
- : callback_(callback) {}
- virtual ~URLFetcherTrampoline() {}
-
- // net::URLFetcherDelegate implementation.
- virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE;
-
- private:
- // Fowarding callback from |OnURLFetchComplete|.
- ForwardingCallback callback_;
-};
-
-void URLFetcherTrampoline::OnURLFetchComplete(
- const net::URLFetcher* source) {
- DCHECK(!callback_.is_null());
- callback_.Run(source);
- delete source;
- delete this;
-}
-
-}
-
-namespace web_intents {
-
-IconLoader::IconLoader(Profile* profile,
- WebIntentPickerModel* model)
- : profile_(profile),
- model_(model),
- ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) {
-}
-
-IconLoader::~IconLoader() {}
-
-void IconLoader::LoadFavicon(const GURL& url) {
- FaviconService* favicon_service =
- FaviconServiceFactory::GetForProfile(profile_,
- Profile::EXPLICIT_ACCESS);
-
- favicon_service->GetFaviconImageForURL(
- FaviconService::FaviconForURLParams(
- profile_, url, history::FAVICON, gfx::kFaviconSize),
- base::Bind(
- &IconLoader::OnFaviconDataAvailable,
- weak_ptr_factory_.GetWeakPtr(), url),
- &cancelable_task_tracker_);
-}
-
-void IconLoader::LoadExtensionIcon(const GURL& url,
- const std::string& extension_id) {
-
- net::URLFetcher* icon_url_fetcher = net::URLFetcher::Create(
- 0,
- url,
- net::URLFetcher::GET,
- new URLFetcherTrampoline(
- base::Bind(
- &IconLoader::OnExtensionIconURLFetchComplete,
- weak_ptr_factory_.GetWeakPtr(), extension_id)));
-
- icon_url_fetcher->SetLoadFlags(
- net::LOAD_DO_NOT_SEND_COOKIES | net::LOAD_DO_NOT_SAVE_COOKIES);
- icon_url_fetcher->SetRequestContext(profile_->GetRequestContext());
- icon_url_fetcher->Start();
-}
-
-void IconLoader::OnFaviconDataAvailable(
- const GURL& url,
- const history::FaviconImageResult& image_result) {
- if (!image_result.image.IsEmpty())
- model_->UpdateFaviconForServiceWithURL(url, image_result.image);
-}
-
-void IconLoader::OnExtensionIconURLFetchComplete(
- const std::string& extension_id, const net::URLFetcher* source) {
- DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
- if (source->GetResponseCode() != 200)
- return;
-
- scoped_ptr<std::string> response(new std::string);
- if (!source->GetResponseAsString(response.get()))
- return;
-
- // Decoding the extension icon needs to happen on a worker thread, not the
- // UI thread. However, callbacks to IconLoader need to happen on the UI
- // thread, since IconLoader lives on UI thread. (And WeakPtrs must be de-
- // referenced on the thread they were created on).
- ExtensionIconAvailableCallback available_callback =
- base::Bind(
- &IconLoader::OnExtensionIconAvailable,
- weak_ptr_factory_.GetWeakPtr(),
- extension_id);
-
- // Decode PNG and resize on worker thread.
- content::BrowserThread::PostBlockingPoolTask(
- FROM_HERE,
- base::Bind(&DecodeExtensionIconAndResize,
- base::Passed(&response),
- available_callback));
-}
-
-void IconLoader::OnExtensionIconAvailable(
- const std::string& extension_id,
- const gfx::Image& icon_image) {
- model_->SetSuggestedExtensionIconWithId(extension_id, icon_image);
-}
-
-} // namespace web_intents
diff --git a/chrome/browser/ui/intents/web_intent_icon_loader.h b/chrome/browser/ui/intents/web_intent_icon_loader.h
deleted file mode 100644
index 76f4c7c..0000000
--- a/chrome/browser/ui/intents/web_intent_icon_loader.h
+++ /dev/null
@@ -1,62 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_UI_INTENTS_WEB_INTENT_ICON_LOADER_H_
-#define CHROME_BROWSER_UI_INTENTS_WEB_INTENT_ICON_LOADER_H_
-
-#include "base/memory/weak_ptr.h"
-#include "chrome/browser/favicon/favicon_service.h"
-#include "chrome/common/cancelable_task_tracker.h"
-
-class Profile;
-class WebIntentPickerModel;
-
-namespace net {
- class URLFetcher;
-}
-
-namespace web_intents {
-
-class IconLoader {
- public:
- IconLoader(Profile* profile, WebIntentPickerModel* model);
- ~IconLoader();
-
- // Load the favicon associated with |url|.
- void LoadFavicon(const GURL& url);
-
- // Load an extension icon
- void LoadExtensionIcon(const GURL& url, const std::string& extension_id);
-
- private:
- // Called when a favicon is returned from the FaviconService.
- void OnFaviconDataAvailable(const GURL& url,
- const history::FaviconImageResult& image_result);
-
- // Called when a suggested extension's icon is fetched.
- void OnExtensionIconURLFetchComplete(const std::string& extension_id,
- const net::URLFetcher* source);
-
- // Called when an extension's icon is successfully decoded and resized.
- void OnExtensionIconAvailable(const std::string& extension_id,
- const gfx::Image& icon_image);
-
- // A weak pointer to the profile for the web contents.
- Profile* profile_;
-
- // A weak pointer to the model being updated.
- WebIntentPickerModel* model_;
-
- // Used to asynchronously load favicons.
- CancelableTaskTracker cancelable_task_tracker_;
-
- // Factory for weak pointers used in callbacks for async calls to load icon.
- base::WeakPtrFactory<IconLoader> weak_ptr_factory_;
-
- DISALLOW_COPY_AND_ASSIGN(IconLoader);
-};
-
-} // namespace web_intents;
-
-#endif // CHROME_BROWSER_UI_INTENTS_WEB_INTENT_ICON_LOADER_H_
diff --git a/chrome/browser/ui/intents/web_intent_inline_disposition_delegate.cc b/chrome/browser/ui/intents/web_intent_inline_disposition_delegate.cc
deleted file mode 100644
index 4e13774..0000000
--- a/chrome/browser/ui/intents/web_intent_inline_disposition_delegate.cc
+++ /dev/null
@@ -1,136 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/ui/intents/web_intent_inline_disposition_delegate.h"
-
-#include "base/logging.h"
-#include "chrome/browser/ui/browser.h"
-#include "chrome/browser/ui/browser_tabstrip.h"
-#include "chrome/browser/ui/intents/web_intent_picker.h"
-#include "chrome/common/extensions/extension_messages.h"
-#include "content/public/browser/navigation_controller.h"
-#include "content/public/browser/render_view_host.h"
-#include "content/public/browser/web_contents.h"
-#include "content/public/common/renderer_preferences.h"
-#include "ipc/ipc_message_macros.h"
-
-WebIntentInlineDispositionDelegate::WebIntentInlineDispositionDelegate(
- WebIntentPicker* picker,
- content::WebContents* contents,
- Browser* browser)
- : picker_(picker),
- web_contents_(contents),
- browser_(browser),
- ALLOW_THIS_IN_INITIALIZER_LIST(
- extension_function_dispatcher_(browser->profile(), this)) {
- content::WebContentsObserver::Observe(web_contents_);
- web_contents_->SetDelegate(this);
- // TODO(groby): Technically, allowing the browser to hande all requests
- // should work just fine. Practically, we're getting a cross-origin warning
- // for a googleapis request.
- // Investigate why OpenURLFromTab delegate misfires on this.
- // web_contents_->GetMutableRendererPrefs()->browser_handles_all_requests =
- // true;
-}
-
-WebIntentInlineDispositionDelegate::~WebIntentInlineDispositionDelegate() {
-}
-
-bool WebIntentInlineDispositionDelegate::IsPopupOrPanel(
- const content::WebContents* source) const {
- return true;
-}
-
-content::WebContents* WebIntentInlineDispositionDelegate::OpenURLFromTab(
- content::WebContents* source, const content::OpenURLParams& params) {
- DCHECK(source); // Can only be invoked from inline disposition.
-
- // Load in place.
- source->GetController().LoadURL(params.url, content::Referrer(),
- content::PAGE_TRANSITION_AUTO_TOPLEVEL, std::string());
-
- // Remove previous history entries - users should not navigate in intents.
- source->GetController().PruneAllButActive();
-
- return source;
-}
-
-void WebIntentInlineDispositionDelegate::AddNewContents(
- content::WebContents* source,
- content::WebContents* new_contents,
- WindowOpenDisposition disposition,
- const gfx::Rect& initial_pos,
- bool user_gesture,
- bool* was_blocked) {
- DCHECK_EQ(source, web_contents_);
- DCHECK_EQ(Profile::FromBrowserContext(new_contents->GetBrowserContext()),
- browser_->profile());
- // Force all links to open in a new tab, even when different disposition is
- // requested.
- disposition =
- disposition == NEW_BACKGROUND_TAB ? disposition : NEW_FOREGROUND_TAB;
- chrome::AddWebContents(browser_, NULL, new_contents, disposition, initial_pos,
- user_gesture, was_blocked);
-}
-
-void WebIntentInlineDispositionDelegate::LoadingStateChanged(
- content::WebContents* source) {
- if (!source->IsLoading())
- picker_->OnInlineDispositionWebContentsLoaded(source);
-}
-
-bool WebIntentInlineDispositionDelegate::OnMessageReceived(
- const IPC::Message& message) {
- bool handled = true;
- IPC_BEGIN_MESSAGE_MAP(WebIntentInlineDispositionDelegate, message)
- IPC_MESSAGE_HANDLER(ExtensionHostMsg_Request, OnRequest)
- IPC_MESSAGE_UNHANDLED(handled = false)
- IPC_END_MESSAGE_MAP()
- return handled;
-}
-
-void WebIntentInlineDispositionDelegate::RenderViewCreated(
- content::RenderViewHost* render_view_host) {
- render_view_host_ = render_view_host;
- SetRenderViewSizeLimits();
-}
-
-void WebIntentInlineDispositionDelegate::DocumentAvailableInMainFrame() {
- std::string css = "body { min-width:400px; }";
- render_view_host_->InsertCSS(string16(), css);
-}
-
-content::WebContents* WebIntentInlineDispositionDelegate::
- GetAssociatedWebContents() const {
- return NULL;
-}
-
-extensions::WindowController*
-WebIntentInlineDispositionDelegate::GetExtensionWindowController() const {
- return NULL;
-}
-
-void WebIntentInlineDispositionDelegate::OnRequest(
- const ExtensionHostMsg_Request_Params& params) {
- extension_function_dispatcher_.Dispatch(params,
- web_contents_->GetRenderViewHost());
-}
-
-void WebIntentInlineDispositionDelegate::ResizeDueToAutoResize(
- content::WebContents* source, const gfx::Size& pref_size) {
- DCHECK(picker_);
- picker_->OnInlineDispositionAutoResize(pref_size);
-}
-
-void WebIntentInlineDispositionDelegate::HandleKeyboardEvent(
- content::WebContents* source,
- const content::NativeWebKeyboardEvent& event) {
- picker_->OnInlineDispositionHandleKeyboardEvent(event);
-}
-
-void WebIntentInlineDispositionDelegate::SetRenderViewSizeLimits() {
- render_view_host_->EnableAutoResize(
- picker_->GetMinInlineDispositionSize(),
- picker_->GetMaxInlineDispositionSize());
-}
diff --git a/chrome/browser/ui/intents/web_intent_inline_disposition_delegate.h b/chrome/browser/ui/intents/web_intent_inline_disposition_delegate.h
deleted file mode 100644
index fdc7265..0000000
--- a/chrome/browser/ui/intents/web_intent_inline_disposition_delegate.h
+++ /dev/null
@@ -1,85 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_UI_INTENTS_WEB_INTENT_INLINE_DISPOSITION_DELEGATE_H_
-#define CHROME_BROWSER_UI_INTENTS_WEB_INTENT_INLINE_DISPOSITION_DELEGATE_H_
-
-#include "base/compiler_specific.h"
-#include "chrome/browser/extensions/extension_function_dispatcher.h"
-#include "content/public/browser/web_contents_delegate.h"
-#include "content/public/browser/web_contents_observer.h"
-
-class Browser;
-class WebIntentPicker;
-
-// This class is the policy delegate for the rendered page in the intents
-// inline disposition bubble. It also acts as a router for extension messages,
-// so we can invoke extension APIs in inline disposition contexts.
-class WebIntentInlineDispositionDelegate
- : public content::WebContentsDelegate,
- public content::WebContentsObserver,
- public ExtensionFunctionDispatcher::Delegate {
- public:
- // |picker| is notified when the web contents loading state changes. Must not
- // be NULL.
- // |contents| is the WebContents for the inline disposition.
- // |browser| is the browser inline disposition was invoked from.
- WebIntentInlineDispositionDelegate(WebIntentPicker* picker,
- content::WebContents* contents,
- Browser* browser);
- virtual ~WebIntentInlineDispositionDelegate();
-
- // WebContentsDelegate implementation.
- virtual bool IsPopupOrPanel(
- const content::WebContents* source) const OVERRIDE;
- virtual content::WebContents* OpenURLFromTab(
- content::WebContents* source,
- const content::OpenURLParams& params) OVERRIDE;
- virtual void AddNewContents(content::WebContents* source,
- content::WebContents* new_contents,
- WindowOpenDisposition disposition,
- const gfx::Rect& initial_pos,
- bool user_gesture,
- bool* was_blocked) OVERRIDE;
- virtual void LoadingStateChanged(content::WebContents* source) OVERRIDE;
- virtual void ResizeDueToAutoResize(content::WebContents* source,
- const gfx::Size& pref_size) OVERRIDE;
- virtual void HandleKeyboardEvent(
- content::WebContents* source,
- const content::NativeWebKeyboardEvent& event) OVERRIDE;
-
- // content::WebContentsObserver
- virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
- virtual void RenderViewCreated(
- content::RenderViewHost* render_view_host) OVERRIDE;
- virtual void DocumentAvailableInMainFrame() OVERRIDE;
-
- // ExtensionFunctionDispatcher::Delegate
- virtual extensions::WindowController* GetExtensionWindowController()
- const OVERRIDE;
- virtual content::WebContents* GetAssociatedWebContents() const OVERRIDE;
-
- // Message handlers.
- void OnRequest(const ExtensionHostMsg_Request_Params& params);
-
- // Updates the inline render view with a new max and min size.
- void SetRenderViewSizeLimits();
-
- private:
- // Picker to notify when loading state changes. Weak pointer.
- WebIntentPicker* picker_;
-
- // The WebContents container. Weak pointer.
- content::WebContents* web_contents_;
-
- Browser* browser_; // Weak pointer.
-
- // The RVH responsible for the RenderView. Weak pointer.
- content::RenderViewHost* render_view_host_;
-
- // Dispatch handler for extension APIs.
- ExtensionFunctionDispatcher extension_function_dispatcher_;
-};
-
-#endif // CHROME_BROWSER_UI_INTENTS_WEB_INTENT_INLINE_DISPOSITION_DELEGATE_H_
diff --git a/chrome/browser/ui/intents/web_intent_inline_disposition_delegate_unittest.cc b/chrome/browser/ui/intents/web_intent_inline_disposition_delegate_unittest.cc
deleted file mode 100644
index 1a03ab1..0000000
--- a/chrome/browser/ui/intents/web_intent_inline_disposition_delegate_unittest.cc
+++ /dev/null
@@ -1,59 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/ui/browser.h"
-#include "chrome/browser/ui/intents/web_intent_inline_disposition_delegate.h"
-#include "chrome/browser/ui/intents/web_intent_picker.h"
-#include "chrome/test/base/browser_with_test_window_test.h"
-#include "chrome/test/base/testing_profile.h"
-#include "content/public/browser/web_contents.h"
-#include "content/public/common/url_constants.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-class WebIntentPickerMock : public WebIntentPicker {
- public:
- virtual void Close() OVERRIDE {}
- virtual void SetActionString(const string16& action) OVERRIDE {}
- virtual void OnExtensionInstallSuccess(const std::string& id) OVERRIDE {}
- virtual void OnExtensionInstallFailure(const std::string& id) OVERRIDE {}
- virtual void OnInlineDispositionAutoResize(const gfx::Size& size) OVERRIDE {}
- virtual void OnPendingAsyncCompleted() OVERRIDE {}
- virtual void InvalidateDelegate() OVERRIDE {}
-};
-
-class WebIntentInlineDispositionBrowserTest
- : public BrowserWithTestWindowTest {
- public:
- virtual void SetUp() {
- BrowserWithTestWindowTest::SetUp();
-
- web_contents_.reset(content::WebContents::Create(
- content::WebContents::CreateParams(browser()->profile())));
- delegate_.reset(new WebIntentInlineDispositionDelegate(
- &mock_, web_contents_.get(), browser()));
- }
-
- protected:
- TestingProfile profile_;
- scoped_ptr<content::WebContents> web_contents_;
- scoped_ptr<WebIntentInlineDispositionDelegate> delegate_;
- WebIntentPickerMock mock_;
-};
-
-// Verifies delegate's OpenURLFromTab works. This allows navigation inside
-// web intents picker.
-TEST_F(WebIntentInlineDispositionBrowserTest, OpenURLFromTabTest) {
- content::WebContents* source = delegate_->OpenURLFromTab(
- web_contents_.get(),
- content::OpenURLParams(GURL(chrome::kAboutBlankURL),
- content::Referrer(),
- NEW_FOREGROUND_TAB,
- content::PAGE_TRANSITION_LINK,
- false));
-
- // Ensure OpenURLFromTab loaded about::blank in |web_contents_|.
- ASSERT_EQ(web_contents_.get(), source);
- EXPECT_EQ(GURL(chrome::kAboutBlankURL).spec(), source->GetURL().spec());
-}
diff --git a/chrome/browser/ui/intents/web_intent_picker.cc b/chrome/browser/ui/intents/web_intent_picker.cc
deleted file mode 100644
index 094a540..0000000
--- a/chrome/browser/ui/intents/web_intent_picker.cc
+++ /dev/null
@@ -1,87 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/ui/intents/web_intent_picker.h"
-
-#include <cmath>
-
-#include "base/utf_string_conversions.h"
-#include "chrome/browser/extensions/extension_install_prompt.h"
-#include "chrome/browser/intents/web_intents_util.h"
-#include "content/public/browser/web_contents.h"
-#include "content/public/browser/web_contents_view.h"
-#include "grit/generated_resources.h"
-#include "grit/theme_resources.h"
-#include "ui/base/l10n/l10n_util.h"
-#include "ui/gfx/size.h"
-
-namespace {
-
-// Maximum inline disposition container sizes.
-const int kMaxInlineDispositionWidth = 900;
-const int kMaxInlineDispositionHeight = 900;
-
-} // namespace
-
-void WebIntentPicker::OnShowExtensionInstallDialog(
- const ExtensionInstallPrompt::ShowParams& show_params,
- ExtensionInstallPrompt::Delegate* delegate,
- const ExtensionInstallPrompt::Prompt& prompt) {
- ExtensionInstallPrompt::GetDefaultShowDialogCallback().Run(
- show_params, delegate, prompt);
-}
-
-gfx::Size WebIntentPicker::GetMinInlineDispositionSize() {
- return gfx::Size(1, 1);
-}
-
-gfx::Size WebIntentPicker::GetMaxInlineDispositionSize() {
- return gfx::Size(kMaxInlineDispositionWidth, kMaxInlineDispositionHeight);
-}
-
-// static
-int WebIntentPicker::GetNthStarImageIdFromCWSRating(double rating, int index) {
- // The fractional part of the rating is converted to stars as:
- // [0, 0.33) -> round down
- // [0.33, 0.66] -> half star
- // (0.66, 1) -> round up
- const double kHalfStarMin = 0.33;
- const double kHalfStarMax = 0.66;
-
- // Add 1 + kHalfStarMax to make values with fraction > 0.66 round up.
- int full_stars = std::floor(rating + 1 - kHalfStarMax);
-
- if (index < full_stars)
- return IDR_CWS_STAR_FULL;
-
- // We don't need to test against the upper bound (kHalfStarMax); when the
- // fractional part is greater than kHalfStarMax, full_stars will be rounded
- // up, which means rating - full_stars is negative.
- bool half_star = rating - full_stars >= kHalfStarMin;
-
- return index == full_stars && half_star ?
- IDR_CWS_STAR_HALF :
- IDR_CWS_STAR_EMPTY;
-}
-
-// static
-string16 WebIntentPicker::GetDisplayStringForIntentAction(
- const string16& action16) {
- std::string action(UTF16ToUTF8(action16));
- if (!action.compare(web_intents::kActionShare))
- return l10n_util::GetStringUTF16(IDS_WEB_INTENTS_ACTION_SHARE);
- else if (!action.compare(web_intents::kActionEdit))
- return l10n_util::GetStringUTF16(IDS_WEB_INTENTS_ACTION_EDIT);
- else if (!action.compare(web_intents::kActionView))
- return l10n_util::GetStringUTF16(IDS_WEB_INTENTS_ACTION_VIEW);
- else if (!action.compare(web_intents::kActionPick))
- // Using generic string per UX suggestions.
- return l10n_util::GetStringUTF16(IDS_INTENT_PICKER_CHOOSE_SERVICE);
- else if (!action.compare(web_intents::kActionSubscribe))
- return l10n_util::GetStringUTF16(IDS_WEB_INTENTS_ACTION_SUBSCRIBE);
- else if (!action.compare(web_intents::kActionSave))
- return l10n_util::GetStringUTF16(IDS_WEB_INTENTS_ACTION_SAVE);
- else
- return l10n_util::GetStringUTF16(IDS_INTENT_PICKER_CHOOSE_SERVICE);
-}
diff --git a/chrome/browser/ui/intents/web_intent_picker.h b/chrome/browser/ui/intents/web_intent_picker.h
deleted file mode 100644
index 6ba3c4c..0000000
--- a/chrome/browser/ui/intents/web_intent_picker.h
+++ /dev/null
@@ -1,130 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_UI_INTENTS_WEB_INTENT_PICKER_H_
-#define CHROME_BROWSER_UI_INTENTS_WEB_INTENT_PICKER_H_
-
-#include <stddef.h>
-#include <string>
-#include <vector>
-
-#include "base/string16.h"
-#include "chrome/browser/extensions/extension_install_prompt.h"
-#include "ui/gfx/size.h"
-
-class WebIntentPickerDelegate;
-class WebIntentPickerModel;
-
-namespace content {
-struct NativeWebKeyboardEvent;
-class WebContents;
-}
-
-// Base class for the web intent picker dialog.
-class WebIntentPicker {
- public:
- // The minimum width of the window.
- static const int kWindowMinWidth = 400;
-
- // The maximum width the window.
- static const int kWindowMaxWidth = 900;
-
- // The minimum height of the window.
- static const int kWindowMinHeight = 145;
-
- // The maximum width in view units of a suggested extension's title link.
- static const int kTitleLinkMaxWidth = 130;
-
- // The space in pixels between the top-level groups and the dialog border.
- static const int kContentAreaBorder = 20;
-
- // Vertical space above the separator.
- static const int kHeaderSeparatorPaddingTop = 16;
-
- // Vertical space below the separator.
- static const int kHeaderSeparatorPaddingBottom = 7;
-
- // Width of the service icon.
- static const int kServiceIconWidth = 16;
-
- // Height of the service icon.
- static const int kServiceIconHeight = 16;
-
- // Space between icon and text.
- static const int kIconTextPadding = 10;
-
- // Space between star rating and select button.
- static const int kStarButtonPadding = 20;
-
- // The height of the suggested and installed service row.
- static const int kServiceRowHeight = 32;
-
- // The maximum number of installed services + suggested servcies to show. Note
- // that all installed services are always shown so the actual number of
- // services shown maybe greater than this.
- static const int kMaxServicesToShow = 4;
-
- // Platform specific factory function. This function will automatically show
- // the picker.
- static WebIntentPicker* Create(content::WebContents* web_contents,
- WebIntentPickerDelegate* delegate,
- WebIntentPickerModel* model);
-
- // Hides the UI for this picker, and destroys its UI.
- virtual void Close() = 0;
-
- // Sets the action string of the picker, e.g.,
- // "Which service should be used for sharing?".
- virtual void SetActionString(const string16& action) = 0;
-
- // Called when an extension is successfully installed via the picker.
- virtual void OnExtensionInstallSuccess(const std::string& id) = 0;
-
- // Called when an extension installation started via the picker has failed.
- virtual void OnExtensionInstallFailure(const std::string& id) = 0;
-
- // Shows the default extension install dialog. Override this to show a custom
- // dialog. We *MUST* eventually call either Proceed() or Abort() on
- // |delegate|.
- virtual void OnShowExtensionInstallDialog(
- const ExtensionInstallPrompt::ShowParams& show_params,
- ExtensionInstallPrompt::Delegate* delegate,
- const ExtensionInstallPrompt::Prompt& prompt);
-
- // Called when the inline disposition experiences an auto-resize.
- virtual void OnInlineDispositionAutoResize(const gfx::Size& size) = 0;
-
- virtual void OnInlineDispositionHandleKeyboardEvent(
- const content::NativeWebKeyboardEvent& event) {}
-
- // Called when the controller has finished all pending asynchronous
- // activities.
- virtual void OnPendingAsyncCompleted() = 0;
-
- // Called once the delegate gets destroyed/invalid. This should only be
- // called during a shut down sequence that will tear down the picker, too.
- virtual void InvalidateDelegate() = 0;
-
- // Called when the inline disposition's web contents have been loaded.
- virtual void OnInlineDispositionWebContentsLoaded(
- content::WebContents* web_contents) {}
-
- // Get the minimum size of the inline disposition content container.
- virtual gfx::Size GetMinInlineDispositionSize();
-
- // Get the maximum size of the inline disposition content container.
- virtual gfx::Size GetMaxInlineDispositionSize();
-
- // Get the star image IDs to use for the nth star (out of 5), given a
- // |rating| in the range [0, 5].
- static int GetNthStarImageIdFromCWSRating(double rating, int index);
-
- // Returns the action-specific string to display for |action|.
- static string16 GetDisplayStringForIntentAction(const string16& action16);
-
- protected:
- virtual ~WebIntentPicker() {}
-};
-
-#endif // CHROME_BROWSER_UI_INTENTS_WEB_INTENT_PICKER_H_
diff --git a/chrome/browser/ui/intents/web_intent_picker_controller.cc b/chrome/browser/ui/intents/web_intent_picker_controller.cc
deleted file mode 100644
index 185b3ef..0000000
--- a/chrome/browser/ui/intents/web_intent_picker_controller.cc
+++ /dev/null
@@ -1,972 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/ui/intents/web_intent_picker_controller.h"
-
-#include <vector>
-
-#include "base/bind.h"
-#include "base/bind_helpers.h"
-#include "base/md5.h"
-#include "base/memory/scoped_ptr.h"
-#include "base/time.h"
-#include "base/utf_string_conversions.h"
-#include "chrome/browser/download/download_item_model.h"
-#include "chrome/browser/extensions/extension_service.h"
-#include "chrome/browser/extensions/extension_system.h"
-#include "chrome/browser/extensions/platform_app_launcher.h"
-#include "chrome/browser/extensions/webstore_installer.h"
-#include "chrome/browser/intents/cws_intents_registry_factory.h"
-#include "chrome/browser/intents/default_web_intent_service.h"
-#include "chrome/browser/intents/intent_service_host.h"
-#include "chrome/browser/intents/native_services.h"
-#include "chrome/browser/intents/web_intents_registry_factory.h"
-#include "chrome/browser/intents/web_intents_reporting.h"
-#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/tab_contents/tab_util.h"
-#include "chrome/browser/ui/browser.h"
-#include "chrome/browser/ui/browser_finder.h"
-#include "chrome/browser/ui/browser_list.h"
-#include "chrome/browser/ui/browser_navigator.h"
-#include "chrome/browser/ui/browser_tabstrip.h"
-#include "chrome/browser/ui/browser_window.h"
-#include "chrome/browser/ui/intents/web_intent_icon_loader.h"
-#include "chrome/browser/ui/intents/web_intent_picker.h"
-#include "chrome/browser/ui/intents/web_intent_picker_model.h"
-#include "chrome/browser/ui/tabs/tab_strip_model.h"
-#include "chrome/browser/ui/web_contents_modal_dialog_manager.h"
-#include "chrome/browser/webdata/web_data_service.h"
-#include "chrome/common/url_constants.h"
-#include "content/public/browser/browser_thread.h"
-#include "content/public/browser/download_manager.h"
-#include "content/public/browser/web_contents.h"
-#include "content/public/browser/web_contents_observer.h"
-#include "content/public/browser/web_intents_dispatcher.h"
-#include "ui/gfx/favicon_size.h"
-#include "ui/gfx/image/image.h"
-
-using extensions::WebstoreInstaller;
-
-DEFINE_WEB_CONTENTS_USER_DATA_KEY(WebIntentPickerController);
-
-namespace {
-
-// Maximum amount of time to delay displaying dialog while waiting for data.
-const int kMaxHiddenSetupTimeMs = 200;
-
-// Minimum amount of time to show waiting dialog, if it is shown.
-const int kMinThrobberDisplayTimeMs = 800;
-
-// Gets the web intents registry for the specified profile.
-WebIntentsRegistry* GetWebIntentsRegistry(Profile* profile) {
- return WebIntentsRegistryFactory::GetForProfile(profile);
-}
-
-// Gets the Chrome web store intents registry for the specified profile.
-CWSIntentsRegistry* GetCWSIntentsRegistry(Profile* profile) {
- return CWSIntentsRegistryFactory::GetForProfile(profile);
-}
-
-class SourceWindowObserver : content::WebContentsObserver {
- public:
- SourceWindowObserver(content::WebContents* web_contents,
- base::WeakPtr<WebIntentPickerController> controller)
- : content::WebContentsObserver(web_contents),
- controller_(controller) {}
- virtual ~SourceWindowObserver() {}
-
- // Implement WebContentsObserver
- virtual void WebContentsDestroyed(
- content::WebContents* web_contents) OVERRIDE {
- if (controller_)
- controller_->SourceWebContentsDestroyed(web_contents);
- delete this;
- }
-
- private:
- base::WeakPtr<WebIntentPickerController> controller_;
-};
-
-// Deletes |service|, presumably called from a dispatcher callback.
-void DeleteIntentService(
- web_intents::IntentServiceHost* service,
- webkit_glue::WebIntentReplyType type) {
- delete service;
-}
-
-} // namespace
-
-// UMAReporter handles reporting Web Intents events to UMA.
-class WebIntentPickerController::UMAReporter {
- public:
-
- // Resets the service active duration timer to "now".
- void ResetServiceActiveTimer();
-
- // Records the duration of time spent using the service. Uses |reply_type|
- // to distinguish between successful and failed service calls.
- void RecordServiceActiveDuration(webkit_glue::WebIntentReplyType reply_type);
-
- private:
-
- // The time when the user began using the service.
- base::TimeTicks service_start_time_;
-};
-
-void WebIntentPickerController::UMAReporter::ResetServiceActiveTimer() {
- service_start_time_ = base::TimeTicks::Now();
-}
-
-void WebIntentPickerController::UMAReporter::RecordServiceActiveDuration(
- webkit_glue::WebIntentReplyType reply_type) {
- if (!service_start_time_.is_null()) {
- web_intents::RecordServiceActiveDuration(reply_type,
- base::TimeTicks::Now() - service_start_time_);
- }
-}
-
-WebIntentPickerController::WebIntentPickerController(
- content::WebContents* web_contents)
- : dialog_state_(kPickerHidden),
- web_contents_(web_contents),
- profile_(Profile::FromBrowserContext(web_contents->GetBrowserContext())),
- picker_(NULL),
- picker_model_(new WebIntentPickerModel()),
- uma_reporter_(new UMAReporter()),
- pending_async_count_(0),
- pending_registry_calls_count_(0),
- pending_cws_request_(false),
- picker_shown_(false),
- window_disposition_source_(NULL),
- source_intents_dispatcher_(NULL),
- intents_dispatcher_(NULL),
- location_bar_button_indicated_(true),
- service_tab_(NULL),
- icon_loader_(NULL),
- ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)),
- ALLOW_THIS_IN_INITIALIZER_LIST(timer_factory_(this)),
- ALLOW_THIS_IN_INITIALIZER_LIST(dispatcher_factory_(this)) {
- native_services_.reset(new web_intents::NativeServiceFactory());
-#if defined(TOOLKIT_VIEWS)
- cancelled_ = true;
-#endif
- icon_loader_.reset(
- new web_intents::IconLoader(profile_, picker_model_.get()));
-}
-
-WebIntentPickerController::~WebIntentPickerController() {
- if (picker_)
- picker_->InvalidateDelegate();
- if (webstore_installer_.get())
- webstore_installer_->InvalidateDelegate();
-}
-
-// TODO(gbillock): combine this with ShowDialog.
-void WebIntentPickerController::SetIntentsDispatcher(
- content::WebIntentsDispatcher* intents_dispatcher) {
- // TODO(gbillock): This is to account for multiple dispatches in the same tab.
- // That is currently not a well-handled case, and this is a band-aid.
- dispatcher_factory_.InvalidateWeakPtrs();
- intents_dispatcher_ = intents_dispatcher;
- intents_dispatcher_->RegisterReplyNotification(
- base::Bind(&WebIntentPickerController::OnSendReturnMessage,
- dispatcher_factory_.GetWeakPtr()));
-
- // Initialize the reporting bucket.
- const webkit_glue::WebIntentData& intent = intents_dispatcher_->GetIntent();
- uma_bucket_ = web_intents::ToUMABucket(intent.action, intent.type);
-}
-
-// TODO(smckay): rename this "StartActivity".
-void WebIntentPickerController::ShowDialog(const string16& action,
- const string16& type) {
- ShowDialog(kEnableDefaults);
-}
-
-void WebIntentPickerController::ReshowDialog() {
- ShowDialog(kSuppressDefaults);
-}
-
-void WebIntentPickerController::ShowDialog(DefaultsUsage suppress_defaults) {
- web_intents::RecordIntentDispatched(uma_bucket_);
-
- DCHECK(intents_dispatcher_);
-
-#if defined(TOOLKIT_VIEWS)
- cancelled_ = true;
-#endif
-
- // Only show a picker once.
- // TODO(gbillock): There's a hole potentially admitting multiple
- // in-flight dispatches since we don't create the picker
- // in this method, but only after calling the registry.
- if (picker_shown_) {
- intents_dispatcher_->SendReply(webkit_glue::WebIntentReply(
- webkit_glue::WEB_INTENT_REPLY_FAILURE,
- ASCIIToUTF16("Simultaneous intent invocation.")));
- return;
- }
-
- // TODO(binji): Figure out what to do when intents are invoked from incognito
- // mode.
- if (profile_->IsOffTheRecord()) {
- intents_dispatcher_->SendReply(webkit_glue::WebIntentReply(
- webkit_glue::WEB_INTENT_REPLY_FAILURE, string16()));
- return;
- }
-
- picker_model_->Clear();
- picker_model_->set_action(intents_dispatcher_->GetIntent().action);
- picker_model_->set_type(intents_dispatcher_->GetIntent().type);
-
- // If the intent is explicit, skip showing the picker.
- const GURL& service = intents_dispatcher_->GetIntent().service;
- // TODO(gbillock): Decide whether to honor the default suppression flag
- // here or suppress the control for explicit intents.
- if (service.is_valid() && !suppress_defaults) {
- // Get services from the registry to verify a registered extension
- // page for this action/type if it is permitted to be dispatched. (Also
- // required to find disposition set by service.)
- pending_async_count_++;
- GetWebIntentsRegistry(profile_)->GetIntentServices(
- picker_model_->action(), picker_model_->type(),
- base::Bind(
- &WebIntentPickerController::
- OnWebIntentServicesAvailableForExplicitIntent,
- weak_ptr_factory_.GetWeakPtr()));
- return;
- }
-
- // As soon as the dialog is requested, block all input events
- // on the original tab.
- WebContentsModalDialogManager* web_contents_modal_dialog_manager =
- WebContentsModalDialogManager::FromWebContents(web_contents_);
- web_contents_modal_dialog_manager->BlockWebContentsInteraction(true);
- SetDialogState(kPickerSetup);
-
- pending_async_count_++;
- pending_registry_calls_count_++;
- GetWebIntentsRegistry(profile_)->GetIntentServices(
- picker_model_->action(), picker_model_->type(),
- base::Bind(&WebIntentPickerController::OnWebIntentServicesAvailable,
- weak_ptr_factory_.GetWeakPtr()));
-
- GURL invoking_url = web_contents_->GetURL();
- if (invoking_url.is_valid() && !suppress_defaults) {
- pending_async_count_++;
- pending_registry_calls_count_++;
- GetWebIntentsRegistry(profile_)->GetDefaultIntentService(
- picker_model_->action(), picker_model_->type(), invoking_url,
- base::Bind(&WebIntentPickerController::OnWebIntentDefaultsAvailable,
- weak_ptr_factory_.GetWeakPtr()));
- }
-
- pending_cws_request_ = true;
- pending_async_count_++;
- GetCWSIntentsRegistry(profile_)->GetIntentServices(
- picker_model_->action(), picker_model_->type(),
- base::Bind(&WebIntentPickerController::OnCWSIntentServicesAvailable,
- weak_ptr_factory_.GetWeakPtr()));
-}
-
-void WebIntentPickerController::OnServiceChosen(
- const GURL& url,
- webkit_glue::WebIntentServiceData::Disposition disposition,
- DefaultsUsage suppress_defaults) {
- web_intents::RecordServiceInvoke(uma_bucket_);
- uma_reporter_->ResetServiceActiveTimer();
- ExtensionService* extension_service =
- extensions::ExtensionSystem::Get(profile_)->extension_service();
- DCHECK(extension_service);
-
-#if defined(TOOLKIT_VIEWS)
- cancelled_ = false;
-#endif
-
- // Set the default here. Activating the intent resets the picker model.
- // TODO(gbillock): we should perhaps couple the model to the dispatcher so
- // we can re-activate the model on use-another-service.
- if (!suppress_defaults)
- SetDefaultServiceForSelection(url);
-
-
- // TODO(smckay): this basically smells like another disposition.
- const extensions::Extension* extension =
- extension_service->GetInstalledApp(url);
- if (extension && extension->is_platform_app()) {
- extensions::LaunchPlatformAppWithWebIntent(profile_,
- extension, intents_dispatcher_, web_contents_);
- ClosePicker();
- return;
- }
-
- // TODO(smckay): This entire method shold basically be pulled out
- // into a separate class dedicated to the execution of intents.
- // The tricky part is with the "INLINE" disposition where we
- // want to (re)use the picker to handle the intent. A bit of
- // artful composition + lazy instantiation should make that possible.
- switch (disposition) {
- case webkit_glue::WebIntentServiceData::DISPOSITION_NATIVE: {
- web_intents::IntentServiceHost* service =
- native_services_->CreateServiceInstance(
- url, intents_dispatcher_->GetIntent(), web_contents_);
- DCHECK(service);
-
- intents_dispatcher_->RegisterReplyNotification(
- base::Bind(&DeleteIntentService, base::Unretained(service)));
-
- service->HandleIntent(intents_dispatcher_);
- break;
- }
-
- case webkit_glue::WebIntentServiceData::DISPOSITION_INLINE: {
- // Set the model to inline disposition. It will notify the picker which
- // will respond (via OnInlineDispositionWebContentsCreated) with the
- // WebContents to dispatch the intent to.
- picker_model_->SetInlineDisposition(url);
- break;
- }
-
- case webkit_glue::WebIntentServiceData::DISPOSITION_WINDOW: {
- content::WebContents* contents = content::WebContents::Create(
- content::WebContents::CreateParams(
- profile_, tab_util::GetSiteInstanceForNewTab(profile_, url)));
- WebIntentPickerController::CreateForWebContents(contents);
-
- // Let the controller for the target WebContents know that it is hosting a
- // web intents service. Suppress if we're not showing the
- // use-another-service button.
- if (picker_model_->show_use_another_service()) {
- WebIntentPickerController::FromWebContents(contents)->
- SetWindowDispositionSource(web_contents_, intents_dispatcher_);
- }
-
- intents_dispatcher_->DispatchIntent(contents);
- service_tab_ = contents;
-
- // This call performs all the tab strip manipulation, notifications, etc.
- // Since we're passing in a target_contents, it assumes that we will
- // navigate the page ourselves, though.
- chrome::NavigateParams params(profile_, url,
- content::PAGE_TRANSITION_LINK);
- params.target_contents = contents;
- params.disposition = NEW_FOREGROUND_TAB;
- params.tabstrip_add_types = TabStripModel::ADD_INHERIT_GROUP;
- chrome::Navigate(&params);
-
- service_tab_->GetController().LoadURL(
- url, content::Referrer(),
- content::PAGE_TRANSITION_AUTO_BOOKMARK, std::string());
-
- ClosePicker();
- break;
- }
-
- default:
- NOTREACHED();
- break;
- }
-}
-
-content::WebContents*
-WebIntentPickerController::CreateWebContentsForInlineDisposition(
- Profile* profile, const GURL& url) {
- content::WebContents::CreateParams create_params(
- profile, tab_util::GetSiteInstanceForNewTab(profile, url));
- content::WebContents* web_contents = content::WebContents::Create(
- create_params);
- intents_dispatcher_->DispatchIntent(web_contents);
- return web_contents;
-}
-
-void WebIntentPickerController::SetDefaultServiceForSelection(const GURL& url) {
- DCHECK(picker_model_.get());
- if (url == picker_model_->default_service_url())
- return;
-
- DefaultWebIntentService record;
- record.action = picker_model_->action();
- record.type = picker_model_->type();
- record.service_url = url.spec();
- record.user_date = static_cast<int>(floor(base::Time::Now().ToDoubleT()));
- GetWebIntentsRegistry(profile_)->RegisterDefaultIntentService(record);
-}
-
-void WebIntentPickerController::OnExtensionInstallRequested(
- const std::string& id) {
- // Create a local copy of |id| since it is a reference to a member on a UI
- // object, and SetPendingExtensionInstallId triggers an OnModelChanged and
- // a subsequent rebuild of UI objects.
- std::string extension_id(id);
-
- picker_model_->SetPendingExtensionInstallId(extension_id);
-
- scoped_ptr<WebstoreInstaller::Approval> approval(
- WebstoreInstaller::Approval::CreateWithInstallPrompt(profile_));
- // Don't show a bubble pointing to the extension or any other post
- // installation UI.
- approval->skip_post_install_ui = true;
- approval->show_dialog_callback = base::Bind(
- &WebIntentPickerController::OnShowExtensionInstallDialog,
- weak_ptr_factory_.GetWeakPtr());
-
- webstore_installer_ = new WebstoreInstaller(profile_, this,
- &web_contents_->GetController(), extension_id,
- approval.Pass(), WebstoreInstaller::FLAG_INLINE_INSTALL);
-
- pending_async_count_++;
- webstore_installer_->Start();
-}
-
-void WebIntentPickerController::OnExtensionLinkClicked(
- const std::string& id,
- WindowOpenDisposition disposition) {
- // Navigate from source tab.
- GURL extension_url(extension_urls::GetWebstoreItemDetailURLPrefix() + id);
- chrome::NavigateParams params(profile_, extension_url,
- content::PAGE_TRANSITION_LINK);
- params.disposition =
- (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition;
- chrome::Navigate(&params);
-}
-
-void WebIntentPickerController::OnSuggestionsLinkClicked(
- WindowOpenDisposition disposition) {
- // Navigate from source tab.
- GURL query_url = extension_urls::GetWebstoreIntentQueryURL(
- UTF16ToUTF8(picker_model_->action()),
- UTF16ToUTF8(picker_model_->type()));
- chrome::NavigateParams params(profile_, query_url,
- content::PAGE_TRANSITION_LINK);
- params.disposition =
- (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition;
- chrome::Navigate(&params);
-}
-
-void WebIntentPickerController::OnUserCancelledPickerDialog() {
- if (!intents_dispatcher_)
- return;
-
- intents_dispatcher_->SendReply(webkit_glue::WebIntentReply(
- webkit_glue::WEB_INTENT_PICKER_CANCELLED, string16()));
- web_intents::RecordPickerCancel(uma_bucket_);
-
- ClosePicker();
-}
-
-void WebIntentPickerController::OnChooseAnotherService() {
- DCHECK(intents_dispatcher_);
- web_intents::RecordChooseAnotherService(uma_bucket_);
- intents_dispatcher_->ResetDispatch();
- picker_model_->SetInlineDisposition(GURL::EmptyGURL());
-}
-
-void WebIntentPickerController::OnClosing() {
- SetDialogState(kPickerHidden);
- picker_ = NULL;
- picker_model_->ClearPendingExtensionInstall();
- CancelDownload();
-#if defined(TOOLKIT_VIEWS)
- if (cancelled_)
- OnUserCancelledPickerDialog();
-#endif
-}
-
-void WebIntentPickerController::OnExtensionDownloadStarted(
- const std::string& id,
- content::DownloadItem* item) {
- DownloadItemModel(item).SetShouldShowInShelf(false);
- download_id_ = item->GetGlobalId();
- picker_model_->UpdateExtensionDownloadState(item);
-}
-
-void WebIntentPickerController::OnExtensionDownloadProgress(
- const std::string& id,
- content::DownloadItem* item) {
- picker_model_->UpdateExtensionDownloadState(item);
-}
-
-void WebIntentPickerController::OnExtensionInstallSuccess(
- const std::string& extension_id) {
- webstore_installer_ = NULL; // Release reference.
-
- // OnExtensionInstallSuccess is called via NotificationService::Notify before
- // the extension is added to the ExtensionService. Dispatch via PostTask to
- // allow ExtensionService to update.
- MessageLoop::current()->PostTask(
- FROM_HERE,
- base::Bind(
- &WebIntentPickerController::DispatchToInstalledExtension,
- base::Unretained(this),
- extension_id));
-}
-
-void WebIntentPickerController::DispatchToInstalledExtension(
- const std::string& extension_id) {
- web_intents::RecordCWSExtensionInstalled(uma_bucket_);
-
- download_id_ = content::DownloadId();
- picker_model_->ClearPendingExtensionInstall();
- if (picker_)
- picker_->OnExtensionInstallSuccess(extension_id);
-
- WebIntentsRegistry::IntentServiceList services;
- GetWebIntentsRegistry(profile_)->GetIntentServicesForExtensionFilter(
- picker_model_->action(), picker_model_->type(),
- extension_id,
- &services);
-
- // Extension must be registered with registry by now.
- DCHECK(services.size() > 0);
-
- // TODO(binji): We're going to need to disambiguate if there are multiple
- // services. For now, just choose the first.
- const webkit_glue::WebIntentServiceData& service_data = services[0];
-
- picker_model_->RemoveSuggestedExtension(extension_id);
- AddServiceToModel(service_data);
- OnServiceChosen(service_data.service_url, service_data.disposition,
- kEnableDefaults);
- AsyncOperationFinished();
-}
-
-void WebIntentPickerController::OnExtensionInstallFailure(
- const std::string& id,
- const std::string& error,
- WebstoreInstaller::FailureReason reason) {
- webstore_installer_ = NULL; // Release reference.
-
- // If the user cancelled the install then don't show an error message.
- if (reason == WebstoreInstaller::FAILURE_REASON_CANCELLED)
- picker_model_->ClearPendingExtensionInstall();
- else
- picker_model_->SetPendingExtensionInstallStatusString(UTF8ToUTF16(error));
-
- if (picker_)
- picker_->OnExtensionInstallFailure(id);
- AsyncOperationFinished();
-}
-
-void WebIntentPickerController::OnSendReturnMessage(
- webkit_glue::WebIntentReplyType reply_type) {
- ClosePicker();
- uma_reporter_->RecordServiceActiveDuration(reply_type);
-
- if (service_tab_ &&
- reply_type != webkit_glue::WEB_INTENT_SERVICE_CONTENTS_CLOSED) {
- Browser* browser = chrome::FindBrowserWithWebContents(service_tab_);
- if (browser) {
- int index = browser->tab_strip_model()->GetIndexOfWebContents(
- service_tab_);
- browser->tab_strip_model()->CloseWebContentsAt(
- index, TabStripModel::CLOSE_CREATE_HISTORICAL_TAB);
-
- // Activate source tab.
- Browser* source_browser =
- chrome::FindBrowserWithWebContents(web_contents_);
- if (source_browser) {
- int source_index = source_browser->tab_strip_model()->
- GetIndexOfWebContents(web_contents_);
- source_browser->tab_strip_model()->ActivateTabAt(source_index, false);
- }
- }
- service_tab_ = NULL;
- }
-
- intents_dispatcher_ = NULL;
-}
-
-void WebIntentPickerController::AddServiceToModel(
- const webkit_glue::WebIntentServiceData& service) {
-
- picker_model_->AddInstalledService(
- service.title,
- service.service_url,
- service.disposition);
-
- icon_loader_->LoadFavicon(service.service_url);
-}
-
-void WebIntentPickerController::OnWebIntentServicesAvailable(
- const std::vector<webkit_glue::WebIntentServiceData>& services) {
- for (size_t i = 0; i < services.size(); ++i)
- AddServiceToModel(services[i]);
-
- RegistryCallsCompleted();
- AsyncOperationFinished();
-}
-
-void WebIntentPickerController::OnWebIntentServicesAvailableForExplicitIntent(
- const std::vector<webkit_glue::WebIntentServiceData>& services) {
- DCHECK(intents_dispatcher_);
- DCHECK(intents_dispatcher_->GetIntent().service.is_valid());
- for (size_t i = 0; i < services.size(); ++i) {
- if (services[i].service_url != intents_dispatcher_->GetIntent().service)
- continue;
-
- InvokeServiceWithSelection(services[i]);
- AsyncOperationFinished();
- return;
- }
-
- // No acceptable extension. The intent cannot be dispatched.
- intents_dispatcher_->SendReply(webkit_glue::WebIntentReply(
- webkit_glue::WEB_INTENT_REPLY_FAILURE, ASCIIToUTF16(
- "Explicit extension URL is not available.")));
-
- AsyncOperationFinished();
-}
-
-void WebIntentPickerController::OnWebIntentDefaultsAvailable(
- const DefaultWebIntentService& default_service) {
- if (!default_service.service_url.empty()) {
- // TODO(gbillock): this doesn't belong in the model, but keep it there
- // for now.
- picker_model_->set_default_service_url(GURL(default_service.service_url));
- }
-
- RegistryCallsCompleted();
- AsyncOperationFinished();
-}
-
-void WebIntentPickerController::RegistryCallsCompleted() {
- pending_registry_calls_count_--;
- if (pending_registry_calls_count_ != 0) return;
-
- if (picker_model_->default_service_url().is_valid()) {
- // If there's a default service, dispatch to it immediately
- // without showing the picker.
- const WebIntentPickerModel::InstalledService* default_service =
- picker_model_->GetInstalledServiceWithURL(
- GURL(picker_model_->default_service_url()));
- if (default_service != NULL) {
- InvokeService(*default_service);
- return;
- }
- }
-
- OnPickerEvent(kPickerEventRegistryDataComplete);
- OnIntentDataArrived();
-}
-
-void WebIntentPickerController::OnCWSIntentServicesAvailable(
- const CWSIntentsRegistry::IntentExtensionList& extensions) {
- ExtensionServiceInterface* extension_service =
- extensions::ExtensionSystem::Get(profile_)->extension_service();
-
- std::vector<WebIntentPickerModel::SuggestedExtension> suggestions;
- for (size_t i = 0; i < extensions.size(); ++i) {
- const CWSIntentsRegistry::IntentExtensionInfo& info = extensions[i];
-
- // Do not include suggestions for already installed extensions.
- if (extension_service->GetExtensionById(info.id, true))
- continue;
-
- suggestions.push_back(WebIntentPickerModel::SuggestedExtension(
- info.name, info.id, info.average_rating));
-
- icon_loader_->LoadExtensionIcon(info.icon_url, info.id);
- }
-
- picker_model_->AddSuggestedExtensions(suggestions);
-
- AsyncOperationFinished();
- pending_cws_request_ = false;
- OnIntentDataArrived();
-}
-
-
-void WebIntentPickerController::OnIntentDataArrived() {
- DCHECK(picker_model_.get());
-
- if (!pending_cws_request_ &&
- pending_registry_calls_count_ == 0)
- OnPickerEvent(kPickerEventAsyncDataComplete);
-}
-
-void WebIntentPickerController::Reset() {
- // Abandon all callbacks.
- weak_ptr_factory_.InvalidateWeakPtrs();
- timer_factory_.InvalidateWeakPtrs();
-
- // Reset state associated with callbacks.
- pending_async_count_ = 0;
- pending_registry_calls_count_ = 0;
- pending_cws_request_ = false;
-
- // Reset picker.
- icon_loader_.reset();
- picker_model_.reset(new WebIntentPickerModel());
- icon_loader_.reset(
- new web_intents::IconLoader(profile_, picker_model_.get()));
-
- picker_shown_ = false;
-
- DCHECK(web_contents_);
- WebContentsModalDialogManager* web_contents_modal_dialog_manager =
- WebContentsModalDialogManager::FromWebContents(web_contents_);
- web_contents_modal_dialog_manager->BlockWebContentsInteraction(false);
-}
-
-void WebIntentPickerController::OnShowExtensionInstallDialog(
- const ExtensionInstallPrompt::ShowParams& show_params,
- ExtensionInstallPrompt::Delegate* delegate,
- const ExtensionInstallPrompt::Prompt& prompt) {
- picker_model_->SetPendingExtensionInstallDelegate(delegate);
- picker_model_->SetPendingExtensionInstallPrompt(prompt);
- if (picker_)
- picker_->OnShowExtensionInstallDialog(show_params, delegate, prompt);
-}
-
-void WebIntentPickerController::SetWindowDispositionSource(
- content::WebContents* source,
- content::WebIntentsDispatcher* dispatcher) {
- DCHECK(source);
- DCHECK(dispatcher);
- location_bar_button_indicated_ = false;
- window_disposition_source_ = source;
- if (window_disposition_source_) {
- // This object is self-deleting when the source WebContents is destroyed.
- new SourceWindowObserver(window_disposition_source_,
- weak_ptr_factory_.GetWeakPtr());
- }
-
- if (dispatcher) {
- dispatcher->RegisterReplyNotification(
- base::Bind(&WebIntentPickerController::SourceDispatcherReplied,
- weak_ptr_factory_.GetWeakPtr()));
- }
- source_intents_dispatcher_ = dispatcher;
-}
-
-void WebIntentPickerController::SourceWebContentsDestroyed(
- content::WebContents* source) {
- window_disposition_source_ = NULL;
- // TODO(gbillock): redraw location bar to kill button
-}
-
-void WebIntentPickerController::SourceDispatcherReplied(
- webkit_glue::WebIntentReplyType reply_type) {
- source_intents_dispatcher_ = NULL;
- // TODO(gbillock): redraw location bar to kill button
-}
-
-bool WebIntentPickerController::ShowLocationBarPickerButton() {
- return window_disposition_source_ || source_intents_dispatcher_;
-}
-
-void WebIntentPickerController::OnPickerEvent(WebIntentPickerEvent event) {
- switch (event) {
- case kPickerEventHiddenSetupTimeout:
- DCHECK(dialog_state_ == kPickerSetup);
- SetDialogState(kPickerWaiting);
- break;
-
- case kPickerEventMaxWaitTimeExceeded:
- DCHECK(dialog_state_ == kPickerWaiting);
-
- // If registry data is complete, go to main dialog. Otherwise, wait.
- if (pending_registry_calls_count_ == 0)
- SetDialogState(kPickerMain);
- else
- SetDialogState(kPickerWaitLong);
- break;
-
- case kPickerEventRegistryDataComplete:
- DCHECK(dialog_state_ == kPickerSetup ||
- dialog_state_ == kPickerWaiting ||
- dialog_state_ == kPickerWaitLong);
-
- // If minimum wait dialog time is exceeded, display main dialog.
- // Either way, we don't do a thing.
- break;
-
- case kPickerEventAsyncDataComplete:
- DCHECK(dialog_state_ == kPickerSetup ||
- dialog_state_ == kPickerWaiting ||
- dialog_state_ == kPickerWaitLong ||
- dialog_state_ == kPickerInline);
-
- // In setup state, transition to main dialog. In waiting state, let
- // timer expire.
- if (dialog_state_ == kPickerSetup)
- SetDialogState(kPickerMain);
- break;
-
- default:
- NOTREACHED();
- break;
- }
-}
-
-void WebIntentPickerController::LocationBarPickerButtonClicked() {
- DCHECK(web_contents_);
- if (window_disposition_source_ && source_intents_dispatcher_) {
- Browser* service_browser =
- chrome::FindBrowserWithWebContents(web_contents_);
- if (!service_browser) return;
-
- Browser* client_browser =
- chrome::FindBrowserWithWebContents(window_disposition_source_);
- if (!client_browser)
- return;
- int client_index = client_browser->tab_strip_model()->GetIndexOfWebContents(
- window_disposition_source_);
- DCHECK(client_index != TabStripModel::kNoTab);
-
- source_intents_dispatcher_->ResetDispatch();
-
- WebIntentPickerController* client_controller =
- WebIntentPickerController::FromWebContents(window_disposition_source_);
- DCHECK(client_controller);
-
- // This call deletes this object, so anything below here needs to
- // use stack variables.
- chrome::CloseWebContents(service_browser, web_contents_, true);
-
- // Re-open the other tab and activate the picker.
- client_browser->window()->Activate();
- client_browser->tab_strip_model()->ActivateTabAt(client_index, true);
- // The picker has been Reset() when the new tab is created; need to fully
- // reload.
- client_controller->ReshowDialog();
- }
- // TODO(gbillock): figure out what we ought to do in this case. Probably
- // nothing? Refresh the location bar?
-}
-
-void WebIntentPickerController::AsyncOperationFinished() {
- DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
- if (--pending_async_count_ == 0) {
- if (picker_)
- picker_->OnPendingAsyncCompleted();
- }
-}
-
-void WebIntentPickerController::InvokeServiceWithSelection(
- const webkit_glue::WebIntentServiceData& service) {
- if (picker_shown_) {
- intents_dispatcher_->SendReply(webkit_glue::WebIntentReply(
- webkit_glue::WEB_INTENT_REPLY_FAILURE,
- ASCIIToUTF16("Simultaneous intent invocation.")));
- return;
- }
-
- // TODO(gbillock): this is a bit hacky and exists because in the inline case,
- // the picker currently assumes it exists.
- AddServiceToModel(service);
- picker_model_->set_show_use_another_service(false);
-
- if (service.disposition ==
- webkit_glue::WebIntentServiceData::DISPOSITION_INLINE) {
- picker_model_->SetInlineDisposition(service.service_url);
- SetDialogState(kPickerInline);
- return;
- }
-
- OnServiceChosen(service.service_url, service.disposition, kSuppressDefaults);
-}
-
-void WebIntentPickerController::InvokeService(
- const WebIntentPickerModel::InstalledService& service) {
- if (service.disposition ==
- webkit_glue::WebIntentServiceData::DISPOSITION_INLINE) {
- // This call will ensure the picker dialog is created and initialized.
- picker_model_->SetInlineDisposition(service.url);
- SetDialogState(kPickerInline);
- return;
- }
- OnServiceChosen(service.url, service.disposition, kEnableDefaults);
-}
-
-void WebIntentPickerController::SetDialogState(WebIntentPickerState state) {
- // Ignore events that don't change state.
- if (state == dialog_state_)
- return;
-
- // Any pending timers are abandoned on state changes.
- timer_factory_.InvalidateWeakPtrs();
-
- switch (state) {
- case kPickerSetup:
- DCHECK_EQ(dialog_state_, kPickerHidden);
- // Post timer CWS pending
- MessageLoop::current()->PostDelayedTask(FROM_HERE,
- base::Bind(&WebIntentPickerController::OnPickerEvent,
- timer_factory_.GetWeakPtr(),
- kPickerEventHiddenSetupTimeout),
- base::TimeDelta::FromMilliseconds(kMaxHiddenSetupTimeMs));
- break;
-
- case kPickerWaiting:
- DCHECK_EQ(dialog_state_, kPickerSetup);
- // Waiting dialog can be dismissed after minimum wait time.
- MessageLoop::current()->PostDelayedTask(FROM_HERE,
- base::Bind(&WebIntentPickerController::OnPickerEvent,
- timer_factory_.GetWeakPtr(),
- kPickerEventMaxWaitTimeExceeded),
- base::TimeDelta::FromMilliseconds(kMinThrobberDisplayTimeMs));
- break;
-
- case kPickerWaitLong:
- DCHECK_EQ(dialog_state_, kPickerWaiting);
- break;
-
- case kPickerInline:
- // Intentional fall-through.
- case kPickerMain:
- // No DCHECK - main state can be reached from any state.
- // Ready to display data.
- picker_model_->SetWaitingForSuggestions(false);
- break;
-
- case kPickerHidden:
- Reset();
- break;
-
- default:
- NOTREACHED();
- break;
-
- }
-
- dialog_state_ = state;
-
- // Create picker dialog when changing away from hidden state.
- if (dialog_state_ != kPickerHidden && dialog_state_ != kPickerSetup)
- CreatePicker();
-}
-
-void WebIntentPickerController::CreatePicker() {
- // If picker is non-NULL, it was set by a test.
- if (picker_ == NULL)
- picker_ = WebIntentPicker::Create(web_contents_, this, picker_model_.get());
- picker_->SetActionString(WebIntentPicker::GetDisplayStringForIntentAction(
- picker_model_->action()));
- web_intents::RecordPickerShow(
- uma_bucket_, picker_model_->GetInstalledServiceCount());
- picker_shown_ = true;
-}
-
-void WebIntentPickerController::ClosePicker() {
- SetDialogState(kPickerHidden);
- if (picker_)
- picker_->Close();
-}
-
-void WebIntentPickerController::CancelDownload() {
- if (!download_id_.IsValid())
- return;
- Profile* profile =
- Profile::FromBrowserContext(web_contents_->GetBrowserContext());
- content::DownloadManager* download_manager =
- content::BrowserContext::GetDownloadManager(profile);
- if (!download_manager)
- return;
- content::DownloadItem* item =
- download_manager->GetDownload(download_id_.local());
- if (item)
- item->Cancel(true);
- download_id_ = content::DownloadId();
-}
diff --git a/chrome/browser/ui/intents/web_intent_picker_controller.h b/chrome/browser/ui/intents/web_intent_picker_controller.h
deleted file mode 100644
index 9653922..0000000
--- a/chrome/browser/ui/intents/web_intent_picker_controller.h
+++ /dev/null
@@ -1,349 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_UI_INTENTS_WEB_INTENT_PICKER_CONTROLLER_H_
-#define CHROME_BROWSER_UI_INTENTS_WEB_INTENT_PICKER_CONTROLLER_H_
-
-#include <vector>
-
-#include "base/compiler_specific.h"
-#include "base/memory/ref_counted.h"
-#include "base/memory/scoped_ptr.h"
-#include "base/memory/weak_ptr.h"
-#include "base/string16.h"
-#include "chrome/browser/extensions/webstore_installer.h"
-#include "chrome/browser/intents/cws_intents_registry.h"
-#include "chrome/browser/intents/web_intents_registry.h"
-#include "chrome/browser/intents/web_intents_reporting.h"
-#include "chrome/browser/ui/intents/web_intent_picker_delegate.h"
-#include "content/public/browser/download_id.h"
-#include "content/public/browser/web_contents_user_data.h"
-#include "webkit/glue/web_intent_data.h"
-#include "webkit/glue/web_intent_reply_data.h"
-#include "webkit/glue/web_intent_service_data.h"
-
-class Browser;
-struct DefaultWebIntentService;
-class GURL;
-class Profile;
-class WebIntentPicker;
-class WebIntentPickerModel;
-
-namespace content {
-class WebContents;
-class WebIntentsDispatcher;
-}
-
-namespace web_intents {
-class NativeServiceFactory;
-class IconLoader;
-}
-
-namespace webkit_glue {
-struct WebIntentServiceData;
-}
-
-// Controls the creation of the WebIntentPicker UI and forwards the user's
-// intent handler choice back to the WebContents object.
-class WebIntentPickerController
- : public WebIntentPickerDelegate,
- public extensions::WebstoreInstaller::Delegate,
- public content::WebContentsUserData<WebIntentPickerController> {
- public:
-
- // The various states that the UI may be in. Public for testing.
- enum WebIntentPickerState {
- kPickerHidden, // Picker not displayed at all.
- kPickerSetup, // Initial setup. Acquires data, keeps picker hidden.
- kPickerWaiting, // Displaying "waiting for CWS".
- kPickerWaitLong, // "waiting" has displayed for longer than min. time.
- kPickerMain, // Displaying main picker dialog.
- kPickerInline, // Displaying inline intent handler.
- };
-
- // Events that happen during picker life time. Drive state machine.
- enum WebIntentPickerEvent {
- kPickerEventHiddenSetupTimeout, // Time for hidden setup exired.
- kPickerEventMaxWaitTimeExceeded, // Exceeded max wait time for CWS results.
- kPickerEventRegistryDataComplete, // Data from the registry has arrived.
- kPickerEventAsyncDataComplete, // Data from registry and CWS has arrived.
- };
-
- virtual ~WebIntentPickerController();
-
- // Sets the intent data and return pathway handler object for which
- // this picker was created. The picker takes ownership of
- // |intents_dispatcher|. |intents_dispatcher| must not be NULL.
- void SetIntentsDispatcher(content::WebIntentsDispatcher* intents_dispatcher);
-
- // Shows the web intent picker given the intent |action| and MIME-type |type|.
- void ShowDialog(const string16& action,
- const string16& type);
-
- // Called directly after SetIntentsDispatcher to handle the dispatch of the
- // intent to the indicated service. The picker model may still be unloaded.
- void InvokeServiceWithSelection(
- const webkit_glue::WebIntentServiceData& service);
-
- // Called by the location bar to see whether the web intents picker button
- // should be shown.
- bool ShowLocationBarPickerButton();
-
- // Record that the location bar button has been animated.
- void SetLocationBarPickerButtonIndicated() {
- location_bar_button_indicated_ = true;
- }
-
- // Check whether the location bar button has been animated.
- bool location_bar_picker_button_indicated() const {
- return location_bar_button_indicated_;
- }
-
- // Called by the location bar to notify picker that the button was clicked.
- // Called in the controller of the tab which is displaying the service.
- void LocationBarPickerButtonClicked();
-
- // Called to notify a controller for a page hosting a web intents service
- // that the source WebContents has been destroyed.
- void SourceWebContentsDestroyed(content::WebContents* source);
-
- protected:
- // WebIntentPickerDelegate implementation.
- virtual void OnServiceChosen(
- const GURL& url,
- webkit_glue::WebIntentServiceData::Disposition disposition,
- DefaultsUsage suppress_defaults) OVERRIDE;
- virtual content::WebContents* CreateWebContentsForInlineDisposition(
- Profile* profile, const GURL& url) OVERRIDE;
- virtual void OnExtensionInstallRequested(const std::string& id) OVERRIDE;
- virtual void OnExtensionLinkClicked(
- const std::string& id,
- WindowOpenDisposition disposition) OVERRIDE;
- virtual void OnSuggestionsLinkClicked(
- WindowOpenDisposition disposition) OVERRIDE;
- virtual void OnUserCancelledPickerDialog() OVERRIDE;
- virtual void OnChooseAnotherService() OVERRIDE;
- virtual void OnClosing() OVERRIDE;
-
- // extensions::WebstoreInstaller::Delegate implementation.
- virtual void OnExtensionDownloadStarted(const std::string& id,
- content::DownloadItem* item) OVERRIDE;
- virtual void OnExtensionDownloadProgress(
- const std::string& id,
- content::DownloadItem* item) OVERRIDE;
- virtual void OnExtensionInstallSuccess(const std::string& id) OVERRIDE;
- virtual void OnExtensionInstallFailure(
- const std::string& id,
- const std::string& error,
- extensions::WebstoreInstaller::FailureReason reason) OVERRIDE;
-
- private:
- explicit WebIntentPickerController(content::WebContents* web_contents);
- friend class content::WebContentsUserData<WebIntentPickerController>;
-
- friend class WebIntentPickerControllerTest;
- friend class WebIntentPickerControllerBrowserTest;
- friend class WebIntentPickerControllerIncognitoBrowserTest;
- friend class WebIntentsButtonDecorationTest;
-
- // Forward declaraton of the internal implementation class.
- class UMAReporter;
-
- // Dispatches intent to a just-installed extension with ID |extension_id|.
- void DispatchToInstalledExtension(const std::string& extension_id);
-
- // Adds a service to the data model.
- void AddServiceToModel(const webkit_glue::WebIntentServiceData& service);
-
- // Register the user-selected service (indicated by the passed |url|) as
- // the default for the combination of action/type/options in the picker.
- void SetDefaultServiceForSelection(const GURL& url);
-
- // Calculate a digest value for the services in the picker.
- int64 DigestServices();
-
- // Gets a notification when the return message is sent to the source tab,
- // so we can close the picker dialog or service tab.
- void OnSendReturnMessage(webkit_glue::WebIntentReplyType reply_type);
-
- // Exposed for tests only.
- void set_picker(WebIntentPicker* picker) { picker_ = picker; }
-
- // Exposed for tests only.
- void set_model_observer(WebIntentPickerModelObserver* observer) {
- picker_model_->set_observer(observer);
- }
-
- // Notify the controller that its WebContents is hosting a web intents
- // service. Sets the source and dispatcher for the invoking client.
- void SetWindowDispositionSource(content::WebContents* source,
- content::WebIntentsDispatcher* dispatcher);
-
- // Called to notify a controller for a page hosting a web intents service
- // that the source dispatcher has been replied on.
- void SourceDispatcherReplied(webkit_glue::WebIntentReplyType reply_type);
-
- // Called by the WebIntentsRegistry, returning |services|, which is
- // a list of WebIntentServiceData matching the query.
- void OnWebIntentServicesAvailable(
- const std::vector<webkit_glue::WebIntentServiceData>& services);
-
- // Called when a default service is returned from the WebIntentsRegistry.
- // (Still called with default_service.service_url empty if there are no
- // defaults.)
- void OnWebIntentDefaultsAvailable(
- const DefaultWebIntentService& default_service);
-
- // Coordination method which is delegated to by the registry calls to get
- // services and defaults. Checks whether the picker should be shown or if
- // default choices allow it to be skipped.
- void RegistryCallsCompleted();
-
- // Called when WebIntentServiceData is ready for checking extensions
- // when dispatching explicit intents. Gets |services|
- // from the WebIntentsRegistry to check for known urls/extensions and find
- // disposition data.
- void OnWebIntentServicesAvailableForExplicitIntent(
- const std::vector<webkit_glue::WebIntentServiceData>& services);
-
- // Called when IntentExtensionInfo is returned from the CWSIntentsRegistry.
- void OnCWSIntentServicesAvailable(
- const CWSIntentsRegistry::IntentExtensionList& extensions);
-
- void OnIntentDataArrived();
-
- // Reset internal state to default values.
- void Reset();
-
- // Called to show a custom extension install dialog.
- void OnShowExtensionInstallDialog(
- const ExtensionInstallPrompt::ShowParams& show_params,
- ExtensionInstallPrompt::Delegate* delegate,
- const ExtensionInstallPrompt::Prompt& prompt);
-
- // Signals that a picker event has occurred.
- void OnPickerEvent(WebIntentPickerEvent event);
-
- // Decrements the |pending_async_count_| and notifies the picker if it
- // reaches zero.
- void AsyncOperationFinished();
-
- // Invoke the specified service at |service_url| with chosen |disposition|.
- void InvokeService(const WebIntentPickerModel::InstalledService& service);
-
- // Sets current dialog state.
- void SetDialogState(WebIntentPickerState state);
-
- // Helper to create picker dialog UI.
- void CreatePicker();
-
- // Closes the currently active picker.
- void ClosePicker();
-
- // Re-starts the process of showing the dialog, suppressing any default
- // queries. Called on the user clicking Use-Another-Service.
- void ReshowDialog();
-
- // Delegate for ShowDialog and ReshowDialog. Starts all the data queries for
- // loading the picker model and showing the dialog.
- void ShowDialog(DefaultsUsage suppress_defaults);
-
- // Cancel a pending download if any.
- void CancelDownload();
-
- WebIntentPickerState dialog_state_; // Current state of the dialog.
-
- // A weak pointer to the web contents that the picker is displayed on.
- content::WebContents* web_contents_;
-
- // A weak pointer to the profile for the web contents.
- Profile* profile_;
-
- // A weak pointer to the picker this controller controls.
- WebIntentPicker* picker_;
-
- // The model for the picker. Owned by this controller. It should not be NULL
- // while this controller exists, even if the picker is not shown.
- scoped_ptr<WebIntentPickerModel> picker_model_;
-
- // UMA reporting manager.
- scoped_ptr<UMAReporter> uma_reporter_;
-
- // A count of the outstanding asynchronous calls.
- int pending_async_count_;
-
- // A count of outstanding WebIntentsRegistry calls.
- int pending_registry_calls_count_;
-
- // Indicator that there is a pending request for cws data.
- bool pending_cws_request_;
-
- // Is true if the picker is currently visible.
- // This bool is not equivalent to picker != NULL in a unit test. In that
- // case, a picker may be non-NULL before it is shown.
- bool picker_shown_;
-
-#if defined(TOOLKIT_VIEWS)
- // Set to true if user cancelled the picker dialog. Set to false if the picker
- // dialog is closing for any other reason.
- // TODO(rouslan): We need to fix DialogDelegate in Views to notify us when the
- // user closes the picker dialog. This boolean is a mediocre workaround for
- // lack of that information.
- bool cancelled_;
-#endif
-
- // Weak pointer to the source WebContents for the intent if it is associated
- // with this controller and hosting a web intents window disposition service.
- content::WebContents* window_disposition_source_;
-
- // If this tab is hosting a web intents service, a weak pointer to dispatcher
- // that invoked us. Weak pointer.
- content::WebIntentsDispatcher* source_intents_dispatcher_;
-
- // Weak pointer to the routing object for the renderer which launched the
- // intent. Contains the intent data and a way to signal back to the
- // client page.
- content::WebIntentsDispatcher* intents_dispatcher_;
-
- // Saves whether the use-another-service button has been
- // animated on the location bar.
- bool location_bar_button_indicated_;
-
- // Weak pointer to the tab servicing the intent. Remembered in order to
- // close it when a reply is sent.
- content::WebContents* service_tab_;
-
- // Object managing the details of icon loading.
- scoped_ptr<web_intents::IconLoader> icon_loader_;
-
- // Factory for weak pointers used in callbacks for async calls to load the
- // picker model.
- base::WeakPtrFactory<WebIntentPickerController> weak_ptr_factory_;
-
- // Timer factory for minimum display time of "waiting" dialog.
- base::WeakPtrFactory<WebIntentPickerController> timer_factory_;
-
- // Weak pointers for the dispatcher OnSendReturnMessage will not be
- // cancelled on picker close.
- base::WeakPtrFactory<WebIntentPickerController> dispatcher_factory_;
-
- // Bucket identifier for UMA reporting. Saved off in a field
- // to avoid repeated calculation of the bucket across
- // multiple UMA calls. Should be recalculated each time
- // |intents_dispatcher_| is set.
- web_intents::UMABucket uma_bucket_;
-
- // Factory used to obtain instance of native services.
- scoped_ptr<web_intents::NativeServiceFactory> native_services_;
-
- // The ID of a pending extension download.
- content::DownloadId download_id_;
-
- // Manager for a pending extension download and installation.
- scoped_refptr<extensions::WebstoreInstaller> webstore_installer_;
-
- DISALLOW_COPY_AND_ASSIGN(WebIntentPickerController);
-};
-
-#endif // CHROME_BROWSER_UI_INTENTS_WEB_INTENT_PICKER_CONTROLLER_H_
diff --git a/chrome/browser/ui/intents/web_intent_picker_controller_browsertest.cc b/chrome/browser/ui/intents/web_intent_picker_controller_browsertest.cc
deleted file mode 100644
index 4ef912e..0000000
--- a/chrome/browser/ui/intents/web_intent_picker_controller_browsertest.cc
+++ /dev/null
@@ -1,806 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include <algorithm>
-#include <iterator>
-
-#include "base/bind.h"
-#include "base/callback.h"
-#include "base/command_line.h"
-#include "base/memory/scoped_ptr.h"
-#include "base/string_util.h"
-#include "base/stringprintf.h"
-#include "base/threading/sequenced_worker_pool.h"
-#include "base/utf_string_conversions.h"
-#include "chrome/browser/favicon/favicon_service.h"
-#include "chrome/browser/favicon/favicon_service_factory.h"
-#include "chrome/browser/intents/default_web_intent_service.h"
-#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/ui/browser.h"
-#include "chrome/browser/ui/browser_commands.h"
-#include "chrome/browser/ui/intents/web_intent_picker.h"
-#include "chrome/browser/ui/intents/web_intent_picker_controller.h"
-#include "chrome/browser/ui/intents/web_intent_picker_model.h"
-#include "chrome/browser/ui/intents/web_intent_picker_model_observer.h"
-#include "chrome/browser/ui/tabs/tab_strip_model.h"
-#include "chrome/browser/webdata/web_data_service.h"
-#include "chrome/browser/webdata/web_data_service_factory.h"
-#include "chrome/common/chrome_notification_types.h"
-#include "chrome/common/chrome_switches.h"
-#include "chrome/common/url_constants.h"
-#include "chrome/test/base/in_process_browser_test.h"
-#include "chrome/test/base/ui_test_utils.h"
-#include "content/public/browser/browser_thread.h"
-#include "content/public/browser/notification_service.h"
-#include "content/public/browser/web_contents.h"
-#include "content/public/browser/web_intents_dispatcher.h"
-#include "content/public/test/test_utils.h"
-#include "extensions/common/constants.h"
-#include "net/base/escape.h"
-#include "net/base/mock_host_resolver.h"
-#include "net/url_request/test_url_fetcher_factory.h"
-#include "testing/gtest/include/gtest/gtest.h"
-#include "ui/gfx/image/image_unittest_util.h"
-#include "ui/gfx/image/image_util.h"
-#include "webkit/glue/web_intent_service_data.h"
-
-namespace {
-
-const string16 kAction1(ASCIIToUTF16("http://webintents.org/share"));
-const string16 kAction2(ASCIIToUTF16("http://www.example.com/foobar"));
-const string16 kType1(ASCIIToUTF16("image/png"));
-const string16 kType2(ASCIIToUTF16("text/*"));
-const GURL kServiceURL1("http://www.google.com");
-const GURL kServiceURL2("http://www.chromium.org");
-const char kDummyExtensionId[] = "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb";
-const char kCWSResponseEmpty[] =
- "{\"kind\":\"chromewebstore#itemList\",\"total_items\":0,\"start_index\":0,"
- "\"items\":[]}";
-
-const char kCWSResponseResultFormat[] =
- "{\"kind\":\"chromewebstore#itemList\","
- "\"total_items\":1,"
- "\"start_index\":0,"
- "\"items\":[{"
- "\"kind\":\"chromewebstore#item\","
- "\"id\":\"%s\","
- "\"type\":\"APPLICATION\","
- "\"num_ratings\":0,"
- "\"average_rating\":0.0,"
- "\"manifest\": \"{\\n"
- "\\\"name\\\": \\\"Dummy Share\\\",\\n"
- "\\\"version\\\": \\\"1.0.0.0\\\",\\n"
- "\\\"intents\\\": {\\n"
- "\\\"%s\\\" : {\\n"
- "\\\"type\\\" : [\\\"%s\\\"],\\n"
- "\\\"path\\\" : \\\"share.html\\\",\\n"
- "\\\"title\\\" : \\\"Dummy share!\\\",\\n"
- "\\\"disposition\\\": \\\"inline\\\"\\n"
- "}\\n"
- "}\\n"
- "}\\n\","
- "\"family_safe\":true,"
- "\"icon_url\": \"%s\"}]}";
-
-const char kCWSFakeIconURLFormat[] = "http://example.com/%s/icon.png";
-
-class DummyURLFetcherFactory : public net::URLFetcherFactory {
- public:
- DummyURLFetcherFactory() {}
- virtual ~DummyURLFetcherFactory() {}
-
- virtual net::URLFetcher* CreateURLFetcher(
- int id,
- const GURL& url,
- net::URLFetcher::RequestType request_type,
- net::URLFetcherDelegate* d) OVERRIDE {
- return new net::TestURLFetcher(id, url, d);
- }
-};
-
-} // namespace
-
-class WebIntentPickerMock : public WebIntentPicker,
- public WebIntentPickerModelObserver {
- public:
- WebIntentPickerMock()
- : num_installed_services_(0),
- num_icons_changed_(0),
- num_extension_icons_changed_(0),
- num_extensions_installed_(0),
- message_loop_started_(false),
- pending_async_completed_(false),
- num_inline_disposition_(0),
- delegate_(NULL) {
- }
-
- void MockClose() {
- delegate_->OnClosing();
- }
-
- // WebIntentPicker implementation.
- virtual void Close() OVERRIDE { StopWaiting(); }
- virtual void SetActionString(const string16& action) OVERRIDE {}
- virtual void OnExtensionInstallSuccess(const std::string& id) OVERRIDE {
- num_extensions_installed_++;
- }
- virtual void OnExtensionInstallFailure(const std::string& id) OVERRIDE {}
- virtual void OnInlineDispositionAutoResize(const gfx::Size& size) OVERRIDE {}
- virtual void OnPendingAsyncCompleted() OVERRIDE {
- StopWaiting();
- }
- virtual void InvalidateDelegate() OVERRIDE {
- delegate_ = NULL;
- }
-
- // WebIntentPickerModelObserver implementation.
- virtual void OnModelChanged(WebIntentPickerModel* model) OVERRIDE {
- num_installed_services_ =
- static_cast<int>(model->GetInstalledServiceCount());
- }
- virtual void OnFaviconChanged(
- WebIntentPickerModel* model, size_t index) OVERRIDE {
- num_icons_changed_++;
- }
- virtual void OnExtensionIconChanged(
- WebIntentPickerModel* model, const std::string& extension_id) OVERRIDE {
- num_extension_icons_changed_++;
- }
- virtual void OnInlineDisposition(
- const string16& title, const GURL& url) OVERRIDE {
- num_inline_disposition_++;
- }
-
- void Wait() {
- if (!pending_async_completed_) {
- message_loop_started_ = true;
- content::RunMessageLoop();
- pending_async_completed_ = false;
- }
- }
-
- void StopWaiting() {
- pending_async_completed_ = true;
- if (message_loop_started_) {
- message_loop_started_ = false;
- MessageLoop::current()->Quit();
- }
- }
-
- int num_installed_services_;
- int num_icons_changed_;
- int num_extension_icons_changed_;
- int num_extensions_installed_;
- bool message_loop_started_;
- bool pending_async_completed_;
- int num_inline_disposition_;
- WebIntentPickerDelegate* delegate_;
-};
-
-class IntentsDispatcherMock : public content::WebIntentsDispatcher {
- public:
- explicit IntentsDispatcherMock(const webkit_glue::WebIntentData& intent)
- : intent_(intent),
- dispatched_(false),
- replied_(false) {}
-
- virtual const webkit_glue::WebIntentData& GetIntent() OVERRIDE {
- return intent_;
- }
-
- virtual void DispatchIntent(content::WebContents* web_contents) OVERRIDE {
- dispatched_ = true;
- }
-
- virtual void ResetDispatch() OVERRIDE {
- }
-
- virtual void SendReply(const webkit_glue::WebIntentReply& reply) OVERRIDE {
- replied_ = true;
- }
-
- virtual void RegisterReplyNotification(
- const base::Callback<void(webkit_glue::WebIntentReplyType)>&) OVERRIDE {
- }
-
- webkit_glue::WebIntentData intent_;
- bool dispatched_;
- bool replied_;
-};
-
-class WebIntentPickerControllerBrowserTest : public InProcessBrowserTest {
- public:
- WebIntentPickerControllerBrowserTest() {}
-
- virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
- // We start the test server now instead of in
- // SetUpInProcessBrowserTestFixture so that we can get its port number.
- ASSERT_TRUE(test_server()->Start());
-
- net::HostPortPair host_port = test_server()->host_port_pair();
- command_line->AppendSwitchASCII(
- switches::kAppsGalleryDownloadURL,
- base::StringPrintf(
- "http://www.example.com:%d/files/extensions/intents/%%s.crx",
- host_port.port()));
- command_line->AppendSwitchASCII(
- switches::kAppsGalleryInstallAutoConfirmForTests, "accept");
- }
-
- virtual void SetUpInProcessBrowserTestFixture() OVERRIDE {
- host_resolver()->AddRule("www.example.com", "127.0.0.1");
- }
-
- content::WebContents* GetWindowDispositionTarget(
- WebIntentPickerController* controller) {
- return controller->window_disposition_source_;
- }
-
- virtual void SetUpOnMainThread() OVERRIDE {
- // The FakeURLFetcherFactory will return a NULL URLFetcher if a request is
- // created for a URL it doesn't know and there is no default factory.
- // Instead, use this dummy factory to infinitely delay the request.
- default_url_fetcher_factory_.reset(new DummyURLFetcherFactory);
- fake_url_fetcher_factory_.reset(
- new net::FakeURLFetcherFactory(default_url_fetcher_factory_.get()));
-
- web_data_service_ = WebDataServiceFactory::GetForProfile(
- GetBrowser()->profile(), Profile::EXPLICIT_ACCESS);
- favicon_service_ = FaviconServiceFactory::GetForProfile(
- GetBrowser()->profile(), Profile::EXPLICIT_ACCESS);
- controller_ = WebIntentPickerController::FromWebContents(
- GetBrowser()->tab_strip_model()->GetActiveWebContents());
-
- SetupMockPicker();
- controller_->set_model_observer(&picker_);
- picker_.delegate_ = controller_;
-
- CreateFakeIcon();
- }
-
- virtual void SetupMockPicker() {
- controller_->set_picker(&picker_);
- }
-
- virtual Browser* GetBrowser() { return browser(); }
-
- void AddWebIntentService(const string16& action, const GURL& service_url) {
- webkit_glue::WebIntentServiceData service;
- service.action = action;
- service.type = kType1;
- service.service_url = service_url;
- web_data_service_->AddWebIntentService(service);
- }
-
- void AddCWSExtensionServiceEmpty(const string16& action) {
- GURL cws_query_url = CWSIntentsRegistry::BuildQueryURL(action, kType1);
- fake_url_fetcher_factory_->SetFakeResponse(cws_query_url.spec(),
- kCWSResponseEmpty, true);
- }
-
- void AddCWSExtensionServiceWithResult(const std::string& extension_id,
- const string16& action,
- const string16& type) {
- GURL cws_query_url = CWSIntentsRegistry::BuildQueryURL(action, type);
- std::string icon_url;
- std::string escaped_action = net::EscapePath(UTF16ToUTF8(action));
- base::SStringPrintf(&icon_url, kCWSFakeIconURLFormat,
- escaped_action.c_str());
-
- std::string response;
- base::SStringPrintf(&response, kCWSResponseResultFormat,
- extension_id.c_str(),
- UTF16ToUTF8(action).c_str(), UTF16ToUTF8(type).c_str(),
- icon_url.c_str());
- fake_url_fetcher_factory_->SetFakeResponse(cws_query_url.spec(), response,
- true);
-
- fake_url_fetcher_factory_->SetFakeResponse(icon_url, icon_response_,
- true);
- }
-
- void SetDefaultService(const string16& action,
- const std::string& url) {
- DefaultWebIntentService default_service;
- default_service.action = action;
- default_service.type = kType1;
- default_service.user_date = 1000000;
- default_service.service_url = url;
- web_data_service_->AddDefaultWebIntentService(default_service);
- }
-
- void OnSendReturnMessage(
- webkit_glue::WebIntentReplyType reply_type) {
- controller_->OnSendReturnMessage(reply_type);
- }
-
- void OnServiceChosen(
- const GURL& url,
- webkit_glue::WebIntentServiceData::Disposition disposition) {
- controller_->OnServiceChosen(url, disposition,
- WebIntentPickerDelegate::kEnableDefaults);
- }
-
- void OnCancelled() {
- controller_->OnUserCancelledPickerDialog();
- }
-
- void OnExtensionInstallRequested(const std::string& extension_id) {
- controller_->OnExtensionInstallRequested(extension_id);
- }
-
- extensions::WebstoreInstaller* GetWebstoreInstaller() const {
- return controller_->webstore_installer_.get();
- }
-
- void CreateFakeIcon() {
- gfx::Image image(gfx::test::CreateImage());
- scoped_refptr<base::RefCountedMemory> image_data = image.As1xPNGBytes();
- DCHECK(image_data->size());
-
- std::copy(image_data->front(), image_data->front() + image_data->size(),
- std::back_inserter(icon_response_));
- }
-
- void ClickLocationBarButton(content::WebContents* service_web_contents) {
- DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
- WebIntentPickerController* service_controller =
- WebIntentPickerController::FromWebContents(service_web_contents);
- service_controller->LocationBarPickerButtonClicked();
- }
-
- void CloseCurrentTab() {
- content::WindowedNotificationObserver tab_close_observer(
- content::NOTIFICATION_WEB_CONTENTS_DESTROYED,
- content::NotificationService::AllSources());
- chrome::CloseTab(browser());
- tab_close_observer.Wait();
- }
-
- WebIntentPickerMock picker_;
- scoped_refptr<WebDataService> web_data_service_;
- FaviconService* favicon_service_;
- WebIntentPickerController* controller_;
- scoped_ptr<DummyURLFetcherFactory> default_url_fetcher_factory_;
- scoped_ptr<net::FakeURLFetcherFactory> fake_url_fetcher_factory_;
- std::string icon_response_;
-};
-
-IN_PROC_BROWSER_TEST_F(WebIntentPickerControllerBrowserTest, ChooseService) {
- AddWebIntentService(kAction1, kServiceURL1);
- AddWebIntentService(kAction1, kServiceURL2);
- AddCWSExtensionServiceEmpty(kAction1);
-
- webkit_glue::WebIntentData intent;
- intent.action = kAction1;
- intent.type = kType1;
- IntentsDispatcherMock dispatcher(intent);
- controller_->SetIntentsDispatcher(&dispatcher);
-
- controller_->ShowDialog(kAction1, kType1);
- picker_.Wait();
- EXPECT_EQ(2, picker_.num_installed_services_);
- EXPECT_EQ(0, picker_.num_icons_changed_);
-
- TabStripModel* tab_strip = browser()->tab_strip_model();
- OnServiceChosen(kServiceURL2,
- webkit_glue::WebIntentServiceData::DISPOSITION_WINDOW);
- ASSERT_EQ(2, tab_strip->count());
- EXPECT_EQ(GURL(kServiceURL2),
- tab_strip->GetActiveWebContents()->GetURL());
-
- EXPECT_TRUE(GetWindowDispositionTarget(
- WebIntentPickerController::FromWebContents(
- tab_strip->GetActiveWebContents())));
-
- EXPECT_TRUE(dispatcher.dispatched_);
-
- OnSendReturnMessage(webkit_glue::WEB_INTENT_REPLY_SUCCESS);
- ASSERT_EQ(1, tab_strip->count());
-}
-
-IN_PROC_BROWSER_TEST_F(WebIntentPickerControllerBrowserTest,
- FetchExtensionIcon) {
- AddWebIntentService(kAction1, kServiceURL1);
- AddWebIntentService(kAction1, kServiceURL2);
- AddCWSExtensionServiceWithResult(kDummyExtensionId, kAction1, kType1);
-
- webkit_glue::WebIntentData intent;
- intent.action = kAction1;
- intent.type = kType1;
- IntentsDispatcherMock dispatcher(intent);
- controller_->SetIntentsDispatcher(&dispatcher);
-
- controller_->ShowDialog(kAction1, kType1);
- picker_.Wait();
- // Flush all pending worker tasks for PNG decoding.
- content::BrowserThread::GetBlockingPool()->FlushForTesting();
- // Flush all tasks posted from the worker tasks.
- MessageLoop::current()->RunUntilIdle();
- EXPECT_EQ(2, picker_.num_installed_services_);
- EXPECT_EQ(0, picker_.num_icons_changed_);
- EXPECT_EQ(1, picker_.num_extension_icons_changed_);
-}
-
-IN_PROC_BROWSER_TEST_F(WebIntentPickerControllerBrowserTest, OpenCancelOpen) {
- AddWebIntentService(kAction1, kServiceURL1);
- AddWebIntentService(kAction1, kServiceURL2);
- AddCWSExtensionServiceEmpty(kAction1);
-
- webkit_glue::WebIntentData intent;
- intent.action = kAction1;
- intent.type = kType1;
- IntentsDispatcherMock dispatcher(intent);
- controller_->SetIntentsDispatcher(&dispatcher);
-
- controller_->ShowDialog(kAction1, kType1);
- picker_.Wait();
- OnCancelled();
-
- controller_->ShowDialog(kAction1, kType1);
- OnCancelled();
-}
-
-IN_PROC_BROWSER_TEST_F(WebIntentPickerControllerBrowserTest,
- CloseTargetTabReturnToSource) {
- AddWebIntentService(kAction1, kServiceURL1);
- AddCWSExtensionServiceEmpty(kAction1);
-
- TabStripModel* tab_strip = browser()->tab_strip_model();
- GURL original = tab_strip->GetActiveWebContents()->GetURL();
-
- // Open a new page, but keep focus on original.
- ui_test_utils::NavigateToURLWithDisposition(
- browser(), GURL(chrome::kChromeUINewTabURL), NEW_BACKGROUND_TAB,
- ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
- ASSERT_EQ(2, tab_strip->count());
- EXPECT_EQ(original, tab_strip->GetActiveWebContents()->GetURL());
-
- webkit_glue::WebIntentData intent;
- intent.action = kAction1;
- intent.type = kType1;
- IntentsDispatcherMock dispatcher(intent);
- controller_->SetIntentsDispatcher(&dispatcher);
-
- controller_->ShowDialog(kAction1, kType1);
- picker_.Wait();
- EXPECT_EQ(1, picker_.num_installed_services_);
-
- OnServiceChosen(kServiceURL1,
- webkit_glue::WebIntentServiceData::DISPOSITION_WINDOW);
- ASSERT_EQ(3, tab_strip->count());
- EXPECT_EQ(GURL(kServiceURL1),
- tab_strip->GetActiveWebContents()->GetURL());
-
- EXPECT_TRUE(dispatcher.dispatched_);
-
- OnSendReturnMessage(webkit_glue::WEB_INTENT_REPLY_SUCCESS);
- ASSERT_EQ(2, tab_strip->count());
- EXPECT_EQ(original, tab_strip->GetActiveWebContents()->GetURL());
-
- CloseCurrentTab();
-}
-
-class WebIntentPickerControllerIncognitoBrowserTest
- : public WebIntentPickerControllerBrowserTest {
- public:
- WebIntentPickerControllerIncognitoBrowserTest() {}
-
- virtual void SetUpOnMainThread() OVERRIDE {
- incognito_browser_ = CreateIncognitoBrowser();
- WebIntentPickerControllerBrowserTest::SetUpOnMainThread();
- }
-
- virtual Browser* GetBrowser() OVERRIDE { return incognito_browser_; }
-
- int pending_async_count() { return controller_->pending_async_count_; }
-
- private:
- Browser* incognito_browser_;
-};
-
-IN_PROC_BROWSER_TEST_F(WebIntentPickerControllerIncognitoBrowserTest,
- ShowDialogShouldntCrash) {
- webkit_glue::WebIntentData intent;
- intent.action = kAction1;
- intent.type = kType1;
- IntentsDispatcherMock dispatcher(intent);
- controller_->SetIntentsDispatcher(&dispatcher);
-
- controller_->ShowDialog(kAction1, kType1);
- // This should do nothing for now.
- EXPECT_EQ(0, pending_async_count());
-}
-
-IN_PROC_BROWSER_TEST_F(WebIntentPickerControllerBrowserTest,
- ExtensionInstallSuccess) {
- const char extension_id[] = "ooodacpbmglpoagccnepcbfhfhpdgddn";
- AddCWSExtensionServiceWithResult(extension_id, kAction1, kType2);
-
- webkit_glue::WebIntentData intent;
- intent.action = kAction1;
- intent.type = kType2;
- IntentsDispatcherMock dispatcher(intent);
- controller_->SetIntentsDispatcher(&dispatcher);
-
- controller_->ShowDialog(kAction1, kType2);
- picker_.Wait();
-
- TabStripModel* tab_strip = browser()->tab_strip_model();
- ASSERT_EQ(1, tab_strip->count());
- OnExtensionInstallRequested(extension_id);
- picker_.Wait();
- EXPECT_EQ(1, picker_.num_extensions_installed_);
- const extensions::Extension* extension = browser()->profile()->
- GetExtensionService()->GetExtensionById(extension_id, false);
- EXPECT_TRUE(extension);
-
- // Installing an extension should also choose it. Since this extension uses
- // window disposition, it will create a new tab.
- EXPECT_EQ(2, tab_strip->count());
- EXPECT_EQ(0, picker_.num_inline_disposition_);
-
- CloseCurrentTab();
-}
-
-// Tests that inline install of an extension using inline disposition works
-// and brings up content as inline content.
-IN_PROC_BROWSER_TEST_F(WebIntentPickerControllerBrowserTest,
- ExtensionInstallSuccessInline) {
- const char extension_id[] = "nnhendkbgefomfgdlnmfhhmihihlljpi";
- AddCWSExtensionServiceWithResult(extension_id, kAction1, kType2);
-
- webkit_glue::WebIntentData intent;
- intent.action = kAction1;
- intent.type = kType2;
- IntentsDispatcherMock dispatcher(intent);
- controller_->SetIntentsDispatcher(&dispatcher);
-
- controller_->ShowDialog(kAction1, kType2);
- picker_.Wait();
-
- OnExtensionInstallRequested(extension_id);
- picker_.Wait();
- EXPECT_EQ(1, picker_.num_extensions_installed_);
- const extensions::Extension* extension = browser()->profile()->
- GetExtensionService()->GetExtensionById(extension_id, false);
- EXPECT_TRUE(extension);
-
- // Installing an extension should also choose it. Since this extension uses
- // inline disposition, it will create no tabs and invoke OnInlineDisposition.
- TabStripModel* tab_strip = browser()->tab_strip_model();
- EXPECT_EQ(1, tab_strip->count());
- EXPECT_EQ(1, picker_.num_inline_disposition_);
-}
-
-IN_PROC_BROWSER_TEST_F(WebIntentPickerControllerBrowserTest,
- WebstoreInstallerLifetime) {
- const char extension_id[] = "nnhendkbgefomfgdlnmfhhmihihlljpi";
- AddCWSExtensionServiceWithResult(extension_id, kAction1, kType2);
-
- webkit_glue::WebIntentData intent;
- intent.action = kAction1;
- intent.type = kType2;
- IntentsDispatcherMock dispatcher(intent);
- controller_->SetIntentsDispatcher(&dispatcher);
-
- controller_->ShowDialog(kAction1, kType2);
- picker_.Wait();
-
- // We haven't yet created a WebstoreInstaller.
- EXPECT_FALSE(GetWebstoreInstaller());
-
- // While extension install is pending, we have a WebstoreInstaller.
- OnExtensionInstallRequested(extension_id);
- EXPECT_TRUE(GetWebstoreInstaller());
-
- // After extension install the WebstoreInstaller is cleaned up.
- picker_.Wait();
- EXPECT_EQ(1, picker_.num_extensions_installed_);
- EXPECT_FALSE(GetWebstoreInstaller());
-}
-
-// Test that an explicit intent does not trigger loading intents from the
-// registry (skips the picker), and creates the intent service handler
-// immediately.
-IN_PROC_BROWSER_TEST_F(WebIntentPickerControllerBrowserTest,
- ExplicitIntentTest) {
- // Install a target service for the explicit intent.
- const char extension_id[] = "ooodacpbmglpoagccnepcbfhfhpdgddn";
- AddCWSExtensionServiceWithResult(extension_id, kAction1, kType2);
-
- webkit_glue::WebIntentData intent;
- intent.action = kAction1;
- intent.type = kType2;
- IntentsDispatcherMock dispatcher(intent);
- controller_->SetIntentsDispatcher(&dispatcher);
-
- controller_->ShowDialog(kAction1, kType2);
- picker_.Wait();
-
- TabStripModel* tab_strip = browser()->tab_strip_model();
- OnExtensionInstallRequested(extension_id);
- picker_.Wait();
- ASSERT_EQ(1, picker_.num_extensions_installed_);
- // The intent launches a new tab.
- ASSERT_EQ(2, tab_strip->count());
-
- // Make the controller think nothing is being shown.
- picker_.MockClose();
- SetupMockPicker();
-
- // Now call the explicit intent.
- webkit_glue::WebIntentData explicitIntent;
- explicitIntent.action = kAction1;
- explicitIntent.type = kType2;
- explicitIntent.service = GURL(StringPrintf("%s://%s/%s",
- extensions::kExtensionScheme,
- extension_id,
- "share.html"));
- IntentsDispatcherMock dispatcher2(explicitIntent);
- controller_->SetIntentsDispatcher(&dispatcher2);
- ui_test_utils::WindowedTabAddedNotificationObserver new_tab_observer((
- content::Source<content::WebContentsDelegate>(browser())));
- controller_->ShowDialog(kAction1, kType2);
- new_tab_observer.Wait();
-
- content::WebContents* service_web_contents = new_tab_observer.GetTab();
- DCHECK(service_web_contents);
-
- // Location bar button should not be shown for explicit intents.
- WebIntentPickerController* service_controller =
- WebIntentPickerController::FromWebContents(service_web_contents);
- DCHECK(service_controller);
- EXPECT_FALSE(service_controller->ShowLocationBarPickerButton());
-
- EXPECT_EQ(3, tab_strip->count());
- EXPECT_EQ(0, picker_.num_inline_disposition_);
- EXPECT_FALSE(dispatcher2.replied_);
-
- // num_installed_services_ would be 2 if the intent wasn't explicit.
- EXPECT_EQ(1, picker_.num_installed_services_);
-
- // Close tabs to get rid of them before the dispatchers go out of scope at the
- // end of this method.
- CloseCurrentTab();
- CloseCurrentTab();
-}
-
-// Test that an explicit intent for non-installed extension won't
-// complete.
-IN_PROC_BROWSER_TEST_F(WebIntentPickerControllerBrowserTest,
- ExplicitIntentNoExtensionTest) {
- AddWebIntentService(kAction1, kServiceURL1);
- AddWebIntentService(kAction1, kServiceURL2);
- AddCWSExtensionServiceWithResult(kDummyExtensionId, kAction1, kType1);
-
- webkit_glue::WebIntentData intent;
- intent.action = kAction1;
- intent.type = kType1;
- intent.service = GURL(StringPrintf("%s://%s/%s",
- extensions::kExtensionScheme,
- kDummyExtensionId,
- UTF16ToASCII(kAction1).c_str()));
- IntentsDispatcherMock dispatcher(intent);
- controller_->SetIntentsDispatcher(&dispatcher);
- controller_->ShowDialog(kAction1, kType1);
- picker_.Wait();
-
- TabStripModel* tab_strip = browser()->tab_strip_model();
- EXPECT_EQ(1, tab_strip->count());
- EXPECT_EQ(0, picker_.num_inline_disposition_);
- EXPECT_TRUE(dispatcher.replied_);
-
- // num_installed_services_ would be 2 if the intent wasn't explicit.
- EXPECT_EQ(0, picker_.num_installed_services_);
-}
-
-// Test that explicit intents won't load uninstalled non-extensions.
-IN_PROC_BROWSER_TEST_F(WebIntentPickerControllerBrowserTest,
- ExplicitIntentNonExtensionTest) {
- AddWebIntentService(kAction1, kServiceURL1);
- AddWebIntentService(kAction1, kServiceURL2);
- AddCWSExtensionServiceWithResult(kDummyExtensionId, kAction1, kType1);
-
- webkit_glue::WebIntentData intent;
- intent.action = kAction1;
- intent.type = kType1;
- intent.service = GURL("http://www.uninstalled.com/");
- IntentsDispatcherMock dispatcher(intent);
- controller_->SetIntentsDispatcher(&dispatcher);
- controller_->ShowDialog(kAction1, kType1);
- picker_.Wait();
-
- TabStripModel* tab_strip = browser()->tab_strip_model();
- EXPECT_EQ(1, tab_strip->count());
- EXPECT_EQ(0, picker_.num_inline_disposition_);
-
- // num_installed_services_ would be 2 if the intent wasn't explicit.
- EXPECT_EQ(0, picker_.num_installed_services_);
- EXPECT_TRUE(dispatcher.replied_);
-}
-
-IN_PROC_BROWSER_TEST_F(WebIntentPickerControllerBrowserTest,
- DefaultsTest) {
- AddWebIntentService(kAction1, kServiceURL1);
- AddWebIntentService(kAction1, kServiceURL2);
- AddCWSExtensionServiceEmpty(kAction1);
-
- SetDefaultService(kAction1, kServiceURL1.spec());
-
- webkit_glue::WebIntentData intent;
- intent.action = kAction1;
- intent.type = kType1;
- IntentsDispatcherMock dispatcher(intent);
- controller_->SetIntentsDispatcher(&dispatcher);
-
- ui_test_utils::WindowedTabAddedNotificationObserver new_tab_observer((
- content::Source<content::WebContentsDelegate>(browser())));
- controller_->ShowDialog(kAction1, kType1);
- new_tab_observer.Wait();
- WebIntentPickerController* service_controller =
- WebIntentPickerController::FromWebContents(new_tab_observer.GetTab());
- EXPECT_TRUE(service_controller->ShowLocationBarPickerButton());
-
- EXPECT_EQ(2, picker_.num_installed_services_);
-
- // The tab is shown immediately without needing to call OnServiceChosen.
- TabStripModel* tab_strip = browser()->tab_strip_model();
- ASSERT_EQ(2, tab_strip->count());
- EXPECT_EQ(GURL(kServiceURL1),
- tab_strip->GetActiveWebContents()->GetURL());
-
- EXPECT_TRUE(dispatcher.dispatched_);
-
- CloseCurrentTab();
-}
-
-IN_PROC_BROWSER_TEST_F(WebIntentPickerControllerBrowserTest,
- ChooseAnotherService) {
- AddWebIntentService(kAction1, kServiceURL1);
- AddWebIntentService(kAction1, kServiceURL2);
- AddCWSExtensionServiceEmpty(kAction1);
-
- // Bring up the picker to get the test-installed services so we can create a
- // default with the right defaulting fingerprint.
- SetDefaultService(kAction1, kServiceURL1.spec());
-
- webkit_glue::WebIntentData intent;
- intent.action = kAction1;
- intent.type = kType1;
- IntentsDispatcherMock dispatcher(intent);
- controller_->SetIntentsDispatcher(&dispatcher);
-
- ui_test_utils::WindowedTabAddedNotificationObserver new_tab_observer((
- content::Source<content::WebContentsDelegate>(browser())));
- controller_->ShowDialog(kAction1, kType1);
- new_tab_observer.Wait();
- content::WebContents* service_web_contents = new_tab_observer.GetTab();
-
- EXPECT_EQ(2, picker_.num_installed_services_);
-
- // The tab is shown immediately without needing to call OnServiceChosen.
- TabStripModel* tab_strip = browser()->tab_strip_model();
- ASSERT_EQ(2, tab_strip->count());
- EXPECT_EQ(GURL(kServiceURL1),
- tab_strip->GetActiveWebContents()->GetURL());
-
- // Simulate click on the location bar use-another-service button.
- content::WindowedNotificationObserver observer(
- chrome::NOTIFICATION_TAB_CLOSING,
- content::NotificationService::AllSources());
- content::BrowserThread::PostTask(
- content::BrowserThread::UI, FROM_HERE,
- base::Bind(&WebIntentPickerControllerBrowserTest::ClickLocationBarButton,
- base::Unretained(this),
- service_web_contents));
- observer.Wait();
- picker_.Wait();
-
- // The service tab is closed and the picker is shown again
- // on the original tab.
- EXPECT_EQ(1, tab_strip->count());
- EXPECT_EQ(2, picker_.num_installed_services_);
- EXPECT_EQ(0, picker_.num_inline_disposition_);
-}
diff --git a/chrome/browser/ui/intents/web_intent_picker_delegate.h b/chrome/browser/ui/intents/web_intent_picker_delegate.h
deleted file mode 100644
index 93b7cc2..0000000
--- a/chrome/browser/ui/intents/web_intent_picker_delegate.h
+++ /dev/null
@@ -1,68 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_UI_INTENTS_WEB_INTENT_PICKER_DELEGATE_H_
-#define CHROME_BROWSER_UI_INTENTS_WEB_INTENT_PICKER_DELEGATE_H_
-
-#include <string>
-#include "chrome/browser/ui/intents/web_intent_picker_model.h"
-#include "ui/base/window_open_disposition.h"
-
-namespace content {
-class WebContents;
-}
-
-class Profile;
-
-// A class used to notify the delegate when the user has chosen a web intent
-// service.
-class WebIntentPickerDelegate {
- public:
- enum DefaultsUsage {
- kEnableDefaults = 0,
- kSuppressDefaults = 1,
- };
-
- // Base destructor.
- virtual ~WebIntentPickerDelegate() {}
-
- // Called when the user has chosen a service.
- virtual void OnServiceChosen(
- const GURL& url,
- webkit_glue::WebIntentServiceData::Disposition disposition,
- DefaultsUsage suppress_defaults) = 0;
-
- // Called to create the WebContents into which the inline disposition will be
- // placed.
- virtual content::WebContents* CreateWebContentsForInlineDisposition(
- Profile* profile, const GURL& url) = 0;
-
- // Called when the user has chosen to install a suggested extension.
- virtual void OnExtensionInstallRequested(const std::string& id) = 0;
-
- // Called when the user has chosen to visit the CWS entry for an extension.
- // |id| is the extension id.
- // |disposition| is user-requested disposition for opening the extension
- // link.
- virtual void OnExtensionLinkClicked(
- const std::string& id,
- WindowOpenDisposition disposition) = 0;
-
- // Called when the user chooses to get more suggestions from CWS.
- // |disposition| is user-requested disposition for opening the suggestions
- // link.
- virtual void OnSuggestionsLinkClicked(WindowOpenDisposition disposition) = 0;
-
- // Called when the user cancels out of the dialog.
- virtual void OnUserCancelledPickerDialog() = 0;
-
- // Called when the user wants to pick another service from within inline
- // disposition.
- virtual void OnChooseAnotherService() = 0;
-
- // Called when the dialog stops showing.
- virtual void OnClosing() = 0;
-};
-
-#endif // CHROME_BROWSER_UI_INTENTS_WEB_INTENT_PICKER_DELEGATE_H_
diff --git a/chrome/browser/ui/intents/web_intent_picker_delegate_mock.cc b/chrome/browser/ui/intents/web_intent_picker_delegate_mock.cc
deleted file mode 100644
index b990f7c..0000000
--- a/chrome/browser/ui/intents/web_intent_picker_delegate_mock.cc
+++ /dev/null
@@ -1,11 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/ui/intents/web_intent_picker_delegate_mock.h"
-
-WebIntentPickerDelegateMock::WebIntentPickerDelegateMock() {
-}
-
-WebIntentPickerDelegateMock::~WebIntentPickerDelegateMock() {
-}
diff --git a/chrome/browser/ui/intents/web_intent_picker_delegate_mock.h b/chrome/browser/ui/intents/web_intent_picker_delegate_mock.h
deleted file mode 100644
index 2cb04a0..0000000
--- a/chrome/browser/ui/intents/web_intent_picker_delegate_mock.h
+++ /dev/null
@@ -1,33 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_UI_INTENTS_WEB_INTENT_PICKER_DELEGATE_MOCK_H_
-#define CHROME_BROWSER_UI_INTENTS_WEB_INTENT_PICKER_DELEGATE_MOCK_H_
-
-#include "chrome/browser/ui/intents/web_intent_picker_delegate.h"
-#include "testing/gmock/include/gmock/gmock.h"
-
-class WebIntentPickerDelegateMock : public WebIntentPickerDelegate {
- public:
- WebIntentPickerDelegateMock();
- virtual ~WebIntentPickerDelegateMock();
-
- MOCK_METHOD3(OnServiceChosen,
- void(const GURL& url,
- webkit_glue::WebIntentServiceData::Disposition disposition,
- WebIntentPickerDelegate::DefaultsUsage suppress_defaults));
- MOCK_METHOD2(CreateWebContentsForInlineDisposition,
- content::WebContents*(Profile* profile, const GURL& url));
- MOCK_METHOD1(OnExtensionInstallRequested, void(const std::string& id));
- MOCK_METHOD2(OnExtensionLinkClicked,
- void(const std::string& id,
- WindowOpenDisposition disposition));
- MOCK_METHOD1(OnSuggestionsLinkClicked,
- void(WindowOpenDisposition disposition));
- MOCK_METHOD0(OnUserCancelledPickerDialog, void());
- MOCK_METHOD0(OnChooseAnotherService, void());
- MOCK_METHOD0(OnClosing, void());
-};
-
-#endif // CHROME_BROWSER_UI_INTENTS_WEB_INTENT_PICKER_DELEGATE_MOCK_H_
diff --git a/chrome/browser/ui/intents/web_intent_picker_model.cc b/chrome/browser/ui/intents/web_intent_picker_model.cc
deleted file mode 100644
index 1a9bda8..0000000
--- a/chrome/browser/ui/intents/web_intent_picker_model.cc
+++ /dev/null
@@ -1,287 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/ui/intents/web_intent_picker_model.h"
-
-#include <algorithm>
-
-#include "base/logging.h"
-#include "base/stl_util.h"
-#include "chrome/browser/download/download_item_model.h"
-#include "chrome/browser/ui/intents/web_intent_picker_model_observer.h"
-#include "content/public/browser/download_item.h"
-#include "grit/generated_resources.h"
-#include "grit/ui_resources.h"
-#include "ui/base/l10n/l10n_util.h"
-#include "ui/base/resource/resource_bundle.h"
-#include "ui/gfx/image/image.h"
-
-namespace {
-
-const size_t kMaxSuggestionCount = 5; // Maximum number of visible suggestions.
-
-} // namespace
-
-WebIntentPickerModel::WebIntentPickerModel()
- : observer_(NULL),
- waiting_for_suggestions_(true),
- pending_extension_install_download_progress_(0),
- pending_extension_install_delegate_(NULL),
- show_use_another_service_(true) {
-}
-
-WebIntentPickerModel::~WebIntentPickerModel() {
- DestroyAll();
-}
-
-void WebIntentPickerModel::AddInstalledService(
- const string16& title,
- const GURL& url,
- webkit_glue::WebIntentServiceData::Disposition disposition) {
- // TODO(groby): Revisit to remove O(n^2) complexity.
- for (size_t i = 0; i < installed_services_.size(); ++i) {
- InstalledService* service = installed_services_[i];
- if (service->title == title && service->url == url &&
- service->disposition == disposition)
- return;
- }
- installed_services_.push_back(new InstalledService(title, url, disposition));
- if (observer_)
- observer_->OnModelChanged(this);
-}
-
-void WebIntentPickerModel::RemoveInstalledServiceAt(size_t index) {
- DCHECK_LT(index, installed_services_.size());
- InstalledService* service = installed_services_[index];
- installed_services_.erase(installed_services_.begin() + index);
- delete service;
- if (observer_)
- observer_->OnModelChanged(this);
-}
-
-void WebIntentPickerModel::Clear() {
- DestroyAll();
- action_.clear();
- type_.clear();
- inline_disposition_url_ = GURL::EmptyGURL();
- waiting_for_suggestions_ = true;
- ClearPendingExtensionInstall();
- if (observer_)
- observer_->OnModelChanged(this);
-}
-
-const WebIntentPickerModel::InstalledService&
- WebIntentPickerModel::GetInstalledServiceAt(size_t index) const {
- DCHECK_LT(index, installed_services_.size());
- return *installed_services_[index];
-}
-
-const WebIntentPickerModel::InstalledService*
- WebIntentPickerModel::GetInstalledServiceWithURL(const GURL& url) const {
- for (size_t i = 0; i < installed_services_.size(); ++i) {
- InstalledService* service = installed_services_[i];
- if (service->url == url)
- return service;
- }
- return NULL;
-}
-
-size_t WebIntentPickerModel::GetInstalledServiceCount() const {
- return installed_services_.size();
-}
-
-void WebIntentPickerModel::UpdateFaviconForServiceWithURL(
- const GURL& url, const gfx::Image& image) {
- for (size_t i = 0; i < installed_services_.size(); ++i) {
- InstalledService* service = installed_services_[i];
- if (service->url == url) {
- service->favicon = image;
- if (observer_)
- observer_->OnFaviconChanged(this, i);
- return;
- }
- }
- NOTREACHED(); // Calling this with an invalid URL is not allowed.
-}
-
-void WebIntentPickerModel::AddSuggestedExtensions(
- const std::vector<SuggestedExtension>& suggestions) {
- suggested_extensions_.insert(suggested_extensions_.end(),
- suggestions.begin(),
- suggestions.end());
- if (observer_)
- observer_->OnModelChanged(this);
-}
-
-void WebIntentPickerModel::RemoveSuggestedExtension(const std::string& id) {
- std::vector<SuggestedExtension>::iterator it;
- for (it = suggested_extensions_.begin();
- it < suggested_extensions_.end();
- ++it) {
- SuggestedExtension extension = *it;
- if (extension.id == id) {
- suggested_extensions_.erase(it);
- break;
- }
- }
-}
-
-const WebIntentPickerModel::SuggestedExtension&
- WebIntentPickerModel::GetSuggestedExtensionAt(size_t index) const {
- DCHECK_LT(index, suggested_extensions_.size());
- return suggested_extensions_[index];
-}
-
-const WebIntentPickerModel::SuggestedExtension*
-WebIntentPickerModel::GetSuggestedExtensionWithId(
- const std::string& id) const {
- for (size_t i = 0; i < suggested_extensions_.size(); ++i) {
- const SuggestedExtension* extension = &suggested_extensions_[i];
- if (extension->id == id)
- return extension;
- }
- return NULL;
-}
-
-size_t WebIntentPickerModel::GetSuggestedExtensionCount() const {
- return std::min(suggested_extensions_.size(), kMaxSuggestionCount);
-}
-
-string16 WebIntentPickerModel::GetSuggestionsLinkText() const {
- if (suggested_extensions_.size() <= kMaxSuggestionCount)
- return string16();
-
- return l10n_util::GetStringUTF16(GetInstalledServiceCount() == 0 ?
- IDS_INTENT_PICKER_GET_MORE_SERVICES_NONE_INSTALLED :
- IDS_INTENT_PICKER_GET_MORE_SERVICES);
-}
-
-void WebIntentPickerModel::SetSuggestedExtensionIconWithId(
- const std::string& id,
- const gfx::Image& image) {
- for (size_t i = 0; i < suggested_extensions_.size(); ++i) {
- SuggestedExtension& extension = suggested_extensions_[i];
- if (extension.id == id) {
- extension.icon = image;
-
- if (observer_)
- observer_->OnExtensionIconChanged(this, extension.id);
- break;
- }
- }
-}
-
-void WebIntentPickerModel::SetInlineDisposition(const GURL& url) {
- inline_disposition_url_ = url;
- if (!observer_)
- return;
-
- if (url.is_empty()) {
- observer_->OnModelChanged(this);
- } else {
- const InstalledService* service = GetInstalledServiceWithURL(url);
- DCHECK(service);
- observer_->OnInlineDisposition(service->title, url);
- }
-}
-
-bool WebIntentPickerModel::IsInlineDisposition() const {
- return !inline_disposition_url_.is_empty();
-}
-
-bool WebIntentPickerModel::IsWaitingForSuggestions() const {
- return waiting_for_suggestions_;
-}
-
-void WebIntentPickerModel::SetWaitingForSuggestions(bool waiting) {
- waiting_for_suggestions_ = waiting;
- if (observer_)
- observer_->OnModelChanged(this);
-}
-
-void WebIntentPickerModel::SetPendingExtensionInstallId(const std::string& id) {
- pending_extension_install_id_ = id;
- if (observer_)
- observer_->OnModelChanged(this);
-}
-
-void WebIntentPickerModel::UpdateExtensionDownloadState(
- content::DownloadItem* item) {
- pending_extension_install_download_progress_ = item->PercentComplete();
- DownloadItemModel download_model(item);
- pending_extension_install_status_string_ = download_model.GetStatusText();
- if (observer_)
- observer_->OnModelChanged(this);
-}
-
-void WebIntentPickerModel::SetPendingExtensionInstallDownloadProgress(
- int progress) {
- pending_extension_install_download_progress_ = progress;
- if (observer_)
- observer_->OnModelChanged(this);
-}
-
-void WebIntentPickerModel::SetPendingExtensionInstallStatusString(
- const string16& status) {
- pending_extension_install_status_string_ = status;
- if (observer_)
- observer_->OnModelChanged(this);
-}
-
-void WebIntentPickerModel::SetPendingExtensionInstallDelegate(
- ExtensionInstallPrompt::Delegate* delegate) {
- pending_extension_install_delegate_ = delegate;
- if (observer_)
- observer_->OnModelChanged(this);
-}
-
-void WebIntentPickerModel::SetPendingExtensionInstallPrompt(
- const ExtensionInstallPrompt::Prompt& prompt) {
- pending_extension_install_prompt_.reset(
- new ExtensionInstallPrompt::Prompt(prompt));
- if (observer_)
- observer_->OnModelChanged(this);
-}
-
-void WebIntentPickerModel::ClearPendingExtensionInstall() {
- pending_extension_install_id_.clear();
- pending_extension_install_download_progress_ = 0;
- pending_extension_install_status_string_.clear();
- pending_extension_install_delegate_ = NULL;
- pending_extension_install_prompt_.reset();
- if (observer_)
- observer_->OnModelChanged(this);
-}
-
-void WebIntentPickerModel::DestroyAll() {
- STLDeleteElements(&installed_services_);
-}
-
-WebIntentPickerModel::InstalledService::InstalledService(
- const string16& title,
- const GURL& url,
- webkit_glue::WebIntentServiceData::Disposition disposition)
- : title(title),
- url(url),
- favicon(ui::ResourceBundle::GetSharedInstance().GetNativeImageNamed(
- IDR_DEFAULT_FAVICON)),
- disposition(disposition) {
-}
-
-WebIntentPickerModel::InstalledService::~InstalledService() {
-}
-
-WebIntentPickerModel::SuggestedExtension::SuggestedExtension(
- const string16& title,
- const std::string& id,
- double average_rating)
- : title(title),
- id(id),
- average_rating(average_rating),
- icon(ui::ResourceBundle::GetSharedInstance().GetNativeImageNamed(
- IDR_DEFAULT_FAVICON)) {
-}
-
-WebIntentPickerModel::SuggestedExtension::~SuggestedExtension() {
-}
diff --git a/chrome/browser/ui/intents/web_intent_picker_model.h b/chrome/browser/ui/intents/web_intent_picker_model.h
deleted file mode 100644
index 171e497..0000000
--- a/chrome/browser/ui/intents/web_intent_picker_model.h
+++ /dev/null
@@ -1,259 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_UI_INTENTS_WEB_INTENT_PICKER_MODEL_H_
-#define CHROME_BROWSER_UI_INTENTS_WEB_INTENT_PICKER_MODEL_H_
-
-#include <vector>
-
-#include "base/basictypes.h"
-#include "base/string16.h"
-#include "chrome/browser/extensions/extension_install_prompt.h"
-#include "googleurl/src/gurl.h"
-#include "ui/gfx/image/image.h"
-#include "webkit/glue/web_intent_service_data.h"
-
-namespace content {
-class DownloadItem;
-}
-
-class WebIntentPickerModelObserver;
-
-// Model for the WebIntentPicker.
-class WebIntentPickerModel {
- public:
- // An intent service to display in the picker.
- struct InstalledService {
- InstalledService(
- const string16& title,
- const GURL& url,
- webkit_glue::WebIntentServiceData::Disposition disposition);
- ~InstalledService();
-
- // The title of this service.
- string16 title;
-
- // The URL of this service.
- GURL url;
-
- // A favicon of this service.
- gfx::Image favicon;
-
- // The disposition to use when displaying this service.
- webkit_glue::WebIntentServiceData::Disposition disposition;
- };
-
- // A suggested extension to display in the picker.
- struct SuggestedExtension {
- SuggestedExtension(const string16& title,
- const std::string& id,
- double average_rating);
- ~SuggestedExtension();
-
- // The title of the intent service.
- string16 title;
-
- // The id of the extension that provides the intent service.
- std::string id;
-
- // The average rating of the extension.
- double average_rating;
-
- // The extension's icon.
- gfx::Image icon;
- };
-
- WebIntentPickerModel();
- ~WebIntentPickerModel();
-
- void set_observer(WebIntentPickerModelObserver* observer) {
- observer_ = observer;
- }
-
- const string16& action() const { return action_; }
- void set_action(const string16& action) { action_ = action; }
-
- const string16& type() const { return type_; }
- void set_type(const string16& type) { type_ = type; }
-
- const GURL& default_service_url() const { return default_service_url_; }
- void set_default_service_url(const GURL& default_url) {
- default_service_url_ = default_url;
- }
-
- // Add a new installed service with |title|, |url| and |disposition| to the
- // picker.
- void AddInstalledService(
- const string16& title,
- const GURL& url,
- webkit_glue::WebIntentServiceData::Disposition disposition);
-
- // Remove an installed service from the picker at |index|.
- void RemoveInstalledServiceAt(size_t index);
-
- // Remove all installed services from the picker, and resets to not
- // displaying inline disposition. Note that this does not clear the
- // observer.
- void Clear();
-
- // Return the intent service installed at |index|.
- const InstalledService& GetInstalledServiceAt(size_t index) const;
-
- // Return the intent service that uses |url| as its service url, or NULL.
- const InstalledService* GetInstalledServiceWithURL(const GURL& url) const;
-
- // Return the number of intent services in the picker.
- size_t GetInstalledServiceCount() const;
-
- // Update favicon for the intent service with service URL |url| to |image|.
- void UpdateFaviconForServiceWithURL(const GURL& url, const gfx::Image& image);
-
- // Add a list of suggested extensions to the model.
- void AddSuggestedExtensions(
- const std::vector<SuggestedExtension>& suggestions);
-
- // Remove the suggested extension with this id.
- void RemoveSuggestedExtension(const std::string& id);
-
- // Return the suggested extension at |index|.
- const SuggestedExtension& GetSuggestedExtensionAt(size_t index) const;
-
- // Return the suggested extension for the given id or NULL if none.
- const SuggestedExtension* GetSuggestedExtensionWithId(
- const std::string& id) const;
-
- // Return the number of suggested extensions to be displayed.
- size_t GetSuggestedExtensionCount() const;
-
- // Return the text to use in the "Get more suggestions" link. Returns UTF8.
- // Will return an empty string if the link should not be shown.
- string16 GetSuggestionsLinkText() const;
-
- // Set the icon image for the suggested extension with |id|.
- void SetSuggestedExtensionIconWithId(const std::string& id,
- const gfx::Image& image);
-
- // Set the picker to display the intent service with |url| inline.
- // To clear the current inline disposition set |url| to an empty URL.
- void SetInlineDisposition(const GURL& url);
-
- // Returns true if the picker is currently displaying an inline service.
- bool IsInlineDisposition() const;
-
- // Returns true if there is still a pending request for suggestions from CWS.
- bool IsWaitingForSuggestions() const;
-
- // Set the "waiting for suggestions" status to |waiting|
- void SetWaitingForSuggestions(bool waiting);
-
- // Returns the url of the intent service that is being displayed inline, or
- // GURL::EmptyGURL() if none.
- const GURL& inline_disposition_url() const { return inline_disposition_url_; }
-
- // Sets the ID of the extension currently being installed.
- void SetPendingExtensionInstallId(const std::string& id);
-
- // Gets the ID of the extension currently being installed.
- const std::string& pending_extension_install_id() const {
- return pending_extension_install_id_;
- }
-
- // Updates the pending install download state.
- void UpdateExtensionDownloadState(content::DownloadItem* item);
-
- // Sets the download progress of the extension currently being downloaded.
- void SetPendingExtensionInstallDownloadProgress(int progress);
-
- // Gets the download progress of the extension currently being downloaded.
- // Returns -1 if progress is indeterminate, otherwise a value from 0 to 100.
- int pending_extension_install_download_progress() const {
- return pending_extension_install_download_progress_;
- }
-
- // Sets the status of extension install process.
- void SetPendingExtensionInstallStatusString(const string16& status);
-
- // Gets the status of extension install process.
- const string16& pending_extension_install_status_string() const {
- return pending_extension_install_status_string_;
- }
-
- // Sets the extension install delegate.
- void SetPendingExtensionInstallDelegate(
- ExtensionInstallPrompt::Delegate* delegate);
-
- // Gets the extension install delegate.
- ExtensionInstallPrompt::Delegate* pending_extension_install_delegate() const {
- return pending_extension_install_delegate_;
- }
-
- // Sets the extension install prompt.
- void SetPendingExtensionInstallPrompt(
- const ExtensionInstallPrompt::Prompt& prompt);
-
- // Gets the extension install prompt.
- const ExtensionInstallPrompt::Prompt* pending_extension_install_prompt()
- const {
- return pending_extension_install_prompt_.get();
- }
-
- // Removes any pending extension install state.
- void ClearPendingExtensionInstall();
-
- // Set whether the picker should be showing the use-another-app control.
- void set_show_use_another_service(bool show) {
- show_use_another_service_ = show;
- }
-
- // Whether or not the picker should show the use-another-app control.
- bool show_use_another_service() const {
- return show_use_another_service_;
- }
-
- private:
- // Delete all elements in |installed_services_| and |suggested_extensions_|.
- // Note that this method does not reset the observer.
- void DestroyAll();
-
- // A vector of all installed services in the picker. Each installed service
- // is owned by this model.
- std::vector<InstalledService*> installed_services_;
-
- // A vector of all suggested extensions in the picker.
- std::vector<SuggestedExtension> suggested_extensions_;
-
- // The observer to send notifications to, or NULL if none. Not owned.
- WebIntentPickerModelObserver* observer_;
-
- // The url of the intent service that is being displayed inline, or
- // GURL::EmptyGURL() if none.
- GURL inline_disposition_url_;
-
- // A cached copy of the action that instantiated the picker.
- string16 action_;
-
- // A cached copy of the type that instantiated the picker.
- string16 type_;
-
- // The non-empty url of the default service if the WebIntentsRegistry
- // finds a default service matching the intent being dispatched.
- GURL default_service_url_;
-
- // Indicates that there are still open requests to CWS.
- bool waiting_for_suggestions_;
-
- // Information about the pending extension install.
- std::string pending_extension_install_id_;
- int pending_extension_install_download_progress_;
- string16 pending_extension_install_status_string_;
- ExtensionInstallPrompt::Delegate* pending_extension_install_delegate_;
- scoped_ptr<ExtensionInstallPrompt::Prompt> pending_extension_install_prompt_;
-
- // Indicates the use-another-service control should be shown.
- bool show_use_another_service_;
-
- DISALLOW_COPY_AND_ASSIGN(WebIntentPickerModel);
-};
-
-#endif // CHROME_BROWSER_UI_INTENTS_WEB_INTENT_PICKER_MODEL_H_
diff --git a/chrome/browser/ui/intents/web_intent_picker_model_observer.h b/chrome/browser/ui/intents/web_intent_picker_model_observer.h
deleted file mode 100644
index db5fa20..0000000
--- a/chrome/browser/ui/intents/web_intent_picker_model_observer.h
+++ /dev/null
@@ -1,33 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_UI_INTENTS_WEB_INTENT_PICKER_MODEL_OBSERVER_H_
-#define CHROME_BROWSER_UI_INTENTS_WEB_INTENT_PICKER_MODEL_OBSERVER_H_
-
-#include "base/string16.h"
-
-class GURL;
-class WebIntentPickerModel;
-
-// Observer for changes to the WebIntentPickerModel.
-class WebIntentPickerModelObserver {
- public:
- virtual ~WebIntentPickerModelObserver() {}
-
- // Called when |model| has changed.
- virtual void OnModelChanged(WebIntentPickerModel* model) = 0;
-
- // Called when the favicon at |index| in |model| has changed.
- virtual void OnFaviconChanged(WebIntentPickerModel* model, size_t index) = 0;
-
- // Called when the extension with |extension_id| has its icon changed.
- virtual void OnExtensionIconChanged(WebIntentPickerModel* model,
- const std::string& extension_id) = 0;
-
- // Called when the inline disposition should be displayed for |model|.
- virtual void OnInlineDisposition(const string16& title,
- const GURL& url) = 0;
-};
-
-#endif // CHROME_BROWSER_UI_INTENTS_WEB_INTENT_PICKER_MODEL_OBSERVER_H_
diff --git a/chrome/browser/ui/intents/web_intent_picker_model_unittest.cc b/chrome/browser/ui/intents/web_intent_picker_model_unittest.cc
deleted file mode 100644
index 9768be5..0000000
--- a/chrome/browser/ui/intents/web_intent_picker_model_unittest.cc
+++ /dev/null
@@ -1,236 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "base/utf_string_conversions.h"
-#include "chrome/browser/ui/intents/web_intent_picker_model.h"
-#include "chrome/browser/ui/intents/web_intent_picker_model_observer.h"
-#include "testing/gmock/include/gmock/gmock.h"
-#include "testing/gtest/include/gtest/gtest.h"
-#include "ui/gfx/image/image.h"
-#include "ui/gfx/image/image_unittest_util.h"
-
-namespace {
-
-const string16 kTitle1(ASCIIToUTF16("Foo"));
-const string16 kTitle2(ASCIIToUTF16("Bar"));
-const string16 kTitle3(ASCIIToUTF16("Baz"));
-const string16 kTitle4(ASCIIToUTF16("Biff"));
-const string16 kTitle5(ASCIIToUTF16("Max"));
-const string16 kTitle6(ASCIIToUTF16("Lulz"));
-const GURL kUrl1("http://www.example.com/foo");
-const GURL kUrl2("http://www.example.com/bar");
-const GURL kUrl3("http://www.example.com/baz");
-const std::string kId1("nhkckhebbbncbkefhcpcgepcgfaclehe");
-const std::string kId2("hcpcgepcgfaclehenhkckhebbbncbkef");
-const std::string kId3("aclehenhkckhebbbncbkefhcpcgepcgf");
-const std::string kId4("bclehenhkckhebbbncbkefhcpcgepcgf");
-const std::string kId5("cclehenhkckhebbbncbkefhcpcgepcgf");
-const std::string kId6("dclehenhkckhebbbncbkefhcpcgepcgf");
-const webkit_glue::WebIntentServiceData::Disposition kWindowDisposition(
- webkit_glue::WebIntentServiceData::DISPOSITION_WINDOW);
-const webkit_glue::WebIntentServiceData::Disposition kInlineDisposition(
- webkit_glue::WebIntentServiceData::DISPOSITION_INLINE);
-
-}
-
-class WebIntentPickerModelObserverMock : public WebIntentPickerModelObserver {
- public:
- MOCK_METHOD1(OnModelChanged, void(WebIntentPickerModel* model));
- MOCK_METHOD2(OnFaviconChanged,
- void(WebIntentPickerModel* model, size_t index));
- MOCK_METHOD2(OnExtensionIconChanged,
- void(WebIntentPickerModel* model,
- const std::string& extension_id));
- MOCK_METHOD2(OnInlineDisposition,
- void(const string16& title, const GURL& url));
-};
-
-class WebIntentPickerModelTest : public testing::Test {
- public:
- typedef WebIntentPickerModel::SuggestedExtension SuggestedExtension;
- WebIntentPickerModelTest() {}
-
- virtual void SetUp() {
- testing::Test::SetUp();
- model_.set_observer(&observer_);
- }
-
- WebIntentPickerModel model_;
- WebIntentPickerModelObserverMock observer_;
-};
-
-TEST_F(WebIntentPickerModelTest, AddInstalledService) {
- EXPECT_CALL(observer_, OnModelChanged(&model_)).Times(2);
-
- EXPECT_EQ(0U, model_.GetInstalledServiceCount());
-
- model_.AddInstalledService(kTitle1, kUrl1, kWindowDisposition);
- model_.AddInstalledService(kTitle2, kUrl2, kWindowDisposition);
-
- EXPECT_EQ(2U, model_.GetInstalledServiceCount());
- EXPECT_EQ(kUrl1, model_.GetInstalledServiceAt(0).url);
- EXPECT_EQ(kUrl2, model_.GetInstalledServiceAt(1).url);
-}
-
-// Test that AddInstalledServices() is idempotent.
-TEST_F(WebIntentPickerModelTest, AddInstalledServiceIsIdempotent) {
- EXPECT_CALL(observer_, OnModelChanged(&model_)).Times(2);
-
- EXPECT_EQ(0U, model_.GetInstalledServiceCount());
-
- model_.AddInstalledService(kTitle1, kUrl1, kWindowDisposition);
- model_.AddInstalledService(kTitle2, kUrl2, kWindowDisposition);
-
- EXPECT_EQ(2U, model_.GetInstalledServiceCount());
- EXPECT_EQ(kUrl1, model_.GetInstalledServiceAt(0).url);
- EXPECT_EQ(kUrl2, model_.GetInstalledServiceAt(1).url);
-
- model_.AddInstalledService(kTitle2, kUrl2, kWindowDisposition);
- model_.AddInstalledService(kTitle1, kUrl1, kWindowDisposition);
-
- EXPECT_EQ(2U, model_.GetInstalledServiceCount());
- EXPECT_EQ(kUrl1, model_.GetInstalledServiceAt(0).url);
- EXPECT_EQ(kUrl2, model_.GetInstalledServiceAt(1).url);
-}
-
-
-TEST_F(WebIntentPickerModelTest, RemoveInstalledServiceAt) {
- EXPECT_CALL(observer_, OnModelChanged(&model_)).Times(4);
-
- model_.AddInstalledService(kTitle1, kUrl1, kWindowDisposition);
- model_.AddInstalledService(kTitle2, kUrl2, kWindowDisposition);
- model_.AddInstalledService(kTitle3, kUrl3, kWindowDisposition);
-
- EXPECT_EQ(3U, model_.GetInstalledServiceCount());
-
- model_.RemoveInstalledServiceAt(1);
-
- EXPECT_EQ(2U, model_.GetInstalledServiceCount());
- EXPECT_EQ(kUrl1, model_.GetInstalledServiceAt(0).url);
- EXPECT_EQ(kUrl3, model_.GetInstalledServiceAt(1).url);
-}
-
-TEST_F(WebIntentPickerModelTest, Clear) {
- EXPECT_CALL(observer_, OnModelChanged(&model_)).Times(testing::AtLeast(3));
-
- model_.AddInstalledService(kTitle1, kUrl1, kWindowDisposition);
- model_.AddInstalledService(kTitle2, kUrl2, kWindowDisposition);
-
- EXPECT_EQ(2U, model_.GetInstalledServiceCount());
-
- model_.Clear();
-
- EXPECT_EQ(0U, model_.GetInstalledServiceCount());
-}
-
-TEST_F(WebIntentPickerModelTest, GetInstalledServiceWithURL) {
- EXPECT_CALL(observer_, OnModelChanged(&model_)).Times(2);
-
- model_.AddInstalledService(kTitle1, kUrl1, kWindowDisposition);
- model_.AddInstalledService(kTitle2, kUrl2, kWindowDisposition);
-
- EXPECT_EQ(kTitle2, model_.GetInstalledServiceWithURL(kUrl2)->title);
- EXPECT_EQ(NULL, model_.GetInstalledServiceWithURL(kUrl3));
-}
-
-TEST_F(WebIntentPickerModelTest, UpdateFaviconForServiceWithURL) {
- EXPECT_CALL(observer_, OnModelChanged(&model_)).Times(2);
- EXPECT_CALL(observer_, OnFaviconChanged(&model_, 1U)).Times(1);
-
- model_.AddInstalledService(kTitle1, kUrl1, kWindowDisposition);
- model_.AddInstalledService(kTitle2, kUrl2, kWindowDisposition);
- gfx::Image image(gfx::test::CreateImage());
- model_.UpdateFaviconForServiceWithURL(kUrl2, image);
-
- EXPECT_FALSE(gfx::test::IsEqual(
- image, model_.GetInstalledServiceAt(0).favicon));
- EXPECT_TRUE(gfx::test::IsEqual(
- image, model_.GetInstalledServiceAt(1).favicon));
-}
-
-TEST_F(WebIntentPickerModelTest, AddSuggestedExtensions) {
- EXPECT_CALL(observer_, OnModelChanged(&model_)).Times(1);
-
- EXPECT_EQ(0U, model_.GetSuggestedExtensionCount());
-
- std::vector<WebIntentPickerModel::SuggestedExtension> suggestions;
- suggestions.push_back(
- WebIntentPickerModel::SuggestedExtension(kTitle1, kId1, 3.0));
- suggestions.push_back(
- WebIntentPickerModel::SuggestedExtension(kTitle2, kId2, 4.0));
- model_.AddSuggestedExtensions(suggestions);
-
- EXPECT_EQ(2U, model_.GetSuggestedExtensionCount());
- EXPECT_EQ(kId1, model_.GetSuggestedExtensionAt(0).id);
- EXPECT_EQ(kId2, model_.GetSuggestedExtensionAt(1).id);
-
- EXPECT_EQ(string16(), model_.GetSuggestionsLinkText());
-}
-
-TEST_F(WebIntentPickerModelTest, MaxSuggestedExtensions) {
- EXPECT_CALL(observer_, OnModelChanged(&model_)).Times(1);
-
- std::vector<SuggestedExtension> suggestions;
- suggestions.push_back(SuggestedExtension(kTitle1, kId1, 3.0));
- suggestions.push_back(SuggestedExtension(kTitle2, kId2, 4.3));
- suggestions.push_back(SuggestedExtension(kTitle3, kId3, 4.4));
- suggestions.push_back(SuggestedExtension(kTitle4, kId4, 4.5));
- suggestions.push_back(SuggestedExtension(kTitle5, kId5, 4.6));
- suggestions.push_back(SuggestedExtension(kTitle6, kId6, 4.7));
- model_.AddSuggestedExtensions(suggestions);
-
- // Max to show currently set to 5.
- EXPECT_EQ(5U, model_.GetSuggestedExtensionCount());
- EXPECT_NE(string16(), model_.GetSuggestionsLinkText());
-}
-
-TEST_F(WebIntentPickerModelTest, SetSuggestedExtensionIconWithId) {
- EXPECT_CALL(observer_, OnModelChanged(&model_)).Times(1);
- EXPECT_CALL(observer_, OnExtensionIconChanged(&model_, kId2)).Times(1);
-
- std::vector<SuggestedExtension> suggestions;
- suggestions.push_back(SuggestedExtension(kTitle1, kId1, 3.0));
- suggestions.push_back(SuggestedExtension(kTitle2, kId2, 4.3));
- model_.AddSuggestedExtensions(suggestions);
-
- gfx::Image image(gfx::test::CreateImage());
- model_.SetSuggestedExtensionIconWithId(kId2, image);
-
- EXPECT_FALSE(gfx::test::IsEqual(
- image, model_.GetSuggestedExtensionAt(0).icon));
- EXPECT_TRUE(gfx::test::IsEqual(
- image, model_.GetSuggestedExtensionAt(1).icon));
-}
-
-TEST_F(WebIntentPickerModelTest, SetInlineDisposition) {
- EXPECT_CALL(observer_, OnModelChanged(&model_)).Times(testing::AtLeast(3));
- EXPECT_CALL(observer_, OnInlineDisposition(kTitle2, testing::_)).Times(1);
-
- EXPECT_FALSE(model_.IsInlineDisposition());
- EXPECT_EQ(GURL::EmptyGURL(), model_.inline_disposition_url());
-
- model_.AddInstalledService(kTitle1, kUrl1, kWindowDisposition);
- model_.AddInstalledService(kTitle2, kUrl2, kInlineDisposition);
- model_.SetInlineDisposition(kUrl2);
-
- EXPECT_TRUE(model_.IsInlineDisposition());
- EXPECT_EQ(kUrl2, model_.inline_disposition_url());
-
- model_.Clear();
- EXPECT_FALSE(model_.IsInlineDisposition());
- EXPECT_EQ(GURL::EmptyGURL(), model_.inline_disposition_url());
-}
-
-
-TEST_F(WebIntentPickerModelTest, WaitingForSuggestions) {
- // Default status is that "waiting for suggestions".
- EXPECT_TRUE(model_.IsWaitingForSuggestions());
-
- // "waiting" status can be toggled manually.
- EXPECT_CALL(observer_, OnModelChanged(&model_)).Times(2);
- model_.SetWaitingForSuggestions(false);
- EXPECT_FALSE(model_.IsWaitingForSuggestions());
- model_.SetWaitingForSuggestions(true);
- EXPECT_TRUE(model_.IsWaitingForSuggestions());
-}
diff --git a/chrome/browser/ui/intents/web_intent_picker_unittest.cc b/chrome/browser/ui/intents/web_intent_picker_unittest.cc
deleted file mode 100644
index 9c3d24f..0000000
--- a/chrome/browser/ui/intents/web_intent_picker_unittest.cc
+++ /dev/null
@@ -1,59 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "base/basictypes.h"
-#include "chrome/browser/ui/intents/web_intent_picker.h"
-#include "grit/theme_resources.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-class WebIntentPickerTest : public testing::Test {
- public:
- WebIntentPickerTest() {}
-};
-
-TEST_F(WebIntentPickerTest, GetStarImageIdsFromCWSRating) {
- struct TestCase {
- double rating;
- int index;
- int expected_star_image;
- } test_cases[] = {
- { 3.4, 0, IDR_CWS_STAR_FULL },
- { 3.4, 1, IDR_CWS_STAR_FULL },
- { 3.4, 2, IDR_CWS_STAR_FULL },
- { 3.4, 3, IDR_CWS_STAR_HALF },
- { 3.4, 4, IDR_CWS_STAR_EMPTY },
- { -1.0, 0, IDR_CWS_STAR_EMPTY },
- { -1.0, 1, IDR_CWS_STAR_EMPTY },
- { -1.0, 2, IDR_CWS_STAR_EMPTY },
- { -1.0, 3, IDR_CWS_STAR_EMPTY },
- { -1.0, 4, IDR_CWS_STAR_EMPTY },
- { 6.0, 0, IDR_CWS_STAR_FULL },
- { 6.0, 1, IDR_CWS_STAR_FULL },
- { 6.0, 2, IDR_CWS_STAR_FULL },
- { 6.0, 3, IDR_CWS_STAR_FULL },
- { 6.0, 4, IDR_CWS_STAR_FULL },
- { 1.6, 0, IDR_CWS_STAR_FULL },
- { 1.6, 1, IDR_CWS_STAR_HALF },
- { 1.6, 2, IDR_CWS_STAR_EMPTY },
- { 1.6, 3, IDR_CWS_STAR_EMPTY },
- { 1.6, 4, IDR_CWS_STAR_EMPTY },
- { 4.2, 0, IDR_CWS_STAR_FULL },
- { 4.2, 1, IDR_CWS_STAR_FULL },
- { 4.2, 2, IDR_CWS_STAR_FULL },
- { 4.2, 3, IDR_CWS_STAR_FULL },
- { 4.2, 4, IDR_CWS_STAR_EMPTY },
- { 3.7, 0, IDR_CWS_STAR_FULL },
- { 3.7, 1, IDR_CWS_STAR_FULL },
- { 3.7, 2, IDR_CWS_STAR_FULL },
- { 3.7, 3, IDR_CWS_STAR_FULL },
- { 3.7, 4, IDR_CWS_STAR_EMPTY },
- };
-
- for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_cases); ++i) {
- EXPECT_EQ(test_cases[i].expected_star_image,
- WebIntentPicker::GetNthStarImageIdFromCWSRating(
- test_cases[i].rating,
- test_cases[i].index));
- }
-}
diff --git a/chrome/browser/ui/omnibox/location_bar.h b/chrome/browser/ui/omnibox/location_bar.h
index 8a0849e..610779b 100644
--- a/chrome/browser/ui/omnibox/location_bar.h
+++ b/chrome/browser/ui/omnibox/location_bar.h
@@ -66,11 +66,6 @@ class LocationBar {
// extension is unloaded or crashes.
virtual void InvalidatePageActions() = 0;
-#if defined(ENABLE_WEB_INTENTS)
- // Updates the state of the web intents use-another-service button.
- virtual void UpdateWebIntentsButton() = 0;
-#endif
-
// Updates the state of the button to open a PDF in Adobe Reader.
virtual void UpdateOpenPDFInReaderPrompt() = 0;
diff --git a/chrome/browser/ui/toolbar/action_box_button_controller.cc b/chrome/browser/ui/toolbar/action_box_button_controller.cc
index 7d8c0fd..5044d8f 100644
--- a/chrome/browser/ui/toolbar/action_box_button_controller.cc
+++ b/chrome/browser/ui/toolbar/action_box_button_controller.cc
@@ -9,8 +9,6 @@
#include "base/utf_string_conversions.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/extension_system.h"
-#include "chrome/browser/intents/web_intents_registry_factory.h"
-#include "chrome/browser/intents/web_intents_registry.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_commands.h"
@@ -23,21 +21,11 @@
#include "content/public/browser/notification_source.h"
#include "content/public/browser/user_metrics.h"
#include "content/public/browser/web_contents.h"
-#include "content/public/browser/web_intents_dispatcher.h"
#include "grit/generated_resources.h"
-#include "webkit/glue/web_intent_data.h"
#include "webkit/glue/webkit_glue.h"
namespace {
-#if defined(ENABLE_WEB_INTENTS)
-// This indicates we need to send UMA data about the number of
-// "Share with X" commands shown in the menu after user tried to
-// find share extensions from web store or the first use of action
-// box after browser starts.
-static bool send_uma_share_command_count = true;
-#endif
-
// Share intents get command IDs that are beyond the maximal valid command ID
// (0xDFFF) so that they are not confused with actual commands that appear in
// the menu. Extensions get a reserved block of commands after share handlers.
@@ -51,9 +39,6 @@ enum ActionBoxLocalCommandIds {
EXTENSION_COMMAND_FIRST
};
-const char kShareIntentAction[] = "http://webintents.org/share";
-const char kShareIntentMimeType[] = "text/uri-list";
-
} // namespace
using content::UserMetricsAction;
@@ -81,50 +66,6 @@ void ActionBoxButtonController::OnButtonClicked() {
extensions::ExtensionSystem::Get(browser_->profile())->
extension_service();
-#if defined(ENABLE_WEB_INTENTS)
- // Add share intent triggers and a link to the web store.
- // Web Intents are not currently supported in Incognito mode.
- if (!browser_->profile()->IsOffTheRecord()) {
- int next_share_intent_command_id = SHARE_COMMAND_FIRST;
- share_intent_service_ids_.clear();
- const ExtensionSet* extension_set = extension_service->extensions();
- WebIntentsRegistry* intents_registry =
- WebIntentsRegistryFactory::GetForProfile(browser_->profile());
- for (ExtensionSet::const_iterator it = extension_set->begin();
- it != extension_set->end(); ++it) {
- const extensions::Extension* extension = *it;
- WebIntentsRegistry::IntentServiceList services;
- intents_registry->GetIntentServicesForExtensionFilter(
- ASCIIToUTF16(kShareIntentAction),
- ASCIIToUTF16(kShareIntentMimeType),
- extension->id(),
- &services);
- if (!services.empty()) {
- int command_id = next_share_intent_command_id++;
- if (command_id > SHARE_COMMAND_LAST)
- break;
- // TODO(skare): If an intent supports multiple services, be able to
- // disambiguate. Choosing the first matches the picker behavior; see
- // TODO in WebIntentPickerController::DispatchToInstalledExtension.
- share_intent_service_ids_[command_id] = services[0].service_url;
- menu_model->AddItem(command_id, services[0].title);
- }
- }
-
- // Add link to the Web Store to find additional share intents.
- menu_model->AddItemWithStringId(CWS_FIND_SHARE_INTENTS_COMMAND,
- IDS_FIND_SHARE_INTENTS);
-
- content::RecordAction(UserMetricsAction("ActionBox.ClickButton"));
- if (send_uma_share_command_count) {
- UMA_HISTOGRAM_ENUMERATION("ActionBox.ShareCommandCount",
- next_share_intent_command_id - SHARE_COMMAND_FIRST,
- kMaxShareItemsToShow + 1);
- send_uma_share_command_count = false;
- }
- }
-#endif
-
// Add Extensions.
next_extension_command_id_ = EXTENSION_COMMAND_FIRST;
extension_command_ids_.clear();
@@ -154,20 +95,6 @@ bool ActionBoxButtonController::GetAcceleratorForCommandId(
}
void ActionBoxButtonController::ExecuteCommand(int command_id) {
- // Handle explicit intent triggers for share intent commands.
- if (share_intent_service_ids_.count(command_id) > 0) {
- TriggerExplicitShareIntent(share_intent_service_ids_[command_id]);
- return;
- }
-
-#if defined(ENABLE_WEB_INTENTS)
- // Handle link to the CWS web store.
- if (command_id == CWS_FIND_SHARE_INTENTS_COMMAND) {
- NavigateToWebStoreShareIntentsList();
- return;
- }
-#endif
-
// Handle commands associated with extensions.
// Note that the extension might have been uninstalled or disabled while the
// menu was open (sync perhaps?) but that will just fall through safely.
@@ -229,33 +156,3 @@ void ActionBoxButtonController::Observe(
// We may also want to listen to EXTENSION_LOADED to do the opposite.
extension_command_ids_.erase(extension->id());
}
-
-void ActionBoxButtonController::TriggerExplicitShareIntent(
- const GURL& share_service_url) {
-#if defined(ENABLE_WEB_INTENTS)
- const GURL& current_url =
- browser_->tab_strip_model()->GetActiveWebContents()->GetURL();
- webkit_glue::WebIntentData intent_data(
- ASCIIToUTF16(kShareIntentAction),
- ASCIIToUTF16(kShareIntentMimeType),
- UTF8ToUTF16(current_url.spec()));
- intent_data.service = share_service_url;
- static_cast<content::WebContentsDelegate*>(browser_)->WebIntentDispatch(
- NULL, content::WebIntentsDispatcher::Create(intent_data));
-#endif
-}
-
-void ActionBoxButtonController::NavigateToWebStoreShareIntentsList() {
-#if defined(ENABLE_WEB_INTENTS)
- const GURL& query_url = extension_urls::GetWebstoreIntentQueryURL(
- kShareIntentAction,
- kShareIntentMimeType);
- chrome::NavigateParams params(browser_->profile(), query_url,
- content::PAGE_TRANSITION_LINK);
- params.disposition = NEW_FOREGROUND_TAB;
- chrome::Navigate(&params);
-
- content::RecordAction(UserMetricsAction("ActionBox.FindShareHandlers"));
- send_uma_share_command_count = true;
-#endif
-}
diff --git a/chrome/browser/ui/toolbar/action_box_button_controller.h b/chrome/browser/ui/toolbar/action_box_button_controller.h
index 13872e0..45c5692 100644
--- a/chrome/browser/ui/toolbar/action_box_button_controller.h
+++ b/chrome/browser/ui/toolbar/action_box_button_controller.h
@@ -68,21 +68,10 @@ class ActionBoxButtonController : public ui::SimpleMenuModel::Delegate,
const content::NotificationSource& source,
const content::NotificationDetails& details) OVERRIDE;
- // Handles "share with X" commands.
- void TriggerExplicitShareIntent(const GURL& share_service_url);
-
- // Handles the "Find places to share" command. Navigates the browser to the
- // web store to find extensions with share intents.
- void NavigateToWebStoreShareIntentsList();
-
Browser* browser_;
Delegate* delegate_;
- // The share service strings that have commands associated with them.
- typedef std::map<int, GURL> ShareIntentServiceCommandMap;
- ShareIntentServiceCommandMap share_intent_service_ids_;
-
// The command ID to assign to the next extension that needs one.
int next_extension_command_id_;
diff --git a/chrome/browser/ui/views/external_tab_container_win.cc b/chrome/browser/ui/views/external_tab_container_win.cc
index be5510a..007168b 100644
--- a/chrome/browser/ui/views/external_tab_container_win.cc
+++ b/chrome/browser/ui/views/external_tab_container_win.cc
@@ -25,7 +25,6 @@
#include "chrome/browser/file_select_helper.h"
#include "chrome/browser/history/history_tab_helper.h"
#include "chrome/browser/history/history_types.h"
-#include "chrome/browser/intents/register_intent_handler_infobar_delegate.h"
#include "chrome/browser/pepper_broker_infobar_delegate.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/repost_form_warning_controller.h"
@@ -52,7 +51,6 @@
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/web_contents.h"
-#include "content/public/browser/web_intents_dispatcher.h"
#include "content/public/common/bindings_policy.h"
#include "content/public/common/frame_navigate_params.h"
#include "content/public/common/page_transition_types.h"
@@ -811,23 +809,6 @@ void ExternalTabContainerWin::RegisterProtocolHandler(
user_gesture, NULL);
}
-#if defined(ENABLE_WEB_INTENTS)
-void ExternalTabContainerWin::RegisterIntentHandler(
- WebContents* tab,
- const webkit_glue::WebIntentServiceData& data,
- bool user_gesture) {
- RegisterIntentHandlerInfoBarDelegate::Create(tab, data);
-}
-
-void ExternalTabContainerWin::WebIntentDispatch(
- WebContents* tab,
- content::WebIntentsDispatcher* intents_dispatcher) {
- // TODO(binji) How do we want to display the WebIntentPicker bubble if there
- // is no BrowserWindow?
- delete intents_dispatcher;
-}
-#endif
-
void ExternalTabContainerWin::FindReply(WebContents* tab,
int request_id,
int number_of_matches,
diff --git a/chrome/browser/ui/views/external_tab_container_win.h b/chrome/browser/ui/views/external_tab_container_win.h
index babc1ae..3d06fec 100644
--- a/chrome/browser/ui/views/external_tab_container_win.h
+++ b/chrome/browser/ui/views/external_tab_container_win.h
@@ -34,10 +34,6 @@ class TabContentsContainer;
class RenderViewContextMenuViews;
struct NavigationInfo;
-namespace content {
-class WebIntentsDispatcher;
-}
-
namespace ui {
class ViewProp;
}
@@ -161,15 +157,6 @@ class ExternalTabContainerWin : public ExternalTabContainer,
const GURL& url,
const string16& title,
bool user_gesture) OVERRIDE;
-#if defined(ENABLE_WEB_INTENTS)
- virtual void RegisterIntentHandler(
- content::WebContents* tab,
- const webkit_glue::WebIntentServiceData& data,
- bool user_gesture) OVERRIDE;
- virtual void WebIntentDispatch(
- content::WebContents* tab,
- content::WebIntentsDispatcher* intents_dispatcher) OVERRIDE;
-#endif
virtual void FindReply(content::WebContents* tab,
int request_id,
int number_of_matches,
diff --git a/chrome/browser/ui/views/location_bar/location_bar_view.cc b/chrome/browser/ui/views/location_bar/location_bar_view.cc
index 76f0852..524d5b0 100644
--- a/chrome/browser/ui/views/location_bar/location_bar_view.cc
+++ b/chrome/browser/ui/views/location_bar/location_bar_view.cc
@@ -48,7 +48,6 @@
#include "chrome/browser/ui/views/location_bar/script_bubble_icon_view.h"
#include "chrome/browser/ui/views/location_bar/selected_keyword_view.h"
#include "chrome/browser/ui/views/location_bar/star_view.h"
-#include "chrome/browser/ui/views/location_bar/web_intents_button_view.h"
#include "chrome/browser/ui/views/location_bar/zoom_bubble_view.h"
#include "chrome/browser/ui/views/location_bar/zoom_view.h"
#include "chrome/browser/ui/views/omnibox/omnibox_view_views.h"
@@ -186,9 +185,6 @@ LocationBarView::LocationBarView(Browser* browser,
open_pdf_in_reader_view_(NULL),
script_bubble_icon_view_(NULL),
star_view_(NULL),
-#if defined(ENABLE_WEB_INTENTS)
- web_intents_button_view_(NULL),
-#endif
action_box_button_view_(NULL),
mode_(mode),
show_focus_rect_(false),
@@ -288,13 +284,6 @@ void LocationBarView::Init() {
zoom_view_->set_id(VIEW_ID_ZOOM_BUTTON);
AddChildView(zoom_view_);
-#if defined(ENABLE_WEB_INTENTS)
- web_intents_button_view_ =
- new WebIntentsButtonView(this, kWIBubbleBackgroundImages, font_,
- GetColor(ToolbarModel::NONE, TEXT));
- AddChildView(web_intents_button_view_);
-#endif
-
open_pdf_in_reader_view_ = new OpenPDFInReaderView(this);
AddChildView(open_pdf_in_reader_view_);
@@ -422,9 +411,6 @@ void LocationBarView::Update(const WebContents* tab_for_state_restoring) {
RefreshZoomView();
RefreshPageActionViews();
RefreshScriptBubble();
-#if defined(ENABLE_WEB_INTENTS)
- web_intents_button_view_->Update(GetWebContents());
-#endif
open_pdf_in_reader_view_->Update(
model_->GetInputInProgress() ? NULL : GetWebContents());
@@ -501,15 +487,6 @@ void LocationBarView::InvalidatePageActions() {
}
}
-#if defined(ENABLE_WEB_INTENTS)
-void LocationBarView::UpdateWebIntentsButton() {
- web_intents_button_view_->Update(GetWebContents());
-
- Layout();
- SchedulePaint();
-}
-#endif
-
void LocationBarView::UpdateOpenPDFInReaderPrompt() {
open_pdf_in_reader_view_->Update(
model_->GetInputInProgress() ? NULL : GetWebContents());
@@ -793,14 +770,6 @@ void LocationBarView::Layout() {
(*i)->GetBuiltInHorizontalPadding(), (*i));
}
}
-#if defined(ENABLE_WEB_INTENTS)
- if (web_intents_button_view_->visible()) {
- right_decorations.AddDecoration(
- kBubbleLocationY, 0, false, 0, GetEdgeItemPadding(), GetItemPadding(),
- web_intents_button_view_->GetBuiltInHorizontalPadding(),
- web_intents_button_view_);
- }
-#endif
if (show_keyword_hint) {
right_decorations.AddDecoration(
kVerticalEdgeThickness, 0, true, 0, GetEdgeItemPadding(),
diff --git a/chrome/browser/ui/views/location_bar/location_bar_view.h b/chrome/browser/ui/views/location_bar/location_bar_view.h
index 75abbf9..345994e 100644
--- a/chrome/browser/ui/views/location_bar/location_bar_view.h
+++ b/chrome/browser/ui/views/location_bar/location_bar_view.h
@@ -48,7 +48,6 @@ class ScriptBubbleIconView;
class SelectedKeywordView;
class StarView;
class TemplateURLService;
-class WebIntentsButtonView;
class ZoomView;
namespace views {
@@ -300,9 +299,6 @@ class LocationBarView : public LocationBar,
virtual void UpdateContentSettingsIcons() OVERRIDE;
virtual void UpdatePageActions() OVERRIDE;
virtual void InvalidatePageActions() OVERRIDE;
-#if defined(ENABLE_WEB_INTENTS)
- virtual void UpdateWebIntentsButton() OVERRIDE;
-#endif
virtual void UpdateOpenPDFInReaderPrompt() OVERRIDE;
virtual void SaveStateToContents(content::WebContents* contents) OVERRIDE;
virtual void Revert() OVERRIDE;
@@ -485,11 +481,6 @@ class LocationBarView : public LocationBar,
// The star.
StarView* star_view_;
-#if defined(ENABLE_WEB_INTENTS)
- // The web intents choose-another-service button
- WebIntentsButtonView* web_intents_button_view_;
-#endif
-
// The action box button (plus).
ActionBoxButtonView* action_box_button_view_;
diff --git a/chrome/browser/ui/views/location_bar/web_intents_button_view.cc b/chrome/browser/ui/views/location_bar/web_intents_button_view.cc
deleted file mode 100644
index 603ac26..0000000
--- a/chrome/browser/ui/views/location_bar/web_intents_button_view.cc
+++ /dev/null
@@ -1,64 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/ui/views/location_bar/web_intents_button_view.h"
-
-#include "chrome/browser/ui/intents/web_intent_picker_controller.h"
-#include "chrome/browser/ui/views/location_bar/location_bar_view.h"
-#include "grit/generated_resources.h"
-#include "ui/base/animation/slide_animation.h"
-#include "ui/base/animation/tween.h"
-#include "ui/base/l10n/l10n_util.h"
-
-// Animation time to open the button.
-const int kMoveTimeMs = 150;
-
-WebIntentsButtonView::WebIntentsButtonView(LocationBarView* parent,
- const int background_images[],
- const gfx::Font& font,
- SkColor font_color)
- : LocationBarDecorationView(parent, background_images, font, font_color) {
-}
-
-void WebIntentsButtonView::Update(content::WebContents* web_contents) {
- WebIntentPickerController* web_intent_picker_controller =
- web_contents ? WebIntentPickerController::FromWebContents(web_contents)
- : NULL;
- if (!web_intent_picker_controller ||
- !web_intent_picker_controller->ShowLocationBarPickerButton()) {
- SetVisible(false);
- return;
- }
-
- int animated_string_id = IDS_INTENT_PICKER_USE_ANOTHER_SERVICE;
- string16 animated_text = l10n_util::GetStringUTF16(animated_string_id);
- SetTooltipText(animated_text);
- SetVisible(true);
-
- // Set the flag to always draw text before we start to draw the label,
- // to avoid any possible race.
- AlwaysDrawText();
-
- if (!web_intent_picker_controller->location_bar_picker_button_indicated()) {
- StartLabelAnimation(animated_text, kMoveTimeMs);
- web_intent_picker_controller->SetLocationBarPickerButtonIndicated();
- }
-}
-
-void WebIntentsButtonView::OnClick(LocationBarView* parent) {
- content::WebContents* web_contents = parent->GetWebContents();
- if (!web_contents)
- return;
-
- WebIntentPickerController::FromWebContents(web_contents)->
- LocationBarPickerButtonClicked();
-}
-
-int WebIntentsButtonView::GetTextAnimationSize(double state, int text_size) {
- if (state < 1.0) {
- return static_cast<int>(text_size * state);
- }
-
- return text_size;
-}
diff --git a/chrome/browser/ui/views/location_bar/web_intents_button_view.h b/chrome/browser/ui/views/location_bar/web_intents_button_view.h
deleted file mode 100644
index 4cf3043..0000000
--- a/chrome/browser/ui/views/location_bar/web_intents_button_view.h
+++ /dev/null
@@ -1,34 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_WEB_INTENTS_BUTTON_VIEW_H_
-#define CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_WEB_INTENTS_BUTTON_VIEW_H_
-
-#include "base/memory/scoped_ptr.h"
-#include "base/string16.h"
-#include "chrome/browser/ui/views/location_bar/location_bar_decoration_view.h"
-
-// Display the use-another-service button for web intents service pages
-// displayed in a tab.
-class WebIntentsButtonView : public LocationBarDecorationView {
- public:
- // |parent| and |background_images| passed to superclass. They are a weak ptr
- // to owning class and the background images for the button background.
- WebIntentsButtonView(LocationBarView* parent,
- const int background_images[],
- const gfx::Font& font,
- SkColor font_color);
- virtual ~WebIntentsButtonView() {}
-
- virtual void Update(content::WebContents* web_contents) OVERRIDE;
-
- protected:
- virtual void OnClick(LocationBarView* parent) OVERRIDE;
- virtual int GetTextAnimationSize(double state, int text_size) OVERRIDE;
-
- private:
- DISALLOW_IMPLICIT_CONSTRUCTORS(WebIntentsButtonView);
-};
-
-#endif // CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_WEB_INTENTS_BUTTON_VIEW_H_
diff --git a/chrome/browser/ui/views/web_intent_picker_views.cc b/chrome/browser/ui/views/web_intent_picker_views.cc
deleted file mode 100644
index a1e555e..0000000
--- a/chrome/browser/ui/views/web_intent_picker_views.cc
+++ /dev/null
@@ -1,1601 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include <algorithm>
-#include <vector>
-
-#include "base/memory/scoped_vector.h"
-#include "base/time.h"
-#include "base/timer.h"
-#include "base/utf_string_conversions.h"
-#include "chrome/browser/download/download_util.h"
-#include "chrome/browser/tab_contents/tab_util.h"
-#include "chrome/browser/ui/browser_finder.h"
-#include "chrome/browser/ui/browser_navigator.h"
-#include "chrome/browser/ui/chrome_style.h"
-#include "chrome/browser/ui/intents/web_intent_inline_disposition_delegate.h"
-#include "chrome/browser/ui/intents/web_intent_picker.h"
-#include "chrome/browser/ui/intents/web_intent_picker_delegate.h"
-#include "chrome/browser/ui/intents/web_intent_picker_model.h"
-#include "chrome/browser/ui/intents/web_intent_picker_model_observer.h"
-#include "chrome/browser/ui/views/constrained_window_views.h"
-#include "chrome/browser/ui/views/frame/browser_view.h"
-#include "chrome/browser/ui/views/location_bar/location_icon_view.h"
-#include "chrome/browser/ui/views/toolbar_view.h"
-#include "chrome/common/extensions/extension_constants.h"
-#include "content/public/browser/web_contents.h"
-#include "content/public/browser/web_contents_view.h"
-#include "grit/chromium_strings.h"
-#include "grit/generated_resources.h"
-#include "grit/google_chrome_strings.h"
-#include "grit/theme_resources.h"
-#include "grit/ui_resources.h"
-#include "ipc/ipc_message.h"
-#include "third_party/skia/include/core/SkColor.h"
-#include "ui/base/l10n/l10n_util.h"
-#include "ui/base/resource/resource_bundle.h"
-#include "ui/base/text/text_elider.h"
-#include "ui/gfx/canvas.h"
-#include "ui/gfx/image/image.h"
-#include "ui/gfx/image/image_skia_operations.h"
-#include "ui/views/border.h"
-#include "ui/views/controls/button/image_button.h"
-#include "ui/views/controls/button/text_button.h"
-#include "ui/views/controls/image_view.h"
-#include "ui/views/controls/label.h"
-#include "ui/views/controls/link.h"
-#include "ui/views/controls/link_listener.h"
-#include "ui/views/controls/separator.h"
-#include "ui/views/controls/throbber.h"
-#include "ui/views/controls/webview/webview.h"
-#include "ui/views/layout/box_layout.h"
-#include "ui/views/layout/fill_layout.h"
-#include "ui/views/layout/grid_layout.h"
-#include "ui/views/layout/layout_constants.h"
-#include "ui/views/view.h"
-#include "ui/views/widget/widget.h"
-#include "ui/views/window/dialog_delegate.h"
-#include "ui/views/window/non_client_view.h"
-
-using content::WebContents;
-using views::GridLayout;
-
-namespace {
-
-// The color used to dim disabled elements.
-const SkColor kHalfOpacityWhite = SkColorSetARGB(128, 255, 255, 255);
-
-// The color used to display an enabled label.
-const SkColor kEnabledLabelColor = SkColorSetRGB(51, 51, 51);
-
-// The color used to display an enabled link.
-const SkColor kEnabledLinkColor = SkColorSetRGB(17, 85, 204);
-
-// The color used to display a disabled link.
-const SkColor kDisabledLinkColor = SkColorSetRGB(128, 128, 128);
-
-// The time between successive throbber frames in milliseconds.
-const int kThrobberFrameTimeMs = 50;
-
-// Width of IntentView action button in pixels
-const int kButtonWidth = 130;
-
-// Minimum number of action buttons - fill up with suggestions as needed.
-const int kMinRowCount = 4;
-
-// Maximum number of action buttons - do not add suggestions to reach.
-const int kMaxRowCount = 8;
-
-// The vertical padding around the UI elements in the waiting view.
-const int kWaitingViewVerticalPadding = 40;
-
-// Enables or disables all child views of |view|.
-void EnableChildViews(views::View* view, bool enabled) {
- for (int i = 0; i < view->child_count(); ++i) {
- views::View* child = view->child_at(i);
- child->SetEnabled(enabled);
- }
-}
-
-// Create a "close" button.
-views::ImageButton* CreateCloseButton(views::ButtonListener* listener) {
- ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
- views::ImageButton* close_button = new views::ImageButton(listener);
- close_button->SetImage(views::CustomButton::STATE_NORMAL,
- rb.GetImageSkiaNamed(IDR_CLOSE_DIALOG));
- close_button->SetImage(views::CustomButton::STATE_HOVERED,
- rb.GetImageSkiaNamed(IDR_CLOSE_DIALOG_H));
- close_button->SetImage(views::CustomButton::STATE_PRESSED,
- rb.GetImageSkiaNamed(IDR_CLOSE_DIALOG_P));
- return close_button;
-}
-
-// Creates a label.
-views::Label* CreateLabel() {
- views::Label* label = new views::Label();
- label->SetEnabledColor(kEnabledLabelColor);
- label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
- return label;
-}
-
-// Creates a title-style label.
-views::Label* CreateTitleLabel() {
- views::Label* label = CreateLabel();
- label->SetFont(ui::ResourceBundle::GetSharedInstance().GetFont(
- ui::ResourceBundle::MediumFont));
- const int kLabelBuiltinTopPadding = 5;
- label->set_border(views::Border::CreateEmptyBorder(
- WebIntentPicker::kContentAreaBorder -
- chrome_style::kCloseButtonPadding -
- kLabelBuiltinTopPadding,
- 0, 0, 0));
- return label;
-}
-
-// Creates a link.
-views::Link* CreateLink() {
- views::Link* link = new views::Link();
- link->SetEnabledColor(kEnabledLinkColor);
- link->SetDisabledColor(kDisabledLinkColor);
- link->SetHorizontalAlignment(gfx::ALIGN_LEFT);
- return link;
-}
-
-// Creates a header for the inline disposition dialog.
-views::View* CreateInlineDispositionHeader(
- views::ImageView* app_icon,
- views::Label* app_title,
- views::Link* use_another_service_link) {
- views::View* header = new views::View();
- views::GridLayout* grid_layout = new views::GridLayout(header);
- const int kIconBuiltinTopPadding = 6;
- grid_layout->SetInsets(
- WebIntentPicker::kContentAreaBorder -
- chrome_style::kCloseButtonPadding -
- kIconBuiltinTopPadding,
- 0, 0, 0);
- header->SetLayoutManager(grid_layout);
- views::ColumnSet* header_cs = grid_layout->AddColumnSet(0);
- header_cs->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0,
- GridLayout::USE_PREF, 0, 0); // App icon.
- header_cs->AddPaddingColumn(0, WebIntentPicker::kIconTextPadding);
- header_cs->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 1,
- GridLayout::USE_PREF, 0, 0); // App title.
- header_cs->AddPaddingColumn(0, views::kUnrelatedControlHorizontalSpacing);
- header_cs->AddColumn(GridLayout::TRAILING, GridLayout::CENTER, 0,
- GridLayout::USE_PREF, 0, 0); // Use another app link.
- grid_layout->StartRow(0, 0);
- grid_layout->AddView(app_icon);
- grid_layout->AddView(app_title);
- grid_layout->AddView(use_another_service_link);
- header->Layout();
- return header;
-}
-
-// Checks whether the inline disposition dialog should show the link for using
-// another service.
-bool IsUseAnotherServiceVisible(WebIntentPickerModel* model) {
- DCHECK(model);
- return model->show_use_another_service() &&
- (model->GetInstalledServiceCount() > 1 ||
- model->GetSuggestedExtensionCount());
-}
-
-
-// StarsView -------------------------------------------------------------------
-
-// A view that displays 5 stars: empty, full or half full, given a rating in
-// the range [0,5].
-class StarsView : public views::View {
- public:
- explicit StarsView(double rating);
- virtual ~StarsView();
-
- private:
- // The star rating to display, in the range [0,5].
- double rating_;
-
- DISALLOW_COPY_AND_ASSIGN(StarsView);
-};
-
-StarsView::StarsView(double rating)
- : rating_(rating) {
- const int kSpacing = 1; // Spacing between stars in pixels.
-
- ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
- SetLayoutManager(
- new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, kSpacing));
-
- for (int i = 0; i < 5; ++i) {
- views::ImageView* image = new views::ImageView();
- image->SetImage(rb.GetImageSkiaNamed(
- WebIntentPicker::GetNthStarImageIdFromCWSRating(rating, i)));
- AddChildView(image);
- }
-
- // TODO(binji): Add tooltip with text rating
- // "Average Rating: X.XX stars (YYYYY)"
- // Y = "1: Hated it, 2: Disliked it, 3: It was okay, 4: Liked it,
- // 5: Loved it"
- // Choose Y based on rounded X.
-}
-
-StarsView::~StarsView() {
-}
-
-
-// ThrobberNativeTextButton ----------------------------------------------------
-
-// A native text button that can display a throbber in place of its icon. Much
-// of the logic of this class is copied from ui/views/controls/throbber.h.
-class ThrobberNativeTextButton : public views::NativeTextButton {
- public:
- ThrobberNativeTextButton(views::ButtonListener* listener,
- const string16& text);
- virtual ~ThrobberNativeTextButton();
-
- // Start or stop the throbber.
- void StartThrobber();
- void StopThrobber();
-
- // Set the throbber bitmap to use. IDR_THROBBER is used by default.
- void SetFrames(const gfx::ImageSkia* frames);
-
- // Provide a preferred size, accomodating buttons wider than their text.
- virtual gfx::Size GetPreferredSize() OVERRIDE;
-
- // Set the width desired for this button.
- void set_preferred_width(int width) { preferred_width_ = width; }
-
- protected:
- virtual const gfx::ImageSkia& GetImageToPaint() const OVERRIDE;
-
- private:
- // The timer callback to schedule painting this view.
- void Run();
-
- // Image that contains the throbber frames.
- const gfx::ImageSkia* frames_;
-
- // The currently displayed frame, given to GetImageToPaint.
- mutable gfx::ImageSkia this_frame_;
-
- // How long one frame is displayed.
- base::TimeDelta frame_time_;
-
- // Used to schedule Run calls.
- base::RepeatingTimer<ThrobberNativeTextButton> timer_;
-
- // How many frames we have.
- int frame_count_;
-
- // Time when StartThrobber was called.
- base::TimeTicks start_time_;
-
- // Whether the throbber is shown an animating.
- bool running_;
-
- // The width this button should assume.
- int preferred_width_;
-
- DISALLOW_COPY_AND_ASSIGN(ThrobberNativeTextButton);
-};
-
-ThrobberNativeTextButton::ThrobberNativeTextButton(
- views::ButtonListener* listener, const string16& text)
- : NativeTextButton(listener, text),
- frame_time_(base::TimeDelta::FromMilliseconds(kThrobberFrameTimeMs)),
- frame_count_(0),
- running_(false),
- preferred_width_(0) {
- SetFrames(ui::ResourceBundle::GetSharedInstance().GetImageNamed(
- IDR_THROBBER).ToImageSkia());
-}
-
-ThrobberNativeTextButton::~ThrobberNativeTextButton() {
- StopThrobber();
-}
-
-void ThrobberNativeTextButton::StartThrobber() {
- if (running_)
- return;
-
- start_time_ = base::TimeTicks::Now();
- timer_.Start(FROM_HERE, frame_time_, this, &ThrobberNativeTextButton::Run);
- running_ = true;
-
- SchedulePaint();
-}
-
-void ThrobberNativeTextButton::StopThrobber() {
- if (!running_)
- return;
-
- timer_.Stop();
- running_ = false;
-}
-
-void ThrobberNativeTextButton::SetFrames(const gfx::ImageSkia* frames) {
- frames_ = frames;
- DCHECK(frames_->width() > 0 && frames_->height() > 0);
- DCHECK(frames_->width() % frames_->height() == 0);
- frame_count_ = frames_->width() / frames_->height();
- PreferredSizeChanged();
-}
-
-gfx::Size ThrobberNativeTextButton::GetPreferredSize() {
- gfx::Size size = NativeTextButton::GetPreferredSize();
- if (preferred_width_)
- size.set_width(preferred_width_);
- return size;
-}
-
-const gfx::ImageSkia& ThrobberNativeTextButton::GetImageToPaint() const {
- if (!running_)
- return NativeTextButton::GetImageToPaint();
-
- const base::TimeDelta elapsed_time = base::TimeTicks::Now() - start_time_;
- const int current_frame =
- static_cast<int>(elapsed_time / frame_time_) % frame_count_;
- const int image_size = frames_->height();
- const int image_offset = current_frame * image_size;
-
- gfx::Rect subset_rect(image_offset, 0, image_size, image_size);
- this_frame_ = gfx::ImageSkiaOperations::ExtractSubset(*frames_, subset_rect);
- return this_frame_;
-}
-
-void ThrobberNativeTextButton::Run() {
- DCHECK(running_);
-
- SchedulePaint();
-}
-
-
-// SpinnerProgressIndicator ----------------------------------------------------
-class SpinnerProgressIndicator : public views::View {
- public:
- SpinnerProgressIndicator();
- virtual ~SpinnerProgressIndicator();
-
- void SetPercentDone(int percent);
- void SetIndeterminate(bool indetereminate);
-
- // Overridden from views::View.
- virtual void Paint(gfx::Canvas* canvas) OVERRIDE;
- virtual gfx::Size GetPreferredSize() OVERRIDE;
-
- private:
- void UpdateTimer();
- int GetProgressAngle();
-
- static const int kTimerIntervalMs = 1000 / 30;
- static const int kSpinRateDegreesPerSecond = 270;
-
- int percent_done_;
- int indeterminate_;
-
- base::TimeTicks start_time_;
- base::RepeatingTimer<SpinnerProgressIndicator> timer_;
-
- DISALLOW_COPY_AND_ASSIGN(SpinnerProgressIndicator);
-};
-
-SpinnerProgressIndicator::SpinnerProgressIndicator()
- : percent_done_(0),
- indeterminate_(true) {}
-
-SpinnerProgressIndicator::~SpinnerProgressIndicator() {
-}
-
-void SpinnerProgressIndicator::SetPercentDone(int percent) {
- percent_done_ = percent;
- SchedulePaint();
- UpdateTimer();
-}
-
-void SpinnerProgressIndicator::SetIndeterminate(bool indetereminate) {
- indeterminate_ = indetereminate;
- SchedulePaint();
- UpdateTimer();
-}
-
-void SpinnerProgressIndicator::Paint(gfx::Canvas* canvas) {
- ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
- gfx::ImageSkia* fg = rb.GetImageSkiaNamed(IDR_WEB_INTENT_PROGRESS_FOREGROUND);
- gfx::ImageSkia* bg = rb.GetImageSkiaNamed(IDR_WEB_INTENT_PROGRESS_BACKGROUND);
- download_util::PaintCustomDownloadProgress(
- canvas,
- *bg,
- *fg,
- fg->width(),
- bounds(),
- GetProgressAngle(),
- indeterminate_ ? -1 : percent_done_);
-}
-
-gfx::Size SpinnerProgressIndicator::GetPreferredSize() {
- ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
- gfx::ImageSkia* fg = rb.GetImageSkiaNamed(IDR_WEB_INTENT_PROGRESS_FOREGROUND);
- return fg->size();
-}
-
-void SpinnerProgressIndicator::UpdateTimer() {
- if (!parent() || !indeterminate_) {
- timer_.Stop();
- return;
- }
-
- if (!timer_.IsRunning()) {
- start_time_ = base::TimeTicks::Now();
- timer_.Start(FROM_HERE, base::TimeDelta::FromMilliseconds(kTimerIntervalMs),
- this, &SpinnerProgressIndicator::SchedulePaint);
- }
-}
-
-int SpinnerProgressIndicator::GetProgressAngle() {
- if (!indeterminate_)
- return download_util::kStartAngleDegrees;
- base::TimeDelta delta = base::TimeTicks::Now() - start_time_;
- int angle = delta.InSecondsF() * kSpinRateDegreesPerSecond;
- return angle % 360;
-}
-
-
-// WaitingView ----------------------------------------------------------
-class WaitingView : public views::View {
- public:
- WaitingView(views::ButtonListener* listener, bool use_close_button);
- virtual ~WaitingView();
-
- private:
- DISALLOW_COPY_AND_ASSIGN(WaitingView);
-};
-
-WaitingView::WaitingView(views::ButtonListener* listener,
- bool use_close_button) {
- views::GridLayout* layout = new views::GridLayout(this);
- layout->set_minimum_size(gfx::Size(WebIntentPicker::kWindowMinWidth, 0));
- const int kMessageBuiltinBottomPadding = 3;
- layout->SetInsets(chrome_style::kCloseButtonPadding,
- 0,
- kWaitingViewVerticalPadding - kMessageBuiltinBottomPadding,
- 0);
- SetLayoutManager(layout);
-
- enum GridLayoutColumnSets {
- HEADER_ROW,
- CONTENT_ROW,
- };
- views::ColumnSet* header_cs = layout->AddColumnSet(HEADER_ROW);
- header_cs->AddPaddingColumn(1, 1);
- header_cs->AddColumn(GridLayout::TRAILING, GridLayout::LEADING, 0,
- GridLayout::USE_PREF, 0, 0);
- header_cs->AddPaddingColumn(
- 0, chrome_style::kCloseButtonPadding);
-
- views::ColumnSet* content_cs = layout->AddColumnSet(CONTENT_ROW);
- content_cs->AddPaddingColumn(0, views::kPanelHorizIndentation);
- content_cs->AddColumn(GridLayout::CENTER, GridLayout::CENTER, 1,
- GridLayout::USE_PREF, 0, 0);
- content_cs->AddPaddingColumn(0, views::kPanelHorizIndentation);
-
- // Close button
- layout->StartRow(0, HEADER_ROW);
- views::ImageButton* close_button = CreateCloseButton(listener);
- layout->AddView(close_button);
- close_button->SetVisible(use_close_button);
-
- // Throbber
- layout->AddPaddingRow(0,
- kWaitingViewVerticalPadding -
- chrome_style::kCloseButtonPadding -
- close_button->GetPreferredSize().height());
- layout->StartRow(0, CONTENT_ROW);
- SpinnerProgressIndicator* throbber = new SpinnerProgressIndicator();
- layout->AddView(throbber);
-
- // Message
- const int kMessageBuiltinTopPadding = 5;
- layout->AddPaddingRow(0,
- chrome_style::kRowPadding -
- kMessageBuiltinTopPadding);
- layout->StartRow(0, CONTENT_ROW);
- views::Label* label = CreateLabel();
- label->SetHorizontalAlignment(gfx::ALIGN_CENTER);
- label->SetText(l10n_util::GetStringUTF16(IDS_INTENT_PICKER_WAIT_FOR_CWS));
- layout->AddView(label);
-
- // Start the throbber.
- throbber->SetIndeterminate(true);
-}
-
-WaitingView::~WaitingView() {
-}
-
-
-// IntentRowView --------------------------------------------------
-
-// A view for each row in the IntentsView. It displays information
-// for both installed and suggested intent handlers.
-class IntentRowView : public views::View,
- public views::ButtonListener,
- public views::LinkListener {
- public:
- enum ActionType {
- ACTION_UNKNOWN,
- ACTION_INSTALL,
- ACTION_INVOKE
- };
-
- class Delegate {
- public:
- // Called when the user clicks the "Add to Chrome" button.
- virtual void OnExtensionInstallClicked(const std::string& extension_id) = 0;
-
- // Called when the user clicks the extension title link.
- virtual void OnExtensionLinkClicked(
- const std::string& extension_id,
- WindowOpenDisposition disposition) = 0;
-
- // Called when the action button is clicked. |type| indicates the requested
- // kind of action, and |tag| identifies the service or extension to
- // operate on.
- virtual void OnActionButtonClicked(ActionType type, size_t tag) = 0;
-
- protected:
- virtual ~Delegate() {}
- };
-
- virtual ~IntentRowView();
-
- // Creates a new view for |service| or |extension| depending on which
- // value is not NULL.
- static IntentRowView* CreateHandlerRow(
- const WebIntentPickerModel::InstalledService* service,
- const WebIntentPickerModel::SuggestedExtension* extension,
- int tag,
- IntentRowView::Delegate* delegate,
- int preferred_width);
-
- // ButtonListener implementation.
- virtual void ButtonPressed(views::Button* sender,
- const ui::Event& event) OVERRIDE;
-
- // LinkListener implementation.
- virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE;
-
- // Start an animating throbber for this row, and hide the star rating and the
- // install button.
- void StartThrobber();
-
- void MarkBusy(const std::string& extension_id);
-
- // Stop the throbber for this row, and show the star rating and the install
- // button.
- void StopThrobber();
-
- protected:
- virtual void OnEnabledChanged() OVERRIDE;
-
- virtual void PaintChildren(gfx::Canvas* canvas) OVERRIDE;
-
- private:
- IntentRowView(ActionType type, size_t tag);
-
- // Gets the proper message string associated with |type_|.
- string16 GetActionButtonMessage();
-
- // Identifier for the suggested extension displayed in this row.
- std::string extension_id_;
-
- // A delegate to respond to button presses and clicked links.
- Delegate* delegate_;
-
- // The icon of the extension.
- views::ImageView* icon_;
-
- // The title of the extension, which links to the CWS detailed description of
- // this extension.
- views::View* title_link_;
-
- // The star rating of this extension.
- StarsView* stars_;
-
- // A button to install the extension.
- ThrobberNativeTextButton* install_button_;
-
- // The type of action that is invoked from the row's button.
- ActionType type_;
-
- // A tag identifying the data associated with this row. For both installed
- // and suggested services, this is an index into the respective collections
- // on the WebIntentPickerModel.
- size_t tag_;
-
- DISALLOW_COPY_AND_ASSIGN(IntentRowView);
-};
-
-IntentRowView::IntentRowView(ActionType type, size_t tag)
- : delegate_(NULL),
- icon_(NULL),
- title_link_(NULL),
- stars_(NULL),
- install_button_(NULL),
- type_(type),
- tag_(tag) {}
-
-IntentRowView* IntentRowView::CreateHandlerRow(
- const WebIntentPickerModel::InstalledService* service,
- const WebIntentPickerModel::SuggestedExtension* extension,
- int tag,
- IntentRowView::Delegate* delegate,
- int preferred_width) {
-
- // one or the other must be set...exclusively
- DCHECK((service != NULL || extension != NULL) &&
- (service == NULL || extension == NULL));
-
-
- const string16& title = (service != NULL)
- ? service->title : extension->title;
-
- // TODO(groby): Once links are properly sized (see SuggestionRowViewLayout
- // refactor notes), can simply SetElideBehavior(views::Label::ELIDE_AT_END).
- // Note: Verify that views links do not treat empty space at the end as
- // part of the link, if this change happens.
- string16 elided_title = ui::ElideText(title, gfx::Font(),
- WebIntentPicker::kTitleLinkMaxWidth,
- ui::ELIDE_AT_END);
-
- const gfx::ImageSkia* icon = NULL;
- StarsView* stars = NULL;
- views::Label* label = NULL;
- IntentRowView* view;
- if (service != NULL) {
- view = new IntentRowView(ACTION_INVOKE, tag);
- icon = service->favicon.ToImageSkia();
- label = CreateLabel();
- label->SetText(elided_title);
- } else {
- view = new IntentRowView(ACTION_INSTALL, tag);
- view->extension_id_ = extension->id;
- icon = extension->icon.ToImageSkia();
- views::Link* link = CreateLink();
- link->SetText(elided_title);
- link->set_listener(view);
- label = link;
- stars = new StarsView(extension->average_rating);
- }
-
- view->delegate_ = delegate;
-
- views::GridLayout* grid_layout = new views::GridLayout(view);
- view->SetLayoutManager(grid_layout);
-
- views::ColumnSet* columns = grid_layout->AddColumnSet(0);
- columns->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0,
- GridLayout::USE_PREF, 0, 0); // Icon.
- columns->AddPaddingColumn(0, WebIntentPicker::kIconTextPadding);
- columns->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 1,
- GridLayout::FIXED, WebIntentPicker::kTitleLinkMaxWidth, 0);
- const int kStarRatingHorizontalSpacing = 20;
- columns->AddPaddingColumn(0, kStarRatingHorizontalSpacing);
- if (stars != NULL) {
- columns->AddColumn(GridLayout::TRAILING, GridLayout::CENTER, 0,
- GridLayout::USE_PREF, 0, 0); // Star rating.
- columns->AddPaddingColumn(0, kStarRatingHorizontalSpacing);
- }
- columns->AddColumn(GridLayout::TRAILING, GridLayout::CENTER, 0,
- GridLayout::FIXED, preferred_width, 0); // Button.
-
- grid_layout->StartRow(0, 0);
-
- view->icon_ = new views::ImageView();
- view->icon_->SetImage(icon);
- grid_layout->AddView(view->icon_);
-
- view->title_link_ = label;
- grid_layout->AddView(view->title_link_);
-
- if (stars != NULL) {
- view->stars_ = stars;
- grid_layout->AddView(view->stars_);
- }
-
- view->install_button_ = new ThrobberNativeTextButton(
- view, view->GetActionButtonMessage());
- view->install_button_->set_preferred_width(preferred_width);
- grid_layout->AddView(view->install_button_);
-
- return view;
-}
-
-IntentRowView::~IntentRowView() {}
-
-void IntentRowView::ButtonPressed(views::Button* sender,
- const ui::Event& event) {
- if (type_ == ACTION_INSTALL)
- delegate_->OnExtensionInstallClicked(extension_id_);
- else
- delegate_->OnActionButtonClicked(type_, tag_);
-}
-
-void IntentRowView::LinkClicked(views::Link* source,
- int event_flags) {
- delegate_->OnExtensionLinkClicked(
- extension_id_, ui::DispositionFromEventFlags(event_flags));
-}
-
-void IntentRowView::MarkBusy(const std::string& extension_id) {
- SetEnabled(false);
- if (extension_id == extension_id_)
- StartThrobber();
-}
-
-void IntentRowView::StartThrobber() {
- install_button_->StartThrobber();
- install_button_->SetText(string16());
-}
-
-void IntentRowView::StopThrobber() {
- install_button_->StopThrobber();
- install_button_->SetText(GetActionButtonMessage());
-}
-
-void IntentRowView::OnEnabledChanged() {
- title_link_->SetEnabled(enabled());
- if (stars_)
- stars_->SetEnabled(enabled());
- install_button_->SetEnabled(enabled());
- View::OnEnabledChanged();
- Layout();
-}
-
-void IntentRowView::PaintChildren(gfx::Canvas* canvas) {
- View::PaintChildren(canvas);
- if (!enabled())
- canvas->FillRect(GetLocalBounds(), kHalfOpacityWhite);
-}
-
-string16 IntentRowView::GetActionButtonMessage() {
- int message_id = 0;
-
- if (type_ == ACTION_INVOKE)
- message_id = IDS_INTENT_PICKER_SELECT_INTENT;
- else if (type_ == ACTION_INSTALL)
- message_id = IDS_INTENT_PICKER_INSTALL_EXTENSION;
- else
- NOTREACHED();
-
- return l10n_util::GetStringUTF16(message_id);
-}
-
-
-// IntentsView -----------------------------------------------------
-
-// A view that contains both installed services and suggested extensions
-// from the Chrome Web Store that provide an intent service matching the
-// action/type pair.
-class IntentsView : public views::View {
- public:
- IntentsView(const WebIntentPickerModel* model,
- IntentRowView::Delegate* delegate);
-
- virtual ~IntentsView();
-
- // Update the view to the new model data.
- void Update();
-
- // Show the install throbber for the row containing |extension_id|. This
- // function also hides hides and disables other buttons and links.
- void StartThrobber(const std::string& extension_id);
-
- // Hide the install throbber. This function re-enables all buttons and links.
- void StopThrobber();
-
- // Adjusts a given width to account for language-specific strings.
- int AdjustWidth(int old_width);
-
- protected:
- virtual void OnEnabledChanged() OVERRIDE;
-
- private:
- const WebIntentPickerModel* model_;
- IntentRowView::Delegate* delegate_;
-
- // Width for the action button, adjusted to be wide enough for all possible
- // strings.
- int button_width_;
-
- DISALLOW_COPY_AND_ASSIGN(IntentsView);
-};
-
-IntentsView::IntentsView(
- const WebIntentPickerModel* model,
- IntentRowView::Delegate* delegate)
- : model_(model),
- delegate_(delegate),
- button_width_(0){
- Update();
-}
-
-IntentsView::~IntentsView() {
-}
-
-void IntentsView::Update() {
- RemoveAllChildViews(true);
-
- ThrobberNativeTextButton size_helper(
- NULL, l10n_util::GetStringUTF16(IDS_INTENT_PICKER_INSTALL_EXTENSION));
- size_helper.SetText(
- l10n_util::GetStringUTF16(IDS_INTENT_PICKER_SELECT_INTENT));
- button_width_ = std::max(
- kButtonWidth, size_helper.GetPreferredSize().width());
-
- const int kAppRowVerticalSpacing = 10;
- views::BoxLayout* layout = new views::BoxLayout(views::BoxLayout::kVertical,
- 0, 0, kAppRowVerticalSpacing);
- SetLayoutManager(layout);
-
- int available_rows = kMaxRowCount;
-
- for (size_t i = 0;
- available_rows > 0 && i < model_->GetInstalledServiceCount();
- ++i, --available_rows) {
- const WebIntentPickerModel::InstalledService& service =
- model_->GetInstalledServiceAt(i);
- AddChildView(IntentRowView::CreateHandlerRow(&service, NULL, i,
- delegate_, button_width_));
- }
-
- // Only fill up with suggestions if we filled less than kMinRowCount rows.
- available_rows -= (kMaxRowCount - kMinRowCount);
-
- for (size_t i = 0;
- available_rows > 0 && i < model_->GetSuggestedExtensionCount();
- ++i, --available_rows) {
- const WebIntentPickerModel::SuggestedExtension& extension =
- model_->GetSuggestedExtensionAt(i);
- AddChildView(IntentRowView::CreateHandlerRow(NULL, &extension, i,
- delegate_, button_width_));
- }
-}
-
-void IntentsView::StartThrobber(const std::string& extension_id) {
- for (int i = 0; i < child_count(); ++i)
- static_cast<IntentRowView*>(child_at(i))->MarkBusy(extension_id);
-}
-
-void IntentsView::StopThrobber() {
- for (int i = 0; i < child_count(); ++i) {
- IntentRowView* row =
- static_cast<IntentRowView*>(child_at(i));
- row->SetEnabled(true);
- row->StopThrobber();
- }
-}
-
-int IntentsView::AdjustWidth(int old_width) {
- return old_width - kButtonWidth + button_width_;
-}
-
-void IntentsView::OnEnabledChanged() {
- EnableChildViews(this, enabled());
- View::OnEnabledChanged();
-}
-
-} // namespace
-
-
-// WebIntentPickerViews --------------------------------------------------------
-
-// Views implementation of WebIntentPicker.
-class WebIntentPickerViews : public views::ButtonListener,
- public views::WidgetDelegate,
- public views::LinkListener,
- public WebIntentPicker,
- public WebIntentPickerModelObserver,
- public IntentRowView::Delegate {
- public:
- WebIntentPickerViews(WebContents* web_contents,
- WebIntentPickerDelegate* delegate,
- WebIntentPickerModel* model);
- virtual ~WebIntentPickerViews();
-
- // views::ButtonListener implementation.
- // This method is called when the user cancels the picker dialog.
- virtual void ButtonPressed(views::Button* sender,
- const ui::Event& event) OVERRIDE;
-
- // views::WidgetDelegate implementation.
- virtual void WindowClosing() OVERRIDE;
- virtual void DeleteDelegate() OVERRIDE;
- virtual views::Widget* GetWidget() OVERRIDE;
- virtual const views::Widget* GetWidget() const OVERRIDE;
- virtual views::View* GetContentsView() OVERRIDE;
-
- // LinkListener implementation.
- virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE;
-
- // WebIntentPicker implementation.
- virtual void Close() OVERRIDE;
- virtual void SetActionString(const string16& action) OVERRIDE;
- virtual void OnExtensionInstallSuccess(const std::string& id) OVERRIDE;
- virtual void OnExtensionInstallFailure(const std::string& id) OVERRIDE;
- virtual void OnInlineDispositionAutoResize(const gfx::Size& size) OVERRIDE;
- virtual void OnPendingAsyncCompleted() OVERRIDE;
- virtual void InvalidateDelegate() OVERRIDE;
- virtual void OnInlineDispositionWebContentsLoaded(
- content::WebContents* web_contents) OVERRIDE;
-
- // WebIntentPickerModelObserver implementation.
- virtual void OnModelChanged(WebIntentPickerModel* model) OVERRIDE;
- virtual void OnFaviconChanged(WebIntentPickerModel* model,
- size_t index) OVERRIDE;
- virtual void OnExtensionIconChanged(WebIntentPickerModel* model,
- const std::string& extension_id) OVERRIDE;
- virtual void OnInlineDisposition(const string16& title,
- const GURL& url) OVERRIDE;
-
- // SuggestedExtensionsRowView::Delegate implementation.
- virtual void OnExtensionInstallClicked(
- const std::string& extension_id) OVERRIDE;
- virtual void OnExtensionLinkClicked(
- const std::string& extension_id,
- WindowOpenDisposition disposition) OVERRIDE;
- virtual void OnActionButtonClicked(
- IntentRowView::ActionType type,
- size_t tag) OVERRIDE;
-
- private:
- enum WebIntentPickerViewsState {
- INITIAL,
- WAITING,
- NO_SERVICES,
- LIST_SERVICES,
- INLINE_SERVICE,
- } state_;
-
- // Update picker contents to reflect the current state of the model.
- void UpdateContents();
-
- // Shows a spinner and notifies the user that we are waiting for information
- // from the Chrome Web Store.
- void ShowWaitingForSuggestions();
-
- // Updates the dialog with the list of available services, suggestions,
- // and a nice link to CWS to find more suggestions. This is the "Main"
- // view of the picker.
- void ShowAvailableServices();
-
- // Informs the user that there are no services available to handle
- // the intent, and that there are no suggestions from the Chrome Web Store.
- void ShowNoServicesMessage();
-
- // Restore the contents of the picker to the initial contents.
- void ResetContents();
-
- // Resize the constrained window to the size of its contents.
- void SizeToContents();
-
- // Clear the contents of the picker.
- void ClearContents();
-
- // Returns the service selection question text used in the title
- // of the picker.
- const string16 GetActionTitle();
-
- // Refresh the icon for the inline disposition service that is being
- // displayed.
- void RefreshInlineServiceIcon();
-
- // Refresh the extensions control in the picker.
- void RefreshExtensions();
-
- // A weak pointer to the WebIntentPickerDelegate to notify when the user
- // chooses a service or cancels.
- WebIntentPickerDelegate* delegate_;
-
- // A weak pointer to the picker model.
- WebIntentPickerModel* model_;
-
- // A weak pointer to the action string label.
- // Created locally, owned by Views.
- views::Label* action_label_;
-
- // A weak pointer to the intents view.
- // Created locally, owned by Views view hierarchy.
- IntentsView* extensions_;
-
- // Delegate for inline disposition tab contents.
- scoped_ptr<WebIntentInlineDispositionDelegate> inline_disposition_delegate_;
-
- // A weak pointer to the WebContents this picker is in.
- WebContents* web_contents_;
-
- // A weak pointer to the WebView that hosts the WebContents being displayed.
- // Created locally, owned by Views.
- views::WebView* webview_;
-
- // A weak pointer to the view that contains all other views in the picker.
- // Created locally, owned by Views.
- views::View* contents_;
-
- // A weak pointer to the constrained window.
- // Created locally, owned by Views.
- ConstrainedWindowViews* window_;
-
- // A weak pointer to the more suggestions link.
- // Created locally, owned by Views.
- views::Link* more_suggestions_link_;
-
- // The icon for the inline disposition service.
- views::ImageView* inline_service_icon_;
-
- // A weak pointer to the choose another service link.
- // Created locally, owned by Views.
- views::Link* choose_another_service_link_;
-
- // Weak pointer to "Waiting for CWS" display. Owned by parent view.
- WaitingView* waiting_view_;
-
- // The text for the current action.
- string16 action_text_;
-
- // Ownership of the WebContents we are displaying in the inline disposition.
- scoped_ptr<WebContents> inline_web_contents_;
-
- // Indicate if dialog should display its own close button.
- // TODO(groby): Only relevant until new WebContentsModalDialog is implemented,
- // from then on always true.
- bool use_close_button_;
-
- // Signals if the picker can be closed. False during extension install.
- bool can_close_;
-
- DISALLOW_COPY_AND_ASSIGN(WebIntentPickerViews);
-};
-
-// static
-WebIntentPicker* WebIntentPicker::Create(content::WebContents* web_contents,
- WebIntentPickerDelegate* delegate,
- WebIntentPickerModel* model) {
- return new WebIntentPickerViews(web_contents, delegate, model);
-}
-
-WebIntentPickerViews::WebIntentPickerViews(WebContents* web_contents,
- WebIntentPickerDelegate* delegate,
- WebIntentPickerModel* model)
- : state_(INITIAL),
- delegate_(delegate),
- model_(model),
- action_label_(NULL),
- extensions_(NULL),
- web_contents_(web_contents),
- webview_(new views::WebView(
- Profile::FromBrowserContext(web_contents->GetBrowserContext()))),
- window_(NULL),
- more_suggestions_link_(NULL),
- inline_service_icon_(NULL),
- choose_another_service_link_(NULL),
- waiting_view_(NULL),
- can_close_(true) {
- use_close_button_ = false;
-
- model_->set_observer(this);
- contents_ = new views::View();
- contents_->set_background(views::Background::CreateSolidBackground(
- chrome_style::GetBackgroundColor()));
-
- // Show the dialog.
- window_ = ConstrainedWindowViews::Create(web_contents, this);
- if (model_->IsInlineDisposition())
- OnInlineDisposition(string16(), model_->inline_disposition_url());
- else
- UpdateContents();
-}
-
-WebIntentPickerViews::~WebIntentPickerViews() {
- model_->set_observer(NULL);
-}
-
-void WebIntentPickerViews::ButtonPressed(views::Button* sender,
- const ui::Event& event) {
- DCHECK(delegate_);
- delegate_->OnUserCancelledPickerDialog();
-}
-
-void WebIntentPickerViews::WindowClosing() {
- if (delegate_)
- delegate_->OnClosing();
-}
-
-void WebIntentPickerViews::DeleteDelegate() {
- delete this;
-}
-
-views::Widget* WebIntentPickerViews::GetWidget() {
- return contents_->GetWidget();
-}
-
-const views::Widget* WebIntentPickerViews::GetWidget() const {
- return contents_->GetWidget();
-}
-
-views::View* WebIntentPickerViews::GetContentsView() {
- return contents_;
-}
-
-void WebIntentPickerViews::LinkClicked(views::Link* source, int event_flags) {
- DCHECK(delegate_);
- if (source == more_suggestions_link_) {
- delegate_->OnSuggestionsLinkClicked(
- ui::DispositionFromEventFlags(event_flags));
- } else if (source == choose_another_service_link_) {
- // Signal cancellation of inline disposition.
- delegate_->OnChooseAnotherService();
- ResetContents();
- } else {
- NOTREACHED();
- }
-}
-
-void WebIntentPickerViews::Close() {
- window_->CloseWebContentsModalDialog();
-}
-
-void WebIntentPickerViews::SetActionString(const string16& action) {
- action_text_ = action;
- if (action_label_) {
- action_label_->SetText(GetActionTitle());
- contents_->Layout();
- SizeToContents();
- }
-}
-
-void WebIntentPickerViews::OnExtensionInstallSuccess(const std::string& id) {
- can_close_ = true;
-}
-
-void WebIntentPickerViews::OnExtensionInstallFailure(const std::string& id) {
- extensions_->StopThrobber();
- extensions_->SetEnabled(true);
- more_suggestions_link_->SetEnabled(true);
- can_close_ = true;
- contents_->Layout();
- SizeToContents();
-
- // TODO(binji): What to display to user on failure?
-}
-
-void WebIntentPickerViews::OnInlineDispositionAutoResize(
- const gfx::Size& size) {
- webview_->SetPreferredSize(size);
- contents_->Layout();
- SizeToContents();
-}
-
-void WebIntentPickerViews::OnPendingAsyncCompleted() {
- UpdateContents();
-}
-
-void WebIntentPickerViews::InvalidateDelegate() {
- delegate_ = NULL;
-}
-
-void WebIntentPickerViews::ShowNoServicesMessage() {
- if (state_ == NO_SERVICES)
- return;
- state_ = NO_SERVICES;
-
- ClearContents();
- views::GridLayout* layout = new views::GridLayout(contents_);
- layout->set_minimum_size(gfx::Size(WebIntentPicker::kWindowMinWidth, 0));
- const int kContentBuiltinBottomPadding = 3;
- layout->SetInsets(chrome_style::kCloseButtonPadding,
- 0,
- chrome_style::kClientBottomPadding -
- kContentBuiltinBottomPadding,
- 0);
- contents_->SetLayoutManager(layout);
-
- enum GridLayoutColumnSets {
- HEADER_ROW,
- CONTENT_ROW,
- };
- views::ColumnSet* header_cs = layout->AddColumnSet(HEADER_ROW);
- header_cs->AddPaddingColumn(
- 0, chrome_style::kHorizontalPadding);
- header_cs->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 1,
- GridLayout::USE_PREF, 0, 0); // Title
- header_cs->AddColumn(GridLayout::TRAILING, GridLayout::LEADING, 0,
- GridLayout::USE_PREF, 0, 0); // Close button
- header_cs->AddPaddingColumn(
- 0, chrome_style::kCloseButtonPadding);
-
- views::ColumnSet* content_cs = layout->AddColumnSet(CONTENT_ROW);
- content_cs->AddPaddingColumn(
- 0, chrome_style::kHorizontalPadding);
- content_cs->AddColumn(GridLayout::FILL, GridLayout::CENTER, 1,
- GridLayout::USE_PREF, 0, 0); // Body
- content_cs->AddPaddingColumn(
- 0, chrome_style::kHorizontalPadding);
-
- // Header
- layout->StartRow(0, HEADER_ROW);
- views::Label* title = CreateTitleLabel();
- title->SetText(l10n_util::GetStringUTF16(
- IDS_INTENT_PICKER_NO_SERVICES_TITLE));
- layout->AddView(title);
-
- views::ImageButton* close_button = CreateCloseButton(this);
- layout->AddView(close_button);
- close_button->SetVisible(use_close_button_);
-
- // Content
- const int kHeaderBuiltinBottomPadding = 4;
- const int kContentBuiltinTopPadding = 5;
- layout->AddPaddingRow(0,
- chrome_style::kRowPadding -
- kHeaderBuiltinBottomPadding -
- kContentBuiltinTopPadding);
- layout->StartRow(0, CONTENT_ROW);
- views::Label* body = CreateLabel();
- body->SetMultiLine(true);
- body->SetText(l10n_util::GetStringUTF16(IDS_INTENT_PICKER_NO_SERVICES));
- layout->AddView(body);
-
- int height = contents_->GetHeightForWidth(WebIntentPicker::kWindowMinWidth);
- contents_->SetSize(gfx::Size(WebIntentPicker::kWindowMinWidth, height));
- contents_->Layout();
-}
-
-void WebIntentPickerViews::OnInlineDispositionWebContentsLoaded(
- content::WebContents* web_contents) {
- if (state_ == INLINE_SERVICE)
- return;
- state_ = INLINE_SERVICE;
-
- // Replace the picker with the inline disposition.
- ClearContents();
- views::GridLayout* grid_layout = new views::GridLayout(contents_);
- grid_layout->set_minimum_size(gfx::Size(WebIntentPicker::kWindowMinWidth, 0));
- grid_layout->SetInsets(chrome_style::kCloseButtonPadding, 0,
- chrome_style::kClientBottomPadding, 0);
- contents_->SetLayoutManager(grid_layout);
-
- enum GridLayoutColumnSets {
- HEADER_ROW,
- SEPARATOR_ROW,
- WEB_CONTENTS_ROW,
- };
- views::ColumnSet* header_cs = grid_layout->AddColumnSet(HEADER_ROW);
- header_cs->AddPaddingColumn(
- 0, chrome_style::kHorizontalPadding);
- header_cs->AddColumn(GridLayout::FILL, GridLayout::CENTER, 1,
- GridLayout::USE_PREF, 0, 0); // Icon, title, link.
- header_cs->AddPaddingColumn(0, views::kRelatedControlHorizontalSpacing);
- header_cs->AddColumn(GridLayout::TRAILING, GridLayout::LEADING, 0,
- GridLayout::USE_PREF, 0, 0); // Close button.
- header_cs->AddPaddingColumn(
- 0, chrome_style::kCloseButtonPadding);
-
- views::ColumnSet* sep_cs = grid_layout->AddColumnSet(SEPARATOR_ROW);
- sep_cs->AddColumn(GridLayout::FILL, GridLayout::CENTER, 1,
- GridLayout::USE_PREF, 0, 0); // Separator.
-
- views::ColumnSet* contents_cs = grid_layout->AddColumnSet(WEB_CONTENTS_ROW);
- contents_cs->AddPaddingColumn(0, 1);
- contents_cs->AddColumn(GridLayout::CENTER, GridLayout::CENTER, 1,
- GridLayout::USE_PREF, 0, 0); // Web contents.
- contents_cs->AddPaddingColumn(0, 1);
-
- // Header.
- grid_layout->StartRow(0, HEADER_ROW);
-
- const WebIntentPickerModel::InstalledService* service =
- model_->GetInstalledServiceWithURL(model_->inline_disposition_url());
-
- if (!inline_service_icon_)
- inline_service_icon_ = new views::ImageView();
- inline_service_icon_->SetImage(service->favicon.ToImageSkia());
-
- views::Label* title = CreateLabel();
- title->SetText(ui::ElideText(
- service->title, title->font(), kTitleLinkMaxWidth, ui::ELIDE_AT_END));
-
- if (!choose_another_service_link_)
- choose_another_service_link_ = CreateLink();
- choose_another_service_link_->SetText(l10n_util::GetStringUTF16(
- IDS_INTENT_PICKER_USE_ALTERNATE_SERVICE));
- choose_another_service_link_->set_listener(this);
-
- grid_layout->AddView(CreateInlineDispositionHeader(
- inline_service_icon_, title, choose_another_service_link_));
- choose_another_service_link_->SetVisible(IsUseAnotherServiceVisible(model_));
-
- views::ImageButton* close_button = CreateCloseButton(this);
- grid_layout->AddView(close_button);
- close_button->SetVisible(use_close_button_);
-
- // Separator.
- const int kHeaderBuiltinBottomPadding = 4;
- grid_layout->AddPaddingRow(0,
- chrome_style::kRowPadding -
- kHeaderBuiltinBottomPadding);
- grid_layout->StartRow(0, SEPARATOR_ROW);
- grid_layout->AddView(new views::Separator());
-
- // Inline web contents.
- const int kSeparatorBottomPadding = 3;
- grid_layout->AddPaddingRow(0, kSeparatorBottomPadding);
- grid_layout->StartRow(0, WEB_CONTENTS_ROW);
- grid_layout->AddView(webview_);
-
- contents_->Layout();
- SizeToContents();
-}
-
-void WebIntentPickerViews::OnModelChanged(WebIntentPickerModel* model) {
- if (state_ == WAITING && !model->IsWaitingForSuggestions())
- UpdateContents();
-
- if (choose_another_service_link_) {
- choose_another_service_link_->SetVisible(IsUseAnotherServiceVisible(model));
- contents_->Layout();
- SizeToContents();
- }
-
- if (extensions_)
- RefreshExtensions();
-}
-
-void WebIntentPickerViews::OnFaviconChanged(WebIntentPickerModel* model,
- size_t index) {
- // TODO(groby): Update favicons on extensions_;
- if (inline_service_icon_)
- RefreshInlineServiceIcon();
- if (extensions_)
- RefreshExtensions();
-}
-
-void WebIntentPickerViews::OnExtensionIconChanged(
- WebIntentPickerModel* model,
- const std::string& extension_id) {
- OnFaviconChanged(model, -1);
-}
-
-void WebIntentPickerViews::OnInlineDisposition(
- const string16&, const GURL& url) {
- DCHECK(delegate_);
- Profile* profile =
- Profile::FromBrowserContext(web_contents_->GetBrowserContext());
- if (!webview_)
- webview_ = new views::WebView(profile);
-
- inline_web_contents_.reset(
- delegate_->CreateWebContentsForInlineDisposition(profile, url));
-
- // Does not take ownership, so we keep a scoped_ptr
- // for the WebContents locally.
- webview_->SetWebContents(inline_web_contents_.get());
- Browser* browser = chrome::FindBrowserWithWebContents(web_contents_);
- inline_disposition_delegate_.reset(
- new WebIntentInlineDispositionDelegate(this, inline_web_contents_.get(),
- browser));
-
- inline_web_contents_->GetController().LoadURL(
- url,
- content::Referrer(),
- content::PAGE_TRANSITION_AUTO_TOPLEVEL,
- std::string());
-
- // Disable all buttons.
- // TODO(groby): Add throbber for inline dispo - see http://crbug.com/142519.
- if (extensions_)
- extensions_->SetEnabled(false);
- if (more_suggestions_link_)
- more_suggestions_link_->SetEnabled(false);
- contents_->Layout();
-}
-
-void WebIntentPickerViews::OnExtensionInstallClicked(
- const std::string& extension_id) {
- DCHECK(delegate_);
- can_close_ = false;
- extensions_->StartThrobber(extension_id);
- more_suggestions_link_->SetEnabled(false);
- contents_->Layout();
- delegate_->OnExtensionInstallRequested(extension_id);
-}
-
-void WebIntentPickerViews::OnExtensionLinkClicked(
- const std::string& extension_id,
- WindowOpenDisposition disposition) {
- DCHECK(delegate_);
- delegate_->OnExtensionLinkClicked(extension_id, disposition);
-}
-
-void WebIntentPickerViews::OnActionButtonClicked(
- IntentRowView::ActionType type, size_t tag) {
- DCHECK(delegate_);
- DCHECK_EQ(IntentRowView::ACTION_INVOKE, type);
- const WebIntentPickerModel::InstalledService& service =
- model_->GetInstalledServiceAt(tag);
- delegate_->OnServiceChosen(service.url, service.disposition,
- WebIntentPickerDelegate::kEnableDefaults);
-}
-
-void WebIntentPickerViews::UpdateContents() {
- if (model_ && model_->IsInlineDisposition())
- return;
-
- if (model_ && model_->IsWaitingForSuggestions()) {
- ShowWaitingForSuggestions();
- } else if (model_ && (model_->GetInstalledServiceCount() ||
- model_->GetSuggestedExtensionCount())) {
- ShowAvailableServices();
- } else {
- ShowNoServicesMessage();
- }
- SizeToContents();
-}
-
-void WebIntentPickerViews::ShowWaitingForSuggestions() {
- if (state_ == WAITING)
- return;
- state_ = WAITING;
- ClearContents();
- contents_->SetLayoutManager(new views::FillLayout());
- waiting_view_ = new WaitingView(this, use_close_button_);
- contents_->AddChildView(waiting_view_);
- int height = contents_->GetHeightForWidth(kWindowMinWidth);
- contents_->SetSize(gfx::Size(kWindowMinWidth, height));
- contents_->Layout();
-}
-
-const string16 WebIntentPickerViews::GetActionTitle() {
- return action_text_.empty() ?
- l10n_util::GetStringUTF16(IDS_INTENT_PICKER_CHOOSE_SERVICE) :
- action_text_;
-}
-
-void WebIntentPickerViews::ShowAvailableServices() {
- ClearContents();
- state_ = LIST_SERVICES;
- extensions_ = new IntentsView(model_, this);
- gfx::Size min_size = gfx::Size(extensions_->AdjustWidth(kWindowMinWidth), 0);
-
- views::GridLayout* grid_layout = new views::GridLayout(contents_);
- grid_layout->set_minimum_size(min_size);
- const int kIconBuiltinBottomPadding = 4;
- grid_layout->SetInsets(chrome_style::kCloseButtonPadding,
- 0,
- chrome_style::kClientBottomPadding -
- kIconBuiltinBottomPadding,
- 0);
- contents_->SetLayoutManager(grid_layout);
-
- enum GridLayoutColumnSets {
- HEADER_ROW,
- CONTENT_ROW,
- };
- views::ColumnSet* header_cs = grid_layout->AddColumnSet(HEADER_ROW);
- header_cs->AddPaddingColumn(
- 0, chrome_style::kHorizontalPadding);
- header_cs->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 1,
- GridLayout::USE_PREF, 0, 0); // Action title
- header_cs->AddColumn(GridLayout::TRAILING, GridLayout::LEADING, 0,
- GridLayout::USE_PREF, 0, 0); // Close button
- header_cs->AddPaddingColumn(
- 0, chrome_style::kCloseButtonPadding);
-
- views::ColumnSet* content_cs = grid_layout->AddColumnSet(CONTENT_ROW);
- content_cs->AddPaddingColumn(
- 0, chrome_style::kHorizontalPadding);
- content_cs->AddColumn(GridLayout::FILL, GridLayout::CENTER, 1,
- GridLayout::USE_PREF, 0, 0); // Content.
- content_cs->AddPaddingColumn(
- 0, chrome_style::kHorizontalPadding);
-
- // Header.
- grid_layout->StartRow(0, HEADER_ROW);
- if (!action_label_)
- action_label_ = CreateTitleLabel();
- action_label_->SetText(GetActionTitle());
- grid_layout->AddView(action_label_);
-
- views::ImageButton* close_button = CreateCloseButton(this);
- grid_layout->AddView(close_button);
- close_button->SetVisible(use_close_button_);
-
- // Extensions.
- const int kHeaderBuiltinBottomPadding = 4;
- grid_layout->AddPaddingRow(0,
- chrome_style::kRowPadding -
- kHeaderBuiltinBottomPadding);
- grid_layout->StartRow(0, CONTENT_ROW);
- grid_layout->AddView(extensions_);
-
-
- // Row with "more suggestions" link.
- const int kIconBuiltinTopPadding = 6;
- grid_layout->AddPaddingRow(0,
- chrome_style::kRowPadding -
- kIconBuiltinTopPadding);
- grid_layout->StartRow(0, CONTENT_ROW);
- views::View* more_view = new views::View();
- more_view->SetLayoutManager(new views::BoxLayout(
- views::BoxLayout::kHorizontal, 0, 0, kIconTextPadding));
- views::ImageView* icon = new views::ImageView();
- icon->SetImage(ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(
- IDR_WEBSTORE_ICON_16));
- more_view->AddChildView(icon);
- if (!more_suggestions_link_)
- more_suggestions_link_ = CreateLink();
- more_suggestions_link_->SetText(
- l10n_util::GetStringUTF16(IDS_FIND_MORE_INTENT_HANDLER_MESSAGE));
- more_suggestions_link_->set_listener(this);
- more_view->AddChildView(more_suggestions_link_);
- grid_layout->AddView(more_view, 1, 1,
- GridLayout::LEADING, GridLayout::CENTER);
-
- contents_->Layout();
-}
-
-void WebIntentPickerViews::ResetContents() {
- // Abandon both web contents and webview.
- webview_->SetWebContents(NULL);
- inline_web_contents_.reset();
- webview_ = NULL;
-
- // Re-initialize the UI.
- UpdateContents();
-
- // Restore previous state.
- if (extensions_)
- extensions_->Update();
- if (action_label_)
- action_label_->SetText(action_text_);
- contents_->Layout();
- SizeToContents();
-}
-
-void WebIntentPickerViews::SizeToContents() {
- gfx::Size client_size = contents_->GetPreferredSize();
- gfx::Rect client_bounds(client_size);
- gfx::Rect new_window_bounds = window_->non_client_view()->frame_view()->
- GetWindowBoundsForClientBounds(client_bounds);
- window_->CenterWindow(new_window_bounds.size());
-}
-
-void WebIntentPickerViews::ClearContents() {
- DCHECK(contents_);
- // The call RemoveAllChildViews(true) deletes all children of |contents|. If
- // we do not set our weak pointers to NULL, then they will continue to point
- // to where the deleted objects used to be, i.e. unitialized memory. This
- // would cause hard-to-explain crashes.
- contents_->RemoveAllChildViews(true);
- action_label_ = NULL;
- extensions_ = NULL;
- more_suggestions_link_ = NULL;
- inline_service_icon_ = NULL;
- choose_another_service_link_ = NULL;
-}
-
-void WebIntentPickerViews::RefreshInlineServiceIcon() {
- DCHECK(inline_service_icon_);
- const WebIntentPickerModel::InstalledService* inline_service =
- model_->GetInstalledServiceWithURL(model_->inline_disposition_url());
- if (inline_service)
- inline_service_icon_->SetImage(inline_service->favicon.ToImageSkia());
-}
-
-void WebIntentPickerViews::RefreshExtensions() {
- DCHECK(extensions_);
- extensions_->Update();
- contents_->Layout();
- SizeToContents();
-}
diff --git a/chrome/browser/ui/webui/options/content_settings_handler.cc b/chrome/browser/ui/webui/options/content_settings_handler.cc
index 52363a5..744d7f6 100644
--- a/chrome/browser/ui/webui/options/content_settings_handler.cc
+++ b/chrome/browser/ui/webui/options/content_settings_handler.cc
@@ -86,7 +86,6 @@ const ContentSettingsTypeNameEntry kContentSettingsTypeGroupNames[] = {
{CONTENT_SETTINGS_TYPE_POPUPS, "popups"},
{CONTENT_SETTINGS_TYPE_GEOLOCATION, "location"},
{CONTENT_SETTINGS_TYPE_NOTIFICATIONS, "notifications"},
- {CONTENT_SETTINGS_TYPE_INTENTS, "intents"},
{CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE, "auto-select-certificate"},
{CONTENT_SETTINGS_TYPE_FULLSCREEN, "fullscreen"},
{CONTENT_SETTINGS_TYPE_MOUSELOCK, "mouselock"},
@@ -666,10 +665,6 @@ void ContentSettingsHandler::UpdateExceptionsViewFromModel(
case CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA:
UpdateMediaExceptionsView();
break;
- case CONTENT_SETTINGS_TYPE_INTENTS:
- // Don't update intents settings at this point.
- // Turn on when enable_web_intents_tag is enabled.
- break;
case CONTENT_SETTINGS_TYPE_MIXEDSCRIPT:
// We don't yet support exceptions for mixed scripting.
break;
@@ -696,7 +691,6 @@ void ContentSettingsHandler::UpdateOTRExceptionsViewFromModel(
switch (type) {
case CONTENT_SETTINGS_TYPE_GEOLOCATION:
case CONTENT_SETTINGS_TYPE_NOTIFICATIONS:
- case CONTENT_SETTINGS_TYPE_INTENTS:
case CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE:
case CONTENT_SETTINGS_TYPE_MIXEDSCRIPT:
#if defined(OS_WIN)
@@ -1202,10 +1196,6 @@ void ContentSettingsHandler::SetContentFilter(const ListValue* args) {
content::RecordAction(
UserMetricsAction("Options_DefaultGeolocationSettingChanged"));
break;
- case CONTENT_SETTINGS_TYPE_INTENTS:
- content::RecordAction(
- UserMetricsAction("Options_DefaultHandlersSettingChanged"));
- break;
case CONTENT_SETTINGS_TYPE_MOUSELOCK:
content::RecordAction(
UserMetricsAction("Options_DefaultMouseLockSettingChanged"));
diff --git a/chrome/browser/webdata/web_data_service.cc b/chrome/browser/webdata/web_data_service.cc
index 9ce374d..d4f8b71 100644
--- a/chrome/browser/webdata/web_data_service.cc
+++ b/chrome/browser/webdata/web_data_service.cc
@@ -11,7 +11,6 @@
#include "chrome/browser/autofill/autofill_country.h"
#include "chrome/browser/autofill/autofill_profile.h"
#include "chrome/browser/autofill/credit_card.h"
-#include "chrome/browser/intents/default_web_intent_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/search_engines/template_url.h"
#include "chrome/browser/ui/profile_error_dialog.h"
@@ -48,7 +47,6 @@
using base::Bind;
using base::Time;
using content::BrowserThread;
-using webkit_glue::WebIntentServiceData;
namespace {
@@ -213,82 +211,6 @@ WebDataService::Handle WebDataService::GetWebAppImages(
Bind(&WebDataService::GetWebAppImagesImpl, this, app_url), consumer);
}
-#if (ENABLE_WEB_INTENTS)
-//////////////////////////////////////////////////////////////////////////////
-//
-// Web Intents.
-//
-//////////////////////////////////////////////////////////////////////////////
-
-void WebDataService::AddWebIntentService(const WebIntentServiceData& service) {
- ScheduleDBTask(FROM_HERE,
- Bind(&WebDataService::AddWebIntentServiceImpl, this, service));
-}
-
-void WebDataService::RemoveWebIntentService(
- const WebIntentServiceData& service) {
- ScheduleDBTask(FROM_HERE, Bind(&WebDataService::RemoveWebIntentServiceImpl,
- this, service));
-}
-
-WebDataService::Handle WebDataService::GetWebIntentServicesForAction(
- const string16& action,
- WebDataServiceConsumer* consumer) {
- return ScheduleDBTaskWithResult(FROM_HERE,
- Bind(&WebDataService::GetWebIntentServicesImpl, this, action), consumer);
-}
-
-WebDataService::Handle WebDataService::GetWebIntentServicesForURL(
- const string16& service_url,
- WebDataServiceConsumer* consumer) {
- return ScheduleDBTaskWithResult(FROM_HERE,
- Bind(&WebDataService::GetWebIntentServicesForURLImpl, this, service_url),
- consumer);
-}
-
-
-WebDataService::Handle WebDataService::GetAllWebIntentServices(
- WebDataServiceConsumer* consumer) {
- return ScheduleDBTaskWithResult(FROM_HERE,
- Bind(&WebDataService::GetAllWebIntentServicesImpl, this), consumer);
-}
-
-void WebDataService::AddDefaultWebIntentService(
- const DefaultWebIntentService& service) {
- ScheduleDBTask(FROM_HERE,
- Bind(&WebDataService::AddDefaultWebIntentServiceImpl, this, service));
-}
-
-void WebDataService::RemoveDefaultWebIntentService(
- const DefaultWebIntentService& service) {
- ScheduleDBTask(FROM_HERE,
- Bind(&WebDataService::RemoveDefaultWebIntentServiceImpl, this, service));
-}
-
-void WebDataService::RemoveWebIntentServiceDefaults(
- const GURL& service_url) {
- ScheduleDBTask(FROM_HERE,
- Bind(&WebDataService::RemoveWebIntentServiceDefaultsImpl, this,
- service_url));
-}
-
-WebDataService::Handle WebDataService::GetDefaultWebIntentServicesForAction(
- const string16& action,
- WebDataServiceConsumer* consumer) {
- return ScheduleDBTaskWithResult(FROM_HERE,
- Bind(&WebDataService::GetDefaultWebIntentServicesForActionImpl, this,
- action),
- consumer);
-}
-
-WebDataService::Handle WebDataService::GetAllDefaultWebIntentServices(
- WebDataServiceConsumer* consumer) {
- return ScheduleDBTaskWithResult(FROM_HERE,
- Bind(&WebDataService::GetAllDefaultWebIntentServicesImpl, this),
- consumer);
-}
-#endif
-
////////////////////////////////////////////////////////////////////////////////
//
// Token Service
@@ -664,89 +586,6 @@ scoped_ptr<WDTypedResult> WebDataService::GetWebAppImagesImpl(
new WDResult<WDAppImagesResult>(WEB_APP_IMAGES, result));
}
-#if defined(ENABLE_WEB_INTENTS)
-////////////////////////////////////////////////////////////////////////////////
-//
-// Web Intents implementation.
-//
-////////////////////////////////////////////////////////////////////////////////
-
-void WebDataService::RemoveWebIntentServiceImpl(
- const webkit_glue::WebIntentServiceData& service) {
- db_->GetWebIntentsTable()->RemoveWebIntentService(service);
- ScheduleCommit();
-}
-
-void WebDataService::AddWebIntentServiceImpl(
- const webkit_glue::WebIntentServiceData& service) {
- db_->GetWebIntentsTable()->SetWebIntentService(service);
- ScheduleCommit();
-}
-
-
-scoped_ptr<WDTypedResult> WebDataService::GetWebIntentServicesImpl(
- const string16& action) {
- std::vector<WebIntentServiceData> result;
- db_->GetWebIntentsTable()->GetWebIntentServicesForAction(action, &result);
- return scoped_ptr<WDTypedResult>(
- new WDResult<std::vector<WebIntentServiceData> >(
- WEB_INTENTS_RESULT, result));
-}
-
-scoped_ptr<WDTypedResult> WebDataService::GetWebIntentServicesForURLImpl(
- const string16& service_url) {
- std::vector<WebIntentServiceData> result;
- db_->GetWebIntentsTable()->GetWebIntentServicesForURL(service_url, &result);
- return scoped_ptr<WDTypedResult>(
- new WDResult<std::vector<WebIntentServiceData> >(
- WEB_INTENTS_RESULT, result));
-}
-
-scoped_ptr<WDTypedResult> WebDataService::GetAllWebIntentServicesImpl() {
- std::vector<WebIntentServiceData> result;
- db_->GetWebIntentsTable()->GetAllWebIntentServices(&result);
- return scoped_ptr<WDTypedResult>(
- new WDResult<std::vector<WebIntentServiceData> >(
- WEB_INTENTS_RESULT, result));
-}
-
-void WebDataService::AddDefaultWebIntentServiceImpl(
- const DefaultWebIntentService& service) {
- db_->GetWebIntentsTable()->SetDefaultService(service);
- ScheduleCommit();
-}
-
-void WebDataService::RemoveDefaultWebIntentServiceImpl(
- const DefaultWebIntentService& service) {
- db_->GetWebIntentsTable()->RemoveDefaultService(service);
- ScheduleCommit();
-}
-
-void WebDataService::RemoveWebIntentServiceDefaultsImpl(
- const GURL& service_url) {
- db_->GetWebIntentsTable()->RemoveServiceDefaults(service_url);
- ScheduleCommit();
-}
-
-scoped_ptr<WDTypedResult>
- WebDataService::GetDefaultWebIntentServicesForActionImpl(
- const string16& action) {
- std::vector<DefaultWebIntentService> result;
- db_->GetWebIntentsTable()->GetDefaultServices(action, &result);
- return scoped_ptr<WDTypedResult>(
- new WDResult<std::vector<DefaultWebIntentService> >(
- WEB_INTENTS_DEFAULTS_RESULT, result));
-}
-
-scoped_ptr<WDTypedResult> WebDataService::GetAllDefaultWebIntentServicesImpl() {
- std::vector<DefaultWebIntentService> result;
- db_->GetWebIntentsTable()->GetAllDefaultServices(&result);
- return scoped_ptr<WDTypedResult>(
- new WDResult<std::vector<DefaultWebIntentService> >(
- WEB_INTENTS_DEFAULTS_RESULT, result));
-}
-#endif
-
////////////////////////////////////////////////////////////////////////////////
//
// Token Service implementation.
diff --git a/chrome/browser/webdata/web_database.cc b/chrome/browser/webdata/web_database.cc
index 548d857..c0111ed 100644
--- a/chrome/browser/webdata/web_database.cc
+++ b/chrome/browser/webdata/web_database.cc
@@ -81,12 +81,6 @@ WebAppsTable* WebDatabase::GetWebAppsTable() {
return web_apps_table_.get();
}
-#if defined(ENABLE_WEB_INTENTS)
-WebIntentsTable* WebDatabase::GetWebIntentsTable() {
- return web_intents_table_.get();
-}
-#endif
-
sql::Connection* WebDatabase::GetSQLConnection() {
return &db_;
}
diff --git a/chrome/browser/webdata/web_database.h b/chrome/browser/webdata/web_database.h
index c11c6cf..9294960 100644
--- a/chrome/browser/webdata/web_database.h
+++ b/chrome/browser/webdata/web_database.h
@@ -49,9 +49,6 @@ class WebDatabase {
virtual LoginsTable* GetLoginsTable();
virtual TokenServiceTable* GetTokenServiceTable();
virtual WebAppsTable* GetWebAppsTable();
-#if defined(ENABLE_WEB_INTENTS)
- virtual WebIntentsTable* GetWebIntentsTable();
-#endif
// Exposed for testing only.
sql::Connection* GetSQLConnection();
@@ -70,6 +67,7 @@ class WebDatabase {
scoped_ptr<LoginsTable> logins_table_;
scoped_ptr<TokenServiceTable> token_service_table_;
scoped_ptr<WebAppsTable> web_apps_table_;
+ // TODO(thakis): Add a migration to delete this table, then remove this.
scoped_ptr<WebIntentsTable> web_intents_table_;
scoped_ptr<content::NotificationService> notification_service_;
diff --git a/chrome/browser/webdata/web_intents_table.cc b/chrome/browser/webdata/web_intents_table.cc
index 1a2ac59..b7f9ecd 100644
--- a/chrome/browser/webdata/web_intents_table.cc
+++ b/chrome/browser/webdata/web_intents_table.cc
@@ -9,42 +9,11 @@
#include "base/logging.h"
#include "base/string_util.h"
#include "base/utf_string_conversions.h"
-#include "chrome/browser/intents/default_web_intent_service.h"
#include "googleurl/src/gurl.h"
#include "net/base/mime_util.h"
#include "sql/statement.h"
#include "third_party/sqlite/sqlite3.h"
-using webkit_glue::WebIntentServiceData;
-
-namespace {
-
-#if defined(ENABLE_WEB_INTENTS)
-bool ExtractIntents(sql::Statement* s,
- std::vector<WebIntentServiceData>* services) {
- DCHECK(s);
- if (!s->is_valid())
- return false;
-
- while (s->Step()) {
- WebIntentServiceData service;
- service.action = s->ColumnString16(0);
- service.type = s->ColumnString16(1);
- service.scheme = s->ColumnString16(2);
- service.service_url = GURL(s->ColumnString16(3));
- service.title = s->ColumnString16(4);
- // Default to window disposition.
- service.disposition = WebIntentServiceData::DISPOSITION_WINDOW;
- if (s->ColumnString16(5) == ASCIIToUTF16("inline"))
- service.disposition = WebIntentServiceData::DISPOSITION_INLINE;
- services->push_back(service);
- }
- return s->Succeeded();
-}
-#endif // defined(ENABLE_WEB_INTENTS)
-
-} // namespace
-
WebIntentsTable::WebIntentsTable(sql::Connection* db,
sql::MetaTable* meta_table)
: WebDatabaseTable(db, meta_table) {
@@ -156,185 +125,3 @@ bool WebIntentsTable::MigrateToVersion46AddSchemeColumn() {
return true;
}
-
-#if defined(ENABLE_WEB_INTENTS)
-bool WebIntentsTable::GetWebIntentServicesForAction(
- const string16& action,
- std::vector<WebIntentServiceData>* services) {
- DCHECK(services);
- sql::Statement s(db_->GetUniqueStatement(
- "SELECT action, type, scheme, service_url, title, disposition"
- " FROM web_intents"
- " WHERE action=?"));
- s.BindString16(0, action);
-
- return ExtractIntents(&s, services);
-}
-
-bool WebIntentsTable::GetWebIntentServicesForScheme(
- const string16& scheme,
- std::vector<WebIntentServiceData>* services) {
- DCHECK(services);
- sql::Statement s(db_->GetUniqueStatement(
- "SELECT action, type, scheme, service_url, title, disposition"
- " FROM web_intents"
- " WHERE scheme=?"));
- s.BindString16(0, scheme);
-
- return ExtractIntents(&s, services);
-}
-
-// TODO(gbillock): This currently does a full-table scan. Eventually we will
-// store registrations by domain, and so have an indexed origin. At that time,
-// this should just change to do lookup by origin instead of URL.
-bool WebIntentsTable::GetWebIntentServicesForURL(
- const string16& service_url,
- std::vector<WebIntentServiceData>* services) {
- DCHECK(services);
- sql::Statement s(db_->GetUniqueStatement(
- "SELECT action, type, scheme, service_url, title, disposition"
- " FROM web_intents"
- " WHERE service_url=?"));
- s.BindString16(0, service_url);
-
- return ExtractIntents(&s, services);
-}
-
-bool WebIntentsTable::GetAllWebIntentServices(
- std::vector<WebIntentServiceData>* services) {
- DCHECK(services);
- sql::Statement s(db_->GetUniqueStatement(
- "SELECT action, type, scheme, service_url, title, disposition"
- " FROM web_intents"));
-
- return ExtractIntents(&s, services);
-}
-
-bool WebIntentsTable::SetWebIntentService(const WebIntentServiceData& service) {
- sql::Statement s(db_->GetUniqueStatement(
- "INSERT OR REPLACE INTO web_intents "
- "(action, type, scheme, service_url, title, disposition) "
- "VALUES (?, ?, ?, ?, ?, ?)"));
-
- // Default to window disposition.
- string16 disposition = ASCIIToUTF16("window");
- if (service.disposition == WebIntentServiceData::DISPOSITION_INLINE)
- disposition = ASCIIToUTF16("inline");
- s.BindString16(0, service.action);
- s.BindString16(1, service.type);
- s.BindString16(2, service.scheme);
- s.BindString(3, service.service_url.spec());
- s.BindString16(4, service.title);
- s.BindString16(5, disposition);
-
- return s.Run();
-}
-
-// TODO(jhawkins): Investigate the need to remove rows matching only
-// |service.service_url|. It's unlikely the user will be given the ability to
-// remove at the granularity of actions or types.
-bool WebIntentsTable::RemoveWebIntentService(
- const WebIntentServiceData& service) {
- sql::Statement s(db_->GetUniqueStatement(
- "DELETE FROM web_intents "
- "WHERE action = ? AND type = ? AND scheme = ? AND service_url = ?"));
-
- s.BindString16(0, service.action);
- s.BindString16(1, service.type);
- s.BindString16(2, service.scheme);
- s.BindString(3, service.service_url.spec());
-
- return s.Run();
-}
-
-bool WebIntentsTable::GetDefaultServices(
- const string16& action,
- std::vector<DefaultWebIntentService>* default_services) {
- sql::Statement s(db_->GetUniqueStatement(
- "SELECT action, type, url_pattern, user_date, suppression, "
- "service_url FROM web_intents_defaults "
- "WHERE action=?"));
- s.BindString16(0, action);
-
- while (s.Step()) {
- DefaultWebIntentService entry;
- entry.action = s.ColumnString16(0);
- entry.type = s.ColumnString16(1);
- if (entry.url_pattern.Parse(s.ColumnString(2)) !=
- URLPattern::PARSE_SUCCESS) {
- return false;
- }
- entry.user_date = s.ColumnInt(3);
- entry.suppression = s.ColumnInt64(4);
- entry.service_url = s.ColumnString(5);
-
- default_services->push_back(entry);
- }
-
- return s.Succeeded();
-}
-
-bool WebIntentsTable::GetAllDefaultServices(
- std::vector<DefaultWebIntentService>* default_services) {
- sql::Statement s(db_->GetUniqueStatement(
- "SELECT action, type, url_pattern, user_date, suppression, "
- "service_url FROM web_intents_defaults"));
-
- while (s.Step()) {
- DefaultWebIntentService entry;
- entry.action = s.ColumnString16(0);
- entry.type = s.ColumnString16(1);
- if (entry.url_pattern.Parse(s.ColumnString(2)) !=
- URLPattern::PARSE_SUCCESS) {
- return false;
- }
- entry.user_date = s.ColumnInt(3);
- entry.suppression = s.ColumnInt64(4);
- entry.service_url = s.ColumnString(5);
-
- default_services->push_back(entry);
- }
-
- return s.Succeeded();
-
-}
-
-bool WebIntentsTable::SetDefaultService(
- const DefaultWebIntentService& default_service) {
- sql::Statement s(db_->GetUniqueStatement(
- "INSERT OR REPLACE INTO web_intents_defaults "
- "(action, type, url_pattern, user_date, suppression,"
- " service_url, scheme) "
- "VALUES (?, ?, ?, ?, ?, ?, ?)"));
- s.BindString16(0, default_service.action);
- s.BindString16(1, default_service.type);
- s.BindString(2, default_service.url_pattern.GetAsString());
- s.BindInt(3, default_service.user_date);
- s.BindInt64(4, default_service.suppression);
- s.BindString(5, default_service.service_url);
- s.BindString16(6, default_service.scheme);
-
- return s.Run();
-}
-
-bool WebIntentsTable::RemoveDefaultService(
- const DefaultWebIntentService& default_service) {
- sql::Statement s(db_->GetUniqueStatement(
- "DELETE FROM web_intents_defaults "
- "WHERE action = ? AND type = ? AND url_pattern = ?"));
- s.BindString16(0, default_service.action);
- s.BindString16(1, default_service.type);
- s.BindString(2, default_service.url_pattern.GetAsString());
-
- return s.Run();
-}
-
-bool WebIntentsTable::RemoveServiceDefaults(const GURL& service_url) {
- sql::Statement s(db_->GetUniqueStatement(
- "DELETE FROM web_intents_defaults WHERE service_url = ?"));
- s.BindString(0, service_url.spec());
-
- return s.Run();
-}
-
-#endif // defined(ENABLE_WEB_INTENTS)
diff --git a/chrome/browser/webdata/web_intents_table.h b/chrome/browser/webdata/web_intents_table.h
index aa6f97c..844de55 100644
--- a/chrome/browser/webdata/web_intents_table.h
+++ b/chrome/browser/webdata/web_intents_table.h
@@ -11,7 +11,6 @@
#include "base/compiler_specific.h"
#include "base/string16.h"
#include "chrome/browser/webdata/web_database_table.h"
-#include "webkit/glue/web_intent_service_data.h"
namespace sql {
class Connection;
@@ -20,6 +19,9 @@ class MetaTable;
struct DefaultWebIntentService;
+// TODO(thakis): Delete this class once there's a migration that drops the
+// table backing it.
+
// This class manages the WebIntents table within the SQLite database passed
// to the constructor. It expects the following schema:
//
@@ -58,57 +60,6 @@ class WebIntentsTable : public WebDatabaseTable {
// Adds "scheme" column to the web_intents and web_intents_defaults tables.
bool MigrateToVersion46AddSchemeColumn();
-#if (ENABLE_WEB_INTENTS)
- // Adds a web intent service to the WebIntents table.
- // If |service| already exists, replaces it.
- bool SetWebIntentService(const webkit_glue::WebIntentServiceData& service);
-
- // Retrieve all |services| from WebIntents table that match |action|.
- bool GetWebIntentServicesForAction(
- const string16& action,
- std::vector<webkit_glue::WebIntentServiceData>* services);
-
- // Retrieve all |services| from WebIntents table that match |scheme|.
- bool GetWebIntentServicesForScheme(
- const string16& scheme,
- std::vector<webkit_glue::WebIntentServiceData>* services);
-
- // Retrieves all |services| from WebIntents table that match |service_url|.
- bool GetWebIntentServicesForURL(
- const string16& service_url,
- std::vector<webkit_glue::WebIntentServiceData>* services);
-
- // Retrieve all |services| from WebIntents table.
- bool GetAllWebIntentServices(
- std::vector<webkit_glue::WebIntentServiceData>* services);
-
- // Removes |service| from WebIntents table - must match all parameters
- // exactly.
- bool RemoveWebIntentService(const webkit_glue::WebIntentServiceData& service);
-
- // Get the default service to be used for the given intent invocation.
- // If any overlapping defaults are found, they're placed in
- // |default_services|, otherwise, it is untouched.
- // Returns true if the method runs successfully, false on database error.
- bool GetDefaultServices(
- const string16& action,
- std::vector<DefaultWebIntentService>* default_services);
-
- // Get a list of all installed default services.
- bool GetAllDefaultServices(
- std::vector<DefaultWebIntentService>* default_services);
-
- // Set a default service to be used on given intent invocations.
- bool SetDefaultService(const DefaultWebIntentService& default_service);
-
- // Removes a default |service| from table - must match the action, type,
- // and url_pattern parameters exactly.
- bool RemoveDefaultService(const DefaultWebIntentService& default_service);
-
- // Removes all default services associated with |service_url|.
- bool RemoveServiceDefaults(const GURL& service_url);
-#endif
-
private:
DISALLOW_COPY_AND_ASSIGN(WebIntentsTable);
};
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index 55e9e2f..0ad8d79 100644
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -954,26 +954,6 @@
'browser/instant/instant_tab.h',
'browser/instant/instant_unload_handler.cc',
'browser/instant/instant_unload_handler.h',
- 'browser/intents/cws_intents_registry.cc',
- 'browser/intents/cws_intents_registry.h',
- 'browser/intents/cws_intents_registry_factory.cc',
- 'browser/intents/cws_intents_registry_factory.h',
- 'browser/intents/default_web_intent_service.cc',
- 'browser/intents/default_web_intent_service.h',
- 'browser/intents/intent_service_host.h',
- 'browser/intents/native_services.cc',
- 'browser/intents/native_services.h',
- 'browser/intents/register_intent_handler_infobar_delegate.cc',
- 'browser/intents/register_intent_handler_infobar_delegate.h',
- 'browser/intents/web_intents_registry.cc',
- 'browser/intents/web_intents_registry.h',
- 'browser/intents/web_intents_registry_factory.cc',
- 'browser/intents/web_intents_registry_factory.h',
- 'browser/intents/web_intents_reporting.cc',
- 'browser/intents/web_intents_reporting.h',
- 'browser/intents/web_intents_util.cc',
- 'browser/intents/web_intents_util.h',
- 'browser/intents/web_intents_util_stub.cc',
'browser/internal_auth.cc',
'browser/internal_auth.h',
'browser/intranet_redirect_detector.cc',
@@ -2705,16 +2685,6 @@
['exclude', '^browser/notifications/'],
],
}],
- ['enable_web_intents==0', {
- 'sources/': [
- ['exclude', '^browser/intents/'],
- ['include', '^browser/intents/web_intents_util_stub.cc'],
- ],
- }, { # enable_web_intents==1
- 'sources!': [
- 'browser/intents/web_intents_util_stub.cc',
- ],
- }],
['enable_themes==0', {
'sources!': [
'browser/sync/glue/theme_data_type_controller.cc',
diff --git a/chrome/chrome_browser_extensions.gypi b/chrome/chrome_browser_extensions.gypi
index 41f8bd0..7916d71 100644
--- a/chrome/chrome_browser_extensions.gypi
+++ b/chrome/chrome_browser_extensions.gypi
@@ -709,10 +709,6 @@
'browser/extensions/user_script_master.h',
'browser/extensions/web_accessible_resources_parser.cc',
'browser/extensions/web_accessible_resources_parser.h',
- 'browser/extensions/web_intent_callbacks.cc',
- 'browser/extensions/web_intent_callbacks.h',
- 'browser/extensions/web_intents_parser.cc',
- 'browser/extensions/web_intents_parser.h',
'browser/extensions/webstore_install_helper.cc',
'browser/extensions/webstore_install_helper.h',
'browser/extensions/webstore_installer.cc',
diff --git a/chrome/chrome_browser_ui.gypi b/chrome/chrome_browser_ui.gypi
index 6b4f6cf8..5cc67ae 100644
--- a/chrome/chrome_browser_ui.gypi
+++ b/chrome/chrome_browser_ui.gypi
@@ -610,7 +610,6 @@
'browser/ui/cocoa/infobars/translate_infobar_base.mm',
'browser/ui/cocoa/infobars/translate_message_infobar_controller.h',
'browser/ui/cocoa/infobars/translate_message_infobar_controller.mm',
- 'browser/ui/cocoa/intents/web_intent_picker_cocoa.mm',
'browser/ui/cocoa/javascript_app_modal_dialog_cocoa.h',
'browser/ui/cocoa/javascript_app_modal_dialog_cocoa.mm',
'browser/ui/cocoa/key_equivalent_constants.h',
@@ -659,8 +658,6 @@
'browser/ui/cocoa/location_bar/separator_decoration.mm',
'browser/ui/cocoa/location_bar/star_decoration.h',
'browser/ui/cocoa/location_bar/star_decoration.mm',
- 'browser/ui/cocoa/location_bar/web_intents_button_decoration.h',
- 'browser/ui/cocoa/location_bar/web_intents_button_decoration.mm',
'browser/ui/cocoa/location_bar/zoom_decoration.h',
'browser/ui/cocoa/location_bar/zoom_decoration.mm',
'browser/ui/cocoa/login_prompt_cocoa.h',
@@ -1141,8 +1138,6 @@
'browser/ui/gtk/web_contents_modal_dialog_manager_gtk.cc',
'browser/ui/gtk/web_dialog_gtk.cc',
'browser/ui/gtk/web_dialog_gtk.h',
- 'browser/ui/gtk/web_intent_picker_gtk.cc',
- 'browser/ui/gtk/web_intent_picker_gtk.h',
'browser/ui/gtk/website_settings/permission_selector.cc',
'browser/ui/gtk/website_settings/permission_selector.h',
'browser/ui/gtk/website_settings/permission_selector_observer.h',
@@ -1154,19 +1149,6 @@
'browser/ui/host_desktop.h',
'browser/ui/hung_plugin_tab_helper.cc',
'browser/ui/hung_plugin_tab_helper.h',
- 'browser/ui/intents/web_intent_icon_loader.h',
- 'browser/ui/intents/web_intent_icon_loader.cc',
- 'browser/ui/intents/native_file_picker_service.cc',
- 'browser/ui/intents/web_intent_inline_disposition_delegate.cc',
- 'browser/ui/intents/web_intent_inline_disposition_delegate.h',
- 'browser/ui/intents/web_intent_picker.cc',
- 'browser/ui/intents/web_intent_picker.h',
- 'browser/ui/intents/web_intent_picker_controller.cc',
- 'browser/ui/intents/web_intent_picker_controller.h',
- 'browser/ui/intents/web_intent_picker_delegate.h',
- 'browser/ui/intents/web_intent_picker_model.cc',
- 'browser/ui/intents/web_intent_picker_model.h',
- 'browser/ui/intents/web_intent_picker_model_observer.h',
'browser/ui/login/login_model.h',
'browser/ui/login/login_prompt.cc',
'browser/ui/login/login_prompt.h',
@@ -1667,8 +1649,6 @@
'browser/ui/views/location_bar/zoom_bubble_view.h',
'browser/ui/views/location_bar/zoom_view.cc',
'browser/ui/views/location_bar/zoom_view.h',
- 'browser/ui/views/location_bar/web_intents_button_view.cc',
- 'browser/ui/views/location_bar/web_intents_button_view.h',
'browser/ui/views/login_prompt_views.cc',
'browser/ui/views/login_view.cc',
'browser/ui/views/login_view.h',
@@ -1793,7 +1773,6 @@
'browser/ui/views/update_recommended_message_box.h',
'browser/ui/views/user_data_dir_dialog_view.cc',
'browser/ui/views/user_data_dir_dialog_view.h',
- 'browser/ui/views/web_intent_picker_views.cc',
'browser/ui/views/web_contents_modal_dialog_manager_views.cc',
'browser/ui/views/website_settings/permission_selector_view.cc',
'browser/ui/views/website_settings/permission_selector_view.h',
@@ -2521,21 +2500,6 @@
'../third_party/undoview/undoview.gyp:undoview',
],
}],
- ['enable_web_intents==0', {
- 'sources/': [
- ['exclude', '^browser/ui/intents/'],
- ],
- 'sources!': [
- 'browser/ui/cocoa/intents/web_intent_picker_cocoa.mm',
- 'browser/ui/cocoa/location_bar/web_intents_button_decoration.h',
- 'browser/ui/cocoa/location_bar/web_intents_button_decoration.mm',
- 'browser/ui/gtk/web_intent_picker_gtk.cc',
- 'browser/ui/gtk/web_intent_picker_gtk.h',
- 'browser/ui/views/location_bar/web_intents_button_view.cc',
- 'browser/ui/views/location_bar/web_intents_button_view.h',
- 'browser/ui/views/web_intent_picker_views.cc',
- ],
- }],
['enable_themes==0', {
'sources!': [
'browser/ui/webui/theme_source.cc',
diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi
index 37a31aa..ee1d544 100644
--- a/chrome/chrome_tests.gypi
+++ b/chrome/chrome_tests.gypi
@@ -1220,7 +1220,6 @@
'browser/importer/toolbar_importer_utils_browsertest.cc',
'browser/infobars/infobar_extension_apitest.cc',
'browser/infobars/infobars_browsertest.cc',
- 'browser/intents/native_services_browsertest.cc',
'browser/loadtimes_extension_bindings_browsertest.cc',
'browser/locale_tests_browsertest.cc',
'browser/logging_chrome_browsertest.cc',
@@ -1335,9 +1334,6 @@
'browser/ui/gtk/location_bar_view_gtk_browsertest.cc',
'browser/ui/gtk/one_click_signin_bubble_gtk_browsertest.cc',
'browser/ui/gtk/view_id_util_browsertest.cc',
- 'browser/ui/intents/web_intent_picker_controller_browsertest.cc',
- 'browser/ui/intents/web_intent_picker_delegate_mock.cc',
- 'browser/ui/intents/web_intent_picker_delegate_mock.h',
'browser/ui/login/login_prompt_browsertest.cc',
'browser/ui/panels/panel_extension_browsertest.cc',
'browser/ui/prefs/prefs_tab_helper_browsertest.cc',
@@ -1639,14 +1635,6 @@
'browser/media/chrome_webrtc_browsertest.cc',
],
}],
- ['enable_web_intents==0', {
- 'sources!': [
- 'browser/intents/native_services_browsertest.cc',
- 'browser/ui/intents/web_intent_picker_controller_browsertest.cc',
- 'browser/ui/intents/web_intent_picker_delegate_mock.cc',
- 'browser/ui/intents/web_intent_picker_delegate_mock.h',
- ],
- }],
['OS=="win"', {
'sources': [
'<(SHARED_INTERMEDIATE_DIR)/chrome/browser_resources.rc',
diff --git a/chrome/chrome_tests_unit.gypi b/chrome/chrome_tests_unit.gypi
index dd1688e..043725f3 100644
--- a/chrome/chrome_tests_unit.gypi
+++ b/chrome/chrome_tests_unit.gypi
@@ -858,13 +858,6 @@
'browser/importer/importer_unittest_utils.h',
'browser/importer/safari_importer_unittest.mm',
'browser/importer/toolbar_importer_unittest.cc',
- 'browser/intents/cws_intents_registry_unittest.cc',
- 'browser/intents/default_web_intent_service_unittest.cc',
- 'browser/intents/native_services_unittest.cc',
- 'browser/intents/register_intent_handler_infobar_delegate_unittest.cc',
- 'browser/intents/web_intents_registry_unittest.cc',
- 'browser/intents/web_intents_reporting_unittest.cc',
- 'browser/intents/web_intents_util_unittest.cc',
'browser/internal_auth_unittest.cc',
'browser/language_usage_metrics_unittest.cc',
'browser/mac/keystone_glue_unittest.mm',
@@ -1331,7 +1324,6 @@
'browser/ui/cocoa/location_bar/search_token_decoration_unittest.mm',
'browser/ui/cocoa/location_bar/selected_keyword_decoration_unittest.mm',
'browser/ui/cocoa/location_bar/separator_decoration_unittest.mm',
- 'browser/ui/cocoa/location_bar/web_intents_button_decoration_unittest.mm',
'browser/ui/cocoa/menu_button_unittest.mm',
'browser/ui/cocoa/menu_controller_unittest.mm',
'browser/ui/cocoa/notifications/balloon_controller_unittest.mm',
@@ -1395,9 +1387,6 @@
'browser/ui/gtk/reload_button_gtk_unittest.cc',
'browser/ui/gtk/status_icons/status_tray_gtk_unittest.cc',
'browser/ui/gtk/tabs/tab_renderer_gtk_unittest.cc',
- 'browser/ui/intents/web_intent_inline_disposition_delegate_unittest.cc',
- 'browser/ui/intents/web_intent_picker_model_unittest.cc',
- 'browser/ui/intents/web_intent_picker_unittest.cc',
'browser/ui/login/login_prompt_unittest.cc',
'browser/ui/omnibox/omnibox_edit_unittest.cc',
'browser/ui/omnibox/omnibox_view_unittest.cc',
@@ -1543,7 +1532,6 @@
'common/extensions/manifest_tests/extension_manifests_update_unittest.cc',
'common/extensions/manifest_tests/extension_manifests_validapp_unittest.cc',
'common/extensions/manifest_tests/extension_manifests_web_accessible_resources_unittest.cc',
- 'common/extensions/manifest_tests/extension_manifests_web_intents_unittest.cc',
'common/extensions/manifest_tests/extension_manifests_web_unittest.cc',
'common/extensions/manifest_unittest.cc',
'common/extensions/manifest_handler_unittest.cc',
@@ -2217,15 +2205,9 @@
],
}], # OS == android
['enable_web_intents==0', {
- 'sources/': [
- ['exclude', '^browser/intents/'],
- ['exclude', '^browser/ui/intents/'],
- ],
'sources!': [
- 'browser/ui/cocoa/location_bar/web_intents_button_decoration_unittest.mm',
'browser/webdata/web_data_service_unittest.cc',
'browser/webdata/web_intents_table_unittest.cc',
- 'common/extensions/manifest_tests/extension_manifests_web_intents_unittest.cc',
'../webkit/glue/web_intent_reply_data_unittest.cc',
'../webkit/glue/web_intent_service_data_unittest.cc',
],
diff --git a/chrome/common/content_settings_types.h b/chrome/common/content_settings_types.h
index e1fd06f..9589af2 100644
--- a/chrome/common/content_settings_types.h
+++ b/chrome/common/content_settings_types.h
@@ -18,7 +18,6 @@ enum ContentSettingsType {
CONTENT_SETTINGS_TYPE_POPUPS,
CONTENT_SETTINGS_TYPE_GEOLOCATION,
CONTENT_SETTINGS_TYPE_NOTIFICATIONS,
- CONTENT_SETTINGS_TYPE_INTENTS,
CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE,
CONTENT_SETTINGS_TYPE_FULLSCREEN,
CONTENT_SETTINGS_TYPE_MOUSELOCK,
diff --git a/chrome/common/extensions/api/app_runtime.idl b/chrome/common/extensions/api/app_runtime.idl
index e63dc5b..391adaa 100644
--- a/chrome/common/extensions/api/app_runtime.idl
+++ b/chrome/common/extensions/api/app_runtime.idl
@@ -4,26 +4,6 @@
namespace app.runtime {
- callback NullCallback = void ();
-
- // A WebIntents intent object. Deprecated.
- [nodoc] dictionary Intent {
- // The WebIntent being invoked.
- DOMString action;
-
- // The MIME type of the data.
- DOMString type;
-
- // Data associated with the intent.
- any data;
-
- // Callback to be compatible with WebIntents.
- NullCallback postResult;
-
- // Callback to be compatible with WebIntents.
- NullCallback postFailure;
- };
-
[inline_doc] dictionary LaunchItem {
// FileEntry for the file.
[instanceOf=FileEntry] object entry;
@@ -34,8 +14,6 @@ namespace app.runtime {
// Optional data for the launch.
[inline_doc] dictionary LaunchData {
- [nodoc] Intent intent;
-
// The id of the file handler that the app is being invoked with.
DOMString? id;
@@ -43,30 +21,11 @@ namespace app.runtime {
};
interface Events {
- // Fired when an app is launched from the launcher or in response to a web
- // intent.
+ // Fired when an app is launched from the launcher.
static void onLaunched(optional LaunchData launchData);
// Fired at Chrome startup to apps that were running when Chrome last shut
// down.
static void onRestarted();
};
-
- dictionary IntentResponse {
- // Identifies the intent.
- long intentId;
-
- // Was this intent successful? (i.e., postSuccess vs postFailure).
- boolean success;
-
- // Data associated with the intent response.
- any data;
- };
-
- interface Functions {
- // postIntentResponse is an internal method to responds to an intent
- // previously sent to a packaged app. This is identified by intentId, and
- // should only be invoked at most once per intentId.
- [nodoc] static void postIntentResponse(IntentResponse intentResponse);
- };
};
diff --git a/chrome/common/pref_names.cc b/chrome/common/pref_names.cc
index ffeb124..3eaabc2 100644
--- a/chrome/common/pref_names.cc
+++ b/chrome/common/pref_names.cc
@@ -994,11 +994,6 @@ const char kPluginsMetadata[] = "plugins.metadata";
const char kPluginsResourceCacheUpdate[] = "plugins.resource_cache_update";
#endif
-#if defined(ENABLE_WEB_INTENTS)
-// Boolean that is true if Web Intents is enabled.
-const char kWebIntentsEnabled[] = "webintents.enabled";
-#endif
-
// Boolean that indicates whether we should check if we are the default browser
// on start-up.
const char kCheckDefaultBrowser[] = "browser.check_default_browser";
diff --git a/chrome/common/pref_names.h b/chrome/common/pref_names.h
index db4b6c1..d232835 100644
--- a/chrome/common/pref_names.h
+++ b/chrome/common/pref_names.h
@@ -778,10 +778,6 @@ extern const char kFactoryResetRequested[];
extern const char kRecoveryComponentVersion[];
extern const char kComponentUpdaterState[];
-#if defined(ENABLE_WEB_INTENTS)
-extern const char kWebIntentsEnabled[];
-#endif
-
extern const char kMediaGalleriesUniqueId[];
extern const char kMediaGalleriesRememberedGalleries[];
diff --git a/chrome/test/base/test_location_bar.h b/chrome/test/base/test_location_bar.h
index 902bde0..57a4c1d 100644
--- a/chrome/test/base/test_location_bar.h
+++ b/chrome/test/base/test_location_bar.h
@@ -39,9 +39,6 @@ class TestLocationBar : public LocationBar {
virtual void UpdateContentSettingsIcons() OVERRIDE {}
virtual void UpdatePageActions() OVERRIDE {}
virtual void InvalidatePageActions() OVERRIDE {}
-#if defined(ENABLE_WEB_INTENTS)
- virtual void UpdateWebIntentsButton() OVERRIDE {}
-#endif
virtual void UpdateOpenPDFInReaderPrompt() OVERRIDE {}
virtual void SaveStateToContents(content::WebContents* contents) OVERRIDE {}
virtual void Revert() OVERRIDE {}
diff --git a/chrome/test/data/extensions/api_test/filebrowser_component/intent.html b/chrome/test/data/extensions/api_test/filebrowser_component/intent.html
deleted file mode 100644
index 4303faa..0000000
--- a/chrome/test/data/extensions/api_test/filebrowser_component/intent.html
+++ /dev/null
@@ -1,10 +0,0 @@
-<!--
- * Copyright (c) 2012 The Chromium Authors. All rights reserved. Use of this
- * source code is governed by a BSD-style license that can be found in the
- * LICENSE file.
--->
-<script src="intent.js"></script>
-<html>
-<head><title>file browser component test</title></head>
-<body><h2>chrome.fileBrowserPrivate.* tests</h2></body>
-</html>
diff --git a/content/browser/intents/OWNERS b/content/browser/intents/OWNERS
deleted file mode 100644
index 46ef6e0..0000000
--- a/content/browser/intents/OWNERS
+++ /dev/null
@@ -1,4 +0,0 @@
-binji@chromium.org
-gbillock@chromium.org
-groby@chromium.org
-jhawkins@chromium.org
diff --git a/content/browser/intents/intent_injector.cc b/content/browser/intents/intent_injector.cc
deleted file mode 100644
index 96e8d87..0000000
--- a/content/browser/intents/intent_injector.cc
+++ /dev/null
@@ -1,130 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "content/browser/intents/intent_injector.h"
-
-#include "base/bind.h"
-#include "base/command_line.h"
-#include "base/file_path.h"
-#include "base/logging.h"
-#include "base/string16.h"
-#include "base/stringprintf.h"
-#include "content/browser/child_process_security_policy_impl.h"
-#include "content/browser/intents/web_intents_dispatcher_impl.h"
-#include "content/browser/renderer_host/render_process_host_impl.h"
-#include "content/browser/renderer_host/render_view_host_impl.h"
-#include "content/browser/web_contents/web_contents_impl.h"
-#include "content/common/intents_messages.h"
-#include "content/public/common/content_switches.h"
-#include "webkit/fileapi/file_system_util.h"
-#include "webkit/fileapi/isolated_context.h"
-#include "webkit/glue/web_intent_data.h"
-#include "webkit/glue/web_intent_reply_data.h"
-
-namespace content {
-
-IntentInjector::IntentInjector(WebContents* web_contents)
- : WebContentsObserver(web_contents),
- intents_dispatcher_(NULL),
- ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) {
- DCHECK(web_contents);
-}
-
-IntentInjector::~IntentInjector() {
-}
-
-void IntentInjector::WebContentsDestroyed(WebContents* contents) {
- if (intents_dispatcher_) {
- intents_dispatcher_->SendReply(webkit_glue::WebIntentReply(
- webkit_glue::WEB_INTENT_SERVICE_CONTENTS_CLOSED, string16()));
- }
-
- delete this;
-}
-
-void IntentInjector::SourceWebContentsDestroyed(WebContents* contents) {
- intents_dispatcher_ = NULL;
-}
-
-void IntentInjector::SetIntent(
- WebIntentsDispatcher* intents_dispatcher,
- const webkit_glue::WebIntentData& intent) {
- intents_dispatcher_ = intents_dispatcher;
- intents_dispatcher_->RegisterReplyNotification(
- base::Bind(&IntentInjector::OnSendReturnMessage,
- weak_factory_.GetWeakPtr()));
- source_intent_.reset(new webkit_glue::WebIntentData(intent));
- initial_url_ = web_contents()->GetPendingSiteInstance()->GetSiteURL();
-}
-
-void IntentInjector::Abandon() {
- intents_dispatcher_ = NULL;
- delete this;
-}
-
-void IntentInjector::OnSendReturnMessage(
- webkit_glue::WebIntentReplyType reply_type) {
- intents_dispatcher_ = NULL;
-}
-
-void IntentInjector::RenderViewCreated(RenderViewHost* render_view_host) {
- if (source_intent_.get() == NULL || !web_contents()->GetRenderViewHost())
- return;
-
- // Only deliver the intent to the renderer if it has the same origin
- // as the initial delivery target.
- if (initial_url_.GetOrigin() !=
- render_view_host->GetSiteInstance()->GetSiteURL().GetOrigin()) {
- return;
- }
-
- // If we're passing a browser-originated blob, either directly or as part of a
- // payload, grant read permission on the blob file to the delivered context.
- if (source_intent_->data_type == webkit_glue::WebIntentData::BLOB ||
- (source_intent_->data_type == webkit_glue::WebIntentData::MIME_TYPE &&
- !source_intent_->blob_file.empty())) {
- const int child_id = render_view_host->GetProcess()->GetID();
- ChildProcessSecurityPolicy* policy =
- ChildProcessSecurityPolicy::GetInstance();
- if (!policy->CanReadFile(child_id, source_intent_->blob_file))
- policy->GrantReadFile(child_id, source_intent_->blob_file);
- } else if (source_intent_->data_type ==
- webkit_glue::WebIntentData::FILESYSTEM) {
- const int child_id = render_view_host->GetProcess()->GetID();
- base::FilePath path;
- const bool valid =
- fileapi::IsolatedContext::GetInstance()->GetRegisteredPath(
- source_intent_->filesystem_id, &path);
- DCHECK(valid);
- ChildProcessSecurityPolicy* policy =
- ChildProcessSecurityPolicy::GetInstance();
- if (!policy->CanReadFile(child_id, path))
- policy->GrantReadFile(child_id, path);
- policy->GrantReadFileSystem(child_id, source_intent_->filesystem_id);
- }
-
- render_view_host->Send(new IntentsMsg_SetWebIntentData(
- render_view_host->GetRoutingID(), *(source_intent_.get())));
-}
-
-bool IntentInjector::OnMessageReceived(const IPC::Message& message) {
- bool handled = true;
- IPC_BEGIN_MESSAGE_MAP(IntentInjector, message)
- IPC_MESSAGE_HANDLER(IntentsHostMsg_WebIntentReply, OnReply);
- IPC_MESSAGE_UNHANDLED(handled = false)
- IPC_END_MESSAGE_MAP()
- return handled;
-}
-
-void IntentInjector::OnReply(const webkit_glue::WebIntentReply& reply) {
- if (!intents_dispatcher_)
- return;
-
- // Ensure SendReplyMessage is only called once.
- WebIntentsDispatcher* intents_dispatcher = intents_dispatcher_;
- intents_dispatcher_ = NULL;
- intents_dispatcher->SendReply(reply);
-}
-
-} // namespace content
diff --git a/content/browser/intents/intent_injector.h b/content/browser/intents/intent_injector.h
deleted file mode 100644
index 942a23e..0000000
--- a/content/browser/intents/intent_injector.h
+++ /dev/null
@@ -1,91 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CONTENT_BROWSER_INTENTS_INTENT_INJECTOR_H_
-#define CONTENT_BROWSER_INTENTS_INTENT_INJECTOR_H_
-
-#include "base/basictypes.h"
-#include "base/gtest_prod_util.h"
-#include "base/memory/scoped_ptr.h"
-#include "base/memory/weak_ptr.h"
-#include "base/string16.h"
-#include "content/public/browser/web_contents_observer.h"
-#include "content/common/content_export.h"
-#include "googleurl/src/gurl.h"
-#include "webkit/glue/web_intent_reply_data.h"
-
-namespace webkit_glue {
-struct WebIntentData;
-}
-
-namespace content {
-class WebIntentsDispatcher;
-
-// Injects an intent into the renderer of a WebContents. The intent dispatch
-// logic will create one of these to take care of passing intent data down into
-// the context of the service, which will be running in the WebContents on which
-// this class is an observer. Attaches to the service contents and deletes
-// itself when that WebContents is closed.
-//
-// This object should be attached to the new WebContents very early: before the
-// RenderView is created. It will then send the intent data down to the renderer
-// on the RenderViewCreated call, so that the intent data is available
-// throughout the parsing of the loaded document.
-class CONTENT_EXPORT IntentInjector : public WebContentsObserver {
- public:
- // |web_contents| must not be NULL.
- explicit IntentInjector(WebContents* web_contents);
-
- // WebContentsObserver implementation.
- virtual void RenderViewCreated(RenderViewHost* render_view_host) OVERRIDE;
- virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
- virtual void WebContentsDestroyed(WebContents* contents) OVERRIDE;
-
- // Used to notify the object that the source contents has been destroyed.
- void SourceWebContentsDestroyed(WebContents* contents);
-
- // Sets the intent data to be injected. Call after the user has selected a
- // service to pass the intent data to that service. |intents_dispatcher| is a
- // sender to use to communicate to the source contents. The caller must
- // ensure that SourceWebContentsDestroyed is called when this object becomes
- // unusable. |intent| is the intent data from the source.
- void SetIntent(WebIntentsDispatcher* intents_dispatcher,
- const webkit_glue::WebIntentData& intent);
-
- // Abandon this injector. Used when re-delivering an intent to a different
- // service provider, i.e. when abandoning an inline disposition and picking
- // a new provider. Self-deletes.
- void Abandon();
-
- private:
- FRIEND_TEST_ALL_PREFIXES(IntentInjectorTest, AbandonDeletes);
-
- // Private, since the class is self-deleting.
- virtual ~IntentInjector();
-
- // Handles receiving a reply from the intent delivery page.
- void OnReply(const webkit_glue::WebIntentReply& reply);
-
- // Gets notification that someone else has replied to the intent call.
- void OnSendReturnMessage(webkit_glue::WebIntentReplyType reply_type);
-
- // Source intent data provided by caller.
- scoped_ptr<webkit_glue::WebIntentData> source_intent_;
-
- // Weak pointer to the message forwarder to the contents invoking the intent.
- WebIntentsDispatcher* intents_dispatcher_;
-
- // Remember the initial delivery url for origin restriction.
- GURL initial_url_;
-
- // The injector may be Abandon()ed and deleted before the dispatcher. Use weak
- // pointers to ensure the notification callback remains valid.
- base::WeakPtrFactory<IntentInjector> weak_factory_;
-
- DISALLOW_COPY_AND_ASSIGN(IntentInjector);
-};
-
-} // namespace content
-
-#endif // CONTENT_BROWSER_INTENTS_INTENT_INJECTOR_H_
diff --git a/content/browser/intents/intent_injector_unittest.cc b/content/browser/intents/intent_injector_unittest.cc
deleted file mode 100644
index b32afc8..0000000
--- a/content/browser/intents/intent_injector_unittest.cc
+++ /dev/null
@@ -1,110 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "base/bind.h"
-#include "base/memory/weak_ptr.h"
-#include "base/utf_string_conversions.h"
-#include "content/browser/intents/intent_injector.h"
-#include "content/browser/intents/internal_web_intents_dispatcher.h"
-#include "content/browser/renderer_host/test_render_view_host.h"
-#include "content/browser/web_contents/test_web_contents.h"
-#include "content/common/intents_messages.h"
-#include "content/common/view_messages.h"
-#include "content/public/test/mock_render_process_host.h"
-#include "content/public/test/web_contents_tester.h"
-#include "webkit/glue/web_intent_data.h"
-#include "webkit/glue/web_intent_reply_data.h"
-
-namespace content {
-
-class IntentInjectorTest : public RenderViewHostImplTestHarness {
- public:
- IntentInjectorTest() {
- webkit_glue::WebIntentData intent(ASCIIToUTF16("action"),
- ASCIIToUTF16("type"),
- ASCIIToUTF16("unserialized_data"));
- // Will be destroyed when the IntentInjector shuts down.
- dispatcher_ = new InternalWebIntentsDispatcher(intent);
- }
-
- ~IntentInjectorTest() {}
-
- InternalWebIntentsDispatcher* dispatcher_;
-};
-
-TEST_F(IntentInjectorTest, TestDispatchLimitedToSameOrigin) {
- contents()->transition_cross_site = true;
- // Set up GetURL within the web_contents, and enable cross-site RVH
- // transitions.
- NavigateAndCommit(GURL("http://www.ddd.com/"));
-
- // Set up the injector, which will lock to the origin of GetURL.
- // The injector is a WebContentsObserver, destroyed when the
- // web_contents() is destroyed at the end of the test.
- IntentInjector* injector = new IntentInjector(web_contents());
- webkit_glue::WebIntentData intent(ASCIIToUTF16("action"),
- ASCIIToUTF16("type"),
- ASCIIToUTF16("unserialized_data"));
- injector->SetIntent(dispatcher_, intent);
-
- // Navigate to a same-origin page. The intent data should be sent.
- controller().LoadURL(GURL("http://www.ddd.com/page1"),
- Referrer(),
- PAGE_TRANSITION_TYPED,
- std::string());
- test_rvh()->OnMessageReceived(ViewHostMsg_ShouldClose_ACK(
- rvh()->GetRoutingID(), true, base::TimeTicks(), base::TimeTicks()));
-
- ASSERT_FALSE(pending_rvh());
- injector->RenderViewCreated(rvh());
-
- EXPECT_FALSE(NULL == process()->sink().GetFirstMessageMatching(
- IntentsMsg_SetWebIntentData::ID));
- process()->sink().ClearMessages();
-
- // Intent data is sent to a different same-origin page.
- controller().LoadURL(GURL("http://www.ddd.com/page2"),
- Referrer(),
- PAGE_TRANSITION_TYPED,
- std::string());
- test_rvh()->OnMessageReceived(ViewHostMsg_ShouldClose_ACK(
- rvh()->GetRoutingID(), true, base::TimeTicks(), base::TimeTicks()));
- ASSERT_FALSE(pending_rvh());
- injector->RenderViewCreated(rvh());
- EXPECT_FALSE(NULL == process()->sink().GetFirstMessageMatching(
- IntentsMsg_SetWebIntentData::ID));
- process()->sink().ClearMessages();
-
- controller().LoadURL(GURL("http://www.domain2.com/"),
- Referrer(),
- PAGE_TRANSITION_TYPED,
- std::string());
- ASSERT_TRUE(contents()->cross_navigation_pending());
- ASSERT_TRUE(pending_rvh());
- injector->RenderViewCreated(pending_test_rvh());
-
- // The injector is still operating on the WebContents with the ddd.com
- // initial page, so no intent data is sent to this new renderer.
- EXPECT_TRUE(NULL == process()->sink().GetFirstMessageMatching(
- IntentsMsg_SetWebIntentData::ID));
-}
-
-TEST_F(IntentInjectorTest, AbandonDeletes) {
- IntentInjector* injector = new IntentInjector(web_contents());
-
- base::WeakPtr<IntentInjector> weak_injector =
- injector->weak_factory_.GetWeakPtr();
- EXPECT_FALSE(weak_injector.get() == NULL);
- weak_injector->Abandon();
- EXPECT_TRUE(weak_injector.get() == NULL);
-
- // Sending a message will both auto-delete |dispatcher_| to clean up and
- // verify that messages don't get sent to the (now deleted) |injector|.
- dispatcher_->SendReply(
- webkit_glue::WebIntentReply(
- webkit_glue::WEB_INTENT_SERVICE_CONTENTS_CLOSED,
- string16()));
-}
-
-} // namespace content
diff --git a/content/browser/intents/internal_web_intents_dispatcher.cc b/content/browser/intents/internal_web_intents_dispatcher.cc
deleted file mode 100644
index 3cc0e46..0000000
--- a/content/browser/intents/internal_web_intents_dispatcher.cc
+++ /dev/null
@@ -1,67 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "content/browser/intents/internal_web_intents_dispatcher.h"
-
-#include "content/browser/intents/intent_injector.h"
-#include "webkit/glue/web_intent_data.h"
-#include "webkit/glue/web_intent_reply_data.h"
-
-namespace content {
-
-InternalWebIntentsDispatcher::InternalWebIntentsDispatcher(
- const webkit_glue::WebIntentData& intent)
- : intent_(intent),
- intent_injector_(NULL) {}
-
-InternalWebIntentsDispatcher::InternalWebIntentsDispatcher(
- const webkit_glue::WebIntentData& intent,
- const ReplyCallback& reply_callback)
- : intent_(intent),
- intent_injector_(NULL),
- reply_callback_(reply_callback) {}
-
-InternalWebIntentsDispatcher::~InternalWebIntentsDispatcher() {}
-
-const webkit_glue::WebIntentData& InternalWebIntentsDispatcher::GetIntent() {
- return intent_;
-}
-
-void InternalWebIntentsDispatcher::DispatchIntent(
- WebContents* destination_contents) {
- DCHECK(destination_contents);
- DCHECK(!intent_injector_);
- intent_injector_ = new IntentInjector(destination_contents);
- intent_injector_->SetIntent(this, intent_);
-}
-
-void InternalWebIntentsDispatcher::ResetDispatch() {
- if (intent_injector_) {
- intent_injector_->Abandon();
- intent_injector_ = NULL;
- }
-}
-
-void InternalWebIntentsDispatcher::SendReply(
- const webkit_glue::WebIntentReply& reply) {
- intent_injector_ = NULL;
-
- for (size_t i = 0; i < reply_notifiers_.size(); ++i) {
- if (!reply_notifiers_[i].is_null())
- reply_notifiers_[i].Run(reply.type);
- }
-
- // Notify the callback of the reply.
- if (!reply_callback_.is_null())
- reply_callback_.Run(reply);
-
- delete this;
-}
-
-void InternalWebIntentsDispatcher::RegisterReplyNotification(
- const WebIntentsDispatcher::ReplyNotification& closure) {
- reply_notifiers_.push_back(closure);
-}
-
-} // namespace content
diff --git a/content/browser/intents/internal_web_intents_dispatcher.h b/content/browser/intents/internal_web_intents_dispatcher.h
deleted file mode 100644
index f8a6f90..0000000
--- a/content/browser/intents/internal_web_intents_dispatcher.h
+++ /dev/null
@@ -1,74 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CONTENT_BROWSER_INTENTS_INTERNAL_WEB_INTENTS_DISPATCHER_H_
-#define CONTENT_BROWSER_INTENTS_INTERNAL_WEB_INTENTS_DISPATCHER_H_
-
-#include <vector>
-
-#include "base/callback.h"
-#include "base/compiler_specific.h"
-#include "base/gtest_prod_util.h"
-#include "content/public/browser/web_intents_dispatcher.h"
-#include "webkit/glue/web_intent_data.h"
-
-namespace content {
-class IntentInjector;
-
-// This class implements a web intents dispatcher which originates
-// within the browser process rather than with a particular renderer.
-// The implementation handles replies to the web intents invocation by
-// notifying a registered callback rather than returning
-// those messages to any renderer.
-class CONTENT_EXPORT InternalWebIntentsDispatcher
- : public WebIntentsDispatcher {
- public:
- // This callback will be called during, and receives the same args as,
- // |SendReplyMessage|.
- typedef base::Callback<void(const webkit_glue::WebIntentReply&)>
- ReplyCallback;
-
- // |intent| is the intent payload to be dispatched.
- explicit InternalWebIntentsDispatcher(
- const webkit_glue::WebIntentData& intent);
-
- // |intent| is the intent payload to be dispatched.
- // |reply_callback| is the callback to notify when the intent is replied to.
- InternalWebIntentsDispatcher(
- const webkit_glue::WebIntentData& intent,
- const ReplyCallback& reply_callback);
-
- virtual ~InternalWebIntentsDispatcher();
-
- // WebIntentsDispatcher implementation.
- virtual const webkit_glue::WebIntentData& GetIntent() OVERRIDE;
- virtual void DispatchIntent(WebContents* destination_contents) OVERRIDE;
- virtual void ResetDispatch() OVERRIDE;
- virtual void SendReply(const webkit_glue::WebIntentReply& reply) OVERRIDE;
- virtual void RegisterReplyNotification(
- const WebIntentsDispatcher::ReplyNotification& closure) OVERRIDE;
-
- private:
- FRIEND_TEST_ALL_PREFIXES(InternalWebIntentsDispatcherTest,
- CancelAbandonsInjector);
- // The intent data to be delivered.
- webkit_glue::WebIntentData intent_;
-
- // Weak pointer to the internal object which delivers the intent to the
- // newly-created service WebContents. This object is self-deleting
- // (connected to the service WebContents).
- IntentInjector* intent_injector_;
-
- // Callbacks to be notified when SendReplyMessage is called.
- std::vector<WebIntentsDispatcher::ReplyNotification> reply_notifiers_;
-
- // Callback to be invoked when the intent is replied to.
- ReplyCallback reply_callback_;
-
- DISALLOW_COPY_AND_ASSIGN(InternalWebIntentsDispatcher);
-};
-
-} // namespace content
-
-#endif // CONTENT_BROWSER_INTENTS_INTERNAL_WEB_INTENTS_DISPATCHER_H_
diff --git a/content/browser/intents/internal_web_intents_dispatcher_unittest.cc b/content/browser/intents/internal_web_intents_dispatcher_unittest.cc
deleted file mode 100644
index 134903f..0000000
--- a/content/browser/intents/internal_web_intents_dispatcher_unittest.cc
+++ /dev/null
@@ -1,76 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "base/bind.h"
-#include "base/memory/scoped_ptr.h"
-#include "base/utf_string_conversions.h"
-#include "content/browser/intents/intent_injector.h"
-#include "content/browser/intents/internal_web_intents_dispatcher.h"
-#include "content/browser/renderer_host/test_render_view_host.h"
-#include "content/browser/web_contents/test_web_contents.h"
-#include "webkit/glue/web_intent_data.h"
-#include "webkit/glue/web_intent_reply_data.h"
-
-namespace content {
-
-class InternalWebIntentsDispatcherTest : public RenderViewHostTestHarness {
- public:
- InternalWebIntentsDispatcherTest() : reply_count_(0) {
- }
-
- ~InternalWebIntentsDispatcherTest() {}
-
- void NotifyReply(const webkit_glue::WebIntentReply& reply) {
- reply_.reset(new webkit_glue::WebIntentReply(reply));
- }
-
- void ReplySent(webkit_glue::WebIntentReplyType reply_type) {
- reply_count_++;
- }
-
- int reply_count_;
- scoped_ptr<const webkit_glue::WebIntentReply> reply_;
-};
-
-// Tests that the internal dispatcher correctly notifies
-// its callbacks of any reply messages.
-TEST_F(InternalWebIntentsDispatcherTest, NotifiesOnReply) {
- webkit_glue::WebIntentData intent(ASCIIToUTF16("action"),
- ASCIIToUTF16("type"),
- ASCIIToUTF16("unserialized_data"));
- InternalWebIntentsDispatcher* dispatcher = new InternalWebIntentsDispatcher(
- intent, base::Bind(&InternalWebIntentsDispatcherTest::NotifyReply,
- base::Unretained(this)));
- dispatcher->RegisterReplyNotification(
- base::Bind(&InternalWebIntentsDispatcherTest::ReplySent,
- base::Unretained(this)));
-
- dispatcher->DispatchIntent(web_contents());
-
- webkit_glue::WebIntentReply reply(
- webkit_glue::WEB_INTENT_REPLY_SUCCESS, ASCIIToUTF16("success"));
- dispatcher->SendReply(reply);
-
- ASSERT_TRUE(1 == reply_count_);
- ASSERT_TRUE(reply_);
- EXPECT_EQ(*reply_.get(), reply);
-}
-
-TEST_F(InternalWebIntentsDispatcherTest, CancelAbandonsInjector) {
- webkit_glue::WebIntentData intent(ASCIIToUTF16("action"),
- ASCIIToUTF16("type"),
- ASCIIToUTF16("unserialized_data"));
- InternalWebIntentsDispatcher* dispatcher = new InternalWebIntentsDispatcher(
- intent, base::Bind(&InternalWebIntentsDispatcherTest::NotifyReply,
- base::Unretained(this)));
- dispatcher->DispatchIntent(web_contents());
- EXPECT_FALSE(dispatcher->intent_injector_ == NULL);
- dispatcher->ResetDispatch();
- EXPECT_TRUE(dispatcher->intent_injector_ == NULL);
-
- dispatcher->SendReply(webkit_glue::WebIntentReply(
- webkit_glue::WEB_INTENT_REPLY_SUCCESS, ASCIIToUTF16("success")));
-}
-
-} // namespace content
diff --git a/content/browser/intents/web_intents_dispatcher_impl.cc b/content/browser/intents/web_intents_dispatcher_impl.cc
deleted file mode 100644
index a649673..0000000
--- a/content/browser/intents/web_intents_dispatcher_impl.cc
+++ /dev/null
@@ -1,90 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "content/browser/intents/web_intents_dispatcher_impl.h"
-
-#include "content/browser/intents/intent_injector.h"
-#include "content/browser/intents/internal_web_intents_dispatcher.h"
-#include "content/browser/web_contents/web_contents_impl.h"
-#include "content/common/intents_messages.h"
-#include "webkit/glue/web_intent_data.h"
-#include "webkit/glue/web_intent_reply_data.h"
-
-namespace content {
-
-WebIntentsDispatcher* WebIntentsDispatcher::Create(
- const webkit_glue::WebIntentData& data) {
- return new InternalWebIntentsDispatcher(data);
-}
-
-WebIntentsDispatcherImpl::WebIntentsDispatcherImpl(
- WebContents* source_contents,
- const webkit_glue::WebIntentData& intent,
- int intent_id)
- : WebContentsObserver(source_contents),
- intent_(intent),
- intent_id_(intent_id),
- intent_injector_(NULL) {
- // Ensure that WebIntentData sent from a renderer process
- // carries the right payload type and no extraneous data.
- intent_.blob_file = base::FilePath();
- intent_.blob_length = 0;
- intent_.root_name = "";
- intent_.filesystem_id = "";
- intent_.data_type = webkit_glue::WebIntentData::SERIALIZED;
-}
-
-WebIntentsDispatcherImpl::~WebIntentsDispatcherImpl() {}
-
-const webkit_glue::WebIntentData& WebIntentsDispatcherImpl::GetIntent() {
- return intent_;
-}
-
-void WebIntentsDispatcherImpl::DispatchIntent(
- WebContents* destination_contents) {
- DCHECK(!intent_injector_);
- intent_injector_ = new IntentInjector(destination_contents);
- intent_injector_->SetIntent(this, intent_);
-}
-
-void WebIntentsDispatcherImpl::ResetDispatch() {
- if (intent_injector_) {
- intent_injector_->Abandon();
- intent_injector_ = NULL;
- }
-}
-
-void WebIntentsDispatcherImpl::SendReply(
- const webkit_glue::WebIntentReply& reply) {
- intent_injector_ = NULL;
-
- // If this intent is attached to a WebContents, we dispatch the request back
- // to the renderer. Browser process initiated intents are not
- // associated with a WebContents.
- if (web_contents()) {
- Send(new IntentsMsg_WebIntentReply(
- routing_id(), reply, intent_id_));
- }
-
- for (size_t i = 0; i < reply_notifiers_.size(); ++i) {
- if (!reply_notifiers_[i].is_null())
- reply_notifiers_[i].Run(reply.type);
- }
-
- delete this;
-}
-
-void WebIntentsDispatcherImpl::RegisterReplyNotification(
- const WebIntentsDispatcher::ReplyNotification& closure) {
- reply_notifiers_.push_back(closure);
-}
-
-void WebIntentsDispatcherImpl::WebContentsDestroyed(WebContents* contents) {
- if (intent_injector_)
- intent_injector_->SourceWebContentsDestroyed(contents);
-
- intent_injector_ = NULL;
-}
-
-} // namespace content
diff --git a/content/browser/intents/web_intents_dispatcher_impl.h b/content/browser/intents/web_intents_dispatcher_impl.h
deleted file mode 100644
index df8ddc1..0000000
--- a/content/browser/intents/web_intents_dispatcher_impl.h
+++ /dev/null
@@ -1,65 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CONTENT_BROWSER_INTENTS_WEB_INTENTS_DISPATCHER_IMPL_H_
-#define CONTENT_BROWSER_INTENTS_WEB_INTENTS_DISPATCHER_IMPL_H_
-
-#include <vector>
-#include "base/callback.h"
-#include "base/compiler_specific.h"
-#include "content/public/browser/web_contents_observer.h"
-#include "content/public/browser/web_intents_dispatcher.h"
-#include "webkit/glue/web_intent_data.h"
-#include "webkit/glue/web_intent_reply_data.h"
-
-namespace content {
-class IntentInjector;
-
-// Implements the coordinator object interface for Web Intents.
-// Observes the source (client) contents to make sure messages sent back by the
-// service can be delivered. Keeps a copy of triggering intent data to
-// be delivered to the service and serves as a forwarder for sending reply
-// messages back to the client page.
-class WebIntentsDispatcherImpl : public WebIntentsDispatcher,
- public WebContentsObserver {
- public:
- // |source_contents| is the page which triggered the web intent.
- // |intent| is the intent payload created by that page.
- // |intent_id| is the identifier assigned by WebKit to direct replies back to
- // the correct Javascript callback.
- WebIntentsDispatcherImpl(WebContents* source_contents,
- const webkit_glue::WebIntentData& intent,
- int intent_id);
- virtual ~WebIntentsDispatcherImpl();
-
- // WebIntentsDispatcher implementation.
- virtual const webkit_glue::WebIntentData& GetIntent() OVERRIDE;
- virtual void DispatchIntent(WebContents* destination_contents) OVERRIDE;
- virtual void ResetDispatch() OVERRIDE;
- virtual void SendReply(const webkit_glue::WebIntentReply& reply) OVERRIDE;
- virtual void RegisterReplyNotification(
- const WebIntentsDispatcher::ReplyNotification& closure) OVERRIDE;
-
- // WebContentsObserver implementation.
- virtual void WebContentsDestroyed(WebContents* contents) OVERRIDE;
-
- private:
- webkit_glue::WebIntentData intent_;
-
- int intent_id_;
-
- // Weak pointer to the internal object which provides the intent to the
- // newly-created service WebContents. This object is self-deleting
- // (connected to the service WebContents).
- IntentInjector* intent_injector_;
-
- // Callbacks to be notified when SendReplyMessage is called.
- std::vector<WebIntentsDispatcher::ReplyNotification> reply_notifiers_;
-
- DISALLOW_COPY_AND_ASSIGN(WebIntentsDispatcherImpl);
-};
-
-} // namespace content
-
-#endif // CONTENT_BROWSER_INTENTS_WEB_INTENTS_DISPATCHER_IMPL_H_
diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc
index f8b462c..c909b1b 100644
--- a/content/browser/web_contents/web_contents_impl.cc
+++ b/content/browser/web_contents/web_contents_impl.cc
@@ -28,7 +28,6 @@
#include "content/browser/gpu/gpu_data_manager_impl.h"
#include "content/browser/gpu/gpu_process_host.h"
#include "content/browser/host_zoom_map_impl.h"
-#include "content/browser/intents/web_intents_dispatcher_impl.h"
#include "content/browser/loader/resource_dispatcher_host_impl.h"
#include "content/browser/renderer_host/render_process_host_impl.h"
#include "content/browser/renderer_host/render_view_host_impl.h"
@@ -42,7 +41,6 @@
#include "content/browser/webui/web_ui_impl.h"
#include "content/common/browser_plugin_messages.h"
#include "content/common/icon_messages.h"
-#include "content/common/intents_messages.h"
#include "content/common/ssl_status_serialization.h"
#include "content/common/view_messages.h"
#include "content/port/browser/render_view_host_delegate_view.h"
@@ -83,8 +81,6 @@
#include "ui/gfx/display.h"
#include "ui/gfx/screen.h"
#include "ui/gl/gl_switches.h"
-#include "webkit/glue/web_intent_data.h"
-#include "webkit/glue/web_intent_service_data.h"
#include "webkit/glue/webpreferences.h"
#if defined(OS_ANDROID)
@@ -716,12 +712,6 @@ bool WebContentsImpl::OnMessageReceived(RenderViewHost* render_view_host,
bool handled = true;
bool message_is_ok = true;
IPC_BEGIN_MESSAGE_MAP_EX(WebContentsImpl, message, message_is_ok)
-#if defined(ENABLE_WEB_INTENTS)
- IPC_MESSAGE_HANDLER(IntentsHostMsg_RegisterIntentService,
- OnRegisterIntentService)
- IPC_MESSAGE_HANDLER(IntentsHostMsg_WebIntentDispatch,
- OnWebIntentDispatch)
-#endif
IPC_MESSAGE_HANDLER(ViewHostMsg_DidLoadResourceFromMemoryCache,
OnDidLoadResourceFromMemoryCache)
IPC_MESSAGE_HANDLER(ViewHostMsg_DidDisplayInsecureContent,
@@ -2069,26 +2059,6 @@ void WebContentsImpl::SetFocusToLocationBar(bool select_all) {
delegate_->SetFocusToLocationBar(select_all);
}
-#if defined(ENABLE_WEB_INTENTS)
-void WebContentsImpl::OnRegisterIntentService(
- const webkit_glue::WebIntentServiceData& data,
- bool user_gesture) {
- if (delegate_)
- delegate_->RegisterIntentHandler(this, data, user_gesture);
-}
-
-void WebContentsImpl::OnWebIntentDispatch(
- const webkit_glue::WebIntentData& intent,
- int intent_id) {
- if (!delegate_)
- return;
-
- WebIntentsDispatcherImpl* intents_dispatcher =
- new WebIntentsDispatcherImpl(this, intent, intent_id);
- delegate_->WebIntentDispatch(this, intents_dispatcher);
-}
-#endif
-
void WebContentsImpl::DidStartProvisionalLoadForFrame(
RenderViewHost* render_view_host,
int64 frame_id,
diff --git a/content/browser/web_contents/web_contents_impl.h b/content/browser/web_contents/web_contents_impl.h
index 6101ff2..fc3bfa4 100644
--- a/content/browser/web_contents/web_contents_impl.h
+++ b/content/browser/web_contents/web_contents_impl.h
@@ -34,11 +34,6 @@ struct BrowserPluginHostMsg_ResizeGuest_Params;
struct ViewHostMsg_DateTimeDialogValue_Params;
struct ViewMsg_PostMessage_Params;
-namespace webkit_glue {
-struct WebIntentData;
-struct WebIntentServiceData;
-}
-
namespace content {
class BrowserPluginEmbedder;
class BrowserPluginGuest;
@@ -520,12 +515,6 @@ class CONTENT_EXPORT WebContentsImpl
void OnPpapiBrokerPermissionResult(int request_id, bool result);
// IPC message handlers.
-#if defined(ENABLE_WEB_INTENTS)
- void OnRegisterIntentService(const webkit_glue::WebIntentServiceData& data,
- bool user_gesture);
- void OnWebIntentDispatch(const webkit_glue::WebIntentData& intent,
- int intent_id);
-#endif
void OnDidLoadResourceFromMemoryCache(const GURL& url,
const std::string& security_info,
const std::string& http_request,
diff --git a/content/common/content_message_generator.h b/content/common/content_message_generator.h
index aa400f1..6c06926 100644
--- a/content/common/content_message_generator.h
+++ b/content/common/content_message_generator.h
@@ -28,7 +28,6 @@
#include "content/common/hyphenator_messages.h"
#include "content/common/icon_messages.h"
#include "content/common/indexed_db/indexed_db_messages.h"
-#include "content/common/intents_messages.h"
#include "content/common/java_bridge_messages.h"
#include "content/common/media/audio_messages.h"
#include "content/common/media/media_player_messages.h"
diff --git a/content/common/intents_messages.h b/content/common/intents_messages.h
deleted file mode 100644
index 3db6a92..0000000
--- a/content/common/intents_messages.h
+++ /dev/null
@@ -1,81 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Message definition file, included multiple times, hence no include guard.
-
-#include "content/common/content_export.h"
-#include "ipc/ipc_message_macros.h"
-#include "ipc/ipc_message_utils.h"
-#include "ipc/param_traits_macros.h"
-#include "webkit/glue/web_intent_data.h"
-#include "webkit/glue/web_intent_reply_data.h"
-#include "webkit/glue/web_intent_service_data.h"
-
-#undef IPC_MESSAGE_EXPORT
-#define IPC_MESSAGE_EXPORT CONTENT_EXPORT
-#define IPC_MESSAGE_START IntentsMsgStart
-
-IPC_ENUM_TRAITS(webkit_glue::WebIntentReplyType)
-IPC_ENUM_TRAITS(webkit_glue::WebIntentData::DataType)
-IPC_ENUM_TRAITS(webkit_glue::WebIntentServiceData::Disposition)
-
-#if defined(ENABLE_WEB_INTENTS)
-
-IPC_STRUCT_TRAITS_BEGIN(webkit_glue::WebIntentData)
- IPC_STRUCT_TRAITS_MEMBER(action)
- IPC_STRUCT_TRAITS_MEMBER(type)
- IPC_STRUCT_TRAITS_MEMBER(data)
- IPC_STRUCT_TRAITS_MEMBER(extra_data)
- IPC_STRUCT_TRAITS_MEMBER(service)
- IPC_STRUCT_TRAITS_MEMBER(suggestions)
- IPC_STRUCT_TRAITS_MEMBER(unserialized_data)
- IPC_STRUCT_TRAITS_MEMBER(message_port_ids)
- IPC_STRUCT_TRAITS_MEMBER(blob_file)
- IPC_STRUCT_TRAITS_MEMBER(blob_length)
- IPC_STRUCT_TRAITS_MEMBER(mime_data)
- IPC_STRUCT_TRAITS_MEMBER(root_name)
- IPC_STRUCT_TRAITS_MEMBER(filesystem_id)
- IPC_STRUCT_TRAITS_MEMBER(data_type)
-IPC_STRUCT_TRAITS_END()
-
-IPC_STRUCT_TRAITS_BEGIN(webkit_glue::WebIntentReply)
- IPC_STRUCT_TRAITS_MEMBER(type)
- IPC_STRUCT_TRAITS_MEMBER(data)
- IPC_STRUCT_TRAITS_MEMBER(data_file)
- IPC_STRUCT_TRAITS_MEMBER(data_file_size)
- IPC_STRUCT_TRAITS_END()
-
-IPC_STRUCT_TRAITS_BEGIN(webkit_glue::WebIntentServiceData)
- IPC_STRUCT_TRAITS_MEMBER(action)
- IPC_STRUCT_TRAITS_MEMBER(type)
- IPC_STRUCT_TRAITS_MEMBER(scheme)
- IPC_STRUCT_TRAITS_MEMBER(service_url)
- IPC_STRUCT_TRAITS_MEMBER(title)
- IPC_STRUCT_TRAITS_MEMBER(disposition)
-IPC_STRUCT_TRAITS_END()
-
-// Set the intent data to be set on the service page.
-IPC_MESSAGE_ROUTED1(IntentsMsg_SetWebIntentData,
- webkit_glue::WebIntentData)
-
-// Send the service's reply to the client page.
-IPC_MESSAGE_ROUTED2(IntentsMsg_WebIntentReply,
- webkit_glue::WebIntentReply, /* reply */
- int /* intent ID */)
-
-// Notify the container that the service has replied to the client page.
-IPC_MESSAGE_ROUTED1(IntentsHostMsg_WebIntentReply,
- webkit_glue::WebIntentReply /* reply */)
-
-// Route the startActivity Intents call from a page to the service picker.
-IPC_MESSAGE_ROUTED2(IntentsHostMsg_WebIntentDispatch,
- webkit_glue::WebIntentData,
- int /* intent ID */)
-
-// Register a new service for Intents with the given action and type filter.
-IPC_MESSAGE_ROUTED2(IntentsHostMsg_RegisterIntentService,
- webkit_glue::WebIntentServiceData,
- bool /* user_gesture */)
-
-#endif
diff --git a/content/content_browser.gypi b/content/content_browser.gypi
index e286757..ef40eab 100644
--- a/content/content_browser.gypi
+++ b/content/content_browser.gypi
@@ -165,7 +165,6 @@
'public/browser/web_contents_view.h',
'public/browser/web_contents_view_delegate.h',
'public/browser/web_drag_dest_delegate.h',
- 'public/browser/web_intents_dispatcher.h',
'public/browser/web_ui.h',
'public/browser/web_ui_controller.cc',
'public/browser/web_ui_controller.h',
@@ -501,12 +500,6 @@
'browser/in_process_webkit/indexed_db_quota_client.h',
'browser/in_process_webkit/webkit_thread.cc',
'browser/in_process_webkit/webkit_thread.h',
- 'browser/intents/intent_injector.cc',
- 'browser/intents/intent_injector.h',
- 'browser/intents/internal_web_intents_dispatcher.cc',
- 'browser/intents/internal_web_intents_dispatcher.h',
- 'browser/intents/web_intents_dispatcher_impl.cc',
- 'browser/intents/web_intents_dispatcher_impl.h',
'browser/loader/async_resource_handler.cc',
'browser/loader/async_resource_handler.h',
'browser/loader/buffered_resource_handler.cc',
@@ -1023,11 +1016,6 @@
'browser/renderer_host/p2p/socket_dispatcher_host.h',
],
}],
- ['enable_web_intents==0', {
- 'sources/': [
- ['exclude', '^browser/intents/' ],
- ],
- }],
['OS=="win"', {
'dependencies': [
# For accessibility
diff --git a/content/content_common.gypi b/content/content_common.gypi
index c435005..fbec6c2 100644
--- a/content/content_common.gypi
+++ b/content/content_common.gypi
@@ -284,7 +284,6 @@
'common/indexed_db/proxy_webidbfactory_impl.h',
'common/inter_process_time_ticks_converter.cc',
'common/inter_process_time_ticks_converter.h',
- 'common/intents_messages.h',
'common/java_bridge_messages.h',
'common/mac/attributed_string_coder.h',
'common/mac/attributed_string_coder.mm',
diff --git a/content/content_renderer.gypi b/content/content_renderer.gypi
index 453eecde..6de842b 100644
--- a/content/content_renderer.gypi
+++ b/content/content_renderer.gypi
@@ -282,8 +282,6 @@
'renderer/text_input_client_observer.h',
'renderer/v8_value_converter_impl.cc',
'renderer/v8_value_converter_impl.h',
- 'renderer/web_intents_host.cc',
- 'renderer/web_intents_host.h',
'renderer/web_ui_extension.cc',
'renderer/web_ui_extension.h',
'renderer/web_ui_extension_data.cc',
@@ -330,12 +328,6 @@
'../third_party/libphonenumber/libphonenumber.gyp:libphonenumber',
],
}],
- ['enable_web_intents==0', {
- 'sources!': [
- 'renderer/web_intents_host.cc',
- 'renderer/web_intents_host.h',
- ],
- }],
# TODO(jrg): remove the OS=="android" section?
# http://crbug.com/113172
# Understand better how media_stream_ is tied into Chromium.
diff --git a/content/content_tests.gypi b/content/content_tests.gypi
index 0f4434b..b0cecdc 100644
--- a/content/content_tests.gypi
+++ b/content/content_tests.gypi
@@ -294,8 +294,6 @@
'browser/in_process_webkit/indexed_db_quota_client_unittest.cc',
'browser/in_process_webkit/indexed_db_unittest.cc',
'browser/in_process_webkit/webkit_thread_unittest.cc',
- 'browser/intents/intent_injector_unittest.cc',
- 'browser/intents/internal_web_intents_dispatcher_unittest.cc',
'browser/loader/resource_buffer_unittest.cc',
'browser/loader/resource_dispatcher_host_unittest.cc',
'browser/loader/resource_loader_unittest.cc',
@@ -567,12 +565,6 @@
'../third_party/webrtc/voice_engine/voice_engine.gyp:voice_engine_core',
]
}],
- ['enable_web_intents==0', {
- 'sources!': [
- 'browser/intents/intent_injector_unittest.cc',
- 'browser/intents/internal_web_intents_dispatcher_unittest.cc',
- ],
- }],
# TODO(jrg): remove the OS=="android" section?
# http://crbug.com/113172
# Understand better how media_stream_ is tied into Chromium.
@@ -760,7 +752,6 @@
'renderer/render_view_browsertest.cc',
'renderer/render_view_browsertest_mac.mm',
'renderer/render_widget_browsertest.cc',
- 'renderer/web_intents_host_browsertest.cc',
'test/browser_test_message_pump_android.cc',
'test/browser_test_message_pump_android.h',
'test/content_browser_test.h',
@@ -875,11 +866,6 @@
'browser/media/webrtc_browsertest.cc',
],
}],
- ['enable_web_intents==0', {
- 'sources!': [
- 'renderer/web_intents_host_browsertest.cc',
- ],
- }],
['enable_plugins==0', {
'sources!': [
'browser/plugin_service_impl_browsertest.cc',
diff --git a/content/public/browser/web_contents_delegate.cc b/content/public/browser/web_contents_delegate.cc
index a34e35a..d236634 100644
--- a/content/public/browser/web_contents_delegate.cc
+++ b/content/public/browser/web_contents_delegate.cc
@@ -9,11 +9,9 @@
#include "base/memory/singleton.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/web_contents.h"
-#include "content/public/browser/web_intents_dispatcher.h"
#include "content/public/common/url_constants.h"
#include "content/public/common/bindings_policy.h"
#include "ui/gfx/rect.h"
-#include "webkit/glue/web_intent_data.h"
namespace content {
@@ -141,14 +139,6 @@ content::ColorChooser* WebContentsDelegate::OpenColorChooser(
return NULL;
}
-void WebContentsDelegate::WebIntentDispatch(
- WebContents* web_contents,
- WebIntentsDispatcher* intents_dispatcher) {
- // The caller passes this method ownership of the |intents_dispatcher|, but
- // this empty implementation will not use it, so we delete it immediately.
- delete intents_dispatcher;
-}
-
bool WebContentsDelegate::RequestPpapiBrokerPermission(
WebContents* web_contents,
const GURL& url,
diff --git a/content/public/browser/web_contents_delegate.h b/content/public/browser/web_contents_delegate.h
index 93433d9..77c3bae 100644
--- a/content/public/browser/web_contents_delegate.h
+++ b/content/public/browser/web_contents_delegate.h
@@ -36,7 +36,6 @@ class JavaScriptDialogManager;
class RenderViewHost;
class WebContents;
class WebContentsImpl;
-class WebIntentsDispatcher;
struct ContextMenuParams;
struct FileChooserParams;
struct NativeWebKeyboardEvent;
@@ -49,11 +48,6 @@ class Rect;
class Size;
}
-namespace webkit_glue {
-struct WebIntentData;
-struct WebIntentServiceData;
-}
-
namespace WebKit {
class WebLayer;
}
@@ -360,20 +354,6 @@ class CONTENT_EXPORT WebContentsDelegate {
const string16& title,
bool user_gesture) {}
- // Register a new Web Intents service.
- // |user_gesture| is true if the registration is made in the context of a user
- // gesture. |web_contents| is the context in which the registration was
- // performed, and |data| is the service record being registered.
- virtual void RegisterIntentHandler(
- WebContents* web_contents,
- const webkit_glue::WebIntentServiceData& data,
- bool user_gesture) {}
-
- // Web Intents notification handler. See WebIntentsDispatcher for
- // documentation of callee responsibility for the dispatcher.
- virtual void WebIntentDispatch(WebContents* web_contents,
- WebIntentsDispatcher* intents_dispatcher);
-
// Result of string search in the page. This includes the number of matches
// found and the selection rect (in screen coordinates) for the string found.
// If |final_update| is false, it indicates that more results follow.
diff --git a/content/public/browser/web_intents_dispatcher.h b/content/public/browser/web_intents_dispatcher.h
deleted file mode 100644
index 922495d..0000000
--- a/content/public/browser/web_intents_dispatcher.h
+++ /dev/null
@@ -1,73 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CONTENT_PUBLIC_BROWSER_WEB_INTENTS_DISPATCHER_H_
-#define CONTENT_PUBLIC_BROWSER_WEB_INTENTS_DISPATCHER_H_
-
-#include "base/callback.h"
-#include "content/common/content_export.h"
-#include "webkit/glue/web_intent_reply_data.h"
-
-namespace webkit_glue {
-enum WebIntentReplyType;
-struct WebIntentData;
-struct WebIntentReply;
-}
-
-namespace content {
-
-class WebContents;
-class WebContentsDelegate;
-
-// This class is the coordinator for dispatching web intents and seeing that
-// return messages are sent to the correct invoking context. The WebContents
-// for the invoking context will create one of these for each intent and hand
-// a pointer to the client WebContentsDelegate code. The WebContentsDelegate
-// code can then read the intent data, create UI to pick the service, and
-// create a new context for that service.
-//
-// At that point, it should call DispatchIntent, which will deliver the intent
-// to the new context. If anything goes wrong during setup, the client
-// should call SendReplyMessage with an error. The dispatcher lives until the
-// SendReplyMessage method is called, which will self-delete the object.
-//
-// The client should also register a reply notification, so it can avoid
-// referencing the dispatcher after other code calls SendReplyMessage, which can
-// happen if, for example, the user closes the delivery context.
-class CONTENT_EXPORT WebIntentsDispatcher {
- public:
- // This callback type is registered for notification of |SendReplyMessage|.
- typedef base::Callback<void(webkit_glue::WebIntentReplyType)>
- ReplyNotification;
-
- // Create internal (browser-triggered) intent. This will create
- // a new dispatcher with the passed intent payload |data|. The caller should
- // manage dispatching it correctly.
- static WebIntentsDispatcher* Create(const webkit_glue::WebIntentData& data);
-
- virtual ~WebIntentsDispatcher() {}
-
- // Get the intent data being dispatched.
- virtual const webkit_glue::WebIntentData& GetIntent() = 0;
-
- // Attach the intent to a new context in which the service page is loaded.
- // |web_contents| must not be NULL.
- virtual void DispatchIntent(WebContents* web_contents) = 0;
-
- // Abandon current attempt to dispatch, allow new call to DispatchIntent.
- virtual void ResetDispatch() = 0;
-
- // Return a reply to the source context which invoked the intent.
- // Calls the reply notifications, if any are registered.
- // Deletes |this| object after handling is complete.
- virtual void SendReply(const webkit_glue::WebIntentReply& reply) = 0;
-
- // Register a callback to be notified when SendReplyMessage is called.
- // Multiple callbacks may be registered.
- virtual void RegisterReplyNotification(const ReplyNotification& closure) = 0;
-};
-
-} // namespace content
-
-#endif // CONTENT_PUBLIC_BROWSER_WEB_INTENTS_DISPATCHER_H_
diff --git a/content/renderer/render_view_browsertest.cc b/content/renderer/render_view_browsertest.cc
index b477ed7..6e39cc0 100644
--- a/content/renderer/render_view_browsertest.cc
+++ b/content/renderer/render_view_browsertest.cc
@@ -7,7 +7,6 @@
#include "base/shared_memory.h"
#include "base/string_util.h"
#include "base/utf_string_conversions.h"
-#include "content/common/intents_messages.h"
#include "content/common/view_messages.h"
#include "content/public/browser/native_web_keyboard_event.h"
#include "content/public/browser/web_ui_controller_factory.h"
@@ -25,7 +24,6 @@
#include "third_party/WebKit/Source/Platform/chromium/public/WebString.h"
#include "third_party/WebKit/Source/Platform/chromium/public/WebURLError.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebHistoryItem.h"
-#include "third_party/WebKit/Source/WebKit/chromium/public/WebIntentServiceInfo.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebWindowFeatures.h"
#include "ui/base/keycodes/keyboard_codes.h"
@@ -1583,32 +1581,6 @@ TEST_F(RenderViewImplTest, SetHistoryLengthAndPrune) {
EXPECT_EQ(expected_page_id_2, view()->history_page_ids_[3]);
}
-#if defined(ENABLE_WEB_INTENTS)
-TEST_F(RenderViewImplTest, FindTitleForIntentsPage) {
- view()->set_send_content_state_immediately(true);
- LoadHTML("<html><head><title>title</title>"
- "<intent action=\"a\" type=\"t\"></intent></head></html>");
- WebKit::WebIntentServiceInfo service;
- service.setAction(ASCIIToUTF16("a"));
- service.setType(ASCIIToUTF16("t"));
- view()->registerIntentService(GetMainFrame(), service);
- ProcessPendingMessages();
-
- EXPECT_TRUE(render_thread_->sink().GetUniqueMessageMatching(
- IntentsHostMsg_RegisterIntentService::ID));
- const IPC::Message* msg = render_thread_->sink().GetUniqueMessageMatching(
- IntentsHostMsg_RegisterIntentService::ID);
- ASSERT_TRUE(msg);
- webkit_glue::WebIntentServiceData service_data;
- bool user_gesture = true;
- IntentsHostMsg_RegisterIntentService::Read(msg, &service_data, &user_gesture);
- EXPECT_EQ(ASCIIToUTF16("a"), service_data.action);
- EXPECT_EQ(ASCIIToUTF16("t"), service_data.type);
- EXPECT_EQ(ASCIIToUTF16("title"), service_data.title);
- EXPECT_FALSE(user_gesture);
-}
-#endif
-
TEST_F(RenderViewImplTest, ContextMenu) {
LoadHTML("<div>Page A</div>");
diff --git a/content/renderer/render_view_impl.cc b/content/renderer/render_view_impl.cc
index 5867b19..11a2f40 100644
--- a/content/renderer/render_view_impl.cc
+++ b/content/renderer/render_view_impl.cc
@@ -38,7 +38,6 @@
#include "content/common/fileapi/file_system_dispatcher.h"
#include "content/common/fileapi/webfilesystem_callback_dispatcher.h"
#include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h"
-#include "content/common/intents_messages.h"
#include "content/common/java_bridge_messages.h"
#include "content/common/pepper_messages.h"
#include "content/common/pepper_plugin_registry.h"
@@ -111,7 +110,6 @@
#include "content/renderer/speech_recognition_dispatcher.h"
#include "content/renderer/text_input_client_observer.h"
#include "content/renderer/v8_value_converter_impl.h"
-#include "content/renderer/web_intents_host.h"
#include "content/renderer/web_ui_extension.h"
#include "content/renderer/web_ui_extension_data.h"
#include "content/renderer/webplugin_delegate_proxy.h"
@@ -160,9 +158,6 @@
#include "third_party/WebKit/Source/WebKit/chromium/public/WebHistoryItem.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebInputElement.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h"
-#include "third_party/WebKit/Source/WebKit/chromium/public/WebIntent.h"
-#include "third_party/WebKit/Source/WebKit/chromium/public/WebIntentRequest.h"
-#include "third_party/WebKit/Source/WebKit/chromium/public/WebIntentServiceInfo.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebMediaPlayerAction.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebMessagePortChannel.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebNavigationPolicy.h"
@@ -200,7 +195,6 @@
#include "webkit/glue/alt_error_page_resource_fetcher.h"
#include "webkit/glue/dom_operations.h"
#include "webkit/glue/glue_serialize.h"
-#include "webkit/glue/web_intent_service_data.h"
#include "webkit/glue/webdropdata.h"
#include "webkit/glue/webkit_constants.h"
#include "webkit/glue/webkit_glue.h"
@@ -279,8 +273,6 @@ using WebKit::WebIconURL;
using WebKit::WebImage;
using WebKit::WebInputElement;
using WebKit::WebInputEvent;
-using WebKit::WebIntentRequest;
-using WebKit::WebIntentServiceInfo;
using WebKit::WebMediaPlayer;
using WebKit::WebMediaPlayerAction;
using WebKit::WebMediaPlayerClient;
@@ -763,11 +755,6 @@ RenderViewImpl::RenderViewImpl(RenderViewImplParams* params)
// along with the RenderView automatically.
devtools_agent_ = new DevToolsAgent(this);
mouse_lock_dispatcher_ = new RenderViewMouseLockDispatcher(this);
-#if defined(ENABLE_WEB_INTENTS)
- intents_host_ = new WebIntentsHost(this);
-#else
- intents_host_ = NULL;
-#endif
favicon_helper_ = new FaviconHelper(this);
// Create renderer_accessibility_ if needed.
@@ -3962,11 +3949,6 @@ void RenderViewImpl::didCreateScriptContext(WebFrame* frame,
int world_id) {
GetContentClient()->renderer()->DidCreateScriptContext(
frame, context, extension_group, world_id);
-
-#if defined(ENABLE_WEB_INTENTS)
- intents_host_->DidCreateScriptContext(
- frame, context, extension_group, world_id);
-#endif
}
void RenderViewImpl::willReleaseScriptContext(WebFrame* frame,
@@ -4338,43 +4320,6 @@ void RenderViewImpl::requestStorageQuota(
QuotaDispatcher::CreateWebStorageQuotaCallbacksWrapper(callbacks));
}
-void RenderViewImpl::registerIntentService(
- WebFrame* frame, const WebIntentServiceInfo& service) {
-#if defined(ENABLE_WEB_INTENTS)
- webkit_glue::WebIntentServiceData data(service);
- if (data.title.empty())
- data.title = webview()->mainFrame()->document().title();
- bool user_gesture = frame->isProcessingUserGesture();
- Send(new IntentsHostMsg_RegisterIntentService(routing_id_,
- data,
- user_gesture));
-#endif
-}
-
-void RenderViewImpl::dispatchIntent(
- WebFrame* frame, const WebIntentRequest& intentRequest) {
-#if defined(ENABLE_WEB_INTENTS)
- webkit_glue::WebIntentData intent_data(intentRequest.intent());
-
- // See WebMessagePortChannelImpl::postMessage() and ::OnMessagedQueued()
- WebKit::WebMessagePortChannelArray* channels =
- intentRequest.intent().messagePortChannelsRelease();
- if (channels) {
- for (size_t i = 0; i < channels->size(); ++i) {
- WebMessagePortChannelImpl* webchannel =
- static_cast<WebMessagePortChannelImpl*>((*channels)[i]);
- intent_data.message_port_ids.push_back(webchannel->message_port_id());
- DCHECK(intent_data.message_port_ids[i] != MSG_ROUTING_NONE);
- }
- delete channels;
- }
-
- int id = intents_host_->RegisterWebIntent(intentRequest);
- Send(new IntentsHostMsg_WebIntentDispatch(
- routing_id_, intent_data, id));
-#endif
-}
-
bool RenderViewImpl::willCheckAndDispatchMessageEvent(
WebKit::WebFrame* sourceFrame,
WebKit::WebFrame* targetFrame,
diff --git a/content/renderer/render_view_impl.h b/content/renderer/render_view_impl.h
index 82edc31..d288ec6 100644
--- a/content/renderer/render_view_impl.h
+++ b/content/renderer/render_view_impl.h
@@ -164,7 +164,6 @@ class RendererPpapiHost;
class RendererWebColorChooserImpl;
class RenderWidgetFullscreenPepper;
class SpeechRecognitionDispatcher;
-class WebIntentsHost;
class WebPluginDelegateProxy;
struct CustomContextMenuContext;
struct FileChooserParams;
@@ -665,11 +664,6 @@ class CONTENT_EXPORT RenderViewImpl
WebKit::WebStorageQuotaType type,
unsigned long long requested_size,
WebKit::WebStorageQuotaCallbacks* callbacks);
- virtual void registerIntentService(
- WebKit::WebFrame* frame,
- const WebKit::WebIntentServiceInfo& service);
- virtual void dispatchIntent(WebKit::WebFrame* frame,
- const WebKit::WebIntentRequest& intentRequest);
virtual void willOpenSocketStream(
WebKit::WebSocketStreamHandle* handle);
virtual void willStartUsingPeerConnectionHandler(WebKit::WebFrame* frame,
@@ -820,7 +814,6 @@ class CONTENT_EXPORT RenderViewImpl
friend class ExternalPopupMenuTest;
friend class PepperDeviceTest;
friend class RendererAccessibilityTest;
- friend class WebIntentsHostTest;
friend class RenderViewTest;
FRIEND_TEST_ALL_PREFIXES(ExternalPopupMenuRemoveTest, RemoveOnChange);
@@ -1397,9 +1390,6 @@ class CONTENT_EXPORT RenderViewImpl
// The geolocation dispatcher attached to this view, lazily initialized.
GeolocationDispatcher* geolocation_dispatcher_;
- // The intents host attached to this view. Not lazily initialized.
- WebIntentsHost* intents_host_;
-
// The speech dispatcher attached to this view, lazily initialized.
InputTagSpeechDispatcher* input_tag_speech_dispatcher_;
diff --git a/content/renderer/web_intents_host.cc b/content/renderer/web_intents_host.cc
deleted file mode 100644
index 944e9c5..0000000
--- a/content/renderer/web_intents_host.cc
+++ /dev/null
@@ -1,258 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "content/renderer/web_intents_host.h"
-
-#include "base/bind.h"
-#include "base/bind_helpers.h"
-#include "base/utf_string_conversions.h"
-#include "content/common/intents_messages.h"
-#include "content/public/renderer/v8_value_converter.h"
-#include "content/renderer/render_view_impl.h"
-#include "third_party/WebKit/Source/Platform/chromium/public/WebCString.h"
-#include "third_party/WebKit/Source/Platform/chromium/public/WebFileSystem.h"
-#include "third_party/WebKit/Source/Platform/chromium/public/WebString.h"
-#include "third_party/WebKit/Source/Platform/chromium/public/WebVector.h"
-#include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h"
-#include "third_party/WebKit/Source/WebKit/chromium/public/WebBlob.h"
-#include "third_party/WebKit/Source/WebKit/chromium/public/WebDeliveredIntentClient.h"
-#include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h"
-#include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
-#include "third_party/WebKit/Source/WebKit/chromium/public/WebIntent.h"
-#include "third_party/WebKit/Source/WebKit/chromium/public/WebIntentRequest.h"
-#include "third_party/WebKit/Source/WebKit/chromium/public/WebSerializedScriptValue.h"
-#include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h"
-#include "webkit/fileapi/file_system_util.h"
-#include "webkit/glue/cpp_bound_class.h"
-
-using WebKit::WebBindings;
-using WebKit::WebBlob;
-using WebKit::WebCString;
-using WebKit::WebDeliveredIntentClient;
-using WebKit::WebFrame;
-using WebKit::WebIntent;
-using WebKit::WebIntentRequest;
-using WebKit::WebString;
-using WebKit::WebSerializedScriptValue;
-using WebKit::WebVector;
-
-namespace content {
-
-namespace {
-
-// Reads reply value, either from the data field, or the data_file field.
-WebSerializedScriptValue GetReplyValue(
- const webkit_glue::WebIntentReply& reply) {
- if (reply.data_file_size > -1) {
- // TODO(smckay): seralize the blob value in the web intent script
- // context. We simply don't know how to do this at this time.
- // The following code kills the renderer when we call toV8Value.
- // v8::HandleScope scope;
- // v8::Local<v8::Context> ctx = ....which context?
- // v8::Context::Scope cscope(ctx);
- // WebKit::WebBlob blob = WebBlob::createFromFile(
- // WebString::fromUTF8(reply.data_file.AsUTF8Unsafe()),
- // reply.data_file_size);
- // v8::Handle<v8::Value> value = blob.toV8Value();
- // return WebSerializedScriptValue::serialize(value);
- return WebSerializedScriptValue::fromString(
- ASCIIToUTF16(reply.data_file.AsUTF8Unsafe()));
- } else {
- return WebSerializedScriptValue::fromString(reply.data);
- }
-}
-
-} // namespace
-
-class DeliveredIntentClientImpl : public WebDeliveredIntentClient {
- public:
- explicit DeliveredIntentClientImpl(WebIntentsHost* host) : host_(host) {}
- virtual ~DeliveredIntentClientImpl() {}
-
- virtual void postResult(const WebSerializedScriptValue& data) const {
- host_->OnResult(data.toString());
- }
-
- virtual void postFailure(const WebSerializedScriptValue& data) const {
- host_->OnFailure(data.toString());
- }
-
- virtual void destroy() OVERRIDE {
- }
-
- private:
- WebIntentsHost* host_;
-};
-
-WebIntentsHost::WebIntentsHost(RenderViewImpl* render_view)
- : RenderViewObserver(render_view),
- id_counter_(0) {
-}
-
-WebIntentsHost::~WebIntentsHost() {
-}
-
-int WebIntentsHost::RegisterWebIntent(
- const WebIntentRequest& request) {
- int id = id_counter_++;
- intent_requests_[id] = request;
- return id;
-}
-
-bool WebIntentsHost::OnMessageReceived(const IPC::Message& message) {
- bool handled = true;
- IPC_BEGIN_MESSAGE_MAP(WebIntentsHost, message)
- IPC_MESSAGE_HANDLER(IntentsMsg_SetWebIntentData, OnSetIntent)
- IPC_MESSAGE_HANDLER(IntentsMsg_WebIntentReply, OnWebIntentReply);
- IPC_MESSAGE_UNHANDLED(handled = false)
- IPC_END_MESSAGE_MAP()
- return handled;
-}
-
-void WebIntentsHost::OnSetIntent(const webkit_glue::WebIntentData& intent) {
- intent_.reset(new webkit_glue::WebIntentData(intent));
-}
-
-void WebIntentsHost::OnWebIntentReply(
- const webkit_glue::WebIntentReply& reply,
- int intent_id) {
- std::map<int, WebIntentRequest>::iterator request =
- intent_requests_.find(intent_id);
- if (request == intent_requests_.end())
- return;
- WebIntentRequest intent_request = request->second;
- intent_requests_.erase(request);
-
- if (reply.type == webkit_glue::WEB_INTENT_REPLY_SUCCESS) {
- intent_request.postResult(GetReplyValue(reply));
- } else {
- intent_request.postFailure(
- WebSerializedScriptValue::fromString(reply.data));
- }
-}
-
-void WebIntentsHost::OnResult(const WebKit::WebString& data) {
- const webkit_glue::WebIntentReply reply(
- webkit_glue::WEB_INTENT_REPLY_SUCCESS, data);
- Send(new IntentsHostMsg_WebIntentReply(routing_id(), reply));
-}
-
-void WebIntentsHost::OnFailure(const WebKit::WebString& data) {
- const webkit_glue::WebIntentReply reply(
- webkit_glue::WEB_INTENT_REPLY_FAILURE, data);
- Send(new IntentsHostMsg_WebIntentReply(routing_id(), reply));
-}
-
-// We set the intent payload into all top-level frame window objects. This
-// should persist the data through redirects, and not deliver it to any
-// sub-frames.
-void WebIntentsHost::DidCreateScriptContext(WebKit::WebFrame* frame,
- v8::Handle<v8::Context> ctx,
- int extension_group,
- int world_id) {
- if (intent_.get() == NULL || frame->top() != frame)
- return;
-
- if (ctx != frame->mainWorldScriptContext())
- return;
-
- if (!delivered_intent_client_.get()) {
- delivered_intent_client_.reset(new DeliveredIntentClientImpl(this));
- }
-
- WebIntent web_intent = CreateWebIntent(frame, *intent_);
-
- if (!web_intent.action().isEmpty())
- frame->deliverIntent(web_intent, NULL, delivered_intent_client_.get());
-}
-
-WebIntent WebIntentsHost::CreateWebIntent(
- WebFrame* frame, const webkit_glue::WebIntentData& intent_data) {
- // Must be called with v8 scope held.
- DCHECK(v8::Context::InContext());
-
- // TODO(gbillock): Remove this block when we get rid of |extras|.
- WebVector<WebString> extras_keys(intent_data.extra_data.size());
- WebVector<WebString> extras_values(intent_data.extra_data.size());
- std::map<string16, string16>::const_iterator iter =
- intent_data.extra_data.begin();
- for (size_t i = 0; iter != intent_data.extra_data.end(); ++i, ++iter) {
- extras_keys[i] = iter->first;
- extras_values[i] = iter->second;
- }
-
- switch (intent_data.data_type) {
- case webkit_glue::WebIntentData::SERIALIZED: {
- return WebIntent::create(intent_data.action, intent_data.type,
- intent_data.data,
- extras_keys, extras_values);
- }
-
- case webkit_glue::WebIntentData::UNSERIALIZED: {
- v8::Local<v8::String> dataV8 = v8::String::New(
- reinterpret_cast<const uint16_t*>(
- intent_data.unserialized_data.data()),
- static_cast<int>(intent_data.unserialized_data.length()));
- WebSerializedScriptValue serialized_data =
- WebSerializedScriptValue::serialize(dataV8);
-
- return WebIntent::create(intent_data.action, intent_data.type,
- serialized_data.toString(),
- extras_keys, extras_values);
- }
-
- case webkit_glue::WebIntentData::BLOB: {
- web_blob_ = WebBlob::createFromFile(
- WebString::fromUTF8(intent_data.blob_file.AsUTF8Unsafe()),
- intent_data.blob_length);
- WebSerializedScriptValue serialized_data =
- WebSerializedScriptValue::serialize(web_blob_.toV8Value());
- return WebIntent::create(intent_data.action, intent_data.type,
- serialized_data.toString(),
- extras_keys, extras_values);
- }
-
- case webkit_glue::WebIntentData::FILESYSTEM: {
- const GURL origin = GURL(frame->document().securityOrigin().toString());
- const GURL root_url =
- fileapi::GetFileSystemRootURI(origin,
- fileapi::kFileSystemTypeIsolated);
- const std::string url = base::StringPrintf(
- "%s%s/%s/",
- root_url.spec().c_str(),
- intent_data.filesystem_id.c_str(),
- intent_data.root_name.c_str());
- // TODO(kmadhusu): This is a temporary hack to create a serializable file
- // system. Once we have a better way to create a serializable file system,
- // remove this hack.
- v8::Handle<v8::Value> filesystem_V8 = frame->createSerializableFileSystem(
- WebKit::WebFileSystem::TypeIsolated,
- WebKit::WebString::fromUTF8(intent_data.root_name),
- WebKit::WebString::fromUTF8(url));
- WebSerializedScriptValue serialized_data =
- WebSerializedScriptValue::serialize(filesystem_V8);
- return WebIntent::create(intent_data.action, intent_data.type,
- serialized_data.toString(),
- extras_keys, extras_values);
- }
-
- case webkit_glue::WebIntentData::MIME_TYPE: {
- scoped_ptr<V8ValueConverter> converter(
- V8ValueConverter::create());
- v8::Handle<v8::Value> valV8 = converter->ToV8Value(
- &intent_data.mime_data, v8::Context::GetCurrent());
-
- WebSerializedScriptValue serialized_data =
- WebSerializedScriptValue::serialize(valV8);
- return WebIntent::create(intent_data.action, intent_data.type,
- serialized_data.toString(),
- WebVector<WebString>(), WebVector<WebString>());
- }
- }
-
- NOTREACHED();
- return WebIntent();
-}
-
-} // namespace content
diff --git a/content/renderer/web_intents_host.h b/content/renderer/web_intents_host.h
deleted file mode 100644
index a17ec3d..0000000
--- a/content/renderer/web_intents_host.h
+++ /dev/null
@@ -1,103 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CONTENT_RENDERER_WEB_INTENTS_HOST_H_
-#define CONTENT_RENDERER_WEB_INTENTS_HOST_H_
-
-#include <map>
-
-#include "base/memory/scoped_ptr.h"
-#include "content/public/renderer/render_view_observer.h"
-#include "third_party/WebKit/Source/Platform/chromium/public/WebString.h"
-#include "third_party/WebKit/Source/WebKit/chromium/public/WebBlob.h"
-#include "third_party/WebKit/Source/WebKit/chromium/public/WebIntent.h"
-#include "v8/include/v8.h"
-#include "webkit/glue/web_intent_data.h"
-#include "webkit/glue/web_intent_reply_data.h"
-
-namespace WebKit {
-class WebDeliveredIntentClient;
-class WebIntentRequest;
-class WebFrame;
-}
-
-namespace webkit_glue {
-struct WebIntentData;
-}
-
-namespace content {
-class RenderViewImpl;
-
-// WebIntentsHost is a delegate for Web Intents messages. It is the
-// renderer-side handler for IPC messages delivering the intent payload data
-// and preparing it for access by the service page.
-class WebIntentsHost : public RenderViewObserver {
- public:
- // |render_view| must not be NULL.
- explicit WebIntentsHost(RenderViewImpl* render_view);
- virtual ~WebIntentsHost();
-
- // Called by the RenderView to register a new Web Intent invocation.
- int RegisterWebIntent(const WebKit::WebIntentRequest& request);
-
- // Called into when the delivered intent object gets a postResult call.
- void OnResult(const WebKit::WebString& data);
- // Called into when the delivered intent object gets a postFailure call.
- void OnFailure(const WebKit::WebString& data);
-
- // Forwarded from RenderViewImpl. Notification that a new script context was
- // created within webkit.
- virtual void DidCreateScriptContext(WebKit::WebFrame* frame,
- v8::Handle<v8::Context> ctx,
- int extension_group,
- int world_id);
-
- private:
- // RenderView::Observer implementation.
- virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
-
- // Converts incoming intent data to a WebIntent object.
- WebKit::WebIntent CreateWebIntent(
- WebKit::WebFrame* frame, const webkit_glue::WebIntentData& intent_data);
-
- // TODO(gbillock): Do we need various ***ClientRedirect methods to implement
- // intent cancelling policy? Figure this out.
-
- // On the service page, handler method for the IntentsMsg_SetWebIntent
- // message.
- CONTENT_EXPORT void OnSetIntent(const webkit_glue::WebIntentData& intent);
-
- // On the client page, handler method for the IntentsMsg_WebIntentReply
- // message. Forwards |reply| to the registered WebIntentRequest
- // (found by |intent_id|), where it is dispatched to the client JS callback.
- void OnWebIntentReply(const webkit_glue::WebIntentReply& reply,
- int intent_id);
-
- friend class WebIntentsHostTest;
-
- // A counter used to assign unique IDs to web intents invocations in this
- // renderer.
- int id_counter_;
-
- // Map tracking registered Web Intent requests by assigned ID numbers to
- // correctly route any return data.
- std::map<int, WebKit::WebIntentRequest> intent_requests_;
-
- // Delivered intent data from the caller.
- scoped_ptr<webkit_glue::WebIntentData> intent_;
-
- // The client object which will receive callback notifications from the
- // delivered intent.
- scoped_ptr<WebKit::WebDeliveredIntentClient> delivered_intent_client_;
-
- // If we deliver a browser-originated blob intent to the client,
- // this is that Blob.
- WebKit::WebBlob web_blob_;
-
- DISALLOW_COPY_AND_ASSIGN(WebIntentsHost);
-};
-
-} // namespace content
-
-#endif // CONTENT_RENDERER_WEB_INTENTS_HOST_H_
diff --git a/content/renderer/web_intents_host_browsertest.cc b/content/renderer/web_intents_host_browsertest.cc
deleted file mode 100644
index abe7adb..0000000
--- a/content/renderer/web_intents_host_browsertest.cc
+++ /dev/null
@@ -1,123 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "base/gtest_prod_util.h"
-#include "base/values.h"
-#include "base/utf_string_conversions.h"
-#include "content/common/intents_messages.h"
-#include "content/public/renderer/v8_value_converter.h"
-#include "content/public/test/render_view_test.h"
-#include "content/renderer/render_view_impl.h"
-#include "content/renderer/web_intents_host.h"
-#include "third_party/WebKit/Source/WebKit/chromium/public/WebDeliveredIntentClient.h"
-#include "third_party/WebKit/Source/WebKit/chromium/public/WebSerializedScriptValue.h"
-#include "webkit/glue/web_intent_data.h"
-
-namespace content {
-
-class WebIntentsHostTest : public RenderViewTest {
- protected:
- RenderViewImpl* view() { return static_cast<RenderViewImpl*>(view_); }
- WebIntentsHost* web_intents_host() { return view()->intents_host_; }
-
- void SetIntentData(const webkit_glue::WebIntentData& data) {
- web_intents_host()->OnSetIntent(data);
- }
-
- base::DictionaryValue* ParseValueFromReply(const IPC::Message* reply_msg) {
- IntentsHostMsg_WebIntentReply::Param reply_params;
- IntentsHostMsg_WebIntentReply::Read(reply_msg, &reply_params);
- WebKit::WebSerializedScriptValue serialized_data =
- WebKit::WebSerializedScriptValue::fromString(reply_params.a.data);
-
- v8::HandleScope scope;
- v8::Local<v8::Context> ctx = GetMainFrame()->mainWorldScriptContext();
- v8::Context::Scope cscope(ctx);
- v8::Handle<v8::Value> v8_val = serialized_data.deserialize();
- scoped_ptr<V8ValueConverter> converter(V8ValueConverter::create());
- base::Value* reply = converter->FromV8Value(v8_val, ctx);
- EXPECT_TRUE(reply->IsType(base::Value::TYPE_DICTIONARY));
- base::DictionaryValue* dict = NULL;
- reply->GetAsDictionary(&dict);
- return dict;
- }
-};
-
-TEST_F(WebIntentsHostTest, TestUnserialized) {
- webkit_glue::WebIntentData data(ASCIIToUTF16("action"), ASCIIToUTF16("type"),
- ASCIIToUTF16("unserialized data"));
- SetIntentData(data);
-
- LoadHTML("<html>"
- "<head><script>\n"
- "var d = {};\n"
- "d.action = window.webkitIntent.action;\n"
- "d.type = window.webkitIntent.type;\n"
- "d.data = window.webkitIntent.data;\n"
- "window.webkitIntent.postResult(d);\n"
- "</script></head>"
- "<body>body</body></html>");
-
- const IPC::Message* reply_msg =
- render_thread_->sink().GetUniqueMessageMatching(
- IntentsHostMsg_WebIntentReply::ID);
- ASSERT_TRUE(reply_msg);
- scoped_ptr<base::DictionaryValue> dict(ParseValueFromReply(reply_msg));
-
- std::string reply_action;
- dict->GetStringASCII(std::string("action"), &reply_action);
- EXPECT_EQ("action", reply_action);
- std::string reply_type;
- dict->GetStringASCII(std::string("type"), &reply_type);
- EXPECT_EQ("type", reply_type);
- std::string reply_data;
- dict->GetStringASCII(std::string("data"), &reply_data);
- EXPECT_EQ("unserialized data", reply_data);
-}
-
-TEST_F(WebIntentsHostTest, TestVector) {
- webkit_glue::WebIntentData data(ASCIIToUTF16("action"), ASCIIToUTF16("type"));
- DictionaryValue* d1 = new DictionaryValue;
- d1->SetString(std::string("key1"), std::string("val1"));
- data.mime_data.Append(d1);
- DictionaryValue* d2 = new DictionaryValue;
- d2->SetString(std::string("key2"), std::string("val2"));
- data.mime_data.Append(d2);
- SetIntentData(data);
-
- LoadHTML("<html>"
- "<head><script>\n"
- "var d = {};\n"
- "d.action = window.webkitIntent.action;\n"
- "d.type = window.webkitIntent.type;\n"
- "d.data = window.webkitIntent.data;\n"
- "window.webkitIntent.postResult(d);\n"
- "</script></head>"
- "<body>body</body></html>");
-
- const IPC::Message* reply_msg =
- render_thread_->sink().GetUniqueMessageMatching(
- IntentsHostMsg_WebIntentReply::ID);
- ASSERT_TRUE(reply_msg);
- scoped_ptr<base::DictionaryValue> dict(ParseValueFromReply(reply_msg));
-
- base::ListValue* payload;
- ASSERT_TRUE(dict->GetList("data", &payload));
- EXPECT_EQ(2U, payload->GetSize());
-
- base::DictionaryValue* v1 = NULL;
- ASSERT_TRUE(payload->GetDictionary(0, &v1));
- DCHECK(v1);
- std::string val1;
- ASSERT_TRUE(v1->GetStringASCII(std::string("key1"), &val1));
- EXPECT_EQ("val1", val1);
-
- base::DictionaryValue* v2 = NULL;
- ASSERT_TRUE(payload->GetDictionary(1, &v2));
- std::string val2;
- v2->GetStringASCII(std::string("key2"), &val2);
- EXPECT_EQ("val2", val2);
-}
-
-} // namespace content
diff --git a/content/shell/webkit_test_runner.cc b/content/shell/webkit_test_runner.cc
index 93275d4..9b380fd 100644
--- a/content/shell/webkit_test_runner.cc
+++ b/content/shell/webkit_test_runner.cc
@@ -48,7 +48,6 @@ using WebKit::WebDevToolsAgent;
using WebKit::WebElement;
using WebKit::WebFrame;
using WebKit::WebGamepads;
-using WebKit::WebIntentRequest;
using WebKit::WebRect;
using WebKit::WebSize;
using WebKit::WebString;
@@ -295,17 +294,6 @@ void WebKitTestRunner::applyPreferences() {
Send(new ShellViewHostMsg_OverridePreferences(routing_id(), prefs));
}
-#if defined(ENABLE_WEB_INTENTS)
-void WebKitTestRunner::setCurrentWebIntentRequest(
- const WebIntentRequest& request) {
- intent_request_ = request;
-}
-
-WebIntentRequest* WebKitTestRunner::currentWebIntentRequest() {
- return &intent_request_;
-}
-#endif
-
std::string WebKitTestRunner::makeURLErrorDescription(
const WebURLError& error) {
std::string domain = error.domain.utf8();
diff --git a/content/shell/webkit_test_runner.h b/content/shell/webkit_test_runner.h
index 538aa9a..127689d 100644
--- a/content/shell/webkit_test_runner.h
+++ b/content/shell/webkit_test_runner.h
@@ -8,7 +8,6 @@
#include "base/file_path.h"
#include "base/memory/scoped_ptr.h"
#include "content/public/renderer/render_view_observer.h"
-#include "third_party/WebKit/Source/WebKit/chromium/public/WebIntentRequest.h"
#include "third_party/WebKit/Tools/DumpRenderTree/chromium/TestRunner/public/WebPreferences.h"
#include "third_party/WebKit/Tools/DumpRenderTree/chromium/TestRunner/public/WebTestDelegate.h"
#include "v8/include/v8.h"
@@ -63,10 +62,6 @@ class WebKitTestRunner : public RenderViewObserver,
virtual WebKit::WebURL rewriteLayoutTestsURL(const std::string& utf8_url);
virtual ::WebTestRunner::WebPreferences* preferences();
virtual void applyPreferences();
-#if defined(ENABLE_WEB_INTENTS)
- virtual void setCurrentWebIntentRequest(const WebKit::WebIntentRequest&);
- virtual WebKit::WebIntentRequest* currentWebIntentRequest();
-#endif
virtual std::string makeURLErrorDescription(const WebKit::WebURLError& error);
void Reset();
@@ -100,10 +95,6 @@ class WebKitTestRunner : public RenderViewObserver,
::WebTestRunner::WebPreferences prefs_;
-#if defined(ENABLE_WEB_INTENTS)
- WebKit::WebIntentRequest intent_request_;
-#endif
-
bool dump_editing_callbacks_;
bool dump_frame_load_callbacks_;
bool dump_user_gesture_in_frame_load_callbacks_;