Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / ui / browser.h
index 0e6d0bb..7172f5c 100644 (file)
@@ -25,6 +25,7 @@
 #include "chrome/browser/ui/browser_navigator.h"
 #include "chrome/browser/ui/chrome_web_modal_dialog_manager_delegate.h"
 #include "chrome/browser/ui/host_desktop.h"
+#include "chrome/browser/ui/search/search_tab_helper_delegate.h"
 #include "chrome/browser/ui/search_engines/search_engine_tab_helper_delegate.h"
 #include "chrome/browser/ui/tab_contents/core_tab_helper_delegate.h"
 #include "chrome/browser/ui/tabs/tab_strip_model_observer.h"
@@ -32,7 +33,6 @@
 #include "chrome/browser/ui/zoom/zoom_observer.h"
 #include "chrome/common/content_settings.h"
 #include "chrome/common/content_settings_types.h"
-#include "chrome/common/extensions/extension_constants.h"
 #include "content/public/browser/notification_observer.h"
 #include "content/public/browser/notification_registrar.h"
 #include "content/public/browser/page_navigator.h"
@@ -98,6 +98,7 @@ class Browser : public TabStripModelObserver,
                 public content::WebContentsDelegate,
                 public CoreTabHelperDelegate,
                 public SearchEngineTabHelperDelegate,
+                public SearchTabHelperDelegate,
                 public ChromeWebModalDialogManagerDelegate,
                 public BookmarkTabHelperDelegate,
                 public ZoomObserver,
@@ -115,14 +116,6 @@ class Browser : public TabStripModelObserver,
     TYPE_POPUP = 2
   };
 
-  // Distinguishes between browsers that host an app (opened from
-  // ApplicationLauncher::OpenApplication), and child browsers created by an app
-  // from Browser::CreateForApp (e.g. by windows.open or the extension API).
-  enum AppType {
-    APP_TYPE_HOST = 1,
-    APP_TYPE_CHILD = 2
-  };
-
   // Possible elements of the Browser window.
   enum WindowFeature {
     FEATURE_NONE = 0,
@@ -156,8 +149,8 @@ class Browser : public TabStripModelObserver,
                  Profile* profile,
                  chrome::HostDesktopType host_desktop_type);
 
-    static CreateParams CreateForApp(Type type,
-                                     const std::string& app_name,
+    static CreateParams CreateForApp(const std::string& app_name,
+                                     bool trusted_source,
                                      const gfx::Rect& window_bounds,
                                      Profile* profile,
                                      chrome::HostDesktopType host_desktop_type);
@@ -175,14 +168,8 @@ class Browser : public TabStripModelObserver,
     // The host desktop the browser is created on.
     chrome::HostDesktopType host_desktop_type;
 
-    // The application name that is also the name of the window to the shell.
-    // This name should be set when:
-    // 1) we launch an application via an application shortcut or extension API.
-    // 2) we launch an undocked devtool window.
-    std::string app_name;
-
-    // Type of app (host or child). See description of AppType.
-    AppType app_type;
+    // Specifies the browser is_trusted_source_ value.
+    bool trusted_source;
 
     // The bounds of the window to open.
     gfx::Rect initial_bounds;
@@ -194,6 +181,17 @@ class Browser : public TabStripModelObserver,
     // Supply a custom BrowserWindow implementation, to be used instead of the
     // default. Intended for testing.
     BrowserWindow* window;
+
+   private:
+    friend class Browser;
+
+    // The application name that is also the name of the window to the shell.
+    // Do not set this value directly, use CreateForApp.
+    // This name will be set for:
+    // 1) v1 applications launched via an application shortcut or extension API.
+    // 2) undocked devtool windows.
+    // 3) popup windows spawned from v1 applications.
+    std::string app_name;
   };
 
   // Constructors, Creation, Showing //////////////////////////////////////////
@@ -230,7 +228,7 @@ class Browser : public TabStripModelObserver,
 
   Type type() const { return type_; }
   const std::string& app_name() const { return app_name_; }
-  AppType app_type() const { return app_type_; }
+  bool is_trusted_source() const { return is_trusted_source_; }
   Profile* profile() const { return profile_; }
   gfx::Rect override_bounds() const { return override_bounds_; }
 
