1 #ifndef BROWSER_NATIVE_WEB_RUNTIME_H_
2 #define BROWSER_NATIVE_WEB_RUNTIME_H_
5 #include <unordered_map>
9 #include "base/observer_list.h"
10 #include "base/timer/timer.h"
15 class BrowserMainRunner;
16 struct MainFunctionParams;
21 class NativeAppControl;
22 class NativeWebRuntimeObserver;
23 class ResourceManager;
25 class WRTProfileDelegate;
26 class WRTSpecialStoragePolicy;
28 class NativeWebRuntime {
32 static NativeWebRuntime& GetInstance();
33 static content::BrowserContext* GetBrowserContext();
35 void CreateBrowserMainRunner(
36 content::MainFunctionParams main_function_params);
39 int RuntimeMain(int argc, char** argv);
42 void ShutdownExtension();
43 void CheckAllWindowClosed();
45 void NotifyAppControl(std::unique_ptr<NativeAppControl> app_control);
48 void NotifyLowMemory();
49 bool NotifyMessage(const std::string& type,
50 const std::vector<std::string>& params);
51 void NotifyAmbientTick();
52 void NotifyAmbientChanged(bool ambient_mode);
53 void NotifyStatusChanged(const std::string& status);
55 void SetLanguage(const std::string& language);
57 std::string GetEncodingType();
58 bool ShouldAllowNavigation(const std::string& url);
59 bool IsTizenWebKitCompatibilityEnabled() const {
60 return tizenCompatibilitySettings_.enabled;
62 void GetTizenVersion(unsigned& major, unsigned& minor, unsigned& release) {
63 major = tizenCompatibilitySettings_.major;
64 minor = tizenCompatibilitySettings_.minor;
65 release = tizenCompatibilitySettings_.release;
68 void AddObserver(NativeWebRuntimeObserver* obs);
69 void RemoveObserver(NativeWebRuntimeObserver* obs);
71 static void HandleQuotaExceed(
72 const scoped_refptr<WRTSpecialStoragePolicy>& wrt_special_storage_policy,
73 const GURL& origin, int64_t current_quota);
75 bool GetPermissionPopupOption() { return permission_popup_option_; }
76 void SetPermissionPopupOption(bool permission) {
77 permission_popup_option_ = permission;
79 std::string GetRuntimeVariable(const std::string& name);
80 void SetRuntimeVariable(const std::string& name, const std::string& value);
82 tts_mode_e GetTTSMode();
83 void SetDelegate(WRTProfileDelegate* delegate) {
84 runtime_delegate_ = delegate;
90 void SetAppExtensibleDataInfo();
92 void SetupTizenCompatibility();
93 void OverrideDataPath();
94 bool IsRunningAsBackground();
101 } tizenCompatibilitySettings_;
103 std::unordered_map<std::string, std::string> runtime_variables_;
104 std::unique_ptr<content::BrowserMainRunner> browser_main_runner_;
105 std::unique_ptr<Runtime> runtime_;
106 std::unique_ptr<ResourceManager> resource_manager_;
108 bool permission_popup_option_; // false, not show permission popup/ true,
109 // show permission popup
110 bool eventloop_is_running_ = true;
111 base::RepeatingTimer gc_timer_;
113 base::ObserverList<NativeWebRuntimeObserver> observers_;
114 WRTProfileDelegate* runtime_delegate_ = nullptr;
119 #endif // BROWSER_NATIVE_WEB_RUNTIME_H_