#include <map>
#include <set>
#include <string>
+#include <vector>
#include "base/callback.h"
#include "base/compiler_specific.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_vector.h"
#include "base/observer_list.h"
+#include "ui/base/ui_base_types.h"
#include "xwalk/application/browser/event_observer.h"
#include "xwalk/application/common/application_data.h"
+#include "xwalk/application/common/security_policy.h"
#include "xwalk/runtime/browser/runtime.h"
namespace xwalk {
class ApplicationHost;
class Manifest;
+class SecurityPolicy;
// The Application class is representing an active (running) application.
// Application instances are owned by ApplicationService.
// Manifest keys that can be used as application entry points.
enum LaunchEntryPoint {
- AppMainKey = 1 << 0, // app.main
- LaunchLocalPathKey = 1 << 1, // app.launch.local_path
- // NOTE: The following key is only used for "dummy" hosted apps,
- // which can be using any arbitrary URL, incl. remote ones.
- // For now this should be disabled for all other cases as this will
- // require special care with permissions etc.
- URLKey = 1 << 2, // url
- Default = AppMainKey | LaunchLocalPathKey
+ StartURLKey = 1 << 0, // start_url
+ AppMainKey = 1 << 1, // app.main
+ LaunchLocalPathKey = 1 << 2, // app.launch.local_path
+ URLKey = 1 << 3, // url
+ Default = StartURLKey | AppMainKey | LaunchLocalPathKey
};
typedef unsigned LaunchEntryPoints;
struct LaunchParams {
LaunchParams() :
entry_points(Default),
- launcher_pid(0) {}
+ launcher_pid(0),
+ force_fullscreen(false) {}
LaunchEntryPoints entry_points;
// Used only when running as service. Specifies the PID of the launcher
// process.
int32 launcher_pid;
+
+ bool force_fullscreen;
};
// Closes all the application's runtimes (application pages).
bool SetPermission(PermissionType type,
const std::string& permission_name,
StoredPermission perm);
+ bool CanRequestURL(const GURL& url) const;
+
+ protected:
+ // We enforce ApplicationService ownership.
+ friend class ApplicationService;
+ Application(scoped_refptr<ApplicationData> data,
+ RuntimeContext* context,
+ Observer* observer);
+
+ virtual void InitSecurityPolicy();
+ void AddSecurityPolicy(const GURL& url, bool subdomains);
+
+ Runtime* main_runtime_;
+ std::set<Runtime*> runtimes_;
+ scoped_refptr<ApplicationData> const application_data_;
+ bool is_security_mode_;
private:
bool HasMainDocument() const;
virtual void OnRuntimeAdded(Runtime* runtime) OVERRIDE;
virtual void OnRuntimeRemoved(Runtime* runtime) OVERRIDE;
- // We enforce ApplicationService ownership.
- friend class ApplicationService;
- Application(scoped_refptr<ApplicationData> data,
- RuntimeContext* context,
- Observer* observer);
bool Launch(const LaunchParams& launch_params);
// Try to extract the URL from different possible keys for entry points in the
// manifest, returns it and the entry point used.
- GURL GetURLForLaunch(const LaunchParams& params, LaunchEntryPoint* used);
+ GURL GetStartURL(const LaunchParams& params, LaunchEntryPoint* used);
+ ui::WindowShowState GetWindowShowState(const LaunchParams& params);
GURL GetURLFromAppMainKey();
- GURL GetURLFromLocalPathKey();
GURL GetURLFromURLKey();
+ GURL GetURLFromRelativePathKey(const std::string& key);
+
friend class FinishEventObserver;
void CloseMainDocument();
void NotifyTermination();
bool IsTerminating() const { return finish_observer_; }
RuntimeContext* runtime_context_;
- const scoped_refptr<ApplicationData> application_data_;
- Runtime* main_runtime_;
- std::set<Runtime*> runtimes_;
scoped_ptr<EventObserver> finish_observer_;
Observer* observer_;
// The entry point used as part of Launch().
LaunchEntryPoint entry_point_used_;
TerminationMode termination_mode_used_;
- base::WeakPtrFactory<Application> weak_factory_;
std::map<std::string, std::string> name_perm_map_;
// Application's session permissions.
StoredPermissionMap permission_map_;
-
+ // Security policy set.
+ ScopedVector<SecurityPolicy> security_policy_;
+ // WeakPtrFactory should be always declared the last.
+ base::WeakPtrFactory<Application> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(Application);
};