Commit 45ce70b4 authored by gbillock@chromium.org's avatar gbillock@chromium.org

intents: Remove the disposition enum in web intents model.

R=groby@chromium.org
BUG=None


Review URL: https://chromiumcodereview.appspot.com/10855066

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@152000 0039d316-1c4b-4281-b951-d872f2087c98
parent 784f930c
...@@ -11,13 +11,16 @@ ...@@ -11,13 +11,16 @@
#include "chrome/browser/ui/intents/web_intent_picker_delegate.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.h"
#include "testing/gmock/include/gmock/gmock.h" #include "testing/gmock/include/gmock/gmock.h"
#include "webkit/glue/web_intent_service_data.h"
class MockIntentPickerDelegate : public WebIntentPickerDelegate { class MockIntentPickerDelegate : public WebIntentPickerDelegate {
public: public:
MockIntentPickerDelegate() {} MockIntentPickerDelegate() {}
virtual ~MockIntentPickerDelegate() {} virtual ~MockIntentPickerDelegate() {}
MOCK_METHOD2(OnServiceChosen, void(const GURL& url, Disposition disposition)); MOCK_METHOD2(OnServiceChosen, void(
const GURL& url,
webkit_glue::WebIntentServiceData::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_METHOD1(OnExtensionInstallRequested, void(const std::string& id));
...@@ -74,10 +77,10 @@ IN_PROC_BROWSER_TEST_F(WebIntentSheetControllerBrowserTest, ...@@ -74,10 +77,10 @@ IN_PROC_BROWSER_TEST_F(WebIntentSheetControllerBrowserTest,
GURL url; GURL url;
model_.AddInstalledService(string16(), url, model_.AddInstalledService(string16(), url,
WebIntentPickerModel::DISPOSITION_WINDOW); webkit_glue::WebIntentServiceData::DISPOSITION_WINDOW);
EXPECT_CALL(delegate_, OnServiceChosen( EXPECT_CALL(delegate_, OnServiceChosen(
url, WebIntentPickerModel::DISPOSITION_WINDOW)); url, webkit_glue::WebIntentServiceData::DISPOSITION_WINDOW));
EXPECT_CALL(delegate_, OnPickerClosed()).Times(0); EXPECT_CALL(delegate_, OnPickerClosed()).Times(0);
EXPECT_CALL(delegate_, OnClosing()); EXPECT_CALL(delegate_, OnClosing());
......
...@@ -100,9 +100,9 @@ TEST_F(WebIntentPickerSheetControllerTest, NoRows) { ...@@ -100,9 +100,9 @@ TEST_F(WebIntentPickerSheetControllerTest, NoRows) {
TEST_F(WebIntentPickerSheetControllerTest, PopulatedRows) { TEST_F(WebIntentPickerSheetControllerTest, PopulatedRows) {
WebIntentPickerModel model; WebIntentPickerModel model;
model.AddInstalledService(string16(), GURL("http://example.org/intent.html"), model.AddInstalledService(string16(), GURL("http://example.org/intent.html"),
WebIntentPickerModel::DISPOSITION_WINDOW); webkit_glue::WebIntentServiceData::DISPOSITION_WINDOW);
model.AddInstalledService(string16(), GURL("http://example.com/intent.html"), model.AddInstalledService(string16(), GURL("http://example.com/intent.html"),
WebIntentPickerModel::DISPOSITION_WINDOW); webkit_glue::WebIntentServiceData::DISPOSITION_WINDOW);
[controller_ performLayoutWithModel:&model]; [controller_ performLayoutWithModel:&model];
......
...@@ -48,7 +48,6 @@ ...@@ -48,7 +48,6 @@
#include "ui/gfx/codec/png_codec.h" #include "ui/gfx/codec/png_codec.h"
#include "ui/gfx/favicon_size.h" #include "ui/gfx/favicon_size.h"
#include "ui/gfx/image/image.h" #include "ui/gfx/image/image.h"
#include "webkit/glue/web_intent_service_data.h"
using extensions::WebstoreInstaller; using extensions::WebstoreInstaller;
...@@ -83,19 +82,6 @@ CWSIntentsRegistry* GetCWSIntentsRegistry(TabContents* tab_contents) { ...@@ -83,19 +82,6 @@ CWSIntentsRegistry* GetCWSIntentsRegistry(TabContents* tab_contents) {
return CWSIntentsRegistryFactory::GetForProfile(tab_contents->profile()); return CWSIntentsRegistryFactory::GetForProfile(tab_contents->profile());
} }
WebIntentPickerModel::Disposition ConvertDisposition(
webkit_glue::WebIntentServiceData::Disposition disposition) {
switch (disposition) {
case webkit_glue::WebIntentServiceData::DISPOSITION_INLINE:
return WebIntentPickerModel::DISPOSITION_INLINE;
case webkit_glue::WebIntentServiceData::DISPOSITION_WINDOW:
return WebIntentPickerModel::DISPOSITION_WINDOW;
default:
NOTREACHED();
return WebIntentPickerModel::DISPOSITION_WINDOW;
}
}
// Returns the action-specific string for |action|. // Returns the action-specific string for |action|.
string16 GetIntentActionString(const std::string& action) { string16 GetIntentActionString(const std::string& action) {
if (!action.compare(kShareActionURL)) if (!action.compare(kShareActionURL))
...@@ -298,8 +284,9 @@ void WebIntentPickerController::Observe( ...@@ -298,8 +284,9 @@ void WebIntentPickerController::Observe(
ClosePicker(); ClosePicker();
} }
void WebIntentPickerController::OnServiceChosen(const GURL& url, void WebIntentPickerController::OnServiceChosen(
Disposition disposition) { const GURL& url,
webkit_glue::WebIntentServiceData::Disposition disposition) {
ExtensionService* service = tab_contents_->profile()->GetExtensionService(); ExtensionService* service = tab_contents_->profile()->GetExtensionService();
DCHECK(service); DCHECK(service);
const extensions::Extension* extension = service->GetInstalledApp(url); const extensions::Extension* extension = service->GetInstalledApp(url);
...@@ -315,14 +302,14 @@ void WebIntentPickerController::OnServiceChosen(const GURL& url, ...@@ -315,14 +302,14 @@ void WebIntentPickerController::OnServiceChosen(const GURL& url,
} }
switch (disposition) { switch (disposition) {
case WebIntentPickerModel::DISPOSITION_INLINE: case webkit_glue::WebIntentServiceData::DISPOSITION_INLINE:
// Set the model to inline disposition. It will notify the picker which // Set the model to inline disposition. It will notify the picker which
// will respond (via OnInlineDispositionWebContentsCreated) with the // will respond (via OnInlineDispositionWebContentsCreated) with the
// WebContents to dispatch the intent to. // WebContents to dispatch the intent to.
picker_model_->SetInlineDisposition(url); picker_model_->SetInlineDisposition(url);
break; break;
case WebIntentPickerModel::DISPOSITION_WINDOW: { case webkit_glue::WebIntentServiceData::DISPOSITION_WINDOW: {
Browser* browser = browser::FindBrowserWithWebContents( Browser* browser = browser::FindBrowserWithWebContents(
tab_contents_->web_contents()); tab_contents_->web_contents());
TabContents* contents = chrome::TabContentsFactory( TabContents* contents = chrome::TabContentsFactory(
...@@ -465,10 +452,8 @@ void WebIntentPickerController::DispatchToInstalledExtension( ...@@ -465,10 +452,8 @@ void WebIntentPickerController::DispatchToInstalledExtension(
picker_model_->AddInstalledService( picker_model_->AddInstalledService(
service_data.title, service_data.service_url, service_data.title, service_data.service_url,
ConvertDisposition(service_data.disposition)); service_data.disposition);
OnServiceChosen( OnServiceChosen(service_data.service_url, service_data.disposition);
service_data.service_url,
ConvertDisposition(service_data.disposition));
AsyncOperationFinished(); AsyncOperationFinished();
} }
...@@ -514,7 +499,7 @@ void WebIntentPickerController::AddServiceToModel( ...@@ -514,7 +499,7 @@ void WebIntentPickerController::AddServiceToModel(
picker_model_->AddInstalledService( picker_model_->AddInstalledService(
service.title, service.title,
service.service_url, service.service_url,
ConvertDisposition(service.disposition)); service.disposition);
pending_async_count_++; pending_async_count_++;
FaviconService::Handle handle = favicon_service->GetFaviconForURL( FaviconService::Handle handle = favicon_service->GetFaviconForURL(
...@@ -829,7 +814,8 @@ void WebIntentPickerController::AsyncOperationFinished() { ...@@ -829,7 +814,8 @@ void WebIntentPickerController::AsyncOperationFinished() {
void WebIntentPickerController::InvokeService( void WebIntentPickerController::InvokeService(
const WebIntentPickerModel::InstalledService& service) { const WebIntentPickerModel::InstalledService& service) {
if (service.disposition == WebIntentPickerModel::DISPOSITION_INLINE) { if (service.disposition ==
webkit_glue::WebIntentServiceData::DISPOSITION_INLINE) {
SetDialogState(kPickerMain); SetDialogState(kPickerMain);
} }
OnServiceChosen(service.url, service.disposition); OnServiceChosen(service.url, service.disposition);
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include "content/public/browser/notification_registrar.h" #include "content/public/browser/notification_registrar.h"
#include "webkit/glue/web_intent_data.h" #include "webkit/glue/web_intent_data.h"
#include "webkit/glue/web_intent_reply_data.h" #include "webkit/glue/web_intent_reply_data.h"
#include "webkit/glue/web_intent_service_data.h"
class Browser; class Browser;
struct DefaultWebIntentService; struct DefaultWebIntentService;
...@@ -91,8 +92,9 @@ class WebIntentPickerController ...@@ -91,8 +92,9 @@ class WebIntentPickerController
const content::NotificationDetails& details) OVERRIDE; const content::NotificationDetails& details) OVERRIDE;
// WebIntentPickerDelegate implementation. // WebIntentPickerDelegate implementation.
virtual void OnServiceChosen(const GURL& url, virtual void OnServiceChosen(
Disposition disposition) OVERRIDE; const GURL& url,
webkit_glue::WebIntentServiceData::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 OnExtensionInstallRequested(const std::string& id) OVERRIDE;
......
...@@ -200,8 +200,6 @@ class IntentsDispatcherMock : public content::WebIntentsDispatcher { ...@@ -200,8 +200,6 @@ class IntentsDispatcherMock : public content::WebIntentsDispatcher {
class WebIntentPickerControllerBrowserTest : public InProcessBrowserTest { class WebIntentPickerControllerBrowserTest : public InProcessBrowserTest {
protected: protected:
typedef WebIntentPickerModel::Disposition Disposition;
WebIntentPickerControllerBrowserTest() {} WebIntentPickerControllerBrowserTest() {}
virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
...@@ -306,7 +304,9 @@ class WebIntentPickerControllerBrowserTest : public InProcessBrowserTest { ...@@ -306,7 +304,9 @@ class WebIntentPickerControllerBrowserTest : public InProcessBrowserTest {
controller_->OnSendReturnMessage(reply_type); controller_->OnSendReturnMessage(reply_type);
} }
void OnServiceChosen(const GURL& url, Disposition disposition) { void OnServiceChosen(
const GURL& url,
webkit_glue::WebIntentServiceData::Disposition disposition) {
controller_->OnServiceChosen(url, disposition); controller_->OnServiceChosen(url, disposition);
} }
...@@ -353,7 +353,8 @@ IN_PROC_BROWSER_TEST_F(WebIntentPickerControllerBrowserTest, ChooseService) { ...@@ -353,7 +353,8 @@ IN_PROC_BROWSER_TEST_F(WebIntentPickerControllerBrowserTest, ChooseService) {
IntentsDispatcherMock dispatcher(intent); IntentsDispatcherMock dispatcher(intent);
controller_->SetIntentsDispatcher(&dispatcher); controller_->SetIntentsDispatcher(&dispatcher);
OnServiceChosen(kServiceURL2, WebIntentPickerModel::DISPOSITION_WINDOW); OnServiceChosen(kServiceURL2,
webkit_glue::WebIntentServiceData::DISPOSITION_WINDOW);
ASSERT_EQ(2, browser()->tab_count()); ASSERT_EQ(2, browser()->tab_count());
EXPECT_EQ(GURL(kServiceURL2), EXPECT_EQ(GURL(kServiceURL2),
chrome::GetActiveWebContents(browser())->GetURL()); chrome::GetActiveWebContents(browser())->GetURL());
...@@ -417,7 +418,8 @@ IN_PROC_BROWSER_TEST_F(WebIntentPickerControllerBrowserTest, ...@@ -417,7 +418,8 @@ IN_PROC_BROWSER_TEST_F(WebIntentPickerControllerBrowserTest,
IntentsDispatcherMock dispatcher(intent); IntentsDispatcherMock dispatcher(intent);
controller_->SetIntentsDispatcher(&dispatcher); controller_->SetIntentsDispatcher(&dispatcher);
OnServiceChosen(kServiceURL1, WebIntentPickerModel::DISPOSITION_WINDOW); OnServiceChosen(kServiceURL1,
webkit_glue::WebIntentServiceData::DISPOSITION_WINDOW);
ASSERT_EQ(3, browser()->tab_count()); ASSERT_EQ(3, browser()->tab_count());
EXPECT_EQ(GURL(kServiceURL1), EXPECT_EQ(GURL(kServiceURL1),
chrome::GetActiveWebContents(browser())->GetURL()); chrome::GetActiveWebContents(browser())->GetURL());
......
...@@ -16,13 +16,13 @@ class WebContents; ...@@ -16,13 +16,13 @@ class WebContents;
// service. // service.
class WebIntentPickerDelegate { class WebIntentPickerDelegate {
public: public:
typedef WebIntentPickerModel::Disposition Disposition;
// Base destructor. // Base destructor.
virtual ~WebIntentPickerDelegate() {} virtual ~WebIntentPickerDelegate() {}
// Called when the user has chosen a service. // Called when the user has chosen a service.
virtual void OnServiceChosen(const GURL& url, Disposition disposition) = 0; virtual void OnServiceChosen(
const GURL& url,
webkit_glue::WebIntentServiceData::Disposition disposition) = 0;
// Called when the picker has created WebContents to use for inline // Called when the picker has created WebContents to use for inline
// disposition. // disposition.
......
...@@ -30,9 +30,10 @@ WebIntentPickerModel::~WebIntentPickerModel() { ...@@ -30,9 +30,10 @@ WebIntentPickerModel::~WebIntentPickerModel() {
DestroyAll(); DestroyAll();
} }
void WebIntentPickerModel::AddInstalledService(const string16& title, void WebIntentPickerModel::AddInstalledService(
const GURL& url, const string16& title,
Disposition disposition) { const GURL& url,
webkit_glue::WebIntentServiceData::Disposition disposition) {
// TODO(groby): Revisit to remove O(n^2) complexity. // TODO(groby): Revisit to remove O(n^2) complexity.
for (size_t i = 0; i < installed_services_.size(); ++i) { for (size_t i = 0; i < installed_services_.size(); ++i) {
InstalledService* service = installed_services_[i]; InstalledService* service = installed_services_[i];
...@@ -165,7 +166,7 @@ void WebIntentPickerModel::DestroyAll() { ...@@ -165,7 +166,7 @@ void WebIntentPickerModel::DestroyAll() {
WebIntentPickerModel::InstalledService::InstalledService( WebIntentPickerModel::InstalledService::InstalledService(
const string16& title, const string16& title,
const GURL& url, const GURL& url,
Disposition disposition) webkit_glue::WebIntentServiceData::Disposition disposition)
: title(title), : title(title),
url(url), url(url),
favicon(ui::ResourceBundle::GetSharedInstance().GetNativeImageNamed( favicon(ui::ResourceBundle::GetSharedInstance().GetNativeImageNamed(
......
...@@ -11,24 +11,19 @@ ...@@ -11,24 +11,19 @@
#include "base/string16.h" #include "base/string16.h"
#include "googleurl/src/gurl.h" #include "googleurl/src/gurl.h"
#include "ui/gfx/image/image.h" #include "ui/gfx/image/image.h"
#include "webkit/glue/web_intent_service_data.h"
class WebIntentPickerModelObserver; class WebIntentPickerModelObserver;
// Model for the WebIntentPicker. // Model for the WebIntentPicker.
class WebIntentPickerModel { class WebIntentPickerModel {
public: public:
// The intent service disposition.
// TODO(gbillock): use the webkit_glue::WebIntentServiceData::Disposition
enum Disposition {
DISPOSITION_WINDOW, // Display the intent service in a new window.
DISPOSITION_INLINE, // Display the intent service in the picker.
};
// An intent service to display in the picker. // An intent service to display in the picker.
struct InstalledService { struct InstalledService {
InstalledService(const string16& title, InstalledService(
const GURL& url, const string16& title,
Disposition disposition); const GURL& url,
webkit_glue::WebIntentServiceData::Disposition disposition);
~InstalledService(); ~InstalledService();
// The title of this service. // The title of this service.
...@@ -41,7 +36,7 @@ class WebIntentPickerModel { ...@@ -41,7 +36,7 @@ class WebIntentPickerModel {
gfx::Image favicon; gfx::Image favicon;
// The disposition to use when displaying this service. // The disposition to use when displaying this service.
Disposition disposition; webkit_glue::WebIntentServiceData::Disposition disposition;
}; };
// A suggested extension to display in the picker. // A suggested extension to display in the picker.
...@@ -84,9 +79,10 @@ class WebIntentPickerModel { ...@@ -84,9 +79,10 @@ class WebIntentPickerModel {
// 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 GURL& url, const string16& title,
Disposition disposition); const GURL& url,
webkit_glue::WebIntentServiceData::Disposition disposition);
// Remove an installed service from the picker at |index|. // Remove an installed service from the picker at |index|.
void RemoveInstalledServiceAt(size_t index); void RemoveInstalledServiceAt(size_t index);
......
...@@ -27,10 +27,10 @@ const string16 kId3(ASCIIToUTF16("aclehenhkckhebbbncbkefhcpcgepcgf")); ...@@ -27,10 +27,10 @@ const string16 kId3(ASCIIToUTF16("aclehenhkckhebbbncbkefhcpcgepcgf"));
const string16 kId4(ASCIIToUTF16("bclehenhkckhebbbncbkefhcpcgepcgf")); const string16 kId4(ASCIIToUTF16("bclehenhkckhebbbncbkefhcpcgepcgf"));
const string16 kId5(ASCIIToUTF16("cclehenhkckhebbbncbkefhcpcgepcgf")); const string16 kId5(ASCIIToUTF16("cclehenhkckhebbbncbkefhcpcgepcgf"));
const string16 kId6(ASCIIToUTF16("dclehenhkckhebbbncbkefhcpcgepcgf")); const string16 kId6(ASCIIToUTF16("dclehenhkckhebbbncbkefhcpcgepcgf"));
const WebIntentPickerModel::Disposition kWindowDisposition( const webkit_glue::WebIntentServiceData::Disposition kWindowDisposition(
WebIntentPickerModel::DISPOSITION_WINDOW); webkit_glue::WebIntentServiceData::DISPOSITION_WINDOW);
const WebIntentPickerModel::Disposition kInlineDisposition( const webkit_glue::WebIntentServiceData::Disposition kInlineDisposition(
WebIntentPickerModel::DISPOSITION_INLINE); webkit_glue::WebIntentServiceData::DISPOSITION_INLINE);
} }
......
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