diff options
author | finnur@chromium.org <finnur@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-06 16:46:11 +0000 |
---|---|---|
committer | finnur@chromium.org <finnur@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-06 16:46:11 +0000 |
commit | ce5c4504531cfd32972dfd123f98183c3706951a (patch) | |
tree | 679f14d1ea5738a6bedb752a4c61b7f3c50efde1 /chrome/browser/tab_contents | |
parent | aec92f83d096ca57ab6ce515ae7063b8081b630e (diff) | |
download | chromium_src-ce5c4504531cfd32972dfd123f98183c3706951a.zip chromium_src-ce5c4504531cfd32972dfd123f98183c3706951a.tar.gz chromium_src-ce5c4504531cfd32972dfd123f98183c3706951a.tar.bz2 |
PageActions now work across tabs and windows.
The extension system now provides TabId to extensions so it is now possible to activate PageActions in other tabs besides the first in the tab strip. :)
BUG=None
TEST=None (requires a PageAction extension to test against).
Review URL: http://codereview.chromium.org/109046
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@15415 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/tab_contents')
-rw-r--r-- | chrome/browser/tab_contents/tab_contents.cc | 26 | ||||
-rw-r--r-- | chrome/browser/tab_contents/tab_contents.h | 16 |
2 files changed, 36 insertions, 6 deletions
diff --git a/chrome/browser/tab_contents/tab_contents.cc b/chrome/browser/tab_contents/tab_contents.cc index 83c49c6..995447d 100644 --- a/chrome/browser/tab_contents/tab_contents.cc +++ b/chrome/browser/tab_contents/tab_contents.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2009 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -32,18 +32,17 @@ #include "chrome/browser/renderer_host/render_widget_host_view.h" #include "chrome/browser/renderer_host/web_cache_manager.h" #include "chrome/browser/tab_contents/navigation_entry.h" -#include "chrome/browser/tab_contents/tab_contents.h" #include "chrome/browser/tab_contents/tab_contents_delegate.h" #include "chrome/browser/tab_contents/tab_contents_view.h" #include "chrome/browser/search_engines/template_url_fetcher.h" #include "chrome/browser/search_engines/template_url_model.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/notification_service.h" +#include "chrome/common/page_action.h" #include "chrome/common/pref_names.h" #include "chrome/common/pref_service.h" #include "chrome/common/render_messages.h" #include "chrome/common/url_constants.h" -//#include "grit/generated_resources.h" #include "grit/locale_settings.h" #include "net/base/mime_util.h" #include "net/base/net_errors.h" @@ -253,7 +252,6 @@ TabContents::TabContents(Profile* profile, #endif last_javascript_message_dismissal_(), suppress_javascript_messages_(false) { - pending_install_.page_id = 0; pending_install_.callback_functor = NULL; @@ -583,6 +581,21 @@ void TabContents::SetIsCrashed(bool state) { NotifyNavigationStateChanged(INVALIDATE_TAB); } +void TabContents::EnablePageAction(const PageAction* page_action) { + DCHECK(page_action); + + if (IsPageActionEnabled(page_action)) + return; // Already enabled. + + enabled_page_actions_.insert(page_action); +} + +bool TabContents::IsPageActionEnabled(const PageAction* page_action) { + DCHECK(page_action); + return enabled_page_actions_.end() != enabled_page_actions_.find(page_action); +} + + void TabContents::NotifyNavigationStateChanged(unsigned changed_flags) { if (delegate_) delegate_->NavigationStateChanged(this, changed_flags); @@ -1153,7 +1166,7 @@ void TabContents::SetIsLoading(bool is_loading, NotificationType type = is_loading ? NotificationType::LOAD_START : NotificationType::LOAD_STOP; - NotificationDetails det = NotificationService::NoDetails();; + NotificationDetails det = NotificationService::NoDetails(); if (details) det = Details<LoadNotificationDetails>(details); NotificationService::current()->Notify(type, @@ -1314,6 +1327,9 @@ void TabContents::DidNavigateMainFramePostCommit( // Get the favicon, either from history or request it from the net. fav_icon_helper_.FetchFavIcon(details.entry->url()); + // Disable all page actions. + enabled_page_actions_.clear(); + // Close constrained popups if necessary. MaybeCloseChildWindows(details.previous_url, details.entry->url()); diff --git a/chrome/browser/tab_contents/tab_contents.h b/chrome/browser/tab_contents/tab_contents.h index 1a83d8c..59549c4 100644 --- a/chrome/browser/tab_contents/tab_contents.h +++ b/chrome/browser/tab_contents/tab_contents.h @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2009 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -8,6 +8,7 @@ #include "build/build_config.h" #include <map> +#include <set> #include <string> #include <vector> @@ -67,6 +68,7 @@ class DOMUIContents; class DownloadItem; class DownloadShelf; class LoadNotificationDetails; +class PageAction; class PasswordManager; class PluginInstaller; class Profile; @@ -245,6 +247,11 @@ class TabContents : public PageNavigator, bool is_crashed() const { return is_crashed_; } void SetIsCrashed(bool state); + // Adds a page action to the list of page actions that are active in this tab. + void EnablePageAction(const PageAction* page_action); + // Checks to see if the PageAction should be visible in this tab. + bool IsPageActionEnabled(const PageAction* page_action); + // Whether the tab is in the process of being destroyed. // Added as a tentative work-around for focus related bug #4633. This allows // us not to store focus when a tab is being closed. @@ -1025,6 +1032,13 @@ class TabContents : public PageNavigator, // information to build its presentation. FindNotificationDetails find_result_; + // Data for Page Actions ----------------------------------------------------- + + // A set of page actions that are enabled in this tab. This list is cleared + // every time the mainframe navigates and populated by the PageAction + // extension API. + std::set<const PageAction*> enabled_page_actions_; + // Data for misc internal state ---------------------------------------------- // See capturing_contents() above. |