diff options
author | saintlou@chromium.org <saintlou@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-20 21:58:48 +0000 |
---|---|---|
committer | saintlou@chromium.org <saintlou@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-20 21:58:48 +0000 |
commit | 4a2697a63edf3887cd7663e45db4a97fc6553bc8 (patch) | |
tree | 39fbca2a16c36ef4062d7a96d5ac043c5b0e4957 /chrome | |
parent | 841135fb2ba586103749b439b3d0fd853fed5559 (diff) | |
download | chromium_src-4a2697a63edf3887cd7663e45db4a97fc6553bc8.zip chromium_src-4a2697a63edf3887cd7663e45db4a97fc6553bc8.tar.gz chromium_src-4a2697a63edf3887cd7663e45db4a97fc6553bc8.tar.bz2 |
Removed more defunct code from ChromeOS.
BUG=none
TEST=none
Review URL: https://chromiumcodereview.appspot.com/9773002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@127804 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
28 files changed, 5 insertions, 2235 deletions
diff --git a/chrome/browser/chromeos/frame/browser_non_client_frame_view_factory_chromeos.cc b/chrome/browser/chromeos/frame/browser_non_client_frame_view_factory_chromeos.cc deleted file mode 100644 index ccb21f5..0000000 --- a/chrome/browser/chromeos/frame/browser_non_client_frame_view_factory_chromeos.cc +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (c) 2012 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/frame/browser_non_client_frame_view.h" - -#include "base/command_line.h" -#include "chrome/browser/ui/panels/panel_browser_frame_view.h" -#include "chrome/browser/ui/panels/panel_browser_view.h" -#include "chrome/browser/ui/views/frame/browser_view.h" -#include "chrome/browser/ui/views/frame/opaque_browser_frame_view.h" -#include "chrome/browser/ui/views/frame/popup_non_client_frame_view.h" -#include "chrome/common/chrome_switches.h" - -namespace browser { - -// TODO(jamescook): Delete this entire file when we're sure all Chrome OS -// is on Aura. - -BrowserNonClientFrameView* CreateBrowserNonClientFrameView( - BrowserFrame* frame, BrowserView* browser_view) { - Browser::Type type = browser_view->browser()->type(); - switch (type) { - case Browser::TYPE_PANEL: - case Browser::TYPE_POPUP: - return new PopupNonClientFrameView(frame); - default: - return new OpaqueBrowserFrameView(frame, browser_view); - } -} - -} // browser diff --git a/chrome/browser/chromeos/frame/browser_view.h b/chrome/browser/chromeos/frame/browser_view.h deleted file mode 100644 index 75de22d..0000000 --- a/chrome/browser/chromeos/frame/browser_view.h +++ /dev/null @@ -1,162 +0,0 @@ -// Copyright (c) 2012 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_CHROMEOS_FRAME_BROWSER_VIEW_H_ -#define CHROME_BROWSER_CHROMEOS_FRAME_BROWSER_VIEW_H_ -#pragma once - -#include <vector> - -#include "base/compiler_specific.h" -#include "base/message_loop.h" -#include "chrome/browser/chromeos/status/status_area_button.h" -#include "chrome/browser/chromeos/status/status_area_view.h" -#include "chrome/browser/ui/browser_list.h" -#include "chrome/browser/ui/views/frame/browser_view.h" -#include "ui/views/context_menu_controller.h" -#include "ui/views/controls/menu/menu_listener.h" - -class StatusAreaButton; - -namespace views { -class AccessiblePaneView; -class MenuDelegate; -class MenuRunner; -} // namespace views - -namespace chromeos { - -class LayoutModeButton; -class StatusAreaViewChromeos; - -// chromeos::BrowserView adds ChromeOS specific controls and menus to a -// BrowserView created with Browser::TYPE_TABBED. This extender adds controls -// to the title bar as follows: -// ____ __ __ -// / \ \ \ [StatusArea] [LayoutModeButton] -// -// and adds the system context menu to the remaining area of the titlebar. -class BrowserView : public ::BrowserView, - public views::ContextMenuController, - public views::MenuListener, - public BrowserList::Observer, - public StatusAreaButton::Delegate, - public MessageLoopForUI::Observer { - public: - explicit BrowserView(Browser* browser); - virtual ~BrowserView(); - - // Adds a new tray icon/button to the Chrome OS Tray. - // Takes ownership of the button object. - void AddTrayButton(StatusAreaButton* button, - StatusAreaView::ButtonBorder border); - - // Remove an existing tray button from the Chrome OS Tray. - // Pointer will become invalid after this call. - void RemoveTrayButton(StatusAreaButton* button); - - // Check if a button is currently contained in the view. - bool ContainsButton(StatusAreaButton* button); - - static BrowserView* GetBrowserViewForBrowser(Browser* browser); - - // BrowserView implementation. - virtual void Init() OVERRIDE; - virtual void Show() OVERRIDE; - virtual void ShowInactive() OVERRIDE; - virtual void FocusChromeOSStatus() OVERRIDE; - virtual views::LayoutManager* CreateLayoutManager() const OVERRIDE; - virtual void ChildPreferredSizeChanged(View* child) OVERRIDE; - virtual bool GetSavedWindowPlacement( - gfx::Rect* bounds, - ui::WindowShowState* show_state) const OVERRIDE; - virtual void Cut() OVERRIDE; - virtual void Copy() OVERRIDE; - virtual void Paste() OVERRIDE; - virtual WindowOpenDisposition GetDispositionForPopupBounds( - const gfx::Rect& bounds) OVERRIDE; - - // views::ContextMenuController implementation. - virtual void ShowContextMenuForView(views::View* source, - const gfx::Point& point) OVERRIDE; - - // views::MenuListener implementation. - virtual void OnMenuOpened() OVERRIDE; - - // BrowserList::Observer implementation. - virtual void OnBrowserAdded(const Browser* browser) OVERRIDE; - virtual void OnBrowserRemoved(const Browser* browser) OVERRIDE; - - // StatusAreaButton::Delegate overrides. - virtual bool ShouldExecuteStatusAreaCommand( - const views::View* button_view, int command_id) const OVERRIDE; - virtual void ExecuteStatusAreaCommand( - const views::View* button_view, int command_id) OVERRIDE; - virtual StatusAreaButton::TextStyle GetStatusAreaTextStyle() const OVERRIDE; - virtual void ButtonVisibilityChanged(views::View* button_view) OVERRIDE; - - // MessageLoopForUI::Observer overrides. -#if defined(USE_AURA) - // MessageLoopForUI::Observer overrides. - virtual base::EventStatus WillProcessEvent( - const base::NativeEvent& event) OVERRIDE; - virtual void DidProcessEvent(const base::NativeEvent& event) OVERRIDE; -#else - virtual void WillProcessEvent(GdkEvent* event) OVERRIDE {} - virtual void DidProcessEvent(GdkEvent* event) OVERRIDE; -#endif - - gfx::NativeView saved_focused_widget() const { - return saved_focused_widget_; - } - - bool has_hide_status_area_property() const { - return has_hide_status_area_property_; - } - bool should_show_layout_mode_button() const { - return should_show_layout_mode_button_; - } - - protected: - virtual void GetAccessiblePanes( - std::vector<views::AccessiblePaneView*>* panes) OVERRIDE; - - private: - void InitSystemMenu(); - - void ShowInternal(bool is_active); - - // Updates |has_hide_status_area_property_| by querying the X server. - void FetchHideStatusAreaProperty(); - - // Updates |should_show_layout_mode_button_|. Changes won't be visible - // onscreen until Layout() is called. - void UpdateLayoutModeButtonVisibility(); - - StatusAreaViewChromeos* status_area_; - LayoutModeButton* layout_mode_button_; - - // System menu. - scoped_ptr<views::MenuRunner> system_menu_runner_; - scoped_ptr<views::MenuDelegate> system_menu_delegate_; - - // Focused native widget before wrench menu shows up. We need this to properly - // perform cut, copy and paste. See http://crosbug.com/8496 - gfx::NativeView saved_focused_widget_; - - // Is the _CHROME_STATE_STATUS_HIDDEN atom present in our toplevel window's - // _CHROME_STATE X property? This gets set by window manager to tell us to - // hide the status area. - bool has_hide_status_area_property_; - - // Should the layout mode button be shown? We only show it if there are - // multiple browsers open. - bool should_show_layout_mode_button_; - - DISALLOW_COPY_AND_ASSIGN(BrowserView); -}; - -} // namespace chromeos - -#endif // CHROME_BROWSER_CHROMEOS_FRAME_BROWSER_VIEW_H_ diff --git a/chrome/browser/chromeos/frame/bubble_frame_view.cc b/chrome/browser/chromeos/frame/bubble_frame_view.cc deleted file mode 100644 index b7d13d8..0000000 --- a/chrome/browser/chromeos/frame/bubble_frame_view.cc +++ /dev/null @@ -1,243 +0,0 @@ -// Copyright (c) 2012 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/chromeos/frame/bubble_frame_view.h" - -#include <algorithm> - -#include "base/utf_string_conversions.h" -#include "chrome/browser/chromeos/frame/bubble_window.h" -#include "chrome/browser/chromeos/login/helper.h" -#include "grit/ui_resources_standard.h" -#include "third_party/skia/include/core/SkColor.h" -#include "third_party/skia/include/core/SkPaint.h" -#include "ui/base/hit_test.h" -#include "ui/base/resource/resource_bundle.h" -#include "ui/gfx/canvas.h" -#include "ui/gfx/font.h" -#include "ui/gfx/insets.h" -#include "ui/gfx/path.h" -#include "ui/gfx/rect.h" -#include "ui/views/controls/button/image_button.h" -#include "ui/views/controls/label.h" -#include "ui/views/controls/throbber.h" -#include "ui/views/widget/widget.h" -#include "ui/views/widget/widget_delegate.h" - -namespace { - -const int kTitleTopPadding = 10; -const int kTitleContentPadding = 10; -const int kHorizontalPadding = 10; - -// Title font size correction. -#if defined(CROS_FONTS_USING_BCI) -const int kTitleFontSizeDelta = 0; -#else -const int kTitleFontSizeDelta = 1; -#endif - -} // namespace - -namespace chromeos { - -BubbleFrameView::BubbleFrameView(views::WidgetDelegate* widget_delegate, - DialogStyle style) - : style_(style), - title_(NULL), - close_button_(NULL), - throbber_(NULL) { - if (widget_delegate->ShouldShowWindowTitle()) { - title_ = new views::Label(widget_delegate->GetWindowTitle()); - title_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); - title_->SetFont(title_->font().DeriveFont(kFontSizeCorrectionDelta, - gfx::Font::BOLD)); - AddChildView(title_); - } - - if (style_ & STYLE_XBAR) { - ResourceBundle& rb = ResourceBundle::GetSharedInstance(); - close_button_ = new views::ImageButton(this); - close_button_->SetImage(views::CustomButton::BS_NORMAL, - rb.GetBitmapNamed(IDR_CLOSE_BAR)); - close_button_->SetImage(views::CustomButton::BS_HOT, - rb.GetBitmapNamed(IDR_CLOSE_BAR_H)); - close_button_->SetImage(views::CustomButton::BS_PUSHED, - rb.GetBitmapNamed(IDR_CLOSE_BAR_P)); - AddChildView(close_button_); - } - - if (style_ & STYLE_THROBBER) { - throbber_ = CreateDefaultSmoothedThrobber(); - AddChildView(throbber_); - } -} - -BubbleFrameView::~BubbleFrameView() { -} - -void BubbleFrameView::StartThrobber() { - DCHECK(throbber_ != NULL); - if (title_) - title_->SetText(string16()); - throbber_->Start(); -} - -void BubbleFrameView::StopThrobber() { - DCHECK(throbber_ != NULL); - throbber_->Stop(); - if (title_) - title_->SetText(GetWidget()->widget_delegate()->GetWindowTitle()); -} - -gfx::Rect BubbleFrameView::GetBoundsForClientView() const { - return client_view_bounds_; -} - -gfx::Rect BubbleFrameView::GetWindowBoundsForClientBounds( - const gfx::Rect& client_bounds) const { - gfx::Insets insets = GetInsets(); - - gfx::Size title_size; - if (title_) - title_size = title_->GetPreferredSize(); - gfx::Size close_button_size; - if (close_button_) - close_button_size = close_button_->GetPreferredSize(); - gfx::Size throbber_size; - if (throbber_) - throbber_size = throbber_->GetPreferredSize(); - - int top_height = insets.top(); - if (title_size.height() > 0 || - close_button_size.height() > 0 || - throbber_size.height() > 0) { - top_height += kTitleContentPadding + std::max( - std::max(title_size.height(), close_button_size.height()), - throbber_size.height()); - } - return gfx::Rect(std::max(0, client_bounds.x() - insets.left()), - std::max(0, client_bounds.y() - top_height), - client_bounds.width() + insets.width(), - client_bounds.height() + top_height + insets.bottom()); -} - -int BubbleFrameView::NonClientHitTest(const gfx::Point& point) { - return HTNOWHERE; -} - -void BubbleFrameView::GetWindowMask(const gfx::Size& size, - gfx::Path* window_mask) { -} - -void BubbleFrameView::ResetWindowControls() { -} - -void BubbleFrameView::UpdateWindowIcon() { -} - -gfx::Insets BubbleFrameView::GetInsets() const { - return (style_ & STYLE_FLUSH || style_ & STYLE_FLUSH_CONTENT) ? - gfx::Insets() : - gfx::Insets(kTitleTopPadding, - kHorizontalPadding, - 0, - kHorizontalPadding); -} - -gfx::Size BubbleFrameView::GetPreferredSize() { - gfx::Size pref = GetWidget()->client_view()->GetPreferredSize(); - gfx::Rect bounds(0, 0, pref.width(), pref.height()); - return GetWidget()->non_client_view()->GetWindowBoundsForClientBounds( - bounds).size(); -} - -void BubbleFrameView::Layout() { - gfx::Insets insets = GetInsets(); - - gfx::Size title_size; - if (title_) - title_size = title_->GetPreferredSize(); - gfx::Size close_button_size; - if (close_button_) - close_button_size = close_button_->GetPreferredSize(); - gfx::Size throbber_size; - if (throbber_) - throbber_size = throbber_->GetPreferredSize(); - - // Need to center elements which are shorter. - int max_height = std::max(title_size.height(), - std::max(close_button_size.height(), - throbber_size.height())); - - gfx::Insets title_insets = gfx::Insets(); - // Need to insert title padding for STYLE_FLUSH_CONTENT. - if (style_ & STYLE_FLUSH_CONTENT) - title_insets = gfx::Insets(kTitleTopPadding, - kHorizontalPadding, - 0, - kHorizontalPadding); - - if (title_) { - title_->SetBounds( - insets.left() + title_insets.left(), - insets.top() + title_insets.top() + - (max_height - title_size.height())/2, // Center. - std::max(0, width() - insets.width() - title_insets.width() - - close_button_size.width()), - title_size.height()); - } - - if (close_button_) { - close_button_->SetBounds( - width() - insets.right() - title_insets.right() - - close_button_size.width(), - insets.top() + title_insets.top() + - (max_height - close_button_size.height())/2, - close_button_size.width(), - close_button_size.height()); - } - - if (throbber_) { - throbber_->SetBounds( - insets.left() + title_insets.left(), - insets.top() + title_insets.top() + - (max_height - throbber_size.height())/2, - std::min(throbber_size.width(), width()), - throbber_size.height()); - } - - int top_height = insets.top() + title_insets.top(); - if (title_size.height() > 0 || - close_button_size.height() > 0 || - throbber_size.height() > 0) { - top_height += kTitleContentPadding + std::max( - std::max(title_size.height(), close_button_size.height()), - throbber_size.height()); - } - client_view_bounds_.SetRect(insets.left(), top_height, - std::max(0, width() - insets.width()), - std::max(0, height() - top_height - insets.bottom())); -} - -void BubbleFrameView::OnPaint(gfx::Canvas* canvas) { - SkPaint paint; - paint.setStyle(SkPaint::kFill_Style); - paint.setColor(kBubbleWindowBackgroundColor); - gfx::Path path; - gfx::Rect bounds(GetContentsBounds()); - SkRect rect; - rect.set(SkIntToScalar(bounds.x()), SkIntToScalar(bounds.y()), - SkIntToScalar(bounds.right()), SkIntToScalar(bounds.bottom())); - path.addRect(rect); - canvas->sk_canvas()->drawPath(path, paint); -} - -void BubbleFrameView::ButtonPressed(views::Button* sender, - const views::Event& event) { - if (close_button_ != NULL && sender == close_button_) - GetWidget()->Close(); -} - -} // namespace chromeos diff --git a/chrome/browser/chromeos/frame/bubble_frame_view.h b/chrome/browser/chromeos/frame/bubble_frame_view.h deleted file mode 100644 index 63b7192..0000000 --- a/chrome/browser/chromeos/frame/bubble_frame_view.h +++ /dev/null @@ -1,82 +0,0 @@ -// 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_CHROMEOS_FRAME_BUBBLE_FRAME_VIEW_H_ -#define CHROME_BROWSER_CHROMEOS_FRAME_BUBBLE_FRAME_VIEW_H_ -#pragma once - -#include "chrome/browser/chromeos/frame/bubble_window.h" -#include "ui/views/controls/button/button.h" -#include "ui/views/window/non_client_view.h" - -namespace gfx { -class Insets; -class Path; -class Point; -class Rect; -class Size; -} - -namespace views { -class ImageButton; -class Label; -class Throbber; -class Widget; -} - -namespace chromeos { - -// BubbleFrameView implements a BubbleBorder based window frame. -class BubbleFrameView : public views::NonClientFrameView, - public views::ButtonListener { - public: - BubbleFrameView(views::WidgetDelegate* widget_delegate, - DialogStyle style); - virtual ~BubbleFrameView(); - - // Overridden from views::NonClientFrameView: - virtual gfx::Rect GetBoundsForClientView() const OVERRIDE; - virtual gfx::Rect GetWindowBoundsForClientBounds( - const gfx::Rect& client_bounds) const OVERRIDE; - virtual int NonClientHitTest(const gfx::Point& point) OVERRIDE; - virtual void GetWindowMask(const gfx::Size& size, gfx::Path* window_mask) - OVERRIDE; - virtual void ResetWindowControls() OVERRIDE; - virtual void UpdateWindowIcon() OVERRIDE; - - // View overrides: - virtual gfx::Insets GetInsets() const OVERRIDE; - virtual gfx::Size GetPreferredSize() OVERRIDE; - virtual void Layout() OVERRIDE; - virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; - - // Overridden from views::ButtonListener: - virtual void ButtonPressed(views::Button* sender, const views::Event& event) - OVERRIDE; - - void StartThrobber(); - void StopThrobber(); - - private: - // Allows to tweak appearance of the view. - DialogStyle style_; - - // Title label - views::Label* title_; - - // The bounds of the client view, in this view's coordinates. - gfx::Rect client_view_bounds_; - - // Close button for STYLE_XBAR case. - views::ImageButton* close_button_; - - // Throbber is optional. Employed by STYLE_THROBBER. - views::Throbber* throbber_; - - DISALLOW_COPY_AND_ASSIGN(BubbleFrameView); -}; - -} // namespace chromeos - -#endif // CHROME_BROWSER_CHROMEOS_FRAME_BUBBLE_FRAME_VIEW_H_ diff --git a/chrome/browser/chromeos/frame/bubble_window.cc b/chrome/browser/chromeos/frame/bubble_window.cc deleted file mode 100644 index 82f2e79..0000000 --- a/chrome/browser/chromeos/frame/bubble_window.cc +++ /dev/null @@ -1,37 +0,0 @@ -// 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/chromeos/frame/bubble_window.h" - -#include "chrome/browser/chromeos/frame/bubble_frame_view.h" - -namespace chromeos { - -// static -const SkColor kBubbleWindowBackgroundColor = SK_ColorWHITE; - -views::Widget* BubbleWindow::Create( - gfx::NativeWindow parent, - DialogStyle style, - views::WidgetDelegate* widget_delegate) { - BubbleWindow* window = new BubbleWindow(style); - views::Widget::InitParams params; - params.delegate = widget_delegate; - params.parent = reinterpret_cast<gfx::NativeView>(parent); - window->Init(params); - return window; -} - -BubbleWindow::~BubbleWindow() { -} - -views::NonClientFrameView* BubbleWindow::CreateNonClientFrameView() { - return new BubbleFrameView(widget_delegate(), style_); -} - -BubbleWindow::BubbleWindow(DialogStyle style) - : style_(style) { -} - -} // namespace chromeos diff --git a/chrome/browser/chromeos/frame/bubble_window.h b/chrome/browser/chromeos/frame/bubble_window.h deleted file mode 100644 index 4a3bf94..0000000 --- a/chrome/browser/chromeos/frame/bubble_window.h +++ /dev/null @@ -1,38 +0,0 @@ -// 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_CHROMEOS_FRAME_BUBBLE_WINDOW_H_ -#define CHROME_BROWSER_CHROMEOS_FRAME_BUBBLE_WINDOW_H_ -#pragma once - -#include "chrome/browser/ui/dialog_style.h" -#include "ui/views/widget/widget.h" - -namespace chromeos { - -extern const SkColor kBubbleWindowBackgroundColor; - -// A window that uses BubbleFrameView as its frame. -class BubbleWindow : public views::Widget { - public: - static views::Widget* Create(gfx::NativeWindow parent, - DialogStyle style, - views::WidgetDelegate* widget_delegate); - - virtual ~BubbleWindow(); - - // Overridden from views::Widget: - virtual views::NonClientFrameView* CreateNonClientFrameView() OVERRIDE; - - private: - explicit BubbleWindow(DialogStyle style); - - DialogStyle style_; - - DISALLOW_COPY_AND_ASSIGN(BubbleWindow); -}; - -} // namespace chromeos - -#endif // CHROME_BROWSER_CHROMEOS_FRAME_BUBBLE_WINDOW_H_ diff --git a/chrome/browser/chromeos/frame/layout_mode_button.cc b/chrome/browser/chromeos/frame/layout_mode_button.cc deleted file mode 100644 index 17b045a..0000000 --- a/chrome/browser/chromeos/frame/layout_mode_button.cc +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright (c) 2012 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/chromeos/frame/layout_mode_button.h" - -#include "base/logging.h" -#include "base/utf_string_conversions.h" -#include "chrome/browser/chromeos/view_ids.h" -#include "chrome/common/chrome_notification_types.h" -#include "content/public/browser/notification_details.h" -#include "content/public/browser/notification_source.h" -#include "grit/generated_resources.h" -#include "grit/theme_resources.h" -#include "third_party/cros_system_api/window_manager/chromeos_wm_ipc_enums.h" -#include "ui/base/l10n/l10n_util.h" -#include "ui/base/resource/resource_bundle.h" -#include "ui/views/widget/widget.h" - -namespace { -const int kHorizontalPaddingPixels = 2; -} // namespace - -namespace chromeos { - -LayoutModeButton::LayoutModeButton() - : ALLOW_THIS_IN_INITIALIZER_LIST(ImageButton(this)) { - set_id(VIEW_ID_LAYOUT_MODE_BUTTON); -} - -LayoutModeButton::~LayoutModeButton() { -} - -gfx::Size LayoutModeButton::GetPreferredSize() { - gfx::Size size = ImageButton::GetPreferredSize(); - size.Enlarge(2 * kHorizontalPaddingPixels, 0); - return size; -} - -bool LayoutModeButton::HitTest(const gfx::Point& l) const { - // Handle events above our bounds so that we'll see clicks occuring in the - // padding between the top of the screen and the button. - const gfx::Point point(l.x(), std::max(y(), l.y())); - return ImageButton::HitTest(point); -} - -void LayoutModeButton::Observe(int type, - const content::NotificationSource& source, - const content::NotificationDetails& details) { - DCHECK(type == chrome::NOTIFICATION_LAYOUT_MODE_CHANGED); - UpdateForCurrentLayoutMode(); -} - -void LayoutModeButton::Init() { - UpdateForCurrentLayoutMode(); -} - -void LayoutModeButton::ButtonPressed(views::Button* sender, - const views::Event& event) { - DCHECK_EQ(sender, this); -} - -void LayoutModeButton::UpdateForCurrentLayoutMode() { -} - -} // namespace chromeos diff --git a/chrome/browser/chromeos/frame/layout_mode_button.h b/chrome/browser/chromeos/frame/layout_mode_button.h deleted file mode 100644 index 18b07de..0000000 --- a/chrome/browser/chromeos/frame/layout_mode_button.h +++ /dev/null @@ -1,52 +0,0 @@ -// 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_CHROMEOS_FRAME_LAYOUT_MODE_BUTTON_H_ -#define CHROME_BROWSER_CHROMEOS_FRAME_LAYOUT_MODE_BUTTON_H_ -#pragma once - -#include "base/basictypes.h" -#include "content/public/browser/notification_observer.h" -#include "content/public/browser/notification_registrar.h" -#include "ui/views/controls/button/button.h" -#include "ui/views/controls/button/image_button.h" - -namespace chromeos { - -// Maximize/restore button in the corner of each browser window. -class LayoutModeButton : public views::ImageButton, - public views::ButtonListener, - public content::NotificationObserver { - public: - LayoutModeButton(); - virtual ~LayoutModeButton(); - - // views::* override. - virtual gfx::Size GetPreferredSize() OVERRIDE; - virtual bool HitTest(const gfx::Point& l) const OVERRIDE; - - // content::NotificationObserver implementation. - virtual void Observe(int type, - const content::NotificationSource& source, - const content::NotificationDetails& details) OVERRIDE; - - void Init(); - - private: - // views::ButtonListener implementation. - virtual void ButtonPressed(views::Button* sender, const views::Event& event) - OVERRIDE; - - // Update our icon and tooltip appropriately for the current layout mode. - void UpdateForCurrentLayoutMode(); - - // A registrar for subscribing to LAYOUT_MODE_CHANGED notifications. - content::NotificationRegistrar registrar_; - - DISALLOW_COPY_AND_ASSIGN(LayoutModeButton); -}; - -} // namespace chromeos - -#endif // CHROME_BROWSER_CHROMEOS_FRAME_LAYOUT_MODE_BUTTON_H_ diff --git a/chrome/browser/chromeos/login/login_html_dialog.cc b/chrome/browser/chromeos/login/login_html_dialog.cc index fedab80..bd64f0d 100644 --- a/chrome/browser/chromeos/login/login_html_dialog.cc +++ b/chrome/browser/chromeos/login/login_html_dialog.cc @@ -5,8 +5,6 @@ #include "chrome/browser/chromeos/login/login_html_dialog.h" #include "base/utf_string_conversions.h" -#include "chrome/browser/chromeos/frame/bubble_frame_view.h" -#include "chrome/browser/chromeos/frame/bubble_window.h" #include "chrome/browser/chromeos/login/helper.h" #include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/ui/views/html_dialog_view.h" diff --git a/chrome/browser/chromeos/native_dialog_window.cc b/chrome/browser/chromeos/native_dialog_window.cc deleted file mode 100644 index 4a3dd7e..0000000 --- a/chrome/browser/chromeos/native_dialog_window.cc +++ /dev/null @@ -1,354 +0,0 @@ -// Copyright (c) 2012 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/chromeos/native_dialog_window.h" - -#include <gtk/gtk.h> - -#include "base/logging.h" -#include "base/utf_string_conversions.h" -#include "chrome/browser/chromeos/frame/bubble_window.h" -#include "chrome/browser/ui/dialog_style.h" -#include "chrome/browser/ui/views/window.h" -#include "ui/base/gtk/gtk_signal.h" -#include "ui/views/controls/native/native_view_host.h" -#include "ui/views/widget/widget.h" -#include "ui/views/window/dialog_delegate.h" -#include "ui/views/window/non_client_view.h" - -namespace { - -const int kDialogPadding = 3; - -const char kNativeDialogHost[] = "_chromeos_native_dialog_host_"; - -// TODO(xiyuan): Use gtk_window_get_default_widget with GTK 2.14+. -// Gets the default widget of given dialog. -GtkWidget* GetDialogDefaultWidget(GtkDialog* dialog) { - GtkWidget* default_widget = NULL; - - GList* children = gtk_container_get_children( - GTK_CONTAINER(dialog->action_area)); - - GList* current = children; - while (current) { - GtkWidget* widget = reinterpret_cast<GtkWidget*>(current->data); - if (gtk_widget_has_default(widget)) { - default_widget = widget; - break; - } - - current = g_list_next(current); - } - - g_list_free(children); - - return default_widget; -} - -} // namespace - -namespace chromeos { - -class NativeDialogHost : public views::DialogDelegateView { - public: - NativeDialogHost(gfx::NativeView native_dialog, - int flags, - const gfx::Size& size, - const gfx::Size& min_size); - ~NativeDialogHost(); - - // views::DialogDelegate implementation: - virtual bool CanResize() const OVERRIDE - { return flags_ & DIALOG_FLAG_RESIZEABLE; } - virtual int GetDialogButtons() const OVERRIDE { return 0; } - virtual string16 GetWindowTitle() const OVERRIDE { return title_; } - virtual views::View* GetContentsView() OVERRIDE { return this; } - virtual ui::ModalType GetModalType() const OVERRIDE { - return flags_ & DIALOG_FLAG_MODAL ? ui::MODAL_TYPE_WINDOW : - ui::MODAL_TYPE_NONE; - } - virtual void WindowClosing() OVERRIDE; - - protected: - CHROMEGTK_CALLBACK_0(NativeDialogHost, void, OnCheckResize); - CHROMEGTK_CALLBACK_0(NativeDialogHost, void, OnDialogDestroy); - CHROMEGTK_CALLBACK_1(NativeDialogHost, gboolean, OnGtkKeyPressed, GdkEvent*); - - // views::View implementation: - virtual gfx::Size GetPreferredSize() OVERRIDE; - virtual void Layout() OVERRIDE; - virtual void ViewHierarchyChanged(bool is_add, - views::View* parent, - views::View* child) OVERRIDE; - - private: - // Init and attach to native dialog. - void Init(); - - // Enable moving focuses over native widgets by the Tab key. - void InitNativeFocusMove(GtkWidget* contents); - - // Check and apply minimum size restriction. - void CheckSize(); - - // The GtkDialog whose vbox will be displayed in this view. - gfx::NativeView dialog_; - - // NativeViewHost for the dialog's contents. - views::NativeViewHost* contents_view_; - - string16 title_; - int flags_; - gfx::Size size_; - gfx::Size preferred_size_; - gfx::Size min_size_; - - int destroy_signal_id_; - - DISALLOW_IMPLICIT_CONSTRUCTORS(NativeDialogHost); -}; - -/////////////////////////////////////////////////////////////////////////////// -// NativeDialogHost, public: - -NativeDialogHost::NativeDialogHost(gfx::NativeView native_dialog, - int flags, - const gfx::Size& size, - const gfx::Size& min_size) - : dialog_(native_dialog), - contents_view_(NULL), - flags_(flags), - size_(size), - preferred_size_(size), - min_size_(min_size), - destroy_signal_id_(0) { - const char* title = gtk_window_get_title(GTK_WINDOW(dialog_)); - if (title) - UTF8ToUTF16(title, strlen(title), &title_); - - destroy_signal_id_ = g_signal_connect(dialog_, "destroy", - G_CALLBACK(&OnDialogDestroyThunk), this); -} - -NativeDialogHost::~NativeDialogHost() { -} - -void NativeDialogHost::OnCheckResize(GtkWidget* widget) { - // Do auto height resize only when we are asked to do so. - if (size_.height() == 0) { - gfx::NativeView contents = contents_view_->native_view(); - - // Check whether preferred height has changed. We keep the current width - // unchanged and pass "-1" as height to let gtk calculate a proper height. - gtk_widget_set_size_request(contents, width(), -1); - GtkRequisition requsition = { 0 }; - gtk_widget_size_request(contents, &requsition); - - if (preferred_size_.height() != requsition.height) { - preferred_size_.set_width(requsition.width); - preferred_size_.set_height(requsition.height); - CheckSize(); - SizeToPreferredSize(); - - gfx::Size window_size = - GetWidget()->non_client_view()->GetPreferredSize(); - gfx::Rect window_bounds = GetWidget()->GetWindowScreenBounds(); - window_bounds.set_width(window_size.width()); - window_bounds.set_height(window_size.height()); - GetWidget()->SetBoundsConstrained(window_bounds); - } - } -} - -void NativeDialogHost::OnDialogDestroy(GtkWidget* widget) { - dialog_ = NULL; - destroy_signal_id_ = 0; - GetWidget()->Close(); -} - -gboolean NativeDialogHost::OnGtkKeyPressed(GtkWidget* widget, GdkEvent* event) { - // Manually handle focus movement by Tab key. - // See the comments in NativeDialogHost::InitNativeFocusMove for more detail. - views::KeyEvent key_event(event); - if (views::FocusManager::IsTabTraversalKeyEvent(key_event)) { - GtkWindow* window = GetWidget()->GetNativeWindow(); - GtkDirectionType dir = - key_event.IsShiftDown() ? GTK_DIR_TAB_BACKWARD : GTK_DIR_TAB_FORWARD; - static_cast<GtkWindowClass*>( - g_type_class_peek(GTK_TYPE_WINDOW))->move_focus(window, dir); - return true; - } - return false; -} - -/////////////////////////////////////////////////////////////////////////////// -// NativeDialogHost, views::DialogDelegate implementation: -void NativeDialogHost::WindowClosing() { - if (dialog_) { - // Disconnect the "destroy" signal because we are about to destroy - // the dialog ourselves and no longer interested in it. - g_signal_handler_disconnect(G_OBJECT(dialog_), destroy_signal_id_); - gtk_dialog_response(GTK_DIALOG(dialog_), GTK_RESPONSE_DELETE_EVENT); - } -} - -/////////////////////////////////////////////////////////////////////////////// -// NativeDialogHost, views::View implementation: - -gfx::Size NativeDialogHost::GetPreferredSize() { - return preferred_size_; -} - -void NativeDialogHost::Layout() { - contents_view_->SetBounds(0, 0, width(), height()); -} - -void NativeDialogHost::ViewHierarchyChanged(bool is_add, - views::View* parent, - views::View* child) { - if (is_add && child == this) - Init(); -} - -/////////////////////////////////////////////////////////////////////////////// -// NativeDialogHost, private: -void NativeDialogHost::Init() { - if (contents_view_) - return; - - // Get default widget of the dialog. - GtkWidget* default_widget = GetDialogDefaultWidget(GTK_DIALOG(dialog_)); - - // Get focus widget of the dialog. - GtkWidget* focus_widget = gtk_window_get_focus(GTK_WINDOW(dialog_)); - - // Create a GtkAlignment as dialog contents container. - GtkWidget* contents = gtk_alignment_new(0.5, 0.5, 1.0, 1.0); - gtk_alignment_set_padding(GTK_ALIGNMENT(contents), - kDialogPadding, kDialogPadding, - kDialogPadding, kDialogPadding); - - // Move dialog contents into our container. - GtkWidget* content_area = gtk_dialog_get_content_area(GTK_DIALOG(dialog_)); - g_object_ref(content_area); - gtk_container_remove(GTK_CONTAINER(dialog_), content_area); - gtk_container_add(GTK_CONTAINER(contents), content_area); - g_object_unref(content_area); - gtk_widget_hide(dialog_); - - g_object_set_data(G_OBJECT(dialog_), kNativeDialogHost, - reinterpret_cast<gpointer>(this)); - - gtk_widget_show_all(contents); - - contents_view_ = new views::NativeViewHost(); - // TODO(xiyuan): Find a better way to get proper background. - contents_view_->set_background(views::Background::CreateSolidBackground( - kBubbleWindowBackgroundColor)); - AddChildView(contents_view_); - contents_view_->Attach(contents); - - InitNativeFocusMove(contents); - - g_signal_connect(GetWidget()->GetNativeWindow(), "check-resize", - G_CALLBACK(&OnCheckResizeThunk), this); - - const int padding = 2 * kDialogPadding; - // Use gtk's default size if size is not specified. - if (size_.IsEmpty()) { - // Use given width or height if given. - if (size_.width() || size_.height()) { - int width = size_.width() == 0 ? -1 : size_.width() + padding; - int height = size_.height() == 0 ? -1 : size_.height() + padding; - gtk_widget_set_size_request(contents, width, height); - } - - GtkRequisition requsition = { 0 }; - gtk_widget_size_request(contents, &requsition); - preferred_size_.set_width(requsition.width); - preferred_size_.set_height(requsition.height); - } else { - preferred_size_.set_width(size_.width() + padding); - preferred_size_.set_height(size_.height() + padding); - } - - CheckSize(); - - if (default_widget) - gtk_widget_grab_default(default_widget); - - if (focus_widget) - gtk_widget_grab_focus(focus_widget); -} - -void NativeDialogHost::InitNativeFocusMove(GtkWidget* contents) { - // Fix for http://crosbug.com/7725. - // - // When a native GTK dialog is hosted on views+GTK, the views framework - // prevents Tab key events to be passed to the GTK's handler in three places: - // 1. views::FocusManager::OnKeyEvent - // It intercepts key events _after_ the usual event handlers through the - // native widget hierarchy and _before_ the native key binding handlers. - // Since moving focus by Tab is implemented as a key binding, it cannot - // be reached. As a workaround for NativeDialogHost, we install an usual - // key event handler for capturing Tab key, before FocusManager. - // 2. ::gtk_views_window_move_focus - // The default "move_focus" method of GtkWindow is overridden by views - // to invoke views::FocusManager. This is avoided by calling the default - // GtkWindow->move_focus explicitly in the OnGtkKeyPressed handler. - // 3. ::gtk_views_fixed_init - // Several GTK widgets of type GtkViewsFixed are inserted between the - // dialog window and the dialog controls, so that views framework can - // observe native events. The problem is that these widgets have CAN_FOCUS - // flags, which means they don't propagate focuses to the child controls. - // Here we turn the flag off to make descendant dialog controls focusable. - // Note that, these "stealing" behaviors of views are required ones in the - // usual situation where native widgets are used just as a hidden background - // implementation of views. Only when a native widget hierarchy is hosted and - // directly exposed to the users, the following workaround is necessary. - - g_signal_connect(contents, "key_press_event", - G_CALLBACK(&OnGtkKeyPressedThunk), this); - - GtkWidget* window = GTK_WIDGET(GetWidget()->GetNativeWindow()); - GtkWidget* anscestor = gtk_widget_get_parent(GTK_WIDGET(contents)); - while (anscestor && anscestor != window) { - GTK_WIDGET_UNSET_FLAGS(anscestor, GTK_CAN_FOCUS); - anscestor = gtk_widget_get_parent(anscestor); - } -} - -void NativeDialogHost::CheckSize() { - // Apply the minimum size. - if (preferred_size_.width() < min_size_.width()) - preferred_size_.set_width(min_size_.width()); - if (preferred_size_.height() < min_size_.height()) - preferred_size_.set_height(min_size_.height()); -} - -void ShowNativeDialog(gfx::NativeWindow parent, - gfx::NativeView native_dialog, - int flags, - const gfx::Size& size, - const gfx::Size& min_size) { - NativeDialogHost* native_dialog_host = - new NativeDialogHost(native_dialog, flags, size, min_size); - browser::CreateViewsWindow(parent, native_dialog_host, STYLE_GENERIC); - native_dialog_host->GetWidget()->Show(); -} - -gfx::NativeWindow GetNativeDialogWindow(gfx::NativeView native_dialog) { - NativeDialogHost* host = reinterpret_cast<NativeDialogHost*>( - g_object_get_data(G_OBJECT(native_dialog), kNativeDialogHost)); - return host ? host->GetWidget()->GetNativeWindow() : NULL; -} - -gfx::Rect GetNativeDialogContentsBounds(gfx::NativeView native_dialog) { - NativeDialogHost* host = reinterpret_cast<NativeDialogHost*>( - g_object_get_data(G_OBJECT(native_dialog), kNativeDialogHost)); - return host ? host->bounds() : gfx::Rect(); -} - -} // namespace chromeos diff --git a/chrome/browser/chromeos/native_dialog_window.h b/chrome/browser/chromeos/native_dialog_window.h deleted file mode 100644 index 06510f9..0000000 --- a/chrome/browser/chromeos/native_dialog_window.h +++ /dev/null @@ -1,43 +0,0 @@ -// 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_CHROMEOS_NATIVE_DIALOG_WINDOW_H_ -#define CHROME_BROWSER_CHROMEOS_NATIVE_DIALOG_WINDOW_H_ -#pragma once - -#include "ui/gfx/native_widget_types.h" - -namespace gfx { -class Rect; -class Size; -} // namespace gfx - -namespace chromeos { - -// Flags for ShowNativeDialog. -enum NativeDialogFlags { - DIALOG_FLAG_DEFAULT = 0x00, // Default non-resizeable, non-modal dialog. - DIALOG_FLAG_RESIZEABLE = 0x01, // For resizeable dialog. - DIALOG_FLAG_MODAL = 0x02, // For modal dialog. -}; - -// Shows a |native_dialog| hosted in a views::Widget. |flags| are combinations -// of the NativeDialogFlags. |size| is a default size. Zero width/height of -// |size| means let gtk choose a proper size for that dimension. |min_size| is -// the minimum size of the final host Window. -void ShowNativeDialog(gfx::NativeWindow parent, - gfx::NativeView native_dialog, - int flags, - const gfx::Size& size, - const gfx::Size& min_size); - -// Gets the container window of the given |native_dialog|. -gfx::NativeWindow GetNativeDialogWindow(gfx::NativeView native_dialog); - -// Gets the bounds of the contained dialog content. -gfx::Rect GetNativeDialogContentsBounds(gfx::NativeView native_dialog); - -} // namespace chromeos - -#endif // CHROME_BROWSER_CHROMEOS_NATIVE_DIALOG_WINDOW_H_ diff --git a/chrome/browser/chromeos/panels/panel_browsertest.cc b/chrome/browser/chromeos/panels/panel_browsertest.cc deleted file mode 100644 index b9d7b91..0000000 --- a/chrome/browser/chromeos/panels/panel_browsertest.cc +++ /dev/null @@ -1,111 +0,0 @@ -// Copyright (c) 2012 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 "base/command_line.h" -#include "chrome/browser/ui/browser.h" -#include "chrome/browser/ui/browser_list.h" -#include "chrome/browser/ui/browser_window.h" -#include "chrome/common/chrome_switches.h" -#include "chrome/test/base/in_process_browser_test.h" -#include "chrome/test/base/ui_test_utils.h" -#include "content/public/browser/notification_service.h" -#include "content/public/browser/notification_types.h" -#include "content/public/browser/render_view_host.h" -#include "third_party/cros_system_api/window_manager/chromeos_wm_ipc_enums.h" - -using content::OpenURLParams; -using content::Referrer; - -namespace chromeos { - -class PanelTest : public InProcessBrowserTest { - public: - PanelTest() { - EnableDOMAutomation(); - } - - protected: - virtual void SetUpCommandLine(CommandLine* command_line) { - command_line->AppendSwitch(switches::kDisablePopupBlocking); - } -}; - -// Small popups should open as a panel. -IN_PROC_BROWSER_TEST_F(PanelTest, PanelOpenSmall) { - const std::string HTML = - "<html><head><title>PanelOpen</title></head>" - "<body onload='window.setTimeout(run_tests, 0)'>" - "<script>" - " function run_tests() {" - " window.open(null, null, 'width=100,height=100');" - " }" - "</script>" - "</body></html>"; - GURL url("data:text/html," + HTML); - CommandLine::ForCurrentProcess()->AppendSwitch( - switches::kDisablePopupBlocking); - - ui_test_utils::WindowedNotificationObserver tab_added_observer( - content::NOTIFICATION_TAB_ADDED, - content::NotificationService::AllSources()); - browser()->OpenURL(OpenURLParams( - url, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED, false)); - tab_added_observer.Wait(); - - // Find the new browser. - Browser* new_browser = NULL; - for (BrowserList::const_iterator i = BrowserList::begin(); - i != BrowserList::end() && !new_browser; ++i) { - if (*i != browser()) - new_browser = *i; - } - - ASSERT_TRUE(new_browser); - EXPECT_TRUE(new_browser->is_type_popup()); - EXPECT_FALSE(new_browser->is_app()); -} - -#if defined(USE_AURA) -// crbug.com/105129. -#define MAYBE_PanelOpenLarge DISABLED_PanelOpenLarge -#else -#define MAYBE_PanelOpenLarge PanelOpenLarge -#endif - -// Large popups should open as new tab. -IN_PROC_BROWSER_TEST_F(PanelTest, MAYBE_PanelOpenLarge) { - const std::string HTML = - "<html><head><title>PanelOpen</title></head>" - "<body onload='window.setTimeout(run_tests, 0)'>" - "<script>" - " function run_tests() {" - " window.open(null, null, 'width=1000,height=1000');" - " }" - "</script>" - "</body></html>"; - GURL url("data:text/html," + HTML); - CommandLine::ForCurrentProcess()->AppendSwitch( - switches::kDisablePopupBlocking); - int old_tab_count = browser()->tab_count(); - ui_test_utils::WindowedNotificationObserver tab_added_observer( - content::NOTIFICATION_TAB_ADDED, - content::NotificationService::AllSources()); - browser()->OpenURL(OpenURLParams( - url, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED, false)); - tab_added_observer.Wait(); - - // Shouldn't find a new browser. - Browser* new_browser = NULL; - for (BrowserList::const_iterator i = BrowserList::begin(); - i != BrowserList::end() && !new_browser; ++i) { - if (*i != browser()) - new_browser = *i; - } - EXPECT_FALSE(new_browser); - - // Should find a new tab. - EXPECT_EQ(old_tab_count + 1, browser()->tab_count()); -} - -} // namespace chromeos diff --git a/chrome/browser/chromeos/panels/panel_scroller.cc b/chrome/browser/chromeos/panels/panel_scroller.cc deleted file mode 100644 index 5c5cfdce..0000000 --- a/chrome/browser/chromeos/panels/panel_scroller.cc +++ /dev/null @@ -1,246 +0,0 @@ -// 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/chromeos/panels/panel_scroller.h" - -#include "base/compiler_specific.h" -#include "base/logging.h" -#include "base/stl_util.h" -#include "base/string_util.h" -#include "base/utf_string_conversions.h" -#include "chrome/browser/chromeos/panels/panel_scroller_container.h" -#include "chrome/browser/chromeos/panels/panel_scroller_header.h" -#include "ui/gfx/canvas.h" -#include "ui/views/widget/widget.h" - -struct PanelScroller::Panel { - PanelScrollerHeader* header; - PanelScrollerContainer* container; -}; - -PanelScroller::PanelScroller() - : views::View(), - divider_height_(18), - needs_layout_(true), - scroll_pos_(0), - ALLOW_THIS_IN_INITIALIZER_LIST(animation_(this)), - animated_scroll_begin_(0), - animated_scroll_end_(0) { - animation_.SetTweenType(ui::Tween::EASE_IN_OUT); - animation_.SetSlideDuration(300); - - Panel* panel = new Panel; - panel->header = new PanelScrollerHeader(this); - panel->header->set_title(ASCIIToUTF16("Email")); - panel->container = new PanelScrollerContainer(this, new views::View()); - panels_.push_back(panel); - - panel = new Panel; - panel->header = new PanelScrollerHeader(this); - panel->header->set_title(ASCIIToUTF16("Chat")); - panel->container = new PanelScrollerContainer(this, new views::View()); - panels_.push_back(panel); - - panel = new Panel; - panel->header = new PanelScrollerHeader(this); - panel->header->set_title(ASCIIToUTF16("Calendar")); - panel->container = new PanelScrollerContainer(this, new views::View()); - panels_.push_back(panel); - - panel = new Panel; - panel->header = new PanelScrollerHeader(this); - panel->header->set_title(ASCIIToUTF16("Recent searches")); - panel->container = new PanelScrollerContainer(this, new views::View()); - panels_.push_back(panel); - - panel = new Panel; - panel->header = new PanelScrollerHeader(this); - panel->header->set_title(ASCIIToUTF16("Pony news")); - panel->container = new PanelScrollerContainer(this, new views::View()); - panels_.push_back(panel); - - // Add the containers first since they're on the bottom. - AddChildView(panels_[0]->container); - AddChildView(panels_[1]->container); - AddChildView(panels_[2]->container); - AddChildView(panels_[3]->container); - AddChildView(panels_[4]->container); - - AddChildView(panels_[0]->header); - AddChildView(panels_[1]->header); - AddChildView(panels_[2]->header); - AddChildView(panels_[3]->header); - AddChildView(panels_[4]->header); -} - -PanelScroller::~PanelScroller() { - STLDeleteContainerPointers(panels_.begin(), panels_.end()); -} - -// static -PanelScroller* PanelScroller::CreateWindow() { - views::Widget* widget = new views::Widget; - views::Widget::InitParams params( - views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); - params.bounds = gfx::Rect(0, 0, 100, 800); - widget->Init(params); - - PanelScroller* scroller = new PanelScroller(); - widget->SetContentsView(scroller); - - widget->Show(); - - return scroller; -} - -void PanelScroller::ViewHierarchyChanged(bool is_add, - views::View* parent, - views::View* child) { - // Our child views changed without us knowing it. Stop the animation and mark - // us as dirty (needs_layout_ = true). - animation_.Stop(); - needs_layout_ = true; -} - -gfx::Size PanelScroller::GetPreferredSize() { - return gfx::Size(75, 200); -} - -void PanelScroller::Layout() { -/* TODO(brettw) this doesn't work for some reason. - if (!needs_layout_ || !animation_.IsShowing()) - return; - needs_layout_ = false;*/ - - // The current location in the content that we're laying out. This is before - // scrolling is accounted for. - int cur_content_pos = 0; - - // Number of pixels used by headers stuck to the top of the scroll area. - int top_header_pixel_count = 0; - - int panel_count = static_cast<int>(panels_.size()); - for (int i = 0; i < panel_count; i++) { - if (cur_content_pos < scroll_pos_ + top_header_pixel_count) { - // This panel is at least partially off the top. Put the header below the - // others already there. - panels_[i]->header->SetBoundsRect(gfx::Rect(0, top_header_pixel_count, - width(), divider_height_)); - top_header_pixel_count += divider_height_; - - } else if (cur_content_pos > height() + scroll_pos_ - - (panel_count - i) * divider_height_) { - // When we've hit the bottom of the visible content, all the remaining - // headers will stack up at the bottom. Counting this header, there are - // (size() - i) left, which is used in the expression above. - int top = height() - (panel_count - i) * divider_height_; - panels_[i]->header->SetBoundsRect(gfx::Rect(0, top, - width(), divider_height_)); - } else { - // Normal header positioning in-flow. - panels_[i]->header->SetBoundsRect( - gfx::Rect(0, cur_content_pos - scroll_pos_, width(), - divider_height_)); - } - - cur_content_pos += divider_height_; - - // Now position the content. It always goes in-flow ignoring any stacked - // up headers at the top or bottom. - int container_height = panels_[i]->container->GetPreferredSize().height(); - panels_[i]->container->SetBoundsRect( - gfx::Rect(0, cur_content_pos - scroll_pos_, - width(), container_height)); - cur_content_pos += container_height; - } -} - -bool PanelScroller::OnMousePressed(const views::MouseEvent& event) { - return true; -} - -bool PanelScroller::OnMouseDragged(const views::MouseEvent& event) { - return true; -} - -void PanelScroller::HeaderClicked(PanelScrollerHeader* source) { - for (size_t i = 0; i < panels_.size(); i++) { - if (panels_[i]->header == source) { - ScrollToPanel(static_cast<int>(i)); - return; - } - } - NOTREACHED() << "Invalid panel passed to HeaderClicked."; -} - -void PanelScroller::ScrollToPanel(int index) { - int affected_panel_height = - panels_[index]->container->GetPreferredSize().height(); - - // The pixel size we need to reserve for the stuck headers. - int top_stuck_header_pixel_size = index * divider_height_; - int bottom_stuck_header_pixel_size = - (static_cast<int>(panels_.size()) - index - 1) * divider_height_; - - // Compute the offset of the top of the panel to scroll to. - int space_above = 0; - for (int i = 0; i < index; i++) { - space_above += divider_height_ + - panels_[i]->container->GetPreferredSize().height(); - } - - // Compute the space below the top of the panel. - int space_below = 0; - for (int i = index; i < static_cast<int>(panels_.size()); i++) { - space_below += divider_height_ + - panels_[i]->container->GetPreferredSize().height(); - } - - // The scroll position of the top of the stuck headers is the space above - // minus the size of the headers stuck there. - int top_stuck_headers_scroll_pos = space_above - top_stuck_header_pixel_size; - - // If the panel is already fully visible, do nothing. - if (scroll_pos_ <= top_stuck_headers_scroll_pos && - space_above + divider_height_ + affected_panel_height - - bottom_stuck_header_pixel_size <= scroll_pos_ + height()) - return; - - // Compute the scroll position. - if (height() > space_below) { - // There's enough room for this panel and everything below it to fit on the - // screen. - animated_scroll_end_ = (space_above + space_below) - height(); - if (animated_scroll_end_ > top_stuck_headers_scroll_pos) - animated_scroll_end_ = top_stuck_headers_scroll_pos; - } else if (space_above > scroll_pos_) { - // If we're going to be scrolling the content up, scroll just until the - // panel in question is fully visible. - animated_scroll_end_ = space_above + - divider_height_ + affected_panel_height + // Size of this panel. - bottom_stuck_header_pixel_size - // Leave room for these. - height(); // Available size in the window. - if (animated_scroll_end_ > top_stuck_headers_scroll_pos) - animated_scroll_end_ = top_stuck_headers_scroll_pos; - } else { - animated_scroll_end_ = top_stuck_headers_scroll_pos; - } - - animated_scroll_begin_ = scroll_pos_; - if (animated_scroll_begin_ == animated_scroll_end_) - return; // Nothing to animate. - - // Start animating to the destination. - animation_.Reset(); - animation_.Show(); -} - -void PanelScroller::AnimationProgressed(const ui::Animation* animation) { - scroll_pos_ = static_cast<int>( - static_cast<double>(animated_scroll_end_ - animated_scroll_begin_) * - animation_.GetCurrentValue()) + animated_scroll_begin_; - - Layout(); - SchedulePaint(); -} diff --git a/chrome/browser/chromeos/panels/panel_scroller.h b/chrome/browser/chromeos/panels/panel_scroller.h deleted file mode 100644 index ed02812..0000000 --- a/chrome/browser/chromeos/panels/panel_scroller.h +++ /dev/null @@ -1,69 +0,0 @@ -// 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_CHROMEOS_PANELS_PANEL_SCROLLER_H_ -#define CHROME_BROWSER_CHROMEOS_PANELS_PANEL_SCROLLER_H_ -#pragma once - -#include <vector> - -#include "base/basictypes.h" -#include "base/compiler_specific.h" -#include "ui/base/animation/animation_delegate.h" -#include "ui/base/animation/slide_animation.h" -#include "ui/views/view.h" - -class PanelScrollerHeader; - -class PanelScroller : public views::View, public ui::AnimationDelegate { - public: - PanelScroller(); - virtual ~PanelScroller(); - - static PanelScroller* CreateWindow(); - - // Overridden from View: - virtual void ViewHierarchyChanged(bool is_add, - views::View* parent, - views::View* child) OVERRIDE; - virtual gfx::Size GetPreferredSize() OVERRIDE; - virtual void Layout() OVERRIDE; - virtual bool OnMousePressed(const views::MouseEvent& event) OVERRIDE; - virtual bool OnMouseDragged(const views::MouseEvent& event) OVERRIDE; - - // Called when a panel header is clicked with the affected container. This - // function will make sure the panel is fully visible. - void HeaderClicked(PanelScrollerHeader* source); - - private: - struct Panel; - - // ui::AnimationDelegate overrides. - virtual void AnimationProgressed(const ui::Animation* animation) OVERRIDE; - - // Scrolls to the panel at the given index. It will be moved to the top. - void ScrollToPanel(int index); - - // All panels in this scroller. - std::vector<Panel*> panels_; - - // Height in pixels of the headers above each panel. - int divider_height_; - - bool needs_layout_; - - // The current scroll position. - int scroll_pos_; - - ui::SlideAnimation animation_; - - // When animating a scroll, these indicate the beginning and ending of the - // scroll. The scroll_pos_ always indicates the current one. - int animated_scroll_begin_; - int animated_scroll_end_; - - DISALLOW_COPY_AND_ASSIGN(PanelScroller); -}; - -#endif // CHROME_BROWSER_CHROMEOS_PANELS_PANEL_SCROLLER_H_ diff --git a/chrome/browser/chromeos/panels/panel_scroller_container.cc b/chrome/browser/chromeos/panels/panel_scroller_container.cc deleted file mode 100644 index c0b9ee2..0000000 --- a/chrome/browser/chromeos/panels/panel_scroller_container.cc +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (c) 2012 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/chromeos/panels/panel_scroller_container.h" - -#include "ui/gfx/canvas.h" - -PanelScrollerContainer::PanelScrollerContainer(PanelScroller* scroller, - views::View* contents) - : views::View(), - scroller_(scroller), - contents_(contents) { - AddChildViewAt(contents_, 0); - // TODO(brettw) figure out memory management. -} - -PanelScrollerContainer::~PanelScrollerContainer() { -} - -gfx::Size PanelScrollerContainer::GetPreferredSize() { - return gfx::Size(100, 500); -} - -void PanelScrollerContainer::Layout() { -} - -void PanelScrollerContainer::OnPaint(gfx::Canvas* canvas) { - canvas->DrawLine(gfx::Point(), gfx::Point(width(), height()), 0xFF000080); -} diff --git a/chrome/browser/chromeos/panels/panel_scroller_container.h b/chrome/browser/chromeos/panels/panel_scroller_container.h deleted file mode 100644 index 01de62f..0000000 --- a/chrome/browser/chromeos/panels/panel_scroller_container.h +++ /dev/null @@ -1,38 +0,0 @@ -// 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_CHROMEOS_PANELS_PANEL_SCROLLER_CONTAINER_H_ -#define CHROME_BROWSER_CHROMEOS_PANELS_PANEL_SCROLLER_CONTAINER_H_ -#pragma once - -#include "base/basictypes.h" -#include "base/compiler_specific.h" -#include "ui/views/view.h" - -class PanelScroller; - -// This class wraps the contents of a panel in the panel scroller. It currently -// doesn't do anything useful, but it just a placeholder. -class PanelScrollerContainer : public views::View { - public: - PanelScrollerContainer(PanelScroller* scroller, views::View* contents); - virtual ~PanelScrollerContainer(); - - int HeaderSize() const; - - // view::View overrides. - virtual gfx::Size GetPreferredSize() OVERRIDE; - virtual void Layout() OVERRIDE; - virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; - - private: - // Non-owning pointer to our parent scroller object. - PanelScroller* scroller_; - - views::View* contents_; - - DISALLOW_COPY_AND_ASSIGN(PanelScrollerContainer); -}; - -#endif // CHROME_BROWSER_CHROMEOS_PANELS_PANEL_SCROLLER_CONTAINER_H_ diff --git a/chrome/browser/chromeos/panels/panel_scroller_header.cc b/chrome/browser/chromeos/panels/panel_scroller_header.cc deleted file mode 100644 index 7c18e64..0000000 --- a/chrome/browser/chromeos/panels/panel_scroller_header.cc +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright (c) 2012 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/chromeos/panels/panel_scroller_header.h" - -#include "base/utf_string_conversions.h" -#include "chrome/browser/chromeos/panels/panel_scroller.h" -#include "ui/base/resource/resource_bundle.h" -#include "ui/gfx/canvas.h" -#include "ui/gfx/font.h" - -PanelScrollerHeader::PanelScrollerHeader(PanelScroller* scroller) - : views::View(), - scroller_(scroller) { -} - -PanelScrollerHeader::~PanelScrollerHeader() { -} - -bool PanelScrollerHeader::OnMousePressed(const views::MouseEvent& event) { - return true; -} - -bool PanelScrollerHeader::OnMouseDragged(const views::MouseEvent& event) { - return false; -} - -void PanelScrollerHeader::OnMouseReleased(const views::MouseEvent& event) { - OnMouseCaptureLost(); -} - -void PanelScrollerHeader::OnMouseCaptureLost() { - scroller_->HeaderClicked(this); -} - -gfx::Size PanelScrollerHeader::GetPreferredSize() { - return gfx::Size(size().width(), 18); -} - -void PanelScrollerHeader::OnPaint(gfx::Canvas* canvas) { - // TODO(brettw) fill this out with real styling. - canvas->FillRect(GetLocalBounds(), 0xFFFFFFFF); - const int y = height() - 1; - canvas->DrawLine(gfx::Point(0, y), gfx::Point(width(), y), 0xFFE6E6E6); - ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); - gfx::Font font = - rb.GetFont(ui::ResourceBundle::BaseFont).DeriveFont(0, gfx::Font::BOLD); - int font_top = 1; - canvas->DrawStringInt(title_, font, 0xFF000000, 3, font_top, - size().width(), size().height() - font_top); -} diff --git a/chrome/browser/chromeos/panels/panel_scroller_header.h b/chrome/browser/chromeos/panels/panel_scroller_header.h deleted file mode 100644 index 5a154e5..0000000 --- a/chrome/browser/chromeos/panels/panel_scroller_header.h +++ /dev/null @@ -1,40 +0,0 @@ -// 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_CHROMEOS_PANELS_PANEL_SCROLLER_HEADER_H_ -#define CHROME_BROWSER_CHROMEOS_PANELS_PANEL_SCROLLER_HEADER_H_ -#pragma once - -#include "base/basictypes.h" -#include "base/compiler_specific.h" -#include "base/string16.h" -#include "ui/views/view.h" - -class PanelScroller; - -class PanelScrollerHeader : public views::View { - public: - explicit PanelScrollerHeader(PanelScroller* scroller); - virtual ~PanelScrollerHeader(); - - void set_title(const string16& title) { title_ = title; } - - // views::View overrides. - virtual bool OnMousePressed(const views::MouseEvent& event) OVERRIDE; - virtual bool OnMouseDragged(const views::MouseEvent& event) OVERRIDE; - virtual void OnMouseReleased(const views::MouseEvent& event) OVERRIDE; - virtual void OnMouseCaptureLost() OVERRIDE; - virtual gfx::Size GetPreferredSize() OVERRIDE; - virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; - - private: - // Non-owning pointer to our parent scroller object. - PanelScroller* scroller_; - - string16 title_; - - DISALLOW_COPY_AND_ASSIGN(PanelScrollerHeader); -}; - -#endif // CHROME_BROWSER_CHROMEOS_PANELS_PANEL_SCROLLER_HEADER_H_ diff --git a/chrome/browser/chromeos/status/accessibility_menu_button_browsertest.cc b/chrome/browser/chromeos/status/accessibility_menu_button_browsertest.cc deleted file mode 100644 index 2692351..0000000 --- a/chrome/browser/chromeos/status/accessibility_menu_button_browsertest.cc +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright (c) 2012 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/chromeos/status/accessibility_menu_button.h" - -#include "chrome/browser/chromeos/accessibility/accessibility_util.h" -#include "chrome/browser/chromeos/frame/browser_view.h" -#include "chrome/browser/chromeos/status/status_area_view.h" -#include "chrome/browser/chromeos/view_ids.h" -#include "chrome/test/base/in_process_browser_test.h" -#include "chrome/browser/ui/browser.h" -#include "chrome/browser/ui/browser_window.h" - -#if defined(USE_AURA) -#include "chrome/browser/ui/views/ash/chrome_shell_delegate.h" -#endif - -namespace chromeos { - -class AccessibilityMenuButtonTest : public InProcessBrowserTest { - protected: - AccessibilityMenuButtonTest() : InProcessBrowserTest() { - } - - const AccessibilityMenuButton* GetAccessibilityMenuButton() { - const views::View* view = -#if defined(USE_AURA) - ChromeShellDelegate::instance()->GetStatusArea(); -#else - static_cast<BrowserView*>(browser()->window()); -#endif - return static_cast<const AccessibilityMenuButton*>( - view->GetViewByID(VIEW_ID_STATUS_BUTTON_ACCESSIBILITY)); - } -}; - -IN_PROC_BROWSER_TEST_F(AccessibilityMenuButtonTest, - VisibilityIsSyncedWithPreference) { - const AccessibilityMenuButton* button = GetAccessibilityMenuButton(); - ASSERT_TRUE(button != NULL); - - accessibility::EnableSpokenFeedback(true, NULL); - EXPECT_TRUE(button->visible()); - - accessibility::EnableSpokenFeedback(false, NULL); - EXPECT_FALSE(button->visible()); -} - -} // namespace chromeos diff --git a/chrome/browser/chromeos/status/caps_lock_menu_button_browsertest.cc b/chrome/browser/chromeos/status/caps_lock_menu_button_browsertest.cc deleted file mode 100644 index 172aae1..0000000 --- a/chrome/browser/chromeos/status/caps_lock_menu_button_browsertest.cc +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright (c) 2012 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/chromeos/status/caps_lock_menu_button.h" - -#include "base/string_util.h" -#include "chrome/browser/chromeos/cros/cros_in_process_browser_test.h" -#include "chrome/browser/chromeos/frame/browser_view.h" -#include "chrome/browser/chromeos/status/status_area_view.h" -#include "chrome/browser/chromeos/view_ids.h" -#include "chrome/browser/ui/browser.h" -#include "chrome/browser/ui/browser_window.h" -#include "grit/theme_resources.h" - -#if defined(USE_AURA) -#include "chrome/browser/ui/views/ash/chrome_shell_delegate.h" -#endif - -namespace chromeos { - -class CapsLockMenuButtonTest : public CrosInProcessBrowserTest { - protected: - CapsLockMenuButtonTest() - : CrosInProcessBrowserTest() { - } - - virtual void SetUpInProcessBrowserTestFixture() { - cros_mock_->InitStatusAreaMocks(); - cros_mock_->SetStatusAreaMocksExpectations(); - } - - const CapsLockMenuButton* GetCapsLockMenuButton() { - const views::View* view = -#if defined(USE_AURA) - ChromeShellDelegate::instance()->GetStatusArea(); -#else - static_cast<BrowserView*>(browser()->window()); -#endif - return static_cast<const CapsLockMenuButton*>( - view->GetViewByID(VIEW_ID_STATUS_BUTTON_CAPS_LOCK)); - } -}; - -IN_PROC_BROWSER_TEST_F(CapsLockMenuButtonTest, InitialIndicatorTest) { - const CapsLockMenuButton* caps_lock = GetCapsLockMenuButton(); - ASSERT_TRUE(caps_lock != NULL); - - // By default, the indicator shouldn't be shown. - EXPECT_FALSE(caps_lock->visible()); -} - -} // namespace chromeos diff --git a/chrome/browser/chromeos/status/clock_menu_button_browsertest.cc b/chrome/browser/chromeos/status/clock_menu_button_browsertest.cc deleted file mode 100644 index 09b85ea..0000000 --- a/chrome/browser/chromeos/status/clock_menu_button_browsertest.cc +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright (c) 2012 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/chromeos/status/clock_menu_button.h" - -#include "base/memory/scoped_ptr.h" -#include "chrome/browser/chromeos/cros/cros_library.h" -#include "chrome/browser/chromeos/frame/browser_view.h" -#include "chrome/browser/chromeos/status/status_area_view.h" -#include "chrome/browser/chromeos/system/timezone_settings.h" -#include "chrome/browser/chromeos/view_ids.h" -#include "chrome/browser/prefs/pref_member.h" -#include "chrome/browser/ui/browser.h" -#include "chrome/browser/ui/browser_window.h" -#include "chrome/test/base/in_process_browser_test.h" -#include "testing/gtest/include/gtest/gtest.h" -#include "unicode/calendar.h" -#include "unicode/timezone.h" - -#if defined(USE_AURA) -#include "chrome/browser/ui/views/ash/chrome_shell_delegate.h" -#endif - -namespace chromeos { - -class ClockMenuButtonTest : public InProcessBrowserTest { - protected: - ClockMenuButtonTest() : InProcessBrowserTest() {} - virtual void SetUpInProcessBrowserTestFixture() { - // This test requires actual libcros, but InProcessBrowserTest has set - // to use stub, so reset it here. - CrosLibrary::Get()->GetTestApi()->ResetUseStubImpl(); - } - const ClockMenuButton* GetClockMenuButton() { - const views::View* parent = NULL; -#if defined(USE_AURA) - parent = ChromeShellDelegate::instance()->GetStatusArea(); -#else - parent = static_cast<const BrowserView*>(browser()->window()); -#endif - return static_cast<const ClockMenuButton*>( - parent->GetViewByID(VIEW_ID_STATUS_BUTTON_CLOCK)); - } -}; - -IN_PROC_BROWSER_TEST_F(ClockMenuButtonTest, TimezoneTest) { - const ClockMenuButton* clock = GetClockMenuButton(); - ASSERT_TRUE(clock != NULL); - - // Update timezone and make sure clock text changes. - scoped_ptr<icu::TimeZone> timezone_first(icu::TimeZone::createTimeZone( - icu::UnicodeString::fromUTF8("Asia/Hong_Kong"))); - system::TimezoneSettings::GetInstance()->SetTimezone(*timezone_first); - string16 text_before = clock->text(); - scoped_ptr<icu::TimeZone> timezone_second(icu::TimeZone::createTimeZone( - icu::UnicodeString::fromUTF8("Pacific/Samoa"))); - system::TimezoneSettings::GetInstance()->SetTimezone(*timezone_second); - string16 text_after = clock->text(); - EXPECT_NE(text_before, text_after); -} - -} // namespace chromeos diff --git a/chrome/browser/chromeos/status/input_method_menu_button_browsertest.cc b/chrome/browser/chromeos/status/input_method_menu_button_browsertest.cc deleted file mode 100644 index bfd7f37..0000000 --- a/chrome/browser/chromeos/status/input_method_menu_button_browsertest.cc +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright (c) 2012 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/chromeos/status/input_method_menu_button.h" - -#include "base/utf_string_conversions.h" -#include "chrome/browser/chromeos/cros/cros_in_process_browser_test.h" -#include "chrome/browser/chromeos/frame/browser_view.h" -#include "chrome/browser/chromeos/status/status_area_view.h" -#include "chrome/browser/chromeos/view_ids.h" -#include "chrome/browser/ui/browser.h" -#include "chrome/browser/ui/browser_window.h" -#include "grit/theme_resources.h" - -#if defined(USE_AURA) -#include "chrome/browser/ui/views/ash/chrome_shell_delegate.h" -#endif - -namespace chromeos { - -class InputMethodMenuButtonTest : public CrosInProcessBrowserTest { - protected: - InputMethodMenuButtonTest() - : CrosInProcessBrowserTest() { - } - - virtual void SetUpInProcessBrowserTestFixture() { - cros_mock_->InitStatusAreaMocks(); - cros_mock_->SetStatusAreaMocksExpectations(); - } - - const InputMethodMenuButton* GetInputMethodMenuButton() { - const views::View* view = -#if defined(USE_AURA) - ChromeShellDelegate::instance()->GetStatusArea(); -#else - static_cast<BrowserView*>(browser()->window()); -#endif - return static_cast<const InputMethodMenuButton*>( - view->GetViewByID(VIEW_ID_STATUS_BUTTON_INPUT_METHOD)); - } -}; - -IN_PROC_BROWSER_TEST_F(InputMethodMenuButtonTest, InitialIndicatorTest) { - const InputMethodMenuButton* input_method = GetInputMethodMenuButton(); - ASSERT_TRUE(input_method != NULL); - - // By default, show the indicator of the hardware keyboard, which is set - // to US for tests. - EXPECT_EQ(ASCIIToUTF16("US"), input_method->text()); -} - -} // namespace chromeos diff --git a/chrome/browser/chromeos/status/power_menu_button_browsertest.cc b/chrome/browser/chromeos/status/power_menu_button_browsertest.cc deleted file mode 100644 index 276cb68..0000000 --- a/chrome/browser/chromeos/status/power_menu_button_browsertest.cc +++ /dev/null @@ -1,154 +0,0 @@ -// Copyright (c) 2012 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/chromeos/status/power_menu_button.h" - -#include "chrome/browser/chromeos/frame/browser_view.h" -#include "chrome/browser/chromeos/status/status_area_view.h" -#include "chrome/browser/chromeos/view_ids.h" -#include "chrome/browser/ui/browser.h" -#include "chrome/browser/ui/browser_window.h" -#include "chrome/test/base/in_process_browser_test.h" -#include "ui/views/view.h" - -#if defined(USE_AURA) -#include "chrome/browser/ui/views/ash/chrome_shell_delegate.h" -#endif - -namespace chromeos { - -class PowerMenuButtonTest : public InProcessBrowserTest { - protected: - PowerMenuButtonTest() : InProcessBrowserTest() { - } - - virtual void SetUpInProcessBrowserTestFixture() { - } - - PowerMenuButton* GetPowerMenuButton() { - views::View* view = -#if defined(USE_AURA) - ChromeShellDelegate::instance()->GetStatusArea(); -#else - static_cast<BrowserView*>(browser()->window()); -#endif - return static_cast<PowerMenuButton*>( - view->GetViewByID(VIEW_ID_STATUS_BUTTON_POWER)); - } - - string16 CallPowerChangedAndGetTooltipText(const PowerSupplyStatus& status) { - PowerMenuButton* power = GetPowerMenuButton(); - - power->PowerChanged(status); - EXPECT_TRUE(power->visible()); - - string16 tooltip; - // There is static_cast<StatusAreaButton*> because GetTootipText is also - // declared in MenuDelegate - EXPECT_TRUE(static_cast<StatusAreaButton*>(power)->GetTooltipText( - gfx::Point(0, 0), &tooltip)); - return tooltip; - } - - string16 SetBatteryPercentageTo50AndGetTooltipText() { - PowerSupplyStatus status; - // No battery present. - status.battery_is_present = true; - status.battery_percentage = 50.0; - status.battery_is_full = false; - status.line_power_on = false; - status.battery_seconds_to_empty = 42; - status.battery_seconds_to_full = 24; - return CallPowerChangedAndGetTooltipText(status); - } -}; - -IN_PROC_BROWSER_TEST_F(PowerMenuButtonTest, BatteryMissingTest) { - const string16 tooltip_before = SetBatteryPercentageTo50AndGetTooltipText(); - - PowerSupplyStatus status; - // No battery present. - status.battery_is_present = false; - status.battery_percentage = 42.0; - status.battery_is_full = false; - status.line_power_on = true; - status.battery_seconds_to_empty = 42; - status.battery_seconds_to_full = 24; - - PowerMenuButton* power = GetPowerMenuButton(); - power->PowerChanged(status); - - EXPECT_FALSE(power->visible()); -} - -IN_PROC_BROWSER_TEST_F(PowerMenuButtonTest, BatteryNotSupportedTest) { - PowerSupplyStatus status; - // No battery present. - status.battery_is_present = false; - status.battery_percentage = 42.0; - status.battery_is_full = false; - status.line_power_on = false; - status.battery_seconds_to_empty = 42; - status.battery_seconds_to_full = 24; - - PowerMenuButton* power = GetPowerMenuButton(); - power->PowerChanged(status); - - EXPECT_FALSE(power->visible()); -} - -IN_PROC_BROWSER_TEST_F(PowerMenuButtonTest, BatteryChargedTest) { - const string16 tooltip_before = SetBatteryPercentageTo50AndGetTooltipText(); - - PowerSupplyStatus status; - // The battery is fully charged, and line power is plugged in. - status.battery_is_present = true; - status.battery_percentage = 42.0; - status.battery_is_full = true; - status.line_power_on = true; - status.battery_seconds_to_empty = 42; - status.battery_seconds_to_full = 24; - - EXPECT_NE(tooltip_before, CallPowerChangedAndGetTooltipText(status)); -} - -IN_PROC_BROWSER_TEST_F(PowerMenuButtonTest, BatteryChargingTest) { - string16 tooltip_before = SetBatteryPercentageTo50AndGetTooltipText(); - - PowerSupplyStatus status; - status.battery_is_present = true; - status.battery_is_full = false; - status.line_power_on = true; - status.battery_seconds_to_empty = 42; - status.battery_seconds_to_full = 24; - - // Simulate various levels of charging. - for (double percent = 5.0; percent < 100.0; percent += 5.0) { - status.battery_percentage = percent; - const string16 tooltip_after = CallPowerChangedAndGetTooltipText(status); - EXPECT_NE(tooltip_before, tooltip_after); - tooltip_before = tooltip_after; - } -} - -IN_PROC_BROWSER_TEST_F(PowerMenuButtonTest, BatteryDischargingTest) { - string16 tooltip_before = SetBatteryPercentageTo50AndGetTooltipText(); - - PowerSupplyStatus status; - status.battery_is_present = true; - status.battery_is_full = false; - status.line_power_on = false; - status.battery_seconds_to_empty = 42; - status.battery_seconds_to_full = 24; - - // Simulate various levels of discharging. - for (double percent = 5.0; percent < 100.0; percent += 5.0) { - status.battery_percentage = percent; - const string16 tooltip_after = CallPowerChangedAndGetTooltipText(status); - EXPECT_NE(tooltip_before, tooltip_after); - tooltip_before = tooltip_after; - } -} - -} // namespace chromeos diff --git a/chrome/browser/chromeos/status/status_area_view_browsertest.cc b/chrome/browser/chromeos/status/status_area_view_browsertest.cc deleted file mode 100644 index 666007a..0000000 --- a/chrome/browser/chromeos/status/status_area_view_browsertest.cc +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright (c) 2012 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/chromeos/frame/browser_view.h" -#include "chrome/browser/chromeos/status/status_area_view.h" -#include "chrome/browser/chromeos/view_ids.h" -#include "chrome/test/base/in_process_browser_test.h" -#include "testing/gtest/include/gtest/gtest.h" -#include "ui/views/view.h" - -#if defined(USE_AURA) -#include "chrome/browser/ui/views/ash/chrome_shell_delegate.h" -#endif - -namespace chromeos { - -class StatusAreaViewTest : public InProcessBrowserTest { - protected: - StatusAreaViewTest() : InProcessBrowserTest() {} - const StatusAreaView* GetStatusAreaView() { - const views::View* view = -#if defined(USE_AURA) - ChromeShellDelegate::instance()->GetStatusArea(); -#else - static_cast<BrowserView*>(browser()->window()); -#endif - return static_cast<const StatusAreaView*>( - view->GetViewByID(VIEW_ID_STATUS_AREA)); - } -}; - -IN_PROC_BROWSER_TEST_F(StatusAreaViewTest, VisibleTest) { - const StatusAreaView* status = GetStatusAreaView(); - EXPECT_TRUE(status->IsDrawn()); - EXPECT_FALSE(status->size().IsEmpty()); -} - -} // namespace chromeos diff --git a/chrome/browser/ui/views/status_icons/status_tray_chromeos_browsertest.cc b/chrome/browser/ui/views/status_icons/status_tray_chromeos_browsertest.cc deleted file mode 100644 index 7ebc675..0000000 --- a/chrome/browser/ui/views/status_icons/status_tray_chromeos_browsertest.cc +++ /dev/null @@ -1,78 +0,0 @@ -// 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 "base/string_util.h" -#include "base/utf_string_conversions.h" -#include "chrome/browser/chromeos/frame/browser_view.h" -#include "chrome/browser/chromeos/status/status_area_button.h" -#include "chrome/browser/ui/browser_list.h" -#include "chrome/browser/ui/views/status_icons/status_icon_chromeos.h" -#include "chrome/browser/ui/views/status_icons/status_tray_chromeos.h" -#include "chrome/test/base/in_process_browser_test.h" -#include "grit/theme_resources.h" -#include "testing/gmock/include/gmock/gmock.h" -#include "testing/gtest/include/gtest/gtest.h" -#include "ui/base/models/simple_menu_model.h" -#include "ui/base/resource/resource_bundle.h" - -class SkBitmap; - -class MockStatusIconObserver : public StatusIcon::Observer { - public: - MOCK_METHOD0(OnClicked, void()); -}; - -// Using a browser test since in ChromeOS the status icons are added -// to the browser windows. If there is no browser nothing is tested. -class StatusTrayChromeOSBrowserTest : public InProcessBrowserTest {}; - -IN_PROC_BROWSER_TEST_F(StatusTrayChromeOSBrowserTest, CreateTray) { - // Just tests creation/destruction. - StatusTrayChromeOS tray; -} - -IN_PROC_BROWSER_TEST_F(StatusTrayChromeOSBrowserTest, CreateIconAndMenu) { - // Create an icon, set the images, tooltip, and context menu, then shut it - // down. - StatusTrayChromeOS tray; - StatusIcon* icon = tray.CreateStatusIcon(); - SkBitmap* bitmap = ResourceBundle::GetSharedInstance().GetBitmapNamed( - IDR_STATUS_TRAY_ICON); - icon->SetImage(*bitmap); - icon->SetPressedImage(*bitmap); - icon->SetToolTip(ASCIIToUTF16("tool tip")); - ui::SimpleMenuModel* menu = new ui::SimpleMenuModel(NULL); - menu->AddItem(0, ASCIIToUTF16("foo")); - icon->SetContextMenu(menu); - - Browser* browser = BrowserList::GetLastActive(); - ASSERT_TRUE(browser != NULL); - chromeos::BrowserView* browser_view = - chromeos::BrowserView::GetBrowserViewForBrowser(browser); - ASSERT_TRUE(browser_view != NULL); - StatusAreaButton* button = - static_cast<StatusIconChromeOS*>(icon)->GetButtonForBrowser(browser); - ASSERT_TRUE(button != NULL); - ASSERT_TRUE(browser_view->ContainsButton(button)); -} - -IN_PROC_BROWSER_TEST_F(StatusTrayChromeOSBrowserTest, ClickOnIcon) { - // Create an icon, send a fake click event, make sure observer is called. - StatusTrayChromeOS tray; - StatusIconChromeOS* icon = - static_cast<StatusIconChromeOS*>(tray.CreateStatusIcon()); - MockStatusIconObserver observer; - icon->AddObserver(&observer); - EXPECT_CALL(observer, OnClicked()); - - // Send a click. - Browser* browser = BrowserList::GetLastActive(); - ASSERT_TRUE(browser != NULL); - StatusAreaButton* button = - static_cast<StatusIconChromeOS*>(icon)->GetButtonForBrowser(browser); - ASSERT_TRUE(button != NULL); - button->Activate(); - icon->RemoveObserver(&observer); -} - diff --git a/chrome/browser/ui/views/window.cc b/chrome/browser/ui/views/window.cc index abf3f00..932b5fa 100644 --- a/chrome/browser/ui/views/window.cc +++ b/chrome/browser/ui/views/window.cc @@ -16,10 +16,6 @@ #include "ui/aura/window.h" #endif -#if defined(OS_CHROMEOS) -#include "chrome/browser/chromeos/frame/bubble_window.h" -#endif // OS_CHROMEOS - // Note: This file should be removed after the old ChromeOS frontend is removed. // It is not needed for Aura. // The visual style implemented by BubbleFrameView/BubbleWindow for @@ -34,21 +30,13 @@ namespace browser { views::Widget* CreateViewsWindow(gfx::NativeWindow parent, views::WidgetDelegate* delegate, DialogStyle style) { -#if defined(OS_CHROMEOS) && !defined(USE_AURA) - return chromeos::BubbleWindow::Create(parent, style, delegate); -#else return views::Widget::CreateWindowWithParent(delegate, parent); -#endif } views::Widget* CreateFramelessViewsWindow(gfx::NativeWindow parent, views::WidgetDelegate* delegate) { -#if defined(OS_CHROMEOS) && !defined(USE_AURA) - return chromeos::BubbleWindow::Create(parent, STYLE_FLUSH, delegate); -#else return CreateFramelessWindowWithParentAndBounds(delegate, parent, gfx::Rect()); -#endif } views::Widget* CreateFramelessWindowWithParentAndBounds( diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index 80d9d2c..682ee03 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -521,14 +521,6 @@ 'browser/chromeos/external_metrics.h', 'browser/chromeos/external_protocol_dialog.cc', 'browser/chromeos/external_protocol_dialog.h', - 'browser/chromeos/frame/browser_non_client_frame_view_factory_chromeos.cc', - 'browser/chromeos/frame/browser_view.h', - 'browser/chromeos/frame/bubble_frame_view.cc', - 'browser/chromeos/frame/bubble_frame_view.h', - 'browser/chromeos/frame/bubble_window.h', - 'browser/chromeos/frame/bubble_window.cc', - 'browser/chromeos/frame/layout_mode_button.cc', - 'browser/chromeos/frame/layout_mode_button.h', 'browser/chromeos/gdata/gdata_auth_service.cc', 'browser/chromeos/gdata/gdata_auth_service.h', 'browser/chromeos/gdata/gdata_documents_service.cc', @@ -760,8 +752,6 @@ 'browser/chromeos/media/media_player_extension_api.h', 'browser/chromeos/mobile_config.cc', 'browser/chromeos/mobile_config.h', - 'browser/chromeos/native_dialog_window.cc', - 'browser/chromeos/native_dialog_window.h', 'browser/chromeos/net/cros_network_change_notifier_factory.cc', 'browser/chromeos/net/cros_network_change_notifier_factory.h', 'browser/chromeos/net/network_change_notifier_chromeos.cc', @@ -790,12 +780,6 @@ 'browser/chromeos/options/vpn_config_view.h', 'browser/chromeos/options/wifi_config_view.cc', 'browser/chromeos/options/wifi_config_view.h', - 'browser/chromeos/panels/panel_scroller.cc', - 'browser/chromeos/panels/panel_scroller.h', - 'browser/chromeos/panels/panel_scroller_container.cc', - 'browser/chromeos/panels/panel_scroller_container.h', - 'browser/chromeos/panels/panel_scroller_header.cc', - 'browser/chromeos/panels/panel_scroller_header.h', 'browser/chromeos/power/brightness_observer.cc', 'browser/chromeos/power/brightness_observer.h', 'browser/chromeos/power/low_battery_observer.cc', @@ -3393,8 +3377,8 @@ 'browser/ui/views/frame/opaque_browser_frame_view.h', 'browser/ui/views/frame/popup_non_client_frame_view.cc', 'browser/ui/views/frame/popup_non_client_frame_view.h', - 'browser/ui/views/frame/system_menu_model_delegate.cc', - 'browser/ui/views/frame/system_menu_model_delegate.h', + 'browser/ui/views/frame/system_menu_model_delegate.cc', + 'browser/ui/views/frame/system_menu_model_delegate.h', 'browser/ui/views/fullscreen_exit_bubble_views.cc', 'browser/ui/views/fullscreen_exit_bubble_views.h', 'browser/ui/views/generic_info_view.cc', @@ -4250,12 +4234,6 @@ ['exclude', '^browser/automation/chrome_frame_automation_provider.cc'], ['exclude', '^browser/automation/chrome_frame_automation_provider.h'], ['exclude', '^browser/automation/testing_automation_provider_win.cc'], - ['exclude', '^browser/chromeos/native_dialog_window.cc'], - ['exclude', '^browser/chromeos/native_dialog_window.h'], - ['exclude', '^browser/chromeos/frame/bubble_frame_view.h'], - ['exclude', '^browser/chromeos/frame/bubble_frame_view.cc'], - ['exclude', '^browser/chromeos/frame/bubble_window.cc'], - ['exclude', '^browser/chromeos/frame/bubble_window.h'], ['exclude', '^browser/external_tab_container_win.cc'], ['exclude', '^browser/external_tab_container_win.h'], ['exclude', '^browser/first_run/try_chrome_dialog_view.cc'], @@ -4908,8 +4886,8 @@ ['include', '^browser/ui/views/frame/opaque_browser_frame_view.h'], ['include', '^browser/ui/views/frame/popup_non_client_frame_view.cc'], ['include', '^browser/ui/views/frame/popup_non_client_frame_view.h'], - ['include', '^browser/ui/views/frame/system_menu_model_delegate.cc'], - ['include', '^browser/ui/views/frame/system_menu_model_delegate.h'], + ['include', '^browser/ui/views/frame/system_menu_model_delegate.cc'], + ['include', '^browser/ui/views/frame/system_menu_model_delegate.h'], ['include', '^browser/ui/views/fullscreen_exit_bubble_views.cc'], ['include', '^browser/ui/views/fullscreen_exit_bubble_views.h'], ['include', '^browser/ui/views/global_error_bubble_view.cc'], @@ -5026,7 +5004,6 @@ ['include', '^browser/ui/views/window.h'], ['include', '^browser/ui/views/wrench_menu.cc'], ['include', '^browser/ui/views/wrench_menu.h'], - ['include', '^browser/ui/window_sizer.cc'], ['include', '^browser/ui/window_sizer.h'], @@ -5080,7 +5057,7 @@ ], }], # GTK build only - ['toolkit_uses_gtk == 1 and toolkit_views == 0', { + ['toolkit_uses_gtk==1', { 'sources/': [ ['include', '^browser/printing/print_dialog_gtk.cc'], ['include', '^browser/printing/print_dialog_gtk.h'], diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi index 56fadc3..09e4d2b 100644 --- a/chrome/chrome_tests.gypi +++ b/chrome/chrome_tests.gypi @@ -2615,7 +2615,6 @@ 'browser/chromeos/login/wizard_in_process_browser_test.cc', 'browser/chromeos/login/wizard_in_process_browser_test.h', 'browser/chromeos/media/media_player_browsertest.cc', - 'browser/chromeos/panels/panel_browsertest.cc', 'browser/chromeos/process_proxy/process_proxy_browsertest.cc', 'browser/chromeos/system_key_event_listener_browsertest.cc', 'browser/chromeos/tab_closeable_state_watcher_browsertest.cc', @@ -2814,7 +2813,6 @@ 'browser/ui/views/dom_view_browsertest.cc', 'browser/ui/views/html_dialog_view_browsertest.cc', 'browser/ui/views/select_file_dialog_extension_browsertest.cc', - 'browser/ui/views/status_icons/status_tray_chromeos_browsertest.cc', 'browser/ui/webui/chrome_url_data_manager_browsertest.cc', 'browser/ui/webui/ntp/most_visited_browsertest.cc', 'browser/ui/webui/test_chrome_web_ui_controller_factory_browsertest.cc', @@ -2987,7 +2985,6 @@ 'browser/extensions/extension_input_method_apitest.cc', 'browser/extensions/api/terminal/terminal_private_apitest.cc', 'browser/oom_priority_manager_browsertest.cc', - 'browser/ui/views/status_icons/status_tray_chromeos_browsertest.cc', 'test/data/webui/certificate_viewer_dialog_test.js', 'test/data/webui/certificate_viewer_ui_test-inl.h', ], @@ -3012,10 +3009,6 @@ 'test/data/webui/certificate_viewer_dialog_test.js', 'test/data/webui/certificate_viewer_ui_test-inl.h', ], - 'sources/': [ - ['exclude', '^browser/chromeos/panels/panel_browsertest.cc'], - ['exclude', '^browser/ui/views/status_icons/status_tray_chromeos_browsertest.cc'], - ], }], ], }], |