Commit 09815490 authored by hbono@chromium.org's avatar hbono@chromium.org

Revert 128189 - [Web Intents] Inline installation of extensions in web intents picker.

Initial CL: http://codereview.chromium.org/9595031/ 
Second try: http://codereview.chromium.org/9763001/

BUG=113476
TEST=WebIntentsRegistryTest.GetIntentServicesForExtensionFilter, WebIntentPickerControllerBrowserTest.ExtensionInstallSuccess

TBR=rsesek@chromium.org

Review URL: http://codereview.chromium.org/9799001

TBR=binji@chromium.org
Review URL: https://chromiumcodereview.appspot.com/9838003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@128191 0039d316-1c4b-4281-b951-d872f2087c98
parent 6c114e4f
...@@ -4,21 +4,16 @@ ...@@ -4,21 +4,16 @@
#include "chrome/browser/intents/web_intents_registry.h" #include "chrome/browser/intents/web_intents_registry.h"
#include "base/bind.h"
#include "base/bind_helpers.h"
#include "base/callback.h" #include "base/callback.h"
#include "base/utf_string_conversions.h" #include "base/utf_string_conversions.h"
#include "chrome/browser/intents/default_web_intent_service.h" #include "chrome/browser/intents/default_web_intent_service.h"
#include "chrome/browser/webdata/web_data_service.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/extension_set.h"
#include "googleurl/src/gurl.h" #include "googleurl/src/gurl.h"
#include "net/base/mime_util.h" #include "net/base/mime_util.h"
namespace { namespace {
typedef WebIntentsRegistry::IntentServiceList IntentServiceList;
// Compares two mime types for equality. Supports wild cards in both // Compares two mime types for equality. Supports wild cards in both
// |type1| and |type2|. Wild cards are of the form '<type>/*' or '*'. // |type1| and |type2|. Wild cards are of the form '<type>/*' or '*'.
bool MimeTypesAreEqual(const string16& type1, const string16& type2) { bool MimeTypesAreEqual(const string16& type1, const string16& type2) {
...@@ -30,33 +25,6 @@ bool MimeTypesAreEqual(const string16& type1, const string16& type2) { ...@@ -30,33 +25,6 @@ bool MimeTypesAreEqual(const string16& type1, const string16& type2) {
return net::MatchesMimeType(UTF16ToUTF8(type2), UTF16ToUTF8(type1)); return net::MatchesMimeType(UTF16ToUTF8(type2), UTF16ToUTF8(type1));
} }
// 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 = extension.intents_services();
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 |mimetype|.
// Wildcards are supported, of the form '<type>/*' or '*'.
void FilterServicesByMimetype(const string16& mimetype,
IntentServiceList* matching_services) {
// Filter out all services not matching the query type.
IntentServiceList::iterator iter(matching_services->begin());
while (iter != matching_services->end()) {
if (MimeTypesAreEqual(iter->type, mimetype))
++iter;
else
iter = matching_services->erase(iter);
}
}
} // namespace } // namespace
using webkit_glue::WebIntentServiceData; using webkit_glue::WebIntentServiceData;
...@@ -143,14 +111,24 @@ void WebIntentsRegistry::OnWebDataServiceRequestDone( ...@@ -143,14 +111,24 @@ void WebIntentsRegistry::OnWebDataServiceRequestDone(
if (extensions) { if (extensions) {
for (ExtensionSet::const_iterator i(extensions->begin()); for (ExtensionSet::const_iterator i(extensions->begin());
i != extensions->end(); ++i) { i != extensions->end(); ++i) {
AddMatchingServicesForExtension(**i, query->action_, const IntentServiceList& services((*i)->intents_services());
&matching_services); for (IntentServiceList::const_iterator j(services.begin());
j != services.end(); ++j) {
if (query->action_.empty() || query->action_ == j->action)
matching_services.push_back(*j);
}
} }
} }
} }
// Filter out all services not matching the query type. // Filter out all services not matching the query type.
FilterServicesByMimetype(query->type_, &matching_services); IntentServiceList::iterator iter(matching_services.begin());
while (iter != matching_services.end()) {
if (MimeTypesAreEqual(iter->type, query->type_))
++iter;
else
iter = matching_services.erase(iter);
}
query->consumer_->OnIntentsQueryDone(query->query_id_, matching_services); query->consumer_->OnIntentsQueryDone(query->query_id_, matching_services);
delete query; delete query;
...@@ -291,45 +269,6 @@ WebIntentsRegistry::QueryID WebIntentsRegistry::IntentServiceExists( ...@@ -291,45 +269,6 @@ WebIntentsRegistry::QueryID WebIntentsRegistry::IntentServiceExists(
return query->query_id_; return query->query_id_;
} }
WebIntentsRegistry::QueryID
WebIntentsRegistry::GetIntentServicesForExtensionFilter(
const string16& action,
const string16& mimetype,
const std::string& extension_id,
Consumer* consumer) {
DCHECK(consumer);
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
scoped_ptr<IntentsQuery> query(
new IntentsQuery(next_query_id_++, consumer, action, mimetype));
int query_id = query->query_id_;
content::BrowserThread::PostTask(
content::BrowserThread::UI,
FROM_HERE,
base::Bind(&WebIntentsRegistry::DoGetIntentServicesForExtensionFilter,
base::Unretained(this),
base::Passed(&query), extension_id));
return query_id;
}
void WebIntentsRegistry::DoGetIntentServicesForExtensionFilter(
scoped_ptr<IntentsQuery> query,
const std::string& extension_id) {
IntentServiceList matching_services;
if (extension_service_) {
const Extension* extension =
extension_service_->GetExtensionById(extension_id, false);
AddMatchingServicesForExtension(*extension,
query->action_,
&matching_services);
FilterServicesByMimetype(query->type_, &matching_services);
}
query->consumer_->OnIntentsQueryDone(query->query_id_, matching_services);
}
void WebIntentsRegistry::RegisterDefaultIntentService( void WebIntentsRegistry::RegisterDefaultIntentService(
const DefaultWebIntentService& default_service) { const DefaultWebIntentService& default_service) {
DCHECK(wds_.get()); DCHECK(wds_.get());
......
...@@ -77,15 +77,6 @@ class WebIntentsRegistry ...@@ -77,15 +77,6 @@ class WebIntentsRegistry
const webkit_glue::WebIntentServiceData& service, const webkit_glue::WebIntentServiceData& service,
const base::Callback<void(bool)>& callback); const base::Callback<void(bool)>& callback);
// Requests all extension services matching |action|, |mimetype| and
// |extension_id|.
// |mimetype| must conform to definition as outlined for GetIntentServices.
// |consumer| must not be NULL.
QueryID GetIntentServicesForExtensionFilter(const string16& action,
const string16& mimetype,
const std::string& extension_id,
Consumer* consumer);
// Record the given default service entry. // Record the given default service entry.
virtual void RegisterDefaultIntentService( virtual void RegisterDefaultIntentService(
const DefaultWebIntentService& default_service); const DefaultWebIntentService& default_service);
...@@ -131,10 +122,6 @@ class WebIntentsRegistry ...@@ -131,10 +122,6 @@ class WebIntentsRegistry
WebDataService::Handle h, WebDataService::Handle h,
const WDTypedResult* result); const WDTypedResult* result);
// Implementation of GetIntentServicesForExtensionFilter.
void DoGetIntentServicesForExtensionFilter(scoped_ptr<IntentsQuery> query,
const std::string& extension_id);
// Map for all in-flight web data requests/intent queries. // Map for all in-flight web data requests/intent queries.
QueryMap queries_; QueryMap queries_;
......
...@@ -25,8 +25,6 @@ class MockExtensionService: public TestExtensionService { ...@@ -25,8 +25,6 @@ class MockExtensionService: public TestExtensionService {
public: public:
virtual ~MockExtensionService() {} virtual ~MockExtensionService() {}
MOCK_CONST_METHOD0(extensions, const ExtensionSet*()); MOCK_CONST_METHOD0(extensions, const ExtensionSet*());
MOCK_CONST_METHOD2(GetExtensionById,
const Extension*(const std::string&, bool));
}; };
namespace { namespace {
...@@ -95,9 +93,6 @@ class WebIntentsRegistryTest : public testing::Test { ...@@ -95,9 +93,6 @@ class WebIntentsRegistryTest : public testing::Test {
registry_.Initialize(wds_, &extension_service_); registry_.Initialize(wds_, &extension_service_);
EXPECT_CALL(extension_service_, extensions()). EXPECT_CALL(extension_service_, extensions()).
WillRepeatedly(testing::Return(&extensions_)); WillRepeatedly(testing::Return(&extensions_));
EXPECT_CALL(extension_service_, GetExtensionById(testing::_, testing::_)).
WillRepeatedly(
testing::Invoke(this, &WebIntentsRegistryTest::GetExtensionById));
} }
virtual void TearDown() { virtual void TearDown() {
...@@ -109,17 +104,6 @@ class WebIntentsRegistryTest : public testing::Test { ...@@ -109,17 +104,6 @@ class WebIntentsRegistryTest : public testing::Test {
MessageLoop::current()->Run(); 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_; MessageLoopForUI message_loop_;
content::TestBrowserThread ui_thread_; content::TestBrowserThread ui_thread_;
content::TestBrowserThread db_thread_; content::TestBrowserThread db_thread_;
...@@ -210,25 +194,6 @@ TEST_F(WebIntentsRegistryTest, BasicTests) { ...@@ -210,25 +194,6 @@ TEST_F(WebIntentsRegistryTest, BasicTests) {
EXPECT_EQ(1U, consumer.services_.size()); 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());
TestConsumer consumer;
consumer.expected_id_ = registry_.GetIntentServicesForExtensionFilter(
ASCIIToUTF16("http://webintents.org/edit"),
ASCIIToUTF16("image/*"),
edit_extension->id(),
&consumer);
consumer.WaitForData();
ASSERT_EQ(1U, consumer.services_.size());
}
TEST_F(WebIntentsRegistryTest, GetAllIntents) { TEST_F(WebIntentsRegistryTest, GetAllIntents) {
webkit_glue::WebIntentServiceData service; webkit_glue::WebIntentServiceData service;
service.service_url = GURL("http://google.com"); service.service_url = GURL("http://google.com");
......
...@@ -25,7 +25,6 @@ class MockIntentPickerDelegate : public WebIntentPickerDelegate { ...@@ -25,7 +25,6 @@ class MockIntentPickerDelegate : public WebIntentPickerDelegate {
MOCK_METHOD2(OnServiceChosen, void(const GURL& url, Disposition disposition)); MOCK_METHOD2(OnServiceChosen, void(const GURL& url, Disposition disposition));
MOCK_METHOD1(OnInlineDispositionWebContentsCreated, MOCK_METHOD1(OnInlineDispositionWebContentsCreated,
void(content::WebContents* web_contents)); void(content::WebContents* web_contents));
MOCK_METHOD1(OnExtensionInstallRequested, void(const std::string& id));
MOCK_METHOD0(OnCancelled, void()); MOCK_METHOD0(OnCancelled, void());
MOCK_METHOD0(OnClosing, void()); MOCK_METHOD0(OnClosing, void());
}; };
......
...@@ -32,12 +32,6 @@ class WebIntentPicker { ...@@ -32,12 +32,6 @@ class WebIntentPicker {
// Hides the UI for this picker, and destroys its UI. // Hides the UI for this picker, and destroys its UI.
virtual void Close() = 0; virtual void Close() = 0;
// Called when an extension is successfully installed via the picker.
virtual void OnExtensionInstallSuccess(const std::string& id) {}
// Called when an extension installation started via the picker has failed.
virtual void OnExtensionInstallFailure(const std::string& id) {}
// Called when the controller has finished all pending asynchronous // Called when the controller has finished all pending asynchronous
// activities. // activities.
virtual void OnPendingAsyncCompleted() {} virtual void OnPendingAsyncCompleted() {}
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
#include "base/bind.h" #include "base/bind.h"
#include "base/bind_helpers.h" #include "base/bind_helpers.h"
#include "chrome/browser/extensions/webstore_installer.h" #include "chrome/browser/ui/browser.h"
#include "chrome/browser/favicon/favicon_service.h" #include "chrome/browser/favicon/favicon_service.h"
#include "chrome/browser/intents/default_web_intent_service.h" #include "chrome/browser/intents/default_web_intent_service.h"
#include "chrome/browser/intents/web_intents_registry_factory.h" #include "chrome/browser/intents/web_intents_registry_factory.h"
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/browser/tab_contents/tab_util.h" #include "chrome/browser/tab_contents/tab_util.h"
#include "chrome/browser/tabs/tab_strip_model.h" #include "chrome/browser/tabs/tab_strip_model.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_list.h" #include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/browser_navigator.h" #include "chrome/browser/ui/browser_navigator.h"
#include "chrome/browser/ui/intents/web_intent_picker.h" #include "chrome/browser/ui/intents/web_intent_picker.h"
...@@ -25,7 +24,6 @@ ...@@ -25,7 +24,6 @@
#include "chrome/browser/webdata/web_data_service.h" #include "chrome/browser/webdata/web_data_service.h"
#include "chrome/common/chrome_notification_types.h" #include "chrome/common/chrome_notification_types.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "content/public/browser/navigation_controller.h"
#include "content/public/browser/notification_source.h" #include "content/public/browser/notification_source.h"
#include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents.h"
#include "content/public/browser/web_intents_dispatcher.h" #include "content/public/browser/web_intents_dispatcher.h"
...@@ -68,77 +66,25 @@ WebIntentPickerModel::Disposition ConvertDisposition( ...@@ -68,77 +66,25 @@ WebIntentPickerModel::Disposition ConvertDisposition(
} }
} }
// Self-deleting trampoline that forwards a WebIntentsRegistry response to a
// callback.
class WebIntentsRegistryTrampoline : public WebIntentsRegistry::Consumer {
public:
typedef std::vector<webkit_glue::WebIntentServiceData> IntentServices;
typedef base::Callback<void(const IntentServices&)> ForwardingCallback;
explicit WebIntentsRegistryTrampoline(const ForwardingCallback& callback);
~WebIntentsRegistryTrampoline();
// WebIntentsRegistry::Consumer implementation.
virtual void OnIntentsQueryDone(
WebIntentsRegistry::QueryID,
const std::vector<webkit_glue::WebIntentServiceData>& services) OVERRIDE;
virtual void OnIntentsDefaultsQueryDone(
WebIntentsRegistry::QueryID,
const DefaultWebIntentService& default_service) OVERRIDE {}
private:
// Forwarding callback from |OnIntentsQueryDone|.
ForwardingCallback callback_;
};
WebIntentsRegistryTrampoline::WebIntentsRegistryTrampoline(
const ForwardingCallback& callback)
: callback_(callback) {
}
WebIntentsRegistryTrampoline::~WebIntentsRegistryTrampoline() {
}
void WebIntentsRegistryTrampoline::OnIntentsQueryDone(
WebIntentsRegistry::QueryID,
const std::vector<webkit_glue::WebIntentServiceData>& services) {
DCHECK(!callback_.is_null());
callback_.Run(services);
delete this;
}
// Self-deleting trampoline that forwards A URLFetcher response to a callback.
class URLFetcherTrampoline : public content::URLFetcherDelegate { class URLFetcherTrampoline : public content::URLFetcherDelegate {
public: public:
typedef base::Callback<void(const content::URLFetcher* source)> typedef base::Callback<void(const content::URLFetcher* source)> Callback;
ForwardingCallback;
explicit URLFetcherTrampoline(const ForwardingCallback& callback); explicit URLFetcherTrampoline(const Callback& callback)
~URLFetcherTrampoline(); : callback_(callback) {}
~URLFetcherTrampoline() {}
// content::URLFetcherDelegate implementation. // content::URLFetcherDelegate implementation.
virtual void OnURLFetchComplete(const content::URLFetcher* source) OVERRIDE; virtual void OnURLFetchComplete(const content::URLFetcher* source) OVERRIDE {
callback_.Run(source);
delete source;
delete this;
}
private: private:
// Fowarding callback from |OnURLFetchComplete|. Callback callback_;
ForwardingCallback callback_;
}; };
URLFetcherTrampoline::URLFetcherTrampoline(const ForwardingCallback& callback)
: callback_(callback) {
}
URLFetcherTrampoline::~URLFetcherTrampoline() {
}
void URLFetcherTrampoline::OnURLFetchComplete(
const content::URLFetcher* source) {
DCHECK(!callback_.is_null());
callback_.Run(source);
delete source;
delete this;
}
} // namespace } // namespace
WebIntentPickerController::WebIntentPickerController( WebIntentPickerController::WebIntentPickerController(
...@@ -183,8 +129,6 @@ void WebIntentPickerController::ShowDialog(Browser* browser, ...@@ -183,8 +129,6 @@ void WebIntentPickerController::ShowDialog(Browser* browser,
return; return;
picker_model_->Clear(); picker_model_->Clear();
picker_model_->set_action(action);
picker_model_->set_mimetype(type);
// If picker is non-NULL, it was set by a test. // If picker is non-NULL, it was set by a test.
if (picker_ == NULL) { if (picker_ == NULL) {
...@@ -194,14 +138,8 @@ void WebIntentPickerController::ShowDialog(Browser* browser, ...@@ -194,14 +138,8 @@ void WebIntentPickerController::ShowDialog(Browser* browser,
picker_shown_ = true; picker_shown_ = true;
pending_async_count_+= 2; pending_async_count_+= 2;
GetWebIntentsRegistry(wrapper_)->GetIntentServices( GetWebIntentsRegistry(wrapper_)->GetIntentServices(action, type, this);
action, type, GetCWSIntentsRegistry(wrapper_)->GetIntentServices(action, type,
// WebIntentsRegistryTrampoline is self-deleting.
new WebIntentsRegistryTrampoline(
base::Bind(&WebIntentPickerController::OnWebIntentServicesAvailable,
weak_ptr_factory_.GetWeakPtr())));
GetCWSIntentsRegistry(wrapper_)->GetIntentServices(
action, type,
base::Bind(&WebIntentPickerController::OnCWSIntentServicesAvailable, base::Bind(&WebIntentPickerController::OnCWSIntentServicesAvailable,
weak_ptr_factory_.GetWeakPtr())); weak_ptr_factory_.GetWeakPtr()));
} }
...@@ -274,16 +212,6 @@ void WebIntentPickerController::OnInlineDispositionWebContentsCreated( ...@@ -274,16 +212,6 @@ void WebIntentPickerController::OnInlineDispositionWebContentsCreated(
intents_dispatcher_->DispatchIntent(web_contents); intents_dispatcher_->DispatchIntent(web_contents);
} }
void WebIntentPickerController::OnExtensionInstallRequested(
const std::string& id) {
webstore_installer_ = new WebstoreInstaller(
wrapper_->profile(), this, &wrapper_->web_contents()->GetController(), id,
WebstoreInstaller::FLAG_INLINE_INSTALL);
pending_async_count_++;
webstore_installer_->Start();
}
void WebIntentPickerController::OnCancelled() { void WebIntentPickerController::OnCancelled() {
if (!intents_dispatcher_) if (!intents_dispatcher_)
return; return;
...@@ -304,28 +232,6 @@ void WebIntentPickerController::OnClosing() { ...@@ -304,28 +232,6 @@ void WebIntentPickerController::OnClosing() {
picker_ = NULL; picker_ = NULL;
} }
void WebIntentPickerController::OnExtensionInstallSuccess(
const std::string& id) {
picker_->OnExtensionInstallSuccess(id);
pending_async_count_++;
GetWebIntentsRegistry(wrapper_)->GetIntentServicesForExtensionFilter(
picker_model_->action(),
picker_model_->mimetype(),
id,
new WebIntentsRegistryTrampoline(
base::Bind(
&WebIntentPickerController::OnExtensionInstallServiceAvailable,
weak_ptr_factory_.GetWeakPtr())));
AsyncOperationFinished();
}
void WebIntentPickerController::OnExtensionInstallFailure(
const std::string& id,
const std::string& error) {
picker_->OnExtensionInstallFailure(id);
AsyncOperationFinished();
}
void WebIntentPickerController::OnSendReturnMessage( void WebIntentPickerController::OnSendReturnMessage(
webkit_glue::WebIntentReplyType reply_type) { webkit_glue::WebIntentReplyType reply_type) {
ClosePicker(); ClosePicker();
...@@ -354,7 +260,8 @@ void WebIntentPickerController::OnSendReturnMessage( ...@@ -354,7 +260,8 @@ void WebIntentPickerController::OnSendReturnMessage(
intents_dispatcher_ = NULL; intents_dispatcher_ = NULL;
} }
void WebIntentPickerController::OnWebIntentServicesAvailable( void WebIntentPickerController::OnIntentsQueryDone(
WebIntentsRegistry::QueryID,
const std::vector<webkit_glue::WebIntentServiceData>& services) { const std::vector<webkit_glue::WebIntentServiceData>& services) {
FaviconService* favicon_service = GetFaviconService(wrapper_); FaviconService* favicon_service = GetFaviconService(wrapper_);
for (size_t i = 0; i < services.size(); ++i) { for (size_t i = 0; i < services.size(); ++i) {
...@@ -377,6 +284,11 @@ void WebIntentPickerController::OnWebIntentServicesAvailable( ...@@ -377,6 +284,11 @@ void WebIntentPickerController::OnWebIntentServicesAvailable(
AsyncOperationFinished(); AsyncOperationFinished();
} }
void WebIntentPickerController::OnIntentsDefaultsQueryDone(
WebIntentsRegistry::QueryID,
const DefaultWebIntentService& default_service) {
}
void WebIntentPickerController::OnFaviconDataAvailable( void WebIntentPickerController::OnFaviconDataAvailable(
FaviconService::Handle handle, history::FaviconData favicon_data) { FaviconService::Handle handle, history::FaviconData favicon_data) {
size_t index = favicon_consumer_.GetClientDataForCurrentRequest(); size_t index = favicon_consumer_.GetClientDataForCurrentRequest();
...@@ -509,19 +421,6 @@ void WebIntentPickerController::OnExtensionIconUnavailable( ...@@ -509,19 +421,6 @@ void WebIntentPickerController::OnExtensionIconUnavailable(
AsyncOperationFinished(); AsyncOperationFinished();
} }
void WebIntentPickerController::OnExtensionInstallServiceAvailable(
const std::vector<webkit_glue::WebIntentServiceData>& services) {
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];
OnServiceChosen(
service_data.service_url,
ConvertDisposition(service_data.disposition));
AsyncOperationFinished();
}
void WebIntentPickerController::AsyncOperationFinished() { void WebIntentPickerController::AsyncOperationFinished() {
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
if (--pending_async_count_ == 0) { if (--pending_async_count_ == 0) {
......
...@@ -9,11 +9,9 @@ ...@@ -9,11 +9,9 @@
#include <vector> #include <vector>
#include "base/compiler_specific.h" #include "base/compiler_specific.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h" #include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
#include "base/string16.h" #include "base/string16.h"
#include "chrome/browser/extensions/webstore_installer.h"
#include "chrome/browser/favicon/favicon_service.h" #include "chrome/browser/favicon/favicon_service.h"
#include "chrome/browser/intents/web_intents_registry.h" #include "chrome/browser/intents/web_intents_registry.h"
#include "chrome/browser/intents/cws_intents_registry.h" #include "chrome/browser/intents/cws_intents_registry.h"
...@@ -29,7 +27,6 @@ class GURL; ...@@ -29,7 +27,6 @@ class GURL;
class TabContentsWrapper; class TabContentsWrapper;
class WebIntentPicker; class WebIntentPicker;
class WebIntentPickerModel; class WebIntentPickerModel;
class WebstoreInstaller;
namespace content { namespace content {
class WebContents; class WebContents;
...@@ -44,7 +41,7 @@ struct WebIntentServiceData; ...@@ -44,7 +41,7 @@ struct WebIntentServiceData;
// intent handler choice back to the TabContents object. // intent handler choice back to the TabContents object.
class WebIntentPickerController : public content::NotificationObserver, class WebIntentPickerController : public content::NotificationObserver,
public WebIntentPickerDelegate, public WebIntentPickerDelegate,
public WebstoreInstaller::Delegate { public WebIntentsRegistry::Consumer {
public: public:
// Takes ownership of |factory|. // Takes ownership of |factory|.
explicit WebIntentPickerController(TabContentsWrapper* wrapper); explicit WebIntentPickerController(TabContentsWrapper* wrapper);
...@@ -72,15 +69,9 @@ class WebIntentPickerController : public content::NotificationObserver, ...@@ -72,15 +69,9 @@ class WebIntentPickerController : public content::NotificationObserver,
Disposition disposition) OVERRIDE; Disposition disposition) OVERRIDE;
virtual void OnInlineDispositionWebContentsCreated( virtual void OnInlineDispositionWebContentsCreated(
content::WebContents* web_contents) OVERRIDE; content::WebContents* web_contents) OVERRIDE;
virtual void OnExtensionInstallRequested(const std::string& id) OVERRIDE;
virtual void OnCancelled() OVERRIDE; virtual void OnCancelled() OVERRIDE;
virtual void OnClosing() OVERRIDE; virtual void OnClosing() OVERRIDE;
// WebstoreInstaller::Delegate implementation.
virtual void OnExtensionInstallSuccess(const std::string& id) OVERRIDE;
virtual void OnExtensionInstallFailure(const std::string& id,
const std::string& error) OVERRIDE;
private: private:
friend class WebIntentPickerControllerTest; friend class WebIntentPickerControllerTest;
friend class WebIntentPickerControllerBrowserTest; friend class WebIntentPickerControllerBrowserTest;
...@@ -100,8 +91,14 @@ class WebIntentPickerController : public content::NotificationObserver, ...@@ -100,8 +91,14 @@ class WebIntentPickerController : public content::NotificationObserver,
} }
// Called when WebIntentServiceData is returned from the WebIntentsRegistry. // Called when WebIntentServiceData is returned from the WebIntentsRegistry.
void OnWebIntentServicesAvailable( virtual void OnIntentsQueryDone(
const std::vector<webkit_glue::WebIntentServiceData>& services); WebIntentsRegistry::QueryID,
const std::vector<webkit_glue::WebIntentServiceData>& services) OVERRIDE;
// Called when the WebIntentsRegistry returns responses to a defaults request.
virtual void OnIntentsDefaultsQueryDone(
WebIntentsRegistry::QueryID,
const DefaultWebIntentService& default_service) OVERRIDE;
// Called when FaviconData is returned from the FaviconService. // Called when FaviconData is returned from the FaviconService.
void OnFaviconDataAvailable(FaviconService::Handle handle, void OnFaviconDataAvailable(FaviconService::Handle handle,
...@@ -130,12 +127,6 @@ class WebIntentPickerController : public content::NotificationObserver, ...@@ -130,12 +127,6 @@ class WebIntentPickerController : public content::NotificationObserver,
// Called when an extension's icon failed to be decoded or resized. // Called when an extension's icon failed to be decoded or resized.
void OnExtensionIconUnavailable(const string16& extension_id); void OnExtensionIconUnavailable(const string16& extension_id);
// When an extension is installed, all that is known is the extension id.
// This callback receives the intent service data for that extension.
// |services| must be a non-empty list.
void OnExtensionInstallServiceAvailable(
const std::vector<webkit_glue::WebIntentServiceData>& services);
// Decrements the |pending_async_count_| and notifies the picker if it // Decrements the |pending_async_count_| and notifies the picker if it
// reaches zero. // reaches zero.
void AsyncOperationFinished(); void AsyncOperationFinished();
...@@ -177,9 +168,6 @@ class WebIntentPickerController : public content::NotificationObserver, ...@@ -177,9 +168,6 @@ class WebIntentPickerController : public content::NotificationObserver,
// Request consumer used when asynchronously loading favicons. // Request consumer used when asynchronously loading favicons.
CancelableRequestConsumerTSimple<size_t> favicon_consumer_; CancelableRequestConsumerTSimple<size_t> favicon_consumer_;
// Used to install extensions from the Chrome Web Store.
scoped_refptr<WebstoreInstaller> webstore_installer_;
base::WeakPtrFactory<WebIntentPickerController> weak_ptr_factory_; base::WeakPtrFactory<WebIntentPickerController> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(WebIntentPickerController); DISALLOW_COPY_AND_ASSIGN(WebIntentPickerController);
......
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
#define CHROME_BROWSER_UI_INTENTS_WEB_INTENT_PICKER_DELEGATE_H_ #define CHROME_BROWSER_UI_INTENTS_WEB_INTENT_PICKER_DELEGATE_H_
#pragma once #pragma once
#include <string>
#include "chrome/browser/ui/intents/web_intent_picker_model.h" #include "chrome/browser/ui/intents/web_intent_picker_model.h"
namespace content { namespace content {
...@@ -30,9 +29,6 @@ class WebIntentPickerDelegate { ...@@ -30,9 +29,6 @@ class WebIntentPickerDelegate {
virtual void OnInlineDispositionWebContentsCreated( virtual void OnInlineDispositionWebContentsCreated(
content::WebContents* web_contents) = 0; content::WebContents* web_contents) = 0;
// Called when the user has chosen to install a suggested extension.
virtual void OnExtensionInstallRequested(const std::string& id) = 0;
// Called when the user cancels out of the dialog, whether by closing it // Called when the user cancels out of the dialog, whether by closing it
// manually or otherwise purposefully. // manually or otherwise purposefully.
virtual void OnCancelled() = 0; virtual void OnCancelled() = 0;
......
...@@ -39,8 +39,6 @@ void WebIntentPickerModel::RemoveInstalledServiceAt(size_t index) { ...@@ -39,8 +39,6 @@ void WebIntentPickerModel::RemoveInstalledServiceAt(size_t index) {
void WebIntentPickerModel::Clear() { void WebIntentPickerModel::Clear() {
DestroyAll(); DestroyAll();
action_.clear();
mimetype_.clear();
inline_disposition_url_ = GURL::EmptyGURL(); inline_disposition_url_ = GURL::EmptyGURL();
if (observer_) if (observer_)
observer_->OnModelChanged(this); observer_->OnModelChanged(this);
......
...@@ -74,14 +74,6 @@ class WebIntentPickerModel { ...@@ -74,14 +74,6 @@ class WebIntentPickerModel {
observer_ = observer; observer_ = observer;
} }
void set_action(const string16& action) { action_ = action; }
const string16& action() { return action_; }
void set_mimetype(const string16& mimetype) { mimetype_ = mimetype; }
const string16& mimetype() { return mimetype_; }
// Add a new installed service with |title|, |url| and |disposition| to the // Add a new installed service with |title|, |url| and |disposition| to the
// picker. // picker.
void AddInstalledService(const string16& title, void AddInstalledService(const string16& title,
...@@ -154,12 +146,6 @@ class WebIntentPickerModel { ...@@ -154,12 +146,6 @@ class WebIntentPickerModel {
// GURL::EmptyGURL() if none. // GURL::EmptyGURL() if none.
GURL inline_disposition_url_; GURL inline_disposition_url_;
// A cached copy of the action that instantiated the picker.
string16 action_;
// A cached copy of the mimetype that instantiated the picker.
string16 mimetype_;
DISALLOW_COPY_AND_ASSIGN(WebIntentPickerModel); DISALLOW_COPY_AND_ASSIGN(WebIntentPickerModel);
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment