diff options
author | Iain Merrick <husky@google.com> | 2010-11-01 12:19:54 +0000 |
---|---|---|
committer | Iain Merrick <husky@google.com> | 2010-11-03 10:21:10 +0000 |
commit | 731df977c0511bca2206b5f333555b1205ff1f43 (patch) | |
tree | 0e750b949b3f00a1ac11fda25d3c2de512f2b465 /chrome/browser/notifications | |
parent | 5add15e10e7bb80512f2c597ca57221314abe577 (diff) | |
download | external_chromium-731df977c0511bca2206b5f333555b1205ff1f43.zip external_chromium-731df977c0511bca2206b5f333555b1205ff1f43.tar.gz external_chromium-731df977c0511bca2206b5f333555b1205ff1f43.tar.bz2 |
Merge Chromium at r63472 : Initial merge by git.
Change-Id: Ifb9ee821af006a5f2211e81471be93ae440a1f5a
Diffstat (limited to 'chrome/browser/notifications')
17 files changed, 216 insertions, 128 deletions
diff --git a/chrome/browser/notifications/balloon_host.cc b/chrome/browser/notifications/balloon_host.cc index 4251086..f47d395 100644 --- a/chrome/browser/notifications/balloon_host.cc +++ b/chrome/browser/notifications/balloon_host.cc @@ -46,12 +46,36 @@ void BalloonHost::Shutdown() { } } +Browser* BalloonHost::GetBrowser() const { + // Notifications aren't associated with a particular browser. + return NULL; +} + +gfx::NativeView BalloonHost::GetNativeViewOfHost() { + // TODO(aa): Should this return the native view of the BalloonView*? + return NULL; +} + +TabContents* BalloonHost::associated_tab_contents() const { return NULL; } + WebPreferences BalloonHost::GetWebkitPrefs() { WebPreferences prefs; prefs.allow_scripts_to_close_windows = true; return prefs; } +SiteInstance* BalloonHost::GetSiteInstance() const { + return site_instance_.get(); +} + +Profile* BalloonHost::GetProfile() const { + return balloon_->profile(); +} + +const GURL& BalloonHost::GetURL() const { + return balloon_->notification().content_url(); +} + void BalloonHost::Close(RenderViewHost* render_view_host) { balloon_->CloseByScript(); NotifyDisconnect(); @@ -76,6 +100,18 @@ void BalloonHost::RenderViewGone(RenderViewHost* render_view_host) { Close(render_view_host); } +int BalloonHost::GetBrowserWindowID() const { + return extension_misc::kUnknownWindowId; +} + +ViewType::Type BalloonHost::GetRenderViewType() const { + return ViewType::NOTIFICATION; +} + +RenderViewHostDelegate::View* BalloonHost::GetViewDelegate() { + return this; +} + void BalloonHost::ProcessDOMUIMessage( const ViewHostMsg_DomMessage_Params& params) { if (extension_function_dispatcher_.get()) { @@ -166,6 +202,18 @@ void BalloonHost::EnableDOMUI() { enable_dom_ui_ = true; } +void BalloonHost::UpdateInspectorSetting(const std::string& key, + const std::string& value) { + RenderViewHostDelegateHelper::UpdateInspectorSetting( + GetProfile(), key, value); +} + +void BalloonHost::ClearInspectorSettings() { + RenderViewHostDelegateHelper::ClearInspectorSettings(GetProfile()); +} + +BalloonHost::~BalloonHost() {} + void BalloonHost::NotifyDisconnect() { if (!should_notify_on_disconnect_) return; diff --git a/chrome/browser/notifications/balloon_host.h b/chrome/browser/notifications/balloon_host.h index fde3bf5..1c8b088 100644 --- a/chrome/browser/notifications/balloon_host.h +++ b/chrome/browser/notifications/balloon_host.h @@ -34,15 +34,9 @@ class BalloonHost : public RenderViewHostDelegate, void Shutdown(); // ExtensionFunctionDispatcher::Delegate overrides. - virtual Browser* GetBrowser() const { - // Notifications aren't associated with a particular browser. - return NULL; - } - virtual gfx::NativeView GetNativeViewOfHost() { - // TODO(aa): Should this return the native view of the BalloonView*? - return NULL; - } - virtual TabContents* associated_tab_contents() const { return NULL; } + virtual Browser* GetBrowser() const; + virtual gfx::NativeView GetNativeViewOfHost(); + virtual TabContents* associated_tab_contents() const; RenderViewHost* render_view_host() const { return render_view_host_; } @@ -52,28 +46,18 @@ class BalloonHost : public RenderViewHostDelegate, // RenderViewHostDelegate overrides. virtual WebPreferences GetWebkitPrefs(); - virtual SiteInstance* GetSiteInstance() const { - return site_instance_.get(); - } - virtual Profile* GetProfile() const { return balloon_->profile(); } - virtual const GURL& GetURL() const { - return balloon_->notification().content_url(); - } + virtual SiteInstance* GetSiteInstance() const; + virtual Profile* GetProfile() const; + virtual const GURL& GetURL() const; virtual void Close(RenderViewHost* render_view_host); virtual void RenderViewCreated(RenderViewHost* render_view_host); virtual void RenderViewReady(RenderViewHost* render_view_host); virtual void RenderViewGone(RenderViewHost* render_view_host); virtual void UpdateTitle(RenderViewHost* render_view_host, int32 page_id, const std::wstring& title) {} - virtual int GetBrowserWindowID() const { - return extension_misc::kUnknownWindowId; - } - virtual ViewType::Type GetRenderViewType() const { - return ViewType::NOTIFICATION; - } - virtual RenderViewHostDelegate::View* GetViewDelegate() { - return this; - } + virtual int GetBrowserWindowID() const; + virtual ViewType::Type GetRenderViewType() const; + virtual RenderViewHostDelegate::View* GetViewDelegate(); virtual void ProcessDOMUIMessage(const ViewHostMsg_DomMessage_Params& params); // RenderViewHostDelegate::View methods. Only the ones for opening new @@ -121,8 +105,12 @@ class BalloonHost : public RenderViewHostDelegate, // Enable DOM UI. This has to be called before renderer is created. void EnableDOMUI(); + virtual void UpdateInspectorSetting(const std::string& key, + const std::string& value); + virtual void ClearInspectorSettings(); + protected: - virtual ~BalloonHost() {} + virtual ~BalloonHost(); // Must override in platform specific implementations. virtual void InitRenderWidgetHostView() = 0; virtual RenderWidgetHostView* render_widget_host_view() const = 0; diff --git a/chrome/browser/notifications/desktop_notification_service.cc b/chrome/browser/notifications/desktop_notification_service.cc index 1b3df09..a4c45d5 100644 --- a/chrome/browser/notifications/desktop_notification_service.cc +++ b/chrome/browser/notifications/desktop_notification_service.cc @@ -6,11 +6,11 @@ #include "app/l10n_util.h" #include "app/resource_bundle.h" -#include "base/histogram.h" +#include "base/metrics/histogram.h" #include "base/thread.h" #include "base/utf_string_conversions.h" #include "chrome/browser/browser_child_process_host.h" -#include "chrome/browser/chrome_thread.h" +#include "chrome/browser/browser_thread.h" #include "chrome/browser/extensions/extensions_service.h" #include "chrome/browser/notifications/notification.h" #include "chrome/browser/notifications/notification_object_proxy.h" @@ -26,6 +26,7 @@ #include "chrome/browser/tab_contents/tab_contents.h" #include "chrome/browser/worker_host/worker_process_host.h" #include "chrome/common/notification_service.h" +#include "chrome/common/notification_type.h" #include "chrome/common/pref_names.h" #include "chrome/common/render_messages.h" #include "chrome/common/render_messages_params.h" @@ -47,8 +48,6 @@ string16 DesktopNotificationService::CreateDataUrl( const GURL& icon_url, const string16& title, const string16& body, WebTextDirection dir) { int resource; - string16 line_name; - string16 line; std::vector<std::string> subst; if (icon_url.is_valid()) { resource = IDR_NOTIFICATION_ICON_HTML; @@ -60,10 +59,10 @@ string16 DesktopNotificationService::CreateDataUrl( "right" : "left"); } else if (title.empty() || body.empty()) { resource = IDR_NOTIFICATION_1LINE_HTML; - line = title.empty() ? body : title; + string16 line = title.empty() ? body : title; // Strings are div names in the template file. - line_name = title.empty() ? ASCIIToUTF16("description") - : ASCIIToUTF16("title"); + string16 line_name = title.empty() ? ASCIIToUTF16("description") + : ASCIIToUTF16("title"); subst.push_back(EscapeForHTML(UTF16ToUTF8(line_name))); subst.push_back(EscapeForHTML(UTF16ToUTF8(line))); } else { @@ -75,6 +74,12 @@ string16 DesktopNotificationService::CreateDataUrl( subst.push_back(dir == WebKit::WebTextDirectionRightToLeft ? "rtl" : "ltr"); + return CreateDataUrl(resource, subst); +} + +// static +string16 DesktopNotificationService::CreateDataUrl( + int resource, const std::vector<std::string>& subst) { const base::StringPiece template_html( ResourceBundle::GetSharedInstance().GetRawDataResource( resource)); @@ -101,7 +106,7 @@ class NotificationPermissionCallbackTask : public Task { } virtual void Run() { - DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO)); + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); RenderViewHost* host = RenderViewHost::FromID(process_id_, route_id_); if (host) host->Send(new ViewMsg_PermissionRequestDone(route_id_, request_id_)); @@ -138,8 +143,8 @@ class NotificationPermissionInfoBarDelegate : public ConfirmInfoBarDelegate { if (!action_taken_) UMA_HISTOGRAM_COUNTS("NotificationPermissionRequest.Ignored", 1); - ChromeThread::PostTask( - ChromeThread::IO, FROM_HERE, + BrowserThread::PostTask( + BrowserThread::IO, FROM_HERE, new NotificationPermissionCallbackTask( process_id_, route_id_, callback_context_)); @@ -268,24 +273,24 @@ void DesktopNotificationService::StopObserving() { } void DesktopNotificationService::GrantPermission(const GURL& origin) { - DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI)); + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); PersistPermissionChange(origin, true); // Schedule a cache update on the IO thread. - ChromeThread::PostTask( - ChromeThread::IO, FROM_HERE, + BrowserThread::PostTask( + BrowserThread::IO, FROM_HERE, NewRunnableMethod( prefs_cache_.get(), &NotificationsPrefsCache::CacheAllowedOrigin, origin)); } void DesktopNotificationService::DenyPermission(const GURL& origin) { - DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI)); + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); PersistPermissionChange(origin, false); // Schedule a cache update on the IO thread. - ChromeThread::PostTask( - ChromeThread::IO, FROM_HERE, + BrowserThread::PostTask( + BrowserThread::IO, FROM_HERE, NewRunnableMethod( prefs_cache_.get(), &NotificationsPrefsCache::CacheDeniedOrigin, origin)); @@ -296,34 +301,48 @@ void DesktopNotificationService::Observe(NotificationType type, const NotificationDetails& details) { DCHECK(NotificationType::PREF_CHANGED == type); PrefService* prefs = profile_->GetPrefs(); - std::string* name = Details<std::string>(details).ptr(); + const std::string& name = *Details<std::string>(details).ptr(); + + if (name == prefs::kDesktopNotificationAllowedOrigins) { + NotificationService::current()->Notify( + NotificationType::DESKTOP_NOTIFICATION_SETTINGS_CHANGED, + Source<DesktopNotificationService>(this), + NotificationService::NoDetails()); - if (0 == name->compare(prefs::kDesktopNotificationAllowedOrigins)) { std::vector<GURL> allowed_origins(GetAllowedOrigins()); // Schedule a cache update on the IO thread. - ChromeThread::PostTask( - ChromeThread::IO, FROM_HERE, + BrowserThread::PostTask( + BrowserThread::IO, FROM_HERE, NewRunnableMethod( prefs_cache_.get(), &NotificationsPrefsCache::SetCacheAllowedOrigins, allowed_origins)); - } else if (0 == name->compare(prefs::kDesktopNotificationDeniedOrigins)) { + } else if (name == prefs::kDesktopNotificationDeniedOrigins) { + NotificationService::current()->Notify( + NotificationType::DESKTOP_NOTIFICATION_SETTINGS_CHANGED, + Source<DesktopNotificationService>(this), + NotificationService::NoDetails()); + std::vector<GURL> denied_origins(GetBlockedOrigins()); // Schedule a cache update on the IO thread. - ChromeThread::PostTask( - ChromeThread::IO, FROM_HERE, + BrowserThread::PostTask( + BrowserThread::IO, FROM_HERE, NewRunnableMethod( prefs_cache_.get(), &NotificationsPrefsCache::SetCacheDeniedOrigins, denied_origins)); - } else if (0 == name->compare( - prefs::kDesktopNotificationDefaultContentSetting)) { + } else if (name == prefs::kDesktopNotificationDefaultContentSetting) { + NotificationService::current()->Notify( + NotificationType::DESKTOP_NOTIFICATION_DEFAULT_CHANGED, + Source<DesktopNotificationService>(this), + NotificationService::NoDetails()); + const ContentSetting default_content_setting = IntToContentSetting( prefs->GetInteger(prefs::kDesktopNotificationDefaultContentSetting)); // Schedule a cache update on the IO thread. - ChromeThread::PostTask( - ChromeThread::IO, FROM_HERE, + BrowserThread::PostTask( + BrowserThread::IO, FROM_HERE, NewRunnableMethod( prefs_cache_.get(), &NotificationsPrefsCache::SetCacheDefaultContentSetting, @@ -407,7 +426,7 @@ ContentSetting DesktopNotificationService::GetDefaultContentSetting() { void DesktopNotificationService::SetDefaultContentSetting( ContentSetting setting) { - DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI)); + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); profile_->GetPrefs()->SetInteger( prefs::kDesktopNotificationDefaultContentSetting, setting == CONTENT_SETTING_DEFAULT ? kDefaultSetting : setting); @@ -415,7 +434,7 @@ void DesktopNotificationService::SetDefaultContentSetting( } void DesktopNotificationService::ResetToDefaultContentSetting() { - DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI)); + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); PrefService* prefs = profile_->GetPrefs(); prefs->ClearPref(prefs::kDesktopNotificationDefaultContentSetting); @@ -491,7 +510,7 @@ void DesktopNotificationService::ResetAllOrigins() { ContentSetting DesktopNotificationService::GetContentSetting( const GURL& origin) { - DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI)); + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); if (profile_->IsOffTheRecord()) return kDefaultSetting; @@ -511,7 +530,7 @@ ContentSetting DesktopNotificationService::GetContentSetting( void DesktopNotificationService::RequestPermission( const GURL& origin, int process_id, int route_id, int callback_context, TabContents* tab) { - DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI)); + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); if (!tab) return; @@ -527,8 +546,8 @@ void DesktopNotificationService::RequestPermission( route_id, callback_context)); } else { // Notify renderer immediately. - ChromeThread::PostTask( - ChromeThread::IO, FROM_HERE, + BrowserThread::PostTask( + BrowserThread::IO, FROM_HERE, new NotificationPermissionCallbackTask( process_id, route_id, callback_context)); } @@ -553,7 +572,7 @@ bool DesktopNotificationService::CancelDesktopNotification( bool DesktopNotificationService::ShowDesktopNotification( const ViewHostMsg_ShowNotification_Params& params, int process_id, int route_id, DesktopNotificationSource source) { - DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI)); + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); const GURL& origin = params.origin; NotificationObjectProxy* proxy = new NotificationObjectProxy(process_id, route_id, diff --git a/chrome/browser/notifications/desktop_notification_service.h b/chrome/browser/notifications/desktop_notification_service.h index 2282cd2..a6815da 100644 --- a/chrome/browser/notifications/desktop_notification_service.h +++ b/chrome/browser/notifications/desktop_notification_service.h @@ -83,6 +83,12 @@ class DesktopNotificationService : public NotificationObserver { const string16& body, WebKit::WebTextDirection dir); + // Creates a data:xxxx URL which contains the full HTML for a notification + // using resource template which contains the standard formatting for + // notifications. + static string16 CreateDataUrl(int resource, + const std::vector<std::string>& subst); + // The default content setting determines how to handle origins that haven't // been allowed or denied yet. ContentSetting GetDefaultContentSetting(); diff --git a/chrome/browser/notifications/desktop_notification_service_unittest.cc b/chrome/browser/notifications/desktop_notification_service_unittest.cc index f88466b..9f0067c 100644 --- a/chrome/browser/notifications/desktop_notification_service_unittest.cc +++ b/chrome/browser/notifications/desktop_notification_service_unittest.cc @@ -28,10 +28,10 @@ class ThreadProxy : public base::RefCountedThreadSafe<ThreadProxy> { permission_(0) { // The current message loop was already initalized by the test superclass. ui_thread_.reset( - new ChromeThread(ChromeThread::UI, MessageLoop::current())); + new BrowserThread(BrowserThread::UI, MessageLoop::current())); // Create IO thread, start its message loop. - io_thread_.reset(new ChromeThread(ChromeThread::IO)); + io_thread_.reset(new BrowserThread(BrowserThread::IO)); io_thread_->Start(); // Calling PauseIOThread() here isn't safe, because the runnable method @@ -39,25 +39,25 @@ class ThreadProxy : public base::RefCountedThreadSafe<ThreadProxy> { } int CacheHasPermission(NotificationsPrefsCache* cache, const GURL& url) { - DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI)); - ChromeThread::PostTask(ChromeThread::IO, FROM_HERE, + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); + BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, NewRunnableMethod(this, &ThreadProxy::CacheHasPermissionIO, cache, url)); io_event_.Signal(); ui_event_.Wait(); // Wait for IO thread to be done. - ChromeThread::PostTask(ChromeThread::IO, FROM_HERE, + BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, NewRunnableMethod(this, &ThreadProxy::PauseIOThreadIO)); return permission_; } void PauseIOThread() { - ChromeThread::PostTask(ChromeThread::IO, FROM_HERE, + BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, NewRunnableMethod(this, &ThreadProxy::PauseIOThreadIO)); } void DrainIOThread() { - DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI)); + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); io_event_.Signal(); io_thread_->Stop(); } @@ -69,20 +69,20 @@ class ThreadProxy : public base::RefCountedThreadSafe<ThreadProxy> { } void PauseIOThreadIO() { - DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO)); + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); io_event_.Wait(); } void CacheHasPermissionIO(NotificationsPrefsCache* cache, const GURL& url) { - DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO)); + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); permission_ = cache->HasPermission(url); ui_event_.Signal(); } base::WaitableEvent io_event_; base::WaitableEvent ui_event_; - scoped_ptr<ChromeThread> ui_thread_; - scoped_ptr<ChromeThread> io_thread_; + scoped_ptr<BrowserThread> ui_thread_; + scoped_ptr<BrowserThread> io_thread_; int permission_; }; diff --git a/chrome/browser/notifications/desktop_notifications_unittest.cc b/chrome/browser/notifications/desktop_notifications_unittest.cc index d324b6a..9946690 100644 --- a/chrome/browser/notifications/desktop_notifications_unittest.cc +++ b/chrome/browser/notifications/desktop_notifications_unittest.cc @@ -68,7 +68,7 @@ int MockBalloonCollection::UppermostVerticalPosition() { } DesktopNotificationsTest::DesktopNotificationsTest() - : ui_thread_(ChromeThread::UI, &message_loop_) { + : ui_thread_(BrowserThread::UI, &message_loop_) { } DesktopNotificationsTest::~DesktopNotificationsTest() { diff --git a/chrome/browser/notifications/desktop_notifications_unittest.h b/chrome/browser/notifications/desktop_notifications_unittest.h index ab3ad63..3b02b7b 100644 --- a/chrome/browser/notifications/desktop_notifications_unittest.h +++ b/chrome/browser/notifications/desktop_notifications_unittest.h @@ -10,7 +10,7 @@ #include <string> #include "base/message_loop.h" -#include "chrome/browser/chrome_thread.h" +#include "chrome/browser/browser_thread.h" #include "chrome/browser/notifications/balloon_collection_impl.h" #include "chrome/browser/notifications/desktop_notification_service.h" #include "chrome/browser/notifications/notification.h" @@ -100,7 +100,7 @@ class DesktopNotificationsTest : public testing::Test { // Create a message loop to allow notifications code to post tasks, // and a thread so that notifications code runs on the expected thread. MessageLoopForUI message_loop_; - ChromeThread ui_thread_; + BrowserThread ui_thread_; // Test profile. scoped_ptr<TestingProfile> profile_; diff --git a/chrome/browser/notifications/notification.cc b/chrome/browser/notifications/notification.cc new file mode 100644 index 0000000..c429efa --- /dev/null +++ b/chrome/browser/notifications/notification.cc @@ -0,0 +1,40 @@ +// Copyright (c) 2010 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/notifications/notification.h" + +Notification::Notification(const GURL& origin_url, + const GURL& content_url, + const string16& display_source, + const string16& replace_id, + NotificationDelegate* delegate) + : origin_url_(origin_url), + content_url_(content_url), + display_source_(display_source), + replace_id_(replace_id), + delegate_(delegate) { +} + +Notification::Notification(const Notification& notification) + : origin_url_(notification.origin_url()), + content_url_(notification.content_url()), + display_source_(notification.display_source()), + replace_id_(notification.replace_id()), + delegate_(notification.delegate()) { +} + +Notification::~Notification() {} + +Notification& Notification::operator=(const Notification& notification) { + origin_url_ = notification.origin_url(); + content_url_ = notification.content_url(); + display_source_ = notification.display_source(); + replace_id_ = notification.replace_id(); + delegate_ = notification.delegate(); + return *this; +} + +bool Notification::IsSame(const Notification& other) const { + return delegate()->id() == other.delegate()->id(); +} diff --git a/chrome/browser/notifications/notification.h b/chrome/browser/notifications/notification.h index f8ab903..7b0ab8c 100644 --- a/chrome/browser/notifications/notification.h +++ b/chrome/browser/notifications/notification.h @@ -17,32 +17,14 @@ class NotificationDelegate; // data: URLs representing simple text+icon notifications. class Notification { public: - Notification(const GURL& origin_url, const GURL& content_url, + Notification(const GURL& origin_url, + const GURL& content_url, const string16& display_source, const string16& replace_id, - NotificationDelegate* delegate) - : origin_url_(origin_url), - content_url_(content_url), - display_source_(display_source), - replace_id_(replace_id), - delegate_(delegate) { - } - - Notification(const Notification& notification) - : origin_url_(notification.origin_url()), - content_url_(notification.content_url()), - display_source_(notification.display_source()), - replace_id_(notification.replace_id()), - delegate_(notification.delegate()) { - } - - void operator=(const Notification& notification) { - origin_url_ = notification.origin_url(); - content_url_ = notification.content_url(); - display_source_ = notification.display_source(); - replace_id_ = notification.replace_id(); - delegate_ = notification.delegate(); - } + NotificationDelegate* delegate); + Notification(const Notification& notification); + ~Notification(); + Notification& operator=(const Notification& notification); // The URL (may be data:) containing the contents for the notification. const GURL& content_url() const { return content_url_; } @@ -60,9 +42,7 @@ class Notification { void Click() const { delegate()->Click(); } void Close(bool by_user) const { delegate()->Close(by_user); } - bool IsSame(const Notification& other) const { - return delegate()->id() == other.delegate()->id(); - } + bool IsSame(const Notification& other) const; private: NotificationDelegate* delegate() const { return delegate_.get(); } diff --git a/chrome/browser/notifications/notification_exceptions_table_model.cc b/chrome/browser/notifications/notification_exceptions_table_model.cc index 2627025..31a44d5 100644 --- a/chrome/browser/notifications/notification_exceptions_table_model.cc +++ b/chrome/browser/notifications/notification_exceptions_table_model.cc @@ -7,10 +7,20 @@ #include "app/l10n_util.h" #include "app/table_model_observer.h" #include "base/utf_string_conversions.h" +#include "chrome/common/content_settings.h" #include "chrome/common/content_settings_helper.h" +#include "chrome/common/content_settings_types.h" #include "chrome/common/url_constants.h" #include "grit/generated_resources.h" +struct NotificationExceptionsTableModel::Entry { + Entry(const GURL& origin, ContentSetting setting); + bool operator<(const Entry& b) const; + + GURL origin; + ContentSetting setting; +}; + NotificationExceptionsTableModel::NotificationExceptionsTableModel( DesktopNotificationService* service) : service_(service), @@ -25,6 +35,8 @@ NotificationExceptionsTableModel::NotificationExceptionsTableModel( sort(entries_.begin(), entries_.end()); } +NotificationExceptionsTableModel::~NotificationExceptionsTableModel() {} + bool NotificationExceptionsTableModel::CanRemoveRows( const Rows& rows) const { return !rows.empty(); diff --git a/chrome/browser/notifications/notification_exceptions_table_model.h b/chrome/browser/notifications/notification_exceptions_table_model.h index bef1fee..0fcf335 100644 --- a/chrome/browser/notifications/notification_exceptions_table_model.h +++ b/chrome/browser/notifications/notification_exceptions_table_model.h @@ -11,13 +11,12 @@ #include "chrome/browser/notifications/desktop_notification_service.h" #include "chrome/browser/remove_rows_table_model.h" -#include "chrome/common/content_settings.h" -#include "chrome/common/content_settings_types.h" class NotificationExceptionsTableModel : public RemoveRowsTableModel { public: explicit NotificationExceptionsTableModel( DesktopNotificationService* service); + virtual ~NotificationExceptionsTableModel(); // RemoveRowsTableModel overrides: virtual bool CanRemoveRows(const Rows& rows) const; @@ -30,13 +29,7 @@ class NotificationExceptionsTableModel : public RemoveRowsTableModel { virtual void SetObserver(TableModelObserver* observer); private: - struct Entry { - Entry(const GURL& origin, ContentSetting setting); - bool operator<(const Entry& b) const; - - GURL origin; - ContentSetting setting; - }; + struct Entry; DesktopNotificationService* service_; diff --git a/chrome/browser/notifications/notification_exceptions_table_model_unittest.cc b/chrome/browser/notifications/notification_exceptions_table_model_unittest.cc index 5a650ae..18a998b 100644 --- a/chrome/browser/notifications/notification_exceptions_table_model_unittest.cc +++ b/chrome/browser/notifications/notification_exceptions_table_model_unittest.cc @@ -5,7 +5,7 @@ #include "chrome/browser/notifications/notification_exceptions_table_model.h" #include "app/l10n_util.h" -#include "chrome/browser/chrome_thread.h" +#include "chrome/browser/browser_thread.h" #include "chrome/browser/renderer_host/test/test_render_view_host.h" #include "chrome/test/testing_profile.h" #include "grit/generated_resources.h" @@ -14,7 +14,7 @@ class NotificationExceptionsTableModelTest : public RenderViewHostTestHarness { public: NotificationExceptionsTableModelTest() - : ui_thread_(ChromeThread::UI, MessageLoop::current()) { + : ui_thread_(BrowserThread::UI, MessageLoop::current()) { } virtual ~NotificationExceptionsTableModelTest() { @@ -47,7 +47,7 @@ class NotificationExceptionsTableModelTest : public RenderViewHostTestHarness { } protected: - ChromeThread ui_thread_; + BrowserThread ui_thread_; scoped_ptr<NotificationExceptionsTableModel> model_; DesktopNotificationService* service_; }; diff --git a/chrome/browser/notifications/notification_object_proxy.cc b/chrome/browser/notifications/notification_object_proxy.cc index edf35df..6b10afe 100644 --- a/chrome/browser/notifications/notification_object_proxy.cc +++ b/chrome/browser/notifications/notification_object_proxy.cc @@ -7,7 +7,7 @@ #include "base/message_loop.h" #include "base/string16.h" #include "chrome/browser/browser_process.h" -#include "chrome/browser/chrome_thread.h" +#include "chrome/browser/browser_thread.h" #include "chrome/browser/renderer_host/render_view_host.h" #include "chrome/common/render_messages.h" @@ -65,9 +65,9 @@ std::string NotificationObjectProxy::id() const { void NotificationObjectProxy::DeliverMessage(IPC::Message* message) { - DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI)); - ChromeThread::PostTask( - ChromeThread::IO, FROM_HERE, + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); + BrowserThread::PostTask( + BrowserThread::IO, FROM_HERE, NewRunnableMethod(this, &NotificationObjectProxy::Send, message)); } @@ -77,7 +77,7 @@ void NotificationObjectProxy::Send(IPC::Message* message) { // Take ownership of the message; ownership will pass to a host if possible. scoped_ptr<IPC::Message> owned_message(message); - DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO)); + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); RenderViewHost* host = RenderViewHost::FromID(process_id_, route_id_); if (host) { // Pass ownership to the host. diff --git a/chrome/browser/notifications/notification_ui_manager.cc b/chrome/browser/notifications/notification_ui_manager.cc index 42b9c5e..adc44cf 100644 --- a/chrome/browser/notifications/notification_ui_manager.cc +++ b/chrome/browser/notifications/notification_ui_manager.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 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. @@ -59,8 +59,8 @@ void NotificationUIManager::Add(const Notification& notification, return; } - LOG(INFO) << "Added notification. URL: " - << notification.content_url().spec().c_str(); + VLOG(1) << "Added notification. URL: " + << notification.content_url().spec(); show_queue_.push_back( new QueuedNotification(notification, profile)); CheckAndShowNotifications(); diff --git a/chrome/browser/notifications/notifications_prefs_cache.cc b/chrome/browser/notifications/notifications_prefs_cache.cc index 8603d9e..b1dbe2e 100644 --- a/chrome/browser/notifications/notifications_prefs_cache.cc +++ b/chrome/browser/notifications/notifications_prefs_cache.cc @@ -6,7 +6,7 @@ #include "base/string_util.h" #include "base/utf_string_conversions.h" -#include "chrome/browser/chrome_thread.h" +#include "chrome/browser/browser_thread.h" #include "chrome/browser/prefs/pref_service.h" #include "third_party/WebKit/WebKit/chromium/public/WebNotificationPresenter.h" @@ -79,6 +79,8 @@ int NotificationsPrefsCache::HasPermission(const GURL& origin) { } } +NotificationsPrefsCache::~NotificationsPrefsCache() {} + bool NotificationsPrefsCache::IsOriginAllowed( const GURL& origin) { CheckThreadAccess(); @@ -93,8 +95,8 @@ bool NotificationsPrefsCache::IsOriginDenied( void NotificationsPrefsCache::CheckThreadAccess() { if (is_initialized_) { - DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO)); + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); } else { - DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI)); + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); } } diff --git a/chrome/browser/notifications/notifications_prefs_cache.h b/chrome/browser/notifications/notifications_prefs_cache.h index 758f0f7..286813b 100644 --- a/chrome/browser/notifications/notifications_prefs_cache.h +++ b/chrome/browser/notifications/notifications_prefs_cache.h @@ -55,7 +55,7 @@ class NotificationsPrefsCache private: friend class base::RefCountedThreadSafe<NotificationsPrefsCache>; - ~NotificationsPrefsCache() {} + virtual ~NotificationsPrefsCache(); // Helper functions which read preferences. bool IsOriginAllowed(const GURL& origin); diff --git a/chrome/browser/notifications/notifications_prefs_cache_unittest.cc b/chrome/browser/notifications/notifications_prefs_cache_unittest.cc index 0cbea9e..d3bbf7d 100644 --- a/chrome/browser/notifications/notifications_prefs_cache_unittest.cc +++ b/chrome/browser/notifications/notifications_prefs_cache_unittest.cc @@ -5,7 +5,7 @@ #include "chrome/browser/notifications/notifications_prefs_cache.h" #include "base/message_loop.h" -#include "chrome/browser/chrome_thread.h" +#include "chrome/browser/browser_thread.h" #include "testing/gtest/include/gtest/gtest.h" #include "third_party/WebKit/WebKit/chromium/public/WebNotificationPresenter.h" @@ -18,7 +18,7 @@ TEST(NotificationsPrefsCacheTest, CanCreate) { { MessageLoop loop; - ChromeThread ui_thread(ChromeThread::UI, &loop); + BrowserThread ui_thread(BrowserThread::UI, &loop); cache->SetCacheAllowedOrigins(allowed_origins); cache->SetCacheDeniedOrigins(denied_origins); @@ -29,7 +29,7 @@ TEST(NotificationsPrefsCacheTest, CanCreate) { { MessageLoop loop; - ChromeThread io_thread(ChromeThread::IO, &loop); + BrowserThread io_thread(BrowserThread::IO, &loop); cache->CacheAllowedOrigin(GURL("http://allowed2.com")); cache->CacheDeniedOrigin(GURL("http://denied2.com")); |