summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-27 06:21:28 +0000
committerananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-27 06:21:28 +0000
commit64e41217726cda2866e54fe2c93207da496c134b (patch)
tree9470fa39bbb730cb283ab38fd5a1d2a0b4d52cbf /chrome
parent44f7efb21de77b1ed977ca73880bbb2bea2a2d71 (diff)
downloadchromium_src-64e41217726cda2866e54fe2c93207da496c134b.zip
chromium_src-64e41217726cda2866e54fe2c93207da496c134b.tar.gz
chromium_src-64e41217726cda2866e54fe2c93207da496c134b.tar.bz2
Attempt 2 at landing this as this broke ui_tests on linux.
The desktop notification service infobar would not display in ChromeFrame rendered pages as the code assumed the existing of a BrowserList and associated objects like Browser etc. In ChromeFrame the tab contents is owned by the ExternalTabContainer. Fix is to pass the current tab contents from the RenderViewHost to the DesktopNotificationService::RequestPermission function and use that if we don't have a browser list. Fixes bug http://code.google.com/p/chromium/issues/detail?id=44913 Bug=44913 Review URL: http://codereview.chromium.org/2266005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@48367 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/notifications/desktop_notification_service.cc13
-rw-r--r--chrome/browser/notifications/desktop_notification_service.h4
-rw-r--r--chrome/browser/renderer_host/render_view_host.cc17
3 files changed, 19 insertions, 15 deletions
diff --git a/chrome/browser/notifications/desktop_notification_service.cc b/chrome/browser/notifications/desktop_notification_service.cc
index 53cc37b..f0eb62d 100644
--- a/chrome/browser/notifications/desktop_notification_service.cc
+++ b/chrome/browser/notifications/desktop_notification_service.cc
@@ -8,7 +8,6 @@
#include "app/resource_bundle.h"
#include "base/thread.h"
#include "base/utf_string_conversions.h"
-#include "chrome/browser/browser_list.h"
#include "chrome/browser/child_process_host.h"
#include "chrome/browser/chrome_thread.h"
#include "chrome/browser/extensions/extensions_service.h"
@@ -376,18 +375,12 @@ void DesktopNotificationService::PersistPermissionChange(
}
void DesktopNotificationService::RequestPermission(
- const GURL& origin, int process_id, int route_id, int callback_context) {
+ const GURL& origin, int process_id, int route_id, int callback_context,
+ TabContents* tab) {
DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
- // Show an info bar requesting permission.
- Browser* browser = BrowserList::GetLastActive();
- if (!browser) {
- // Reached during ui tests.
- return;
- }
- TabContents* tab = browser->GetSelectedTabContents();
if (!tab)
return;
-
+ // Show an info bar requesting permission.
std::wstring display_name = DisplayNameForOrigin(origin);
tab->AddInfoBar(new NotificationPermissionInfoBarDelegate(
diff --git a/chrome/browser/notifications/desktop_notification_service.h b/chrome/browser/notifications/desktop_notification_service.h
index c3a41f9..4a651f8 100644
--- a/chrome/browser/notifications/desktop_notification_service.h
+++ b/chrome/browser/notifications/desktop_notification_service.h
@@ -19,6 +19,7 @@ class NotificationsPrefsCache;
class PrefService;
class Profile;
class Task;
+class TabContents;
// The DesktopNotificationService is an object, owned by the Profile,
// which provides the creation of desktop "toasts" to web pages and workers.
@@ -39,7 +40,8 @@ class DesktopNotificationService : public NotificationObserver {
void RequestPermission(const GURL& origin,
int process_id,
int route_id,
- int callback_context);
+ int callback_context,
+ TabContents* tab);
// Takes a notification object and shows it in the UI.
void ShowNotification(const Notification& notification);
diff --git a/chrome/browser/renderer_host/render_view_host.cc b/chrome/browser/renderer_host/render_view_host.cc
index 7d5a58a..0d45bc2 100644
--- a/chrome/browser/renderer_host/render_view_host.cc
+++ b/chrome/browser/renderer_host/render_view_host.cc
@@ -15,6 +15,7 @@
#include "base/string_util.h"
#include "base/time.h"
#include "base/waitable_event.h"
+#include "chrome/browser/browser_list.h"
#include "chrome/browser/child_process_security_policy.h"
#include "chrome/browser/cross_site_request_manager.h"
#include "chrome/browser/debugger/devtools_manager.h"
@@ -1752,10 +1753,18 @@ void RenderViewHost::OnCancelDesktopNotification(int notification_id) {
void RenderViewHost::OnRequestNotificationPermission(
const GURL& source_origin, int callback_context) {
- DesktopNotificationService* service =
- process()->profile()->GetDesktopNotificationService();
- service->RequestPermission(
- source_origin, process()->id(), routing_id(), callback_context);
+ Browser* browser = BrowserList::GetLastActive();
+ // We may not have a BrowserList if the chrome browser process is launched as
+ // a ChromeFrame process in which case we attempt to use the TabContents
+ // provided by the RenderViewHostDelegate.
+ TabContents* tab = browser ? browser->GetSelectedTabContents() :
+ (delegate_ ? delegate_->GetAsTabContents() : NULL);
+ if (tab) {
+ DesktopNotificationService* service =
+ process()->profile()->GetDesktopNotificationService();
+ service->RequestPermission(
+ source_origin, process()->id(), routing_id(), callback_context, tab);
+ }
}
void RenderViewHost::OnExtensionRequest(const std::string& name,