summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/extensions/app_notify_channel_setup.cc49
-rw-r--r--chrome/browser/extensions/app_notify_channel_setup.h52
-rw-r--r--chrome/browser/extensions/app_notify_channel_setup_unittest.cc78
-rw-r--r--chrome/browser/extensions/extension_tab_helper.cc45
-rw-r--r--chrome/browser/extensions/extension_tab_helper.h23
5 files changed, 5 insertions, 242 deletions
diff --git a/chrome/browser/extensions/app_notify_channel_setup.cc b/chrome/browser/extensions/app_notify_channel_setup.cc
deleted file mode 100644
index 8bbe51f..0000000
--- a/chrome/browser/extensions/app_notify_channel_setup.cc
+++ /dev/null
@@ -1,49 +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.
-
-#include "chrome/browser/extensions/app_notify_channel_setup.h"
-
-#include "content/browser/browser_thread.h"
-
-AppNotifyChannelSetup::AppNotifyChannelSetup(
- int request_id,
- const std::string& client_id,
- const GURL& requestor_url,
- base::WeakPtr<AppNotifyChannelSetup::Delegate> delegate)
- : request_id_(request_id),
- client_id_(client_id),
- requestor_url_(requestor_url),
- delegate_(delegate) {}
-
-AppNotifyChannelSetup::~AppNotifyChannelSetup() {}
-
-void AppNotifyChannelSetup::Start() {
- AddRef(); // Balanced in ReportResult.
-
-
- // TODO(asargent) - We will eventually check here whether the user is logged
- // in to the browser or not. If they are, we'll make a request to a server
- // with the browser login credentials to get a channel id for the app to use
- // in server pushed notifications. If they are not logged in, we'll prompt
- // for login and if they sign in, then continue as in the first case.
- // Otherwise we'll return an error message.
-
- // For now, just reply with an error of 'not_implemented'.
- BrowserThread::PostTask(
- BrowserThread::UI,
- FROM_HERE,
- NewRunnableMethod(this,
- &AppNotifyChannelSetup::ReportResult,
- std::string(),
- std::string("not_implemented")));
-}
-
-void AppNotifyChannelSetup::ReportResult(
- const std::string& channel_id,
- const std::string& error) {
- CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- if (delegate_.get())
- delegate_->AppNotifyChannelSetupComplete(request_id_, channel_id, error);
- Release(); // Matches AddRef in Start.
-}
diff --git a/chrome/browser/extensions/app_notify_channel_setup.h b/chrome/browser/extensions/app_notify_channel_setup.h
deleted file mode 100644
index c44f8f1..0000000
--- a/chrome/browser/extensions/app_notify_channel_setup.h
+++ /dev/null
@@ -1,52 +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_EXTENSIONS_APP_NOTIFY_CHANNEL_SETUP_H_
-#define CHROME_BROWSER_EXTENSIONS_APP_NOTIFY_CHANNEL_SETUP_H_
-
-#include "base/memory/ref_counted.h"
-#include "base/memory/weak_ptr.h"
-#include "googleurl/src/gurl.h"
-
-// This class uses the browser login credentials to fetch a channel ID for an
-// app to use when sending server push notifications.
-class AppNotifyChannelSetup
- : public base::RefCountedThreadSafe<AppNotifyChannelSetup> {
- public:
- class Delegate {
- public:
- // If successful, |channel_id| will be non-empty. On failure, |channel_id|
- // will be empty and |error| will contain an error to report to the JS
- // callback.
- virtual void AppNotifyChannelSetupComplete(int request_id,
- const std::string& channel_id,
- const std::string& error) = 0;
- };
-
- AppNotifyChannelSetup(int request_id,
- const std::string& client_id,
- const GURL& requestor_url,
- base::WeakPtr<Delegate> delegate);
-
- // This begins the process of fetching the channel id using the browser login
- // credentials. If the user isn't logged in to chrome, this will first cause a
- // prompt to appear asking the user to log in.
- void Start();
-
- private:
- friend class base::RefCountedThreadSafe<AppNotifyChannelSetup>;
-
- virtual ~AppNotifyChannelSetup();
-
- void ReportResult(const std::string& channel_id, const std::string& error);
-
- int request_id_;
- std::string client_id_;
- GURL requestor_url_;
- base::WeakPtr<Delegate> delegate_;
-
- DISALLOW_COPY_AND_ASSIGN(AppNotifyChannelSetup);
-};
-
-#endif // CHROME_BROWSER_EXTENSIONS_APP_NOTIFY_CHANNEL_SETUP_H_
diff --git a/chrome/browser/extensions/app_notify_channel_setup_unittest.cc b/chrome/browser/extensions/app_notify_channel_setup_unittest.cc
deleted file mode 100644
index 07e2421..0000000
--- a/chrome/browser/extensions/app_notify_channel_setup_unittest.cc
+++ /dev/null
@@ -1,78 +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.
-
-#include "base/compiler_specific.h"
-#include "base/memory/weak_ptr.h"
-#include "base/message_loop.h"
-#include "chrome/browser/extensions/app_notify_channel_setup.h"
-#include "content/browser/browser_thread.h"
-#include "googleurl/src/gurl.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-namespace {
-
-class TestDelegate : public AppNotifyChannelSetup::Delegate,
- public base::SupportsWeakPtr<TestDelegate> {
- public:
- TestDelegate() {}
- virtual ~TestDelegate() {}
-
- virtual void AppNotifyChannelSetupComplete(
- int request_id,
- const std::string& channel_id,
- const std::string& error) OVERRIDE {
- EXPECT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::UI));
- EXPECT_FALSE(was_called_);
- was_called_ = true;
- request_id_ = request_id;
- channel_id_ = channel_id;
- error_ = error;
- MessageLoop::current()->Quit();
- }
-
- // Called to check that we were called with the expected arguments.
- void ExpectWasCalled(int expected_request_id,
- const std::string& expected_channel_id,
- const std::string& expected_error) {
- EXPECT_TRUE(was_called_);
- EXPECT_EQ(expected_request_id, request_id_);
- EXPECT_EQ(expected_channel_id, channel_id_);
- EXPECT_EQ(expected_error, error_);
- }
-
- private:
- // Has our callback been called yet?
- bool was_called_;
-
- // When our AppNotifyChannelSetupComplete method is called, we copy the
- // arguments into these member variables.
- int request_id_;
- std::string channel_id_;
- std::string error_;
-
- DISALLOW_COPY_AND_ASSIGN(TestDelegate);
-};
-
-} // namespace
-
-
-TEST(AppNotifyChannelSetupTest, WasDelegateCalled) {
- MessageLoop message_loop;
- BrowserThread thread(BrowserThread::UI, &message_loop);
-
- TestDelegate delegate;
- int request_id = 5;
- std::string client_id = "12345";
- GURL url("http://www.google.com");
-
- scoped_refptr<AppNotifyChannelSetup > setup =
- new AppNotifyChannelSetup(request_id,
- client_id,
- url,
- delegate.AsWeakPtr());
- setup->Start();
- MessageLoop::current()->Run();
- delegate.ExpectWasCalled(
- request_id, std::string(), std::string("not_implemented"));
-}
diff --git a/chrome/browser/extensions/extension_tab_helper.cc b/chrome/browser/extensions/extension_tab_helper.cc
index 0d91f82..df7209c 100644
--- a/chrome/browser/extensions/extension_tab_helper.cc
+++ b/chrome/browser/extensions/extension_tab_helper.cc
@@ -18,7 +18,6 @@
#include "chrome/common/extensions/extension_icon_set.h"
#include "chrome/common/extensions/extension_messages.h"
#include "chrome/common/extensions/extension_resource.h"
-#include "content/browser/renderer_host/render_view_host.h"
#include "content/browser/renderer_host/render_widget_host_view.h"
#include "content/browser/tab_contents/navigation_details.h"
#include "content/browser/tab_contents/tab_contents.h"
@@ -128,8 +127,6 @@ bool ExtensionTabHelper::OnMessageReceived(const IPC::Message& message) {
OnInstallApplication)
IPC_MESSAGE_HANDLER(ExtensionHostMsg_InlineWebstoreInstall,
OnInlineWebstoreInstall)
- IPC_MESSAGE_HANDLER(ExtensionHostMsg_GetAppNotifyChannel,
- OnGetAppNotifyChannel)
IPC_MESSAGE_HANDLER(ExtensionHostMsg_Request, OnRequest)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
@@ -158,48 +155,6 @@ void ExtensionTabHelper::OnInlineWebstoreInstall(
installer->BeginInstall();
}
-void ExtensionTabHelper::OnGetAppNotifyChannel(
- int request_id,
- const GURL& requestor_url,
- const std::string& client_id) {
-
- // Check for permission first.
- Profile* profile =
- Profile::FromBrowserContext(tab_contents()->browser_context());
- ExtensionService* extension_service = profile->GetExtensionService();
- ExtensionProcessManager* process_manager =
- profile->GetExtensionProcessManager();
- RenderProcessHost* process =
- tab_contents_wrapper()->render_view_host()->process();
- const Extension* extension =
- extension_service->GetInstalledApp(requestor_url);
- bool allowed =
- extension &&
- extension->is_app() &&
- extension->HasAPIPermission(
- ExtensionAPIPermission::kExperimental) &&
- (extension->is_hosted_app() ||
- process_manager->GetExtensionProcess(requestor_url) == process);
- if (!allowed) {
- AppNotifyChannelSetupComplete(request_id, "", "permission_error");
- return;
- }
-
- scoped_refptr<AppNotifyChannelSetup> channel_setup(
- new AppNotifyChannelSetup(request_id,
- client_id,
- requestor_url,
- this->AsWeakPtr()));
- channel_setup->Start();
- // We'll get called back in AppNotifyChannelSetupComplete.
-}
-
-void ExtensionTabHelper::AppNotifyChannelSetupComplete(
- int request_id, const std::string& client_id, const std::string& error) {
- Send(new ExtensionMsg_GetAppNotifyChannelResponse(
- routing_id(), request_id, client_id, error));
-}
-
void ExtensionTabHelper::OnRequest(
const ExtensionHostMsg_Request_Params& request) {
extension_function_dispatcher_.Dispatch(request,
diff --git a/chrome/browser/extensions/extension_tab_helper.h b/chrome/browser/extensions/extension_tab_helper.h
index 9e77970..7dda6ff 100644
--- a/chrome/browser/extensions/extension_tab_helper.h
+++ b/chrome/browser/extensions/extension_tab_helper.h
@@ -6,13 +6,11 @@
#define CHROME_BROWSER_EXTENSIONS_EXTENSION_TAB_HELPER_H_
#pragma once
-#include "base/memory/weak_ptr.h"
-#include "chrome/browser/extensions/app_notify_channel_setup.h"
+#include "content/browser/tab_contents/tab_contents_observer.h"
#include "chrome/browser/extensions/extension_function_dispatcher.h"
#include "chrome/browser/extensions/image_loading_tracker.h"
#include "chrome/browser/extensions/webstore_inline_installer.h"
#include "chrome/common/web_apps.h"
-#include "content/browser/tab_contents/tab_contents_observer.h"
#include "third_party/skia/include/core/SkBitmap.h"
class Extension;
@@ -24,13 +22,10 @@ struct LoadCommittedDetails;
}
// Per-tab extension helper. Also handles non-extension apps.
-class ExtensionTabHelper
- : public TabContentsObserver,
- public ExtensionFunctionDispatcher::Delegate,
- public ImageLoadingTracker::Observer,
- public WebstoreInlineInstaller::Delegate,
- public AppNotifyChannelSetup::Delegate,
- public base::SupportsWeakPtr<ExtensionTabHelper> {
+class ExtensionTabHelper : public TabContentsObserver,
+ public ExtensionFunctionDispatcher::Delegate,
+ public ImageLoadingTracker::Observer,
+ public WebstoreInlineInstaller::Delegate {
public:
explicit ExtensionTabHelper(TabContentsWrapper* wrapper);
virtual ~ExtensionTabHelper();
@@ -105,9 +100,6 @@ class ExtensionTabHelper
void OnInlineWebstoreInstall(int install_id,
const std::string& webstore_item_id,
const GURL& requestor_url);
- void OnGetAppNotifyChannel(int request_id,
- const GURL& requestor_url,
- const std::string& client_id);
void OnRequest(const ExtensionHostMsg_Request_Params& params);
// App extensions related methods:
@@ -125,11 +117,6 @@ class ExtensionTabHelper
virtual void OnInlineInstallFailure(int install_id,
const std::string& error) OVERRIDE;
- // AppNotifyChannelSetup::Delegate.
- virtual void AppNotifyChannelSetupComplete(int request_id,
- const std::string& channel_id,
- const std::string& error);
-
// Data for app extensions ---------------------------------------------------
// If non-null this tab is an app tab and this is the extension the tab was