#include "base/memory/weak_ptr.h"
#include "base/prefs/pref_change_registrar.h"
#include "base/prefs/pref_member.h"
+#include "base/scoped_observer.h"
#include "base/strings/string16.h"
#include "chrome/browser/devtools/devtools_toggle_action.h"
#include "chrome/browser/ui/bookmarks/bookmark_bar.h"
#include "ui/gfx/rect.h"
#include "ui/shell_dialogs/select_file_dialog.h"
+#if defined(ENABLE_EXTENSIONS)
+#include "extensions/browser/extension_registry_observer.h"
+#endif
+
class BrowserContentSettingBubbleModelDelegate;
class BrowserContentTranslateDriverObserver;
class BrowserInstantController;
namespace extensions {
class Extension;
+class ExtensionRegistry;
class WindowController;
}
public ZoomObserver,
public content::PageNavigator,
public content::NotificationObserver,
+#if defined(ENABLE_EXTENSIONS)
+ public extensions::ExtensionRegistryObserver,
+#endif
public ui::SelectFileDialog::Listener {
public:
// SessionService::WindowType mirrors these values. If you add to this
// Constructors, Creation, Showing //////////////////////////////////////////
explicit Browser(const CreateParams& params);
- virtual ~Browser();
+ ~Browser() override;
// Set overrides for the initial window bounds and maximized state.
void set_override_bounds(const gfx::Rect& bounds) {
// Interface implementations ////////////////////////////////////////////////
// Overridden from content::PageNavigator:
- virtual content::WebContents* OpenURL(
- const content::OpenURLParams& params) OVERRIDE;
+ content::WebContents* OpenURL(const content::OpenURLParams& params) override;
// Overridden from TabStripModelObserver:
- virtual void TabInsertedAt(content::WebContents* contents,
- int index,
- bool foreground) OVERRIDE;
- virtual void TabClosingAt(TabStripModel* tab_strip_model,
- content::WebContents* contents,
- int index) OVERRIDE;
- virtual void TabDetachedAt(content::WebContents* contents,
- int index) OVERRIDE;
- virtual void TabDeactivated(content::WebContents* contents) OVERRIDE;
- virtual void ActiveTabChanged(content::WebContents* old_contents,
- content::WebContents* new_contents,
- int index,
- int reason) OVERRIDE;
- virtual void TabMoved(content::WebContents* contents,
- int from_index,
- int to_index) OVERRIDE;
- virtual void TabReplacedAt(TabStripModel* tab_strip_model,
- content::WebContents* old_contents,
- content::WebContents* new_contents,
- int index) OVERRIDE;
- virtual void TabPinnedStateChanged(content::WebContents* contents,
- int index) OVERRIDE;
- virtual void TabStripEmpty() OVERRIDE;
+ void TabInsertedAt(content::WebContents* contents,
+ int index,
+ bool foreground) override;
+ void TabClosingAt(TabStripModel* tab_strip_model,
+ content::WebContents* contents,
+ int index) override;
+ void TabDetachedAt(content::WebContents* contents, int index) override;
+ void TabDeactivated(content::WebContents* contents) override;
+ void ActiveTabChanged(content::WebContents* old_contents,
+ content::WebContents* new_contents,
+ int index,
+ int reason) override;
+ void TabMoved(content::WebContents* contents,
+ int from_index,
+ int to_index) override;
+ void TabReplacedAt(TabStripModel* tab_strip_model,
+ content::WebContents* old_contents,
+ content::WebContents* new_contents,
+ int index) override;
+ void TabPinnedStateChanged(content::WebContents* contents,
+ int index) override;
+ void TabStripEmpty() override;
// 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,
- bool* is_keyboard_shortcut) OVERRIDE;
- virtual void HandleKeyboardEvent(
- content::WebContents* source,
- const content::NativeWebKeyboardEvent& event) OVERRIDE;
- virtual void OverscrollUpdate(int delta_y) OVERRIDE;
- virtual void ShowValidationMessage(content::WebContents* web_contents,
- const gfx::Rect& anchor_in_root_view,
- const base::string16& main_text,
- const base::string16& sub_text) OVERRIDE;
- virtual void HideValidationMessage(
- content::WebContents* web_contents) OVERRIDE;
- virtual void MoveValidationMessage(
- content::WebContents* web_contents,
- const gfx::Rect& anchor_in_root_view) OVERRIDE;
- virtual bool PreHandleGestureEvent(
- content::WebContents* source,
- const blink::WebGestureEvent& event) OVERRIDE;
- virtual bool CanDragEnter(
+ bool CanOverscrollContent() const override;
+ bool ShouldPreserveAbortedURLs(content::WebContents* source) override;
+ bool PreHandleKeyboardEvent(content::WebContents* source,
+ const content::NativeWebKeyboardEvent& event,
+ bool* is_keyboard_shortcut) override;
+ void HandleKeyboardEvent(
content::WebContents* source,
- const content::DropData& data,
- blink::WebDragOperationsMask operations_allowed) OVERRIDE;
+ const content::NativeWebKeyboardEvent& event) override;
+ void ShowValidationMessage(content::WebContents* web_contents,
+ const gfx::Rect& anchor_in_root_view,
+ const base::string16& main_text,
+ const base::string16& sub_text) override;
+ void HideValidationMessage(content::WebContents* web_contents) override;
+ void MoveValidationMessage(content::WebContents* web_contents,
+ const gfx::Rect& anchor_in_root_view) override;
+ bool PreHandleGestureEvent(content::WebContents* source,
+ const blink::WebGestureEvent& event) override;
+ bool CanDragEnter(content::WebContents* source,
+ const content::DropData& data,
+ blink::WebDragOperationsMask operations_allowed) override;
bool is_type_tabbed() const { return type_ == TYPE_TABBED; }
bool is_type_popup() const { return type_ == TYPE_POPUP; }
};
// Overridden from content::WebContentsDelegate:
- virtual content::WebContents* OpenURLFromTab(
+ content::WebContents* OpenURLFromTab(
content::WebContents* source,
- const content::OpenURLParams& params) OVERRIDE;
- virtual void NavigationStateChanged(
- const content::WebContents* source,
- content::InvalidateTypes changed_flags) OVERRIDE;
- virtual void VisibleSSLStateChanged(
- const content::WebContents* source) OVERRIDE;
- virtual void AddNewContents(content::WebContents* source,
- content::WebContents* new_contents,
- WindowOpenDisposition disposition,
- const gfx::Rect& initial_pos,
- bool user_gesture,
- bool* was_blocked) OVERRIDE;
- virtual void ActivateContents(content::WebContents* contents) OVERRIDE;
- virtual void DeactivateContents(content::WebContents* contents) OVERRIDE;
- virtual void LoadingStateChanged(content::WebContents* source,
- bool to_different_document) OVERRIDE;
- virtual void CloseContents(content::WebContents* source) OVERRIDE;
- virtual void MoveContents(content::WebContents* source,
- const gfx::Rect& pos) OVERRIDE;
- virtual bool IsPopupOrPanel(
- const content::WebContents* source) const OVERRIDE;
- virtual void UpdateTargetURL(content::WebContents* source,
- const GURL& url) OVERRIDE;
- virtual void ContentsMouseEvent(content::WebContents* source,
- const gfx::Point& location,
- bool motion) OVERRIDE;
- virtual void ContentsZoomChange(bool zoom_in) OVERRIDE;
- virtual void WebContentsFocused(content::WebContents* content) OVERRIDE;
- virtual bool TakeFocus(content::WebContents* source, bool reverse) OVERRIDE;
- virtual gfx::Rect GetRootWindowResizerRect() const OVERRIDE;
- virtual void BeforeUnloadFired(content::WebContents* source,
- bool proceed,
- bool* proceed_to_fire_unload) OVERRIDE;
- virtual bool ShouldFocusLocationBarByDefault(
- content::WebContents* source) OVERRIDE;
- virtual void SetFocusToLocationBar(bool select_all) OVERRIDE;
- virtual int GetExtraRenderViewHeight() const OVERRIDE;
- virtual void ViewSourceForTab(content::WebContents* source,
- const GURL& page_url) OVERRIDE;
- virtual void ViewSourceForFrame(
- content::WebContents* source,
- const GURL& frame_url,
- const content::PageState& frame_page_state) OVERRIDE;
- virtual void ShowRepostFormWarningDialog(
- content::WebContents* source) OVERRIDE;
- virtual bool ShouldCreateWebContents(
+ const content::OpenURLParams& params) override;
+ void NavigationStateChanged(const content::WebContents* source,
+ content::InvalidateTypes changed_flags) override;
+ void VisibleSSLStateChanged(const content::WebContents* source) override;
+ void AddNewContents(content::WebContents* source,
+ content::WebContents* new_contents,
+ WindowOpenDisposition disposition,
+ const gfx::Rect& initial_pos,
+ bool user_gesture,
+ bool* was_blocked) override;
+ void ActivateContents(content::WebContents* contents) override;
+ void DeactivateContents(content::WebContents* contents) override;
+ void LoadingStateChanged(content::WebContents* source,
+ bool to_different_document) override;
+ void CloseContents(content::WebContents* source) override;
+ void MoveContents(content::WebContents* source,
+ const gfx::Rect& pos) override;
+ bool IsPopupOrPanel(const content::WebContents* source) const override;
+ void UpdateTargetURL(content::WebContents* source, const GURL& url) override;
+ void ContentsMouseEvent(content::WebContents* source,
+ const gfx::Point& location,
+ bool motion) override;
+ void ContentsZoomChange(bool zoom_in) override;
+ void WebContentsFocused(content::WebContents* content) override;
+ bool TakeFocus(content::WebContents* source, bool reverse) override;
+ gfx::Rect GetRootWindowResizerRect() const override;
+ void BeforeUnloadFired(content::WebContents* source,
+ bool proceed,
+ bool* proceed_to_fire_unload) override;
+ bool ShouldFocusLocationBarByDefault(content::WebContents* source) override;
+ void SetFocusToLocationBar(bool select_all) override;
+ int GetExtraRenderViewHeight() const override;
+ void ViewSourceForTab(content::WebContents* source,
+ const GURL& page_url) override;
+ void ViewSourceForFrame(content::WebContents* source,
+ const GURL& frame_url,
+ const content::PageState& frame_page_state) override;
+ void ShowRepostFormWarningDialog(content::WebContents* source) override;
+ bool ShouldCreateWebContents(
content::WebContents* web_contents,
int route_id,
WindowContainerType window_container_type,
const base::string16& frame_name,
const GURL& target_url,
const std::string& partition_id,
- content::SessionStorageNamespace* session_storage_namespace) OVERRIDE;
- virtual void WebContentsCreated(content::WebContents* source_contents,
- int opener_render_frame_id,
- const base::string16& frame_name,
- const GURL& target_url,
- content::WebContents* new_contents) OVERRIDE;
- virtual void RendererUnresponsive(content::WebContents* source) OVERRIDE;
- virtual void RendererResponsive(content::WebContents* source) OVERRIDE;
- virtual void WorkerCrashed(content::WebContents* source) OVERRIDE;
- virtual void DidNavigateMainFramePostCommit(
- content::WebContents* web_contents) OVERRIDE;
- virtual void DidNavigateToPendingEntry(
- content::WebContents* web_contents) OVERRIDE;
- virtual content::JavaScriptDialogManager*
- GetJavaScriptDialogManager() OVERRIDE;
- virtual content::ColorChooser* OpenColorChooser(
+ content::SessionStorageNamespace* session_storage_namespace) override;
+ void WebContentsCreated(content::WebContents* source_contents,
+ int opener_render_frame_id,
+ const base::string16& frame_name,
+ const GURL& target_url,
+ content::WebContents* new_contents) override;
+ void RendererUnresponsive(content::WebContents* source) override;
+ void RendererResponsive(content::WebContents* source) override;
+ void WorkerCrashed(content::WebContents* source) override;
+ void DidNavigateMainFramePostCommit(
+ content::WebContents* web_contents) override;
+ void DidNavigateToPendingEntry(content::WebContents* web_contents) override;
+ content::JavaScriptDialogManager* GetJavaScriptDialogManager() override;
+ content::ColorChooser* OpenColorChooser(
content::WebContents* web_contents,
SkColor color,
- const std::vector<content::ColorSuggestion>& suggestions) OVERRIDE;
- virtual void RunFileChooser(
- content::WebContents* web_contents,
- const content::FileChooserParams& params) OVERRIDE;
- virtual void EnumerateDirectory(content::WebContents* web_contents,
- int request_id,
- const base::FilePath& path) OVERRIDE;
- virtual bool EmbedsFullscreenWidget() const OVERRIDE;
- virtual void ToggleFullscreenModeForTab(content::WebContents* web_contents,
- bool enter_fullscreen) OVERRIDE;
- virtual bool IsFullscreenForTabOrPending(
- const content::WebContents* web_contents) const OVERRIDE;
- virtual void RegisterProtocolHandler(content::WebContents* web_contents,
- const std::string& protocol,
- const GURL& url,
- bool user_gesture) OVERRIDE;
- virtual void UnregisterProtocolHandler(content::WebContents* web_contents,
- const std::string& protocol,
- const GURL& url,
- bool user_gesture) OVERRIDE;
- virtual void UpdatePreferredSize(content::WebContents* source,
- const gfx::Size& pref_size) OVERRIDE;
- virtual void ResizeDueToAutoResize(content::WebContents* source,
- const gfx::Size& new_size) OVERRIDE;
- virtual void FindReply(content::WebContents* web_contents,
- int request_id,
- int number_of_matches,
- const gfx::Rect& selection_rect,
- int active_match_ordinal,
- bool final_update) OVERRIDE;
- virtual void RequestToLockMouse(content::WebContents* web_contents,
- bool user_gesture,
- bool last_unlocked_by_target) OVERRIDE;
- virtual void LostMouseLock() OVERRIDE;
- virtual void RequestMediaAccessPermission(
+ const std::vector<content::ColorSuggestion>& suggestions) override;
+ void RunFileChooser(content::WebContents* web_contents,
+ const content::FileChooserParams& params) override;
+ void EnumerateDirectory(content::WebContents* web_contents,
+ int request_id,
+ const base::FilePath& path) override;
+ bool EmbedsFullscreenWidget() const override;
+ void ToggleFullscreenModeForTab(content::WebContents* web_contents,
+ bool enter_fullscreen) override;
+ bool IsFullscreenForTabOrPending(
+ const content::WebContents* web_contents) const override;
+ void RegisterProtocolHandler(content::WebContents* web_contents,
+ const std::string& protocol,
+ const GURL& url,
+ bool user_gesture) override;
+ void UnregisterProtocolHandler(content::WebContents* web_contents,
+ const std::string& protocol,
+ const GURL& url,
+ bool user_gesture) override;
+ void UpdatePreferredSize(content::WebContents* source,
+ const gfx::Size& pref_size) override;
+ void ResizeDueToAutoResize(content::WebContents* source,
+ const gfx::Size& new_size) override;
+ void FindReply(content::WebContents* web_contents,
+ int request_id,
+ int number_of_matches,
+ const gfx::Rect& selection_rect,
+ int active_match_ordinal,
+ bool final_update) override;
+ void RequestToLockMouse(content::WebContents* web_contents,
+ bool user_gesture,
+ bool last_unlocked_by_target) override;
+ void LostMouseLock() override;
+ void RequestMediaAccessPermission(
content::WebContents* web_contents,
const content::MediaStreamRequest& request,
- const content::MediaResponseCallback& callback) OVERRIDE;
- virtual bool CheckMediaAccessPermission(
- content::WebContents* web_contents,
- const GURL& security_origin,
- content::MediaStreamType type) OVERRIDE;
- virtual bool RequestPpapiBrokerPermission(
+ const content::MediaResponseCallback& callback) override;
+ bool CheckMediaAccessPermission(content::WebContents* web_contents,
+ const GURL& security_origin,
+ content::MediaStreamType type) override;
+ bool RequestPpapiBrokerPermission(
content::WebContents* web_contents,
const GURL& url,
const base::FilePath& plugin_path,
- const base::Callback<void(bool)>& callback) OVERRIDE;
- virtual gfx::Size GetSizeForNewRenderView(
- content::WebContents* web_contents) const OVERRIDE;
+ const base::Callback<void(bool)>& callback) override;
+ gfx::Size GetSizeForNewRenderView(
+ content::WebContents* web_contents) const override;
// Overridden from CoreTabHelperDelegate:
// Note that the caller is responsible for deleting |old_contents|.
- virtual void SwapTabContents(content::WebContents* old_contents,
- content::WebContents* new_contents,
- bool did_start_load,
- bool did_finish_load) OVERRIDE;
- virtual bool CanReloadContents(
- content::WebContents* web_contents) const OVERRIDE;
- virtual bool CanSaveContents(
- content::WebContents* web_contents) const OVERRIDE;
+ void SwapTabContents(content::WebContents* old_contents,
+ content::WebContents* new_contents,
+ bool did_start_load,
+ bool did_finish_load) override;
+ bool CanReloadContents(content::WebContents* web_contents) const override;
+ bool CanSaveContents(content::WebContents* web_contents) const override;
// Overridden from SearchEngineTabHelperDelegate:
- virtual void ConfirmAddSearchProvider(TemplateURL* template_url,
- Profile* profile) OVERRIDE;
+ 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;
+ void NavigateOnThumbnailClick(const GURL& url,
+ WindowOpenDisposition disposition,
+ content::WebContents* source_contents) override;
+ void OnWebContentsInstantSupportDisabled(
+ const content::WebContents* web_contents) override;
+ OmniboxView* GetOmniboxView() override;
+ std::set<std::string> GetOpenUrls() override;
// Overridden from WebContentsModalDialogManagerDelegate:
- virtual void SetWebContentsBlocked(content::WebContents* web_contents,
- bool blocked) OVERRIDE;
- virtual web_modal::WebContentsModalDialogHost*
- GetWebContentsModalDialogHost() OVERRIDE;
+ void SetWebContentsBlocked(content::WebContents* web_contents,
+ bool blocked) override;
+ web_modal::WebContentsModalDialogHost* GetWebContentsModalDialogHost()
+ override;
// Overridden from BookmarkTabHelperDelegate:
- virtual void URLStarredChanged(content::WebContents* web_contents,
- bool starred) OVERRIDE;
+ void URLStarredChanged(content::WebContents* web_contents,
+ bool starred) override;
// Overridden from ZoomObserver:
- virtual void OnZoomChanged(
- const ZoomController::ZoomChangedEventData& data) OVERRIDE;
+ void OnZoomChanged(const ZoomController::ZoomChangedEventData& data) override;
// Overridden from SelectFileDialog::Listener:
- virtual void FileSelected(const base::FilePath& path,
- int index,
- void* params) OVERRIDE;
- virtual void FileSelectedWithExtraInfo(
- const ui::SelectedFileInfo& file_info,
- int index,
- void* params) OVERRIDE;
+ void FileSelected(const base::FilePath& path,
+ int index,
+ void* params) override;
+ void FileSelectedWithExtraInfo(const ui::SelectedFileInfo& file_info,
+ int index,
+ void* params) override;
// Overridden from content::NotificationObserver:
- virtual void Observe(int type,
- const content::NotificationSource& source,
- const content::NotificationDetails& details) OVERRIDE;
+ void Observe(int type,
+ const content::NotificationSource& source,
+ const content::NotificationDetails& details) override;
+
+#if defined(ENABLE_EXTENSIONS)
+ // Overridden from extensions::ExtensionRegistryObserver:
+ void OnExtensionUninstalled(content::BrowserContext* browser_context,
+ const extensions::Extension* extension,
+ extensions::UninstallReason reason) override;
+ void OnExtensionLoaded(content::BrowserContext* browser_context,
+ const extensions::Extension* extension) override;
+ void OnExtensionUnloaded(
+ content::BrowserContext* browser_context,
+ const extensions::Extension* extension,
+ extensions::UnloadedExtensionInfo::Reason reason) override;
+#endif
// Command and state updating ///////////////////////////////////////////////
// the LocationBarView's edit.
friend class AutomationProvider;
friend class BrowserProxy;
- friend class TestingAutomationProvider;
// Returns the StatusBubble from the current toolbar. It is possible for
// this to return NULL if called before the toolbar has initialized.
content::NotificationRegistrar registrar_;
+#if defined(ENABLE_EXTENSIONS)
+ ScopedObserver<extensions::ExtensionRegistry,
+ extensions::ExtensionRegistryObserver>
+ extension_registry_observer_;
+#endif
+
PrefChangeRegistrar profile_pref_registrar_;
// This Browser's type.