diff options
-rw-r--r-- | build/common.gypi | 4 | ||||
-rw-r--r-- | chrome/browser/chrome_browser_main.cc | 4 | ||||
-rw-r--r-- | chrome/browser/ui/views/aura/chrome_shell_delegate.cc | 35 | ||||
-rw-r--r-- | chrome/browser/ui/views/aura/chrome_shell_delegate.h | 29 | ||||
-rw-r--r-- | chrome/browser/ui/views/aura/launcher_icon_updater.cc | 109 | ||||
-rw-r--r-- | chrome/browser/ui/views/aura/launcher_icon_updater.h | 62 | ||||
-rw-r--r-- | chrome/browser/ui/views/frame/browser_view.cc | 24 | ||||
-rw-r--r-- | chrome/browser/ui/views/frame/browser_view.h | 12 | ||||
-rw-r--r-- | chrome/chrome_browser.gypi | 5 | ||||
-rw-r--r-- | ui/aura/window.cc | 5 | ||||
-rw-r--r-- | ui/aura/window_observer.h | 5 | ||||
-rw-r--r-- | ui/aura_shell/launcher/launcher.cc | 37 | ||||
-rw-r--r-- | ui/aura_shell/launcher/launcher.h | 14 | ||||
-rw-r--r-- | ui/aura_shell/launcher/launcher_model.cc | 16 | ||||
-rw-r--r-- | ui/aura_shell/launcher/launcher_model.h | 9 | ||||
-rw-r--r-- | ui/aura_shell/launcher/launcher_view.cc | 13 | ||||
-rw-r--r-- | ui/gfx/compositor/layer.h | 1 | ||||
-rw-r--r-- | ui/ui.gyp | 4 | ||||
-rw-r--r-- | views/widget/native_widget_aura.cc | 25 | ||||
-rw-r--r-- | views/widget/native_widget_aura.h | 14 |
20 files changed, 392 insertions, 35 deletions
diff --git a/build/common.gypi b/build/common.gypi index 25816560..92c2da0 100644 --- a/build/common.gypi +++ b/build/common.gypi @@ -1272,7 +1272,9 @@ 'sources/': [ ['exclude', '_views\\.(h|cc)$'] ] }], ['use_aura==0', { - 'sources/': [ ['exclude', '_aura\\.(h|cc)$'] ] + 'sources/': [ ['exclude', '_aura\\.(h|cc)$'], + ['exclude', '(^|/)aura/'], + ] }], ['use_aura==0 or use_x11==0', { 'sources/': [ ['exclude', '_aurax11\\.(h|cc)$'] ] diff --git a/chrome/browser/chrome_browser_main.cc b/chrome/browser/chrome_browser_main.cc index 83ac7034..225fc5a 100644 --- a/chrome/browser/chrome_browser_main.cc +++ b/chrome/browser/chrome_browser_main.cc @@ -201,6 +201,7 @@ #endif #if defined(USE_AURA) +#include "chrome/browser/ui/views/aura/chrome_shell_delegate.h" #include "ui/aura/desktop.h" #include "ui/aura_shell/shell.h" #endif @@ -1366,7 +1367,8 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunInternal() { child_process_logging::SetCommandLine(CommandLine::ForCurrentProcess()); #if defined(USE_AURA) - aura_shell::Shell::GetInstance(); + // Shell takes ownership of ChromeShellDelegate. + aura_shell::Shell::GetInstance()->SetDelegate(new ChromeShellDelegate); #elif defined(TOOLKIT_VIEWS) views::Widget::SetPureViews( CommandLine::ForCurrentProcess()->HasSwitch(switches::kUsePureViews)); diff --git a/chrome/browser/ui/views/aura/chrome_shell_delegate.cc b/chrome/browser/ui/views/aura/chrome_shell_delegate.cc new file mode 100644 index 0000000..b3c7d40 --- /dev/null +++ b/chrome/browser/ui/views/aura/chrome_shell_delegate.cc @@ -0,0 +1,35 @@ +// Copyright (c) 2011 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. + +#include "chrome/browser/ui/views/aura/chrome_shell_delegate.h" + +#include "chrome/browser/ui/browser.h" +#include "chrome/browser/ui/views/frame/browser_view.h" +#include "ui/aura_shell/launcher/launcher_types.h" + +ChromeShellDelegate::ChromeShellDelegate() { +} + +ChromeShellDelegate::~ChromeShellDelegate() { +} + +void ChromeShellDelegate::CreateNewWindow() { +} + +void ChromeShellDelegate::ShowApps() { +} + +void ChromeShellDelegate::LauncherItemClicked( + const aura_shell::LauncherItem& item) { +} + +bool ChromeShellDelegate::ConfigureLauncherItem( + aura_shell::LauncherItem* item) { + BrowserView* view = BrowserView::GetBrowserViewForNativeWindow(item->window); + if (!view) + return false; + item->type = (view->browser()->type() == Browser::TYPE_TABBED) ? + aura_shell::TYPE_TABBED : aura_shell::TYPE_APP; + return true; +} diff --git a/chrome/browser/ui/views/aura/chrome_shell_delegate.h b/chrome/browser/ui/views/aura/chrome_shell_delegate.h new file mode 100644 index 0000000..5eff4a9 --- /dev/null +++ b/chrome/browser/ui/views/aura/chrome_shell_delegate.h @@ -0,0 +1,29 @@ +// Copyright (c) 2011 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. + +#ifndef CHROME_BROWSER_UI_VIEWS_AURA_CHROME_SHELL_DELEGATE_H_ +#define CHROME_BROWSER_UI_VIEWS_AURA_CHROME_SHELL_DELEGATE_H_ +#pragma once + +#include "base/basictypes.h" +#include "base/compiler_specific.h" +#include "ui/aura_shell/shell_delegate.h" + +class ChromeShellDelegate : public aura_shell::ShellDelegate { + public: + ChromeShellDelegate(); + virtual ~ChromeShellDelegate(); + + // aura_shell::ShellDelegate overrides; + virtual void CreateNewWindow() OVERRIDE; + virtual void ShowApps() OVERRIDE; + virtual void LauncherItemClicked( + const aura_shell::LauncherItem& item) OVERRIDE; + virtual bool ConfigureLauncherItem(aura_shell::LauncherItem* item) OVERRIDE; + + private: + DISALLOW_COPY_AND_ASSIGN(ChromeShellDelegate); +}; + +#endif // CHROME_BROWSER_UI_VIEWS_AURA_CHROME_SHELL_DELEGATE_H_ diff --git a/chrome/browser/ui/views/aura/launcher_icon_updater.cc b/chrome/browser/ui/views/aura/launcher_icon_updater.cc new file mode 100644 index 0000000..4bff5ca9 --- /dev/null +++ b/chrome/browser/ui/views/aura/launcher_icon_updater.cc @@ -0,0 +1,109 @@ +// Copyright (c) 2011 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. + +#include "chrome/browser/ui/views/aura/launcher_icon_updater.h" + +#include <algorithm> + +#include "chrome/browser/favicon/favicon_tab_helper.h" +#include "chrome/browser/tabs/tab_strip_model.h" +#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" +#include "grit/ui_resources.h" +#include "ui/aura_shell/launcher/launcher_model.h" +#include "ui/aura/window.h" +#include "ui/base/resource/resource_bundle.h" + +// Max number of tabs we'll send icons over for. +const int kMaxCount = 3; + +LauncherIconUpdater::LauncherIconUpdater( + TabStripModel* tab_model, + aura_shell::LauncherModel* launcher_model, + aura::Window* window) + : tab_model_(tab_model), + launcher_model_(launcher_model), + window_(window) { + tab_model->AddObserver(this); + if (tab_model->GetActiveTabContents()) + tabs_.push_front(tab_model->GetActiveTabContents()); + for (int i = 0; i < tab_model->count(); ++i) { + if (i != tab_model->active_index()) + tabs_.push_back(tab_model->GetTabContentsAt(i)); + } + UpdateLauncher(); +} + +LauncherIconUpdater::~LauncherIconUpdater() { + tab_model_->RemoveObserver(this); +} + +void LauncherIconUpdater::TabInsertedAt(TabContentsWrapper* contents, + int index, + bool foreground) { + if (std::find(tabs_.begin(), tabs_.end(), contents) == tabs_.end()) + tabs_.push_back(contents); +} + +void LauncherIconUpdater::TabDetachedAt(TabContentsWrapper* contents, + int index) { + Tabs::iterator i = std::find(tabs_.begin(), tabs_.end(), contents); + bool update = i != tabs_.end() ? (i - tabs_.begin()) < kMaxCount : false; + if (i != tabs_.end()) + tabs_.erase(i); + if (update) + UpdateLauncher(); +} + +void LauncherIconUpdater::TabSelectionChanged( + TabStripModel* tab_strip_model, + const TabStripSelectionModel& old_model) { + TabContentsWrapper* tab = tab_strip_model->GetActiveTabContents(); + if (!tab) + return; + + Tabs::iterator i = std::find(tabs_.begin(), tabs_.end(), tab); + if (i == tabs_.begin()) + return; // The active tab didn't change, ignore it. + + // Move the active tab to the front. + if (i != tabs_.end()) + tabs_.erase(i); + tabs_.push_front(tab); + UpdateLauncher(); +} + +void LauncherIconUpdater::TabChangedAt( + TabContentsWrapper* tab, + int index, + TabStripModelObserver::TabChangeType change_type) { + if (change_type != TabStripModelObserver::LOADING_ONLY && + change_type != TabStripModelObserver::TITLE_NOT_LOADING) { + Tabs::iterator i = std::find(tabs_.begin(), tabs_.end(), tab); + if (i != tabs_.end() && (i - tabs_.begin()) < kMaxCount) + UpdateLauncher(); + } +} + +void LauncherIconUpdater::UpdateLauncher() { + if (tabs_.empty()) + return; // Assume the window is going to be closed if there are no tabs. + + int item_index = launcher_model_->ItemIndexByWindow(window_); + if (item_index == -1) + return; + + aura_shell::LauncherTabbedImages images; + size_t count = std::min(static_cast<size_t>(kMaxCount), tabs_.size()); + images.resize(count); + for (size_t i = 0; i < count; ++i) { + // TODO: needs to be updated for apps. + images[i].image = tabs_[i]->favicon_tab_helper()->GetFavicon(); + if (images[i].image.empty()) { + images[i].image = *ResourceBundle::GetSharedInstance().GetBitmapNamed( + IDR_DEFAULT_FAVICON); + } + images[i].user_data = tabs_[i]; + } + launcher_model_->SetTabbedImages(item_index, images); +} diff --git a/chrome/browser/ui/views/aura/launcher_icon_updater.h b/chrome/browser/ui/views/aura/launcher_icon_updater.h new file mode 100644 index 0000000..8b642ee --- /dev/null +++ b/chrome/browser/ui/views/aura/launcher_icon_updater.h @@ -0,0 +1,62 @@ +// Copyright (c) 2011 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. + +#ifndef CHROME_BROWSER_UI_VIEWS_AURA_LAUNCHER_ICON_UPDATER_H_ +#define CHROME_BROWSER_UI_VIEWS_AURA_LAUNCHER_ICON_UPDATER_H_ +#pragma once + +#include <deque> + +#include "base/basictypes.h" +#include "base/compiler_specific.h" +#include "chrome/browser/tabs/tab_strip_model_observer.h" + +namespace aura { +class Window; +} +namespace aura_shell { +class LauncherModel; +} + +// LauncherIconUpdater is responsible for keeping the launcher representation +// of a window up to date with the tabs. +class LauncherIconUpdater : public TabStripModelObserver { + public: + LauncherIconUpdater(TabStripModel* tab_model, + aura_shell::LauncherModel* launcher_model, + aura::Window* window); + virtual ~LauncherIconUpdater(); + + // TabStripModel overrides: + virtual void TabInsertedAt(TabContentsWrapper* contents, + int index, + bool foreground) OVERRIDE; + virtual void TabDetachedAt(TabContentsWrapper* contents, int index) OVERRIDE; + virtual void TabSelectionChanged( + TabStripModel* tab_strip_model, + const TabStripSelectionModel& old_model) OVERRIDE; + virtual void TabChangedAt( + TabContentsWrapper* tab, + int index, + TabStripModelObserver::TabChangeType change_type) OVERRIDE; + + private: + typedef std::deque<TabContentsWrapper*> Tabs; + + // Updates the launcher from the current set of tabs. + void UpdateLauncher(); + + TabStripModel* tab_model_; + + aura_shell::LauncherModel* launcher_model_; + + aura::Window* window_; + + // The tabs. This is an MRU cache of the tabs in the tabstrip model. + Tabs tabs_; + + DISALLOW_COPY_AND_ASSIGN(LauncherIconUpdater); +}; + +#endif // CHROME_BROWSER_UI_VIEWS_AURA_LAUNCHER_ICON_UPDATER_H_ diff --git a/chrome/browser/ui/views/frame/browser_view.cc b/chrome/browser/ui/views/frame/browser_view.cc index 950c85d..e970b7c 100644 --- a/chrome/browser/ui/views/frame/browser_view.cc +++ b/chrome/browser/ui/views/frame/browser_view.cc @@ -105,11 +105,15 @@ #include "views/window/dialog_delegate.h" #if defined(USE_AURA) +#include "chrome/browser/ui/views/aura/launcher_icon_updater.h" +#include "ui/aura_shell/launcher/launcher.h" +#include "ui/aura_shell/launcher/launcher_model.h" +#include "ui/aura_shell/shell.h" +#include "ui/base/view_prop.h" #elif defined(OS_WIN) #include "chrome/browser/aeropeek_manager.h" #include "chrome/browser/jumplist_win.h" #include "ui/base/message_box_win.h" -#include "ui/base/view_prop.h" #include "views/widget/native_widget_win.h" #elif defined(TOOLKIT_USES_GTK) #include "chrome/browser/ui/views/accelerator_table_linux.h" @@ -125,6 +129,10 @@ #include "chrome/browser/ui/views/download/download_shelf_view.h" #endif +#if defined(OS_WIN) && !defined(USE_AURA) +#include "ui/base/view_prop.h" +#endif + #if defined(TOUCH_UI) #include "chrome/browser/ui/touch/status_bubble_touch.h" #endif @@ -366,13 +374,12 @@ BrowserView::~BrowserView() { browser_.reset(); } -// Tab dragging code on windows needs this. -#if defined(OS_WIN) && !defined(USE_AURA) +#if defined(OS_WIN) || defined(USE_AURA) // static BrowserView* BrowserView::GetBrowserViewForNativeWindow( gfx::NativeWindow window) { - return IsWindow(window) ? reinterpret_cast<BrowserView*>( - ui::ViewProp::GetValue(window, kBrowserViewKey)) : NULL; + return reinterpret_cast<BrowserView*>( + ui::ViewProp::GetValue(window, kBrowserViewKey)); } #endif @@ -1920,6 +1927,13 @@ void BrowserView::Init() { // We're now initialized and ready to process Layout requests. ignore_layout_ = false; + +#if defined(USE_AURA) + icon_updater_.reset(new LauncherIconUpdater( + browser_->tabstrip_model(), + aura_shell::Shell::GetInstance()->launcher()->model(), + frame_->GetNativeWindow())); +#endif } void BrowserView::LoadingAnimationCallback() { diff --git a/chrome/browser/ui/views/frame/browser_view.h b/chrome/browser/ui/views/frame/browser_view.h index 0753da1..6622021 100644 --- a/chrome/browser/ui/views/frame/browser_view.h +++ b/chrome/browser/ui/views/frame/browser_view.h @@ -46,6 +46,7 @@ class BrowserViewLayout; class ContentsContainer; class DownloadShelfView; class EncodingMenuModel; +class Extension; class FullscreenExitBubbleViews; class HtmlDialogUIDelegate; class InfoBarContainerView; @@ -56,13 +57,16 @@ class TabContentsContainer; class TabStripModel; class ToolbarView; class ZoomMenuModel; -class Extension; #if defined(OS_WIN) class AeroPeekManager; class JumpList; #endif +#if defined(USE_AURA) +class LauncherIconUpdater; +#endif + namespace views { class ExternalFocusTracker; class Menu; @@ -95,7 +99,7 @@ class BrowserView : public BrowserBubbleHost, void set_frame(BrowserFrame* frame) { frame_ = frame; } BrowserFrame* frame() const { return frame_; } -#if defined(OS_WIN) && !defined(USE_AURA) +#if defined(OS_WIN) || defined(USE_AURA) // Returns a pointer to the BrowserView* interface implementation (an // instance of this object, typically) for a given native window, or NULL if // there is no such association. @@ -684,6 +688,10 @@ class BrowserView : public BrowserBubbleHost, scoped_ptr<AeroPeekManager> aeropeek_manager_; #endif +#if defined(USE_AURA) + scoped_ptr<LauncherIconUpdater> icon_updater_; +#endif + // The timer used to update frames for the Loading Animation. base::RepeatingTimer<BrowserView> loading_animation_timer_; diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index f52c526..55ff343 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -3225,6 +3225,10 @@ 'browser/ui/views/app_menu_button_win.h', 'browser/ui/views/appcache_info_view.cc', 'browser/ui/views/appcache_info_view.h', + 'browser/ui/views/aura/chrome_shell_delegate.cc', + 'browser/ui/views/aura/chrome_shell_delegate.h', + 'browser/ui/views/aura/launcher_icon_updater.cc', + 'browser/ui/views/aura/launcher_icon_updater.h', 'browser/ui/views/autocomplete/autocomplete_popup_contents_view.cc', 'browser/ui/views/autocomplete/autocomplete_popup_contents_view.h', 'browser/ui/views/autocomplete/autocomplete_result_view.cc', @@ -5057,6 +5061,7 @@ ['exclude', '^browser/process_singleton_linux.cc'], ['exclude', '^browser/ui/input_window_dialog.h'], ['exclude', '^browser/ui/input_window_dialog_win.cc'], + ['include', '^browser/ui/views/aura/'], ['include', '^browser/ui/views/browser_bubble_aura.cc'], ['include', '^browser/ui/views/constrained_html_delegate_views.cc'], ['include', '^browser/ui/views/constrained_window_views.cc'], diff --git a/ui/aura/window.cc b/ui/aura/window.cc index b14f2f3..9fa858e 100644 --- a/ui/aura/window.cc +++ b/ui/aura/window.cc @@ -389,6 +389,9 @@ internal::RootWindow* Window::GetRoot() { } void Window::SetVisible(bool visible) { + if (visible == layer_->visible()) + return; // No change. + bool was_visible = IsVisible(); layer_->SetVisible(visible); bool is_visible = IsVisible(); @@ -397,6 +400,8 @@ void Window::SetVisible(bool visible) { if (delegate_) delegate_->OnWindowVisibilityChanged(is_visible); } + FOR_EACH_OBSERVER(WindowObserver, observers_, + OnWindowVisibilityChanged(this, is_visible)); } void Window::SchedulePaint() { diff --git a/ui/aura/window_observer.h b/ui/aura/window_observer.h index fd71a5f..224f0d0 100644 --- a/ui/aura/window_observer.h +++ b/ui/aura/window_observer.h @@ -20,6 +20,11 @@ class AURA_EXPORT WindowObserver { // Invoked prior to removing |window|. virtual void OnWillRemoveWindow(Window* window) {} + // Invoked when the SetVisible() is invoked on a window. |visible| is the + // value supplied to SetVisible(). If |visible| is true, window->IsVisible() + // may still return false. See description in Window::IsVisible() for details. + virtual void OnWindowVisibilityChanged(Window* window, bool visibile) {} + protected: virtual ~WindowObserver() {} }; diff --git a/ui/aura_shell/launcher/launcher.cc b/ui/aura_shell/launcher/launcher.cc index 5cb6a13..d2551cd 100644 --- a/ui/aura_shell/launcher/launcher.cc +++ b/ui/aura_shell/launcher/launcher.cc @@ -43,25 +43,44 @@ Launcher::~Launcher() { window_container_->RemoveObserver(this); } -void Launcher::OnWindowAdded(aura::Window* new_window) { +void Launcher::MaybeAdd(aura::Window* window) { + if (known_windows_[window] == true) + return; // We already tried to add this window. + + known_windows_[window] = true; ShellDelegate* delegate = Shell::GetInstance()->delegate(); if (!delegate) return; LauncherItem item; - item.window = new_window; + item.window = window; if (!delegate->ConfigureLauncherItem(&item)) return; // The delegate doesn't want to show this item in the launcher. model_->Add(model_->items().size(), item); } +void Launcher::OnWindowAdded(aura::Window* new_window) { + DCHECK(known_windows_.find(new_window) == known_windows_.end()); + known_windows_[new_window] = false; + new_window->AddObserver(this); + // Windows are created initially invisible. Wait until the window is made + // visible before asking, as othewise the delegate likely doesn't know about + // window (it's still creating it). + if (new_window->IsVisible()) + MaybeAdd(new_window); +} + void Launcher::OnWillRemoveWindow(aura::Window* window) { - const LauncherItems& items(model_->items()); - for (LauncherItems::const_iterator i = items.begin(); i != items.end(); ++i) { - if (i->window == window) { - model_->RemoveItemAt(i - items.begin()); - break; - } - } + window->RemoveObserver(this); + known_windows_.erase(window); + LauncherItems::const_iterator i = model_->ItemByWindow(window); + if (i != model_->items().end()) + model_->RemoveItemAt(i - model_->items().begin()); +} + +void Launcher::OnWindowVisibilityChanged(aura::Window* window, + bool visibile) { + if (visibile && !known_windows_[window]) + MaybeAdd(window); } } // namespace aura_shell diff --git a/ui/aura_shell/launcher/launcher.h b/ui/aura_shell/launcher/launcher.h index 0dda152..a1c97de 100644 --- a/ui/aura_shell/launcher/launcher.h +++ b/ui/aura_shell/launcher/launcher.h @@ -6,6 +6,8 @@ #define UI_AURA_SHELL_LAUNCHER_LAUNCHER_H_ #pragma once +#include <map> + #include "base/basictypes.h" #include "base/memory/scoped_ptr.h" #include "ui/aura/window_observer.h" @@ -32,9 +34,17 @@ class AURA_SHELL_EXPORT Launcher : public aura::WindowObserver { views::Widget* widget() { return widget_; } private: + typedef std::map<aura::Window*, bool> WindowMap; + + // If necessary asks the delegate if an entry should be created in the + // launcher for |window|. This only asks the delegate once for a window. + void MaybeAdd(aura::Window* window); + // WindowObserver overrides: virtual void OnWindowAdded(aura::Window* new_window) OVERRIDE; virtual void OnWillRemoveWindow(aura::Window* window) OVERRIDE; + virtual void OnWindowVisibilityChanged(aura::Window* window, + bool visibile) OVERRIDE; scoped_ptr<LauncherModel> model_; @@ -43,6 +53,10 @@ class AURA_SHELL_EXPORT Launcher : public aura::WindowObserver { aura::ToplevelWindowContainer* window_container_; + // The set of windows we know about. The boolean indicates whether we've asked + // the delegate if the window should added to the launcher. + WindowMap known_windows_; + DISALLOW_COPY_AND_ASSIGN(Launcher); }; diff --git a/ui/aura_shell/launcher/launcher_model.cc b/ui/aura_shell/launcher/launcher_model.cc index 43a6d00..5f4502e 100644 --- a/ui/aura_shell/launcher/launcher_model.cc +++ b/ui/aura_shell/launcher/launcher_model.cc @@ -4,6 +4,7 @@ #include "ui/aura_shell/launcher/launcher_model.h" +#include "ui/aura/window.h" #include "ui/aura_shell/launcher/launcher_model_observer.h" namespace aura_shell { @@ -45,6 +46,21 @@ void LauncherModel::SetAppImage(int index, const SkBitmap& image) { LauncherItemImagesChanged(index)); } +int LauncherModel::ItemIndexByWindow(aura::Window* window) { + LauncherItems::const_iterator i = ItemByWindow(window); + return i == items_.end() ? -1 : static_cast<int>((i - items_.begin())); +} + +LauncherItems::const_iterator LauncherModel::ItemByWindow( + aura::Window* window) const { + for (LauncherItems::const_iterator i = items_.begin(); + i != items_.end(); ++i) { + if (i->window == window) + return i; + } + return items_.end(); +} + void LauncherModel::AddObserver(LauncherModelObserver* observer) { observers_.AddObserver(observer); } diff --git a/ui/aura_shell/launcher/launcher_model.h b/ui/aura_shell/launcher/launcher_model.h index 242129e..579a673 100644 --- a/ui/aura_shell/launcher/launcher_model.h +++ b/ui/aura_shell/launcher/launcher_model.h @@ -12,8 +12,8 @@ #include "ui/aura_shell/aura_shell_export.h" #include "ui/aura_shell/launcher/launcher_types.h" -namespace views { -class View; +namespace aura { +class Window; } namespace aura_shell { @@ -36,6 +36,11 @@ class AURA_SHELL_EXPORT LauncherModel { void SetTabbedImages(int index, const LauncherTabbedImages& images); void SetAppImage(int index, const SkBitmap& image); + // Returns the index of the item with the specified window. + int ItemIndexByWindow(aura::Window* window); + + LauncherItems::const_iterator ItemByWindow(aura::Window* window) const; + const LauncherItems& items() const { return items_; } int item_count() const { return static_cast<int>(items_.size()); } diff --git a/ui/aura_shell/launcher/launcher_view.cc b/ui/aura_shell/launcher/launcher_view.cc index ed2f362..561b26d 100644 --- a/ui/aura_shell/launcher/launcher_view.cc +++ b/ui/aura_shell/launcher/launcher_view.cc @@ -123,7 +123,18 @@ void LauncherView::LauncherItemRemoved(int index) { } void LauncherView::LauncherItemImagesChanged(int index) { - // TODO: implement me. + // TODO: implement better coordinate conversion. + const LauncherItem& item(model_->items()[index]); + if (item.type == TYPE_TABBED) { + TabbedLauncherButton* button = + static_cast<TabbedLauncherButton*>(child_at(index + 1)); + gfx::Size pref = button->GetPreferredSize(); + button->SetImages(item.tab_images); + if (pref != button->GetPreferredSize()) + Resize(); + else + button->SchedulePaint(); + } } void LauncherView::ButtonPressed(views::Button* sender, diff --git a/ui/gfx/compositor/layer.h b/ui/gfx/compositor/layer.h index 3d63f03..c449e88 100644 --- a/ui/gfx/compositor/layer.h +++ b/ui/gfx/compositor/layer.h @@ -105,6 +105,7 @@ class COMPOSITOR_EXPORT Layer : public LayerAnimatorDelegate { // Sets the visibility of the Layer. A Layer may be visible but not // drawn. This happens if any ancestor of a Layer is not visible. void SetVisible(bool visible); + bool visible() const { return visible_; } // Returns true if this Layer is drawn. A Layer is drawn only if all ancestors // are visible. @@ -478,8 +478,6 @@ 'base/dragdrop/drop_target.cc', 'base/dragdrop/drop_target.h', 'base/dragdrop/os_exchange_data.cc', - 'base/view_prop.cc', - 'base/view_prop.h', 'gfx/native_theme_win.cc', 'gfx/native_theme_win.h', ], @@ -541,6 +539,8 @@ }], ['toolkit_views==0', { 'sources!': [ + 'base/view_prop.cc', + 'base/view_prop.h', 'gfx/render_text.cc', 'gfx/render_text.h', 'gfx/render_text_linux.cc', diff --git a/views/widget/native_widget_aura.cc b/views/widget/native_widget_aura.cc index b3673a0..1158e7b 100644 --- a/views/widget/native_widget_aura.cc +++ b/views/widget/native_widget_aura.cc @@ -9,6 +9,7 @@ #include "ui/aura/event.h" #include "ui/aura/window.h" #include "ui/aura/window_types.h" +#include "ui/base/view_prop.h" #include "ui/base/ui_base_types.h" #include "ui/gfx/canvas.h" #include "ui/gfx/compositor/layer.h" @@ -28,6 +29,8 @@ #include "views/ime/mock_input_method.h" #endif +using ui::ViewProp; + namespace views { namespace { @@ -173,15 +176,24 @@ void NativeWidgetAura::ViewRemoved(View* view) { } void NativeWidgetAura::SetNativeWindowProperty(const char* name, void* value) { - if (!value) - props_map_.erase(name); - else - props_map_[name] = value; + // TODO(sky): push this to Widget when we get rid of NativeWidgetGtk. + if (!window_) + return; + + // Remove the existing property (if any). + for (ViewProps::iterator i = props_.begin(); i != props_.end(); ++i) { + if ((*i)->Key() == name) { + props_.erase(i); + break; + } + } + + if (value) + props_.push_back(new ViewProp(window_, name, value)); } void* NativeWidgetAura::GetNativeWindowProperty(const char* name) const { - PropsMap::const_iterator i = props_map_.find(name); - return i == props_map_.end() ? NULL : i->second; + return window_ ? ViewProp::GetValue(window_, name) : NULL; } TooltipManager* NativeWidgetAura::GetTooltipManager() const { @@ -538,6 +550,7 @@ void NativeWidgetAura::OnWindowDestroying() { } void NativeWidgetAura::OnWindowDestroyed() { + props_.reset(); window_ = NULL; delegate_->OnNativeWidgetDestroyed(); if (ownership_ == Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET) diff --git a/views/widget/native_widget_aura.h b/views/widget/native_widget_aura.h index 23bb405..a21637b 100644 --- a/views/widget/native_widget_aura.h +++ b/views/widget/native_widget_aura.h @@ -6,8 +6,7 @@ #define VIEWS_WIDGET_NATIVE_WIDGET_AURA_H_ #pragma once -#include <map> - +#include "base/memory/scoped_vector.h" #include "base/memory/weak_ptr.h" #include "ui/aura/window_delegate.h" #include "views/views_export.h" @@ -20,6 +19,10 @@ namespace gfx { class Font; } +namespace ui { +class ViewProp; +} + namespace views { class VIEWS_EXPORT NativeWidgetAura : public internal::NativeWidgetPrivate, @@ -138,7 +141,7 @@ class VIEWS_EXPORT NativeWidgetAura : public internal::NativeWidgetPrivate, virtual void OnWindowVisibilityChanged(bool visible) OVERRIDE; private: - typedef std::map<const char*, void*> PropsMap; + typedef ScopedVector<ui::ViewProp> ViewProps; internal::NativeWidgetDelegate* delegate_; @@ -153,11 +156,10 @@ class VIEWS_EXPORT NativeWidgetAura : public internal::NativeWidgetPrivate, bool can_activate_; - // Map used by Set/GetNativeWindowProperty. - PropsMap props_map_; - gfx::NativeCursor cursor_; + ViewProps props_; + DISALLOW_COPY_AND_ASSIGN(NativeWidgetAura); }; |