| Index: chrome/browser/sidebar/sidebar_container.cc
|
| ===================================================================
|
| --- chrome/browser/sidebar/sidebar_container.cc (revision 74134)
|
| +++ chrome/browser/sidebar/sidebar_container.cc (working copy)
|
| @@ -11,6 +11,7 @@
|
| #include "chrome/browser/tab_contents/navigation_entry.h"
|
| #include "chrome/browser/tab_contents/tab_contents.h"
|
| #include "chrome/browser/tab_contents/tab_contents_view.h"
|
| +#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
|
| #include "chrome/common/bindings_policy.h"
|
| #include "chrome/common/extensions/extension.h"
|
| #include "chrome/common/extensions/extension_resource.h"
|
| @@ -19,7 +20,7 @@
|
| #include "googleurl/src/gurl.h"
|
| #include "third_party/skia/include/core/SkBitmap.h"
|
|
|
| -SidebarContainer::SidebarContainer(TabContents* tab,
|
| +SidebarContainer::SidebarContainer(TabContentsWrapper* tab,
|
| const std::string& content_id,
|
| Delegate* delegate)
|
| : tab_(tab),
|
| @@ -41,7 +42,7 @@
|
| }
|
|
|
| void SidebarContainer::SidebarClosing() {
|
| - delegate_->UpdateSidebar(this);
|
| + NotifyUpdate(SidebarChangedDetails::SIDEBAR_STATE_CHANGED);
|
| }
|
|
|
| void SidebarContainer::LoadDefaults() {
|
| @@ -65,7 +66,7 @@
|
| }
|
|
|
| void SidebarContainer::Show() {
|
| - delegate_->UpdateSidebar(this);
|
| + NotifyUpdate(SidebarChangedDetails::SIDEBAR_STATE_CHANGED);
|
| }
|
|
|
| void SidebarContainer::Expand() {
|
| @@ -79,47 +80,79 @@
|
| }
|
| }
|
|
|
| - delegate_->UpdateSidebar(this);
|
| + NotifyUpdate(SidebarChangedDetails::SIDEBAR_STATE_CHANGED);
|
| sidebar_contents_->view()->SetInitialFocus();
|
| }
|
|
|
| void SidebarContainer::Collapse() {
|
| - delegate_->UpdateSidebar(this);
|
| + NotifyUpdate(SidebarChangedDetails::SIDEBAR_STATE_CHANGED);
|
| }
|
|
|
| void SidebarContainer::Navigate(const GURL& url) {
|
| - // TODO(alekseys): add a progress UI.
|
| navigate_to_default_page_on_expand_ = false;
|
| sidebar_contents_->controller().LoadURL(
|
| url, GURL(), PageTransition::START_PAGE);
|
| }
|
|
|
| void SidebarContainer::SetBadgeText(const string16& badge_text) {
|
| - badge_text_ = badge_text;
|
| + if (badge_text_ != badge_text) {
|
| + badge_text_ = badge_text;
|
| + NotifyUpdate(SidebarChangedDetails::SIDEBAR_PROPS_CHANGED);
|
| + }
|
| }
|
|
|
| void SidebarContainer::SetIcon(const SkBitmap& bitmap) {
|
| use_default_icon_ = false;
|
| *icon_ = bitmap;
|
| + NotifyUpdate(SidebarChangedDetails::SIDEBAR_PROPS_CHANGED);
|
| }
|
|
|
| void SidebarContainer::SetTitle(const string16& title) {
|
| - title_ = title;
|
| + if (title_ != title) {
|
| + title_ = title;
|
| + NotifyUpdate(SidebarChangedDetails::SIDEBAR_PROPS_CHANGED);
|
| + }
|
| }
|
|
|
| -bool SidebarContainer::IsPopup(const TabContents* source) const {
|
| - return false;
|
| +// TabContentsDelegate overrides.
|
| +void SidebarContainer::NavigationStateChanged(const TabContents* source,
|
| + unsigned changed_flags) {
|
| + if (changed_flags & TabContents::INVALIDATE_TAB)
|
| + NotifyUpdate(SidebarChangedDetails::SIDEBAR_PROPS_CHANGED);
|
| + if (changed_flags & TabContents::INVALIDATE_LOAD)
|
| + NotifyUpdate(SidebarChangedDetails::SIDEBAR_LOADING_STATE_CHANGED);
|
| }
|
|
|
| +bool SidebarContainer::PreHandleKeyboardEvent(
|
| + const NativeWebKeyboardEvent& event,
|
| + bool* is_keyboard_shortcut) {
|
| + return tab_->tab_contents()->delegate()->PreHandleKeyboardEvent(
|
| + event, is_keyboard_shortcut);
|
| +}
|
| +
|
| +void SidebarContainer::HandleKeyboardEvent(
|
| + const NativeWebKeyboardEvent& event) {
|
| + return tab_->tab_contents()->delegate()->HandleKeyboardEvent(event);
|
| +}
|
| +
|
| +// ImageLoadingTracker::Observer overrides.
|
| void SidebarContainer::OnImageLoaded(SkBitmap* image,
|
| ExtensionResource resource,
|
| int index) {
|
| if (image && use_default_icon_) {
|
| *icon_ = *image;
|
| - delegate_->UpdateSidebar(this);
|
| + NotifyUpdate(SidebarChangedDetails::SIDEBAR_PROPS_CHANGED);
|
| }
|
| }
|
|
|
| +void SidebarContainer::NotifyUpdate(
|
| + SidebarChangedDetails::UpdateType update_type) {
|
| + SidebarChangedDetails details;
|
| + details.source = this;
|
| + details.update_type = update_type;
|
| + delegate_->UpdateSidebar(&details);
|
| +}
|
| +
|
| const Extension* SidebarContainer::GetExtension() const {
|
| ExtensionService* service =
|
| sidebar_contents_->profile()->GetExtensionService();
|
|
|