15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Copyright (c) 2012 The Chromium Authors. All rights reserved.
25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file.
45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifndef CHROME_BROWSER_EXTENSIONS_TAB_HELPER_H_
65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define CHROME_BROWSER_EXTENSIONS_TAB_HELPER_H_
75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
85d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include <set>
92a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include <string>
102a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include <vector>
112a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/memory/ref_counted.h"
134e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)#include "base/memory/scoped_ptr.h"
145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/memory/weak_ptr.h"
155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/observer_list.h"
165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/extensions/active_tab_permission_granter.h"
175f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)#include "chrome/common/extensions/webstore_install_result.h"
18b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles)#include "chrome/common/web_application_info.h"
195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "content/public/browser/notification_observer.h"
205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "content/public/browser/notification_registrar.h"
215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "content/public/browser/web_contents_observer.h"
225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "content/public/browser/web_contents_user_data.h"
23a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "extensions/browser/extension_function_dispatcher.h"
246e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)#include "extensions/browser/script_execution_observer.h"
256e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)#include "extensions/browser/script_executor.h"
2658537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)#include "extensions/common/stack_frame.h"
275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "third_party/skia/include/core/SkBitmap.h"
285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
295d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)class FaviconDownloader;
305d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace content {
325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)struct LoadCommittedDetails;
3346d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)class RenderFrameHost;
345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
362a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)namespace gfx {
372a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)class Image;
382a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
392a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace extensions {
411320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucciclass ActiveScriptController;
42effb81e5f8246d0db0270817048dc992db66e9fbBen Murdochclass BookmarkAppHelper;
435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class Extension;
445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class LocationBarController;
454e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)class WebstoreInlineInstallerFactory;
465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Per-tab extension helper. Also handles non-extension apps.
485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class TabHelper : public content::WebContentsObserver,
49e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch                  public extensions::ExtensionFunctionDispatcher::Delegate,
505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                  public base::SupportsWeakPtr<TabHelper>,
515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                  public content::NotificationObserver,
525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                  public content::WebContentsUserData<TabHelper> {
535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) public:
545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual ~TabHelper();
555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void CreateApplicationShortcuts();
57f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  void CreateHostedAppFromWebContents();
585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool CanCreateApplicationShortcuts() const;
59c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch  bool CanCreateBookmarkApp() const;
605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
61116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  void UpdateShortcutOnLoadComplete() {
62116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch    update_shortcut_on_load_complete_ = true;
635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
656e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  // ScriptExecutionObserver::Delegate
666e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  virtual void AddScriptExecutionObserver(ScriptExecutionObserver* observer);
676e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  virtual void RemoveScriptExecutionObserver(ScriptExecutionObserver* observer);
686e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)
695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // App extensions ------------------------------------------------------------
705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Sets the extension denoting this as an app. If |extension| is non-null this
725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // tab becomes an app-tab. WebContents does not listen for unload events for
735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // the extension. It's up to consumers of WebContents to do that.
745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  //
755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // NOTE: this should only be manipulated before the tab is added to a browser.
765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // TODO(sky): resolve if this is the right way to identify an app tab. If it
775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // is, than this should be passed in the constructor.
785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void SetExtensionApp(const Extension* extension);
795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Convenience for setting the app extension by id. This does nothing if
815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // |extension_app_id| is empty, or an extension can't be found given the
825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // specified id.
835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void SetExtensionAppById(const std::string& extension_app_id);
845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Set just the app icon, used by panels created by an extension.
865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void SetExtensionAppIconById(const std::string& extension_app_id);
875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  const Extension* extension_app() const { return extension_app_; }
895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool is_app() const { return extension_app_ != NULL; }
905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  const WebApplicationInfo& web_app_info() const {
915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return web_app_info_;
925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // If an app extension has been explicitly set for this WebContents its icon
955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // is returned.
965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  //
975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // NOTE: the returned icon is larger than 16x16 (its size is
982a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // extension_misc::EXTENSION_ICON_SMALLISH).
995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  SkBitmap* GetExtensionAppIcon();
1005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  ScriptExecutor* script_executor() {
1025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return script_executor_.get();
1035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
1045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  LocationBarController* location_bar_controller() {
1065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return location_bar_controller_.get();
1075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
1085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1091320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  ActiveScriptController* active_script_controller() {
1101320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci    return active_script_controller_.get();
1111320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  }
1121320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci
1135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  ActiveTabPermissionGranter* active_tab_permission_granter() {
1145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    return active_tab_permission_granter_.get();
1155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
1165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Sets a non-extension app icon associated with WebContents and fires an
1185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // INVALIDATE_TYPE_TITLE navigation state change to trigger repaint of title.
1195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void SetAppIcon(const SkBitmap& app_icon);
1205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1214e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  // Sets the factory used to create inline webstore item installers.
1224e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  // Used for testing. Takes ownership of the factory instance.
1234e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  void SetWebstoreInlineInstallerFactoryForTests(
1244e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)      WebstoreInlineInstallerFactory* factory);
1254e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)
1265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) private:
127116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  // Different types of action when web app info is available.
128116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  // OnDidGetApplicationInfo uses this to dispatch calls.
129116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  enum WebAppAction {
130116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch    NONE,               // No action at all.
131116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch    CREATE_SHORTCUT,    // Bring up create application shortcut dialog.
132116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch    CREATE_HOSTED_APP,  // Create and install a hosted app.
133116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch    UPDATE_SHORTCUT     // Update icon for app shortcut.
134116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  };
135116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch
1365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  explicit TabHelper(content::WebContents* web_contents);
1375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  friend class content::WebContentsUserData<TabHelper>;
1385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
139effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch  // Displays UI for completion of creating a bookmark hosted app.
140effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch  void FinishCreateBookmarkApp(const extensions::Extension* extension,
141effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch                               const WebApplicationInfo& web_app_info);
1425d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
1435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // content::WebContentsObserver overrides.
1445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void RenderViewCreated(
1455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      content::RenderViewHost* render_view_host) OVERRIDE;
1465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void DidNavigateMainFrame(
1475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      const content::LoadCommittedDetails& details,
1485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      const content::FrameNavigateParams& params) OVERRIDE;
1495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
15046d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)  virtual bool OnMessageReceived(
15146d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)      const IPC::Message& message,
15246d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)      content::RenderFrameHost* render_frame_host) OVERRIDE;
1535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void DidCloneToNewWebContents(
1545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      content::WebContents* old_web_contents,
1555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      content::WebContents* new_web_contents) OVERRIDE;
1565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
157e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch  // extensions::ExtensionFunctionDispatcher::Delegate overrides.
1585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual extensions::WindowController* GetExtensionWindowController()
1595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      const OVERRIDE;
1605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual content::WebContents* GetAssociatedWebContents() const OVERRIDE;
1615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Message handlers.
1631320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  void OnDidGetWebApplicationInfo(const WebApplicationInfo& info);
1645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void OnInlineWebstoreInstall(int install_id,
1655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                               int return_route_id,
1665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                               const std::string& webstore_item_id,
167effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch                               const GURL& requestor_url,
168effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch                               int listeners_mask);
1695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void OnGetAppInstallState(const GURL& requestor_url,
1705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                            int return_route_id,
1715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                            int callback_id);
1725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void OnRequest(const ExtensionHostMsg_Request_Params& params);
1735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void OnContentScriptsExecuting(
1745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      const ScriptExecutionObserver::ExecutingScriptsMap& extension_ids,
1755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      const GURL& on_url);
1762a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  void OnWatchedPageChange(const std::vector<std::string>& css_selectors);
17758537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)  void OnDetailedConsoleMessageAdded(const base::string16& message,
17858537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)                                     const base::string16& source,
17958537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)                                     const StackTrace& stack_trace,
18058537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)                                     int32 severity_level);
1815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // App extensions related methods:
1835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1842a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Resets app_icon_ and if |extension| is non-null uses ImageLoader to load
1852a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // the extension's image asynchronously.
1865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void UpdateExtensionAppIcon(const Extension* extension);
1875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1882a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  const Extension* GetExtension(const std::string& extension_app_id);
1895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1902a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  void OnImageLoaded(const gfx::Image& image);
1915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // WebstoreStandaloneInstaller::Callback.
1935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void OnInlineInstallComplete(int install_id,
1945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                       int return_route_id,
1955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                       bool success,
1965f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)                                       const std::string& error,
1975f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)                                       webstore_install::Result result);
1985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // content::NotificationObserver.
2005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void Observe(int type,
2015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                       const content::NotificationSource& source,
2025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                       const content::NotificationDetails& details) OVERRIDE;
2035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Requests application info for the specified page. This is an asynchronous
2055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // request. The delegate is notified by way of OnDidGetApplicationInfo when
2065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // the data is available.
207116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  void GetApplicationInfo(WebAppAction action);
2085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
20990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)  // Sends our tab ID to |render_view_host|.
21090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)  void SetTabId(content::RenderViewHost* render_view_host);
21190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)
2125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Data for app extensions ---------------------------------------------------
2135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Our content script observers. Declare at top so that it will outlive all
2155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // other members, since they might add themselves as observers.
2165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  ObserverList<ScriptExecutionObserver> script_execution_observers_;
2175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // If non-null this tab is an app tab and this is the extension the tab was
2195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // created for.
2205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  const Extension* extension_app_;
2215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Icon for extension_app_ (if non-null) or a manually-set icon for
2235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // non-extension apps.
2245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  SkBitmap extension_app_icon_;
2255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Process any extension messages coming from the tab.
227e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch  extensions::ExtensionFunctionDispatcher extension_function_dispatcher_;
2285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Cached web app info data.
2305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  WebApplicationInfo web_app_info_;
2315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Which deferred action to perform when OnDidGetApplicationInfo is notified
2335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // from a WebContents.
2345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  WebAppAction pending_web_app_action_;
2355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
236116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  // Which page id was active when the GetApplicationInfo request was sent, for
237116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  // verification when the reply returns.
238116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  int32 last_committed_page_id_;
239116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch
240116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  // Whether to trigger an update when the page load completes.
241116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  bool update_shortcut_on_load_complete_;
242116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch
2435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  content::NotificationRegistrar registrar_;
2445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  scoped_ptr<ScriptExecutor> script_executor_;
2465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  scoped_ptr<LocationBarController> location_bar_controller_;
2485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2491320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  scoped_ptr<ActiveScriptController> active_script_controller_;
2501320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci
2515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  scoped_ptr<ActiveTabPermissionGranter> active_tab_permission_granter_;
2525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
253effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch  scoped_ptr<BookmarkAppHelper> bookmark_app_helper_;
2545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2552a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  Profile* profile_;
2562a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
2574e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  // Creates WebstoreInlineInstaller instances for inline install triggers.
2584e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  scoped_ptr<WebstoreInlineInstallerFactory> webstore_inline_installer_factory_;
2594e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)
2601320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  // Vend weak pointers that can be invalidated to stop in-progress loads.
2611320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  base::WeakPtrFactory<TabHelper> image_loader_ptr_factory_;
2621320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci
2635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  DISALLOW_COPY_AND_ASSIGN(TabHelper);
2645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)};
2655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}  // namespace extensions
2675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif  // CHROME_BROWSER_EXTENSIONS_TAB_HELPER_H_
269