@@ -354,11 +352,6 @@ class Browser : public TabStripModelObserver,
   // Invoked when visible SSL state (as defined by SSLStatus) changes.
   void VisibleSSLStateChanged(content::WebContents* web_contents);
 
-  // Invoked when the |web_contents| no longer supports Instant. Refreshes the
-  // omnibox so it no longer shows search terms.
-  void OnWebContentsInstantSupportDisabled(
-      const content::WebContents* web_contents);
-
   // Assorted browser commands ////////////////////////////////////////////////
 
   // NOTE: Within each of the following sections, the IDs are ordered roughly by
@@ -367,6 +360,7 @@ class Browser : public TabStripModelObserver,
   // See the description of
   // FullscreenController::ToggleFullscreenModeWithExtension.
   void ToggleFullscreenModeWithExtension(const GURL& extension_url);
+
 #if defined(OS_WIN)
   // See the description of FullscreenController::ToggleMetroSnapMode.
   void SetMetroSnapMode(bool enable);
@@ -434,6 +428,7 @@ class Browser : public TabStripModelObserver,
 
   // Overridden from content::WebContentsDelegate:
   virtual bool CanOverscrollContent() const OVERRIDE;
+  virtual bool ShouldPreserveAbortedURLs(content::WebContents* source) OVERRIDE;
   virtual bool PreHandleKeyboardEvent(
       content::WebContents* source,
       const content::NativeWebKeyboardEvent& event,
@@ -493,6 +488,7 @@ class Browser : public TabStripModelObserver,
   FRIEND_TEST_ALL_PREFIXES(BrowserTest, ConvertTabToAppShortcut);
   FRIEND_TEST_ALL_PREFIXES(BrowserTest, OpenAppWindowLikeNtp);
   FRIEND_TEST_ALL_PREFIXES(BrowserTest, AppIdSwitch);
+  FRIEND_TEST_ALL_PREFIXES(BrowserTest, ShouldShowLocationBar);
   FRIEND_TEST_ALL_PREFIXES(FullscreenControllerTest,
                            TabEntersPresentationModeFromWindowed);
   FRIEND_TEST_ALL_PREFIXES(FullscreenExitBubbleControllerTest,
@@ -646,7 +642,7 @@ class Browser : public TabStripModelObserver,
       const base::FilePath& plugin_path,
       const base::Callback<void(bool)>& callback) OVERRIDE;
   virtual gfx::Size GetSizeForNewRenderView(
-      const content::WebContents* web_contents) const OVERRIDE;
+      content::WebContents* web_contents) const OVERRIDE;
 
   // Overridden from CoreTabHelperDelegate:
   // Note that the caller is responsible for deleting |old_contents|.
@@ -663,6 +659,16 @@ class Browser : public TabStripModelObserver,
   virtual void ConfirmAddSearchProvider(TemplateURL* template_url,
                                         Profile* profile) OVERRIDE;
 
+  // Overridden from SearchTabHelperDelegate:
+  virtual void NavigateOnThumbnailClick(
+      const GURL& url,
+      WindowOpenDisposition disposition,
+      content::WebContents* source_contents) OVERRIDE;
+  virtual void OnWebContentsInstantSupportDisabled(
+      const content::WebContents* web_contents) OVERRIDE;
+  virtual OmniboxView* GetOmniboxView() OVERRIDE;
+  virtual std::set<std::string> GetOpenUrls() OVERRIDE;
+
   // Overridden from WebContentsModalDialogManagerDelegate:
   virtual void SetWebContentsBlocked(content::WebContents* web_contents,
                                      bool blocked) OVERRIDE;
@@ -822,8 +828,10 @@ class Browser : public TabStripModelObserver,
   // 2) we launch an undocked devtool window.
   std::string app_name_;
 
-  // Type of app (host or child). See description of AppType.
-  AppType app_type_;
+  // True if the source is trusted (i.e. we do not need to show the URL in a
+  // a popup window). Also used to determine which app windows to save and
+  // restore on Chrome OS.
+  bool is_trusted_source_;
 
   // Unique identifier of this browser for session restore. This id is only
   // unique within the current session, and is not guaranteed to be unique