browser_client.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. // Copyright (c) 2012 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE-CHROMIUM file.
  4. #ifndef BRIGHTRAY_BROWSER_BROWSER_CLIENT_H_
  5. #define BRIGHTRAY_BROWSER_BROWSER_CLIENT_H_
  6. #include <string>
  7. #include <vector>
  8. #include "brightray/browser/net_log.h"
  9. #include "content/public/browser/content_browser_client.h"
  10. namespace brightray {
  11. class BrowserMainParts;
  12. class NotificationPresenter;
  13. class PlatformNotificationService;
  14. class BrowserClient : public content::ContentBrowserClient {
  15. public:
  16. static BrowserClient* Get();
  17. static void SetApplicationLocale(const std::string& locale);
  18. BrowserClient();
  19. ~BrowserClient() override;
  20. BrowserMainParts* browser_main_parts() { return browser_main_parts_; }
  21. NotificationPresenter* GetNotificationPresenter();
  22. // Subclasses should override this to enable or disable WebNotification.
  23. virtual void WebNotificationAllowed(
  24. int render_process_id,
  25. const base::Callback<void(bool, bool)>& callback);
  26. // Subclasses that override this (e.g., to provide their own protocol
  27. // handlers) should call this implementation after doing their own work.
  28. content::BrowserMainParts* CreateBrowserMainParts(
  29. const content::MainFunctionParams&) override;
  30. content::MediaObserver* GetMediaObserver() override;
  31. content::PlatformNotificationService* GetPlatformNotificationService()
  32. override;
  33. void GetAdditionalAllowedSchemesForFileSystem(
  34. std::vector<std::string>* additional_schemes) override;
  35. void GetAdditionalWebUISchemes(
  36. std::vector<std::string>* additional_schemes) override;
  37. net::NetLog* GetNetLog() override;
  38. base::FilePath GetDefaultDownloadDirectory() override;
  39. content::DevToolsManagerDelegate* GetDevToolsManagerDelegate() override;
  40. std::string GetApplicationLocale() override;
  41. protected:
  42. // Subclasses should override this to provide their own BrowserMainParts
  43. // implementation. The lifetime of the returned instance is managed by the
  44. // caller.
  45. virtual BrowserMainParts* OverrideCreateBrowserMainParts(
  46. const content::MainFunctionParams&);
  47. private:
  48. BrowserMainParts* browser_main_parts_;
  49. NetLog net_log_;
  50. std::unique_ptr<PlatformNotificationService> notification_service_;
  51. std::unique_ptr<NotificationPresenter> notification_presenter_;
  52. DISALLOW_COPY_AND_ASSIGN(BrowserClient);
  53. };
  54. } // namespace brightray
  55. #endif // BRIGHTRAY_BROWSER_BROWSER_CLIENT_H_