diff options
author | saintlou@chromium.org <saintlou@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-23 21:42:33 +0000 |
---|---|---|
committer | saintlou@chromium.org <saintlou@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-23 21:42:33 +0000 |
commit | c12d2f2252f7f2250f1ce7f01628dc4a55265e3c (patch) | |
tree | c32c184f2b3da9c26ffaa0ddcec55595d7b7f5dd /chrome/browser/ui/touch | |
parent | 70cda72e43ba03e77f6e07df1966247c20eea05e (diff) | |
download | chromium_src-c12d2f2252f7f2250f1ce7f01628dc4a55265e3c.zip chromium_src-c12d2f2252f7f2250f1ce7f01628dc4a55265e3c.tar.gz chromium_src-c12d2f2252f7f2250f1ce7f01628dc4a55265e3c.tar.bz2 |
Touch constants and dead code removal.
BUG=105046
TEST=none
Review URL: http://codereview.chromium.org/8678015
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@111415 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/ui/touch')
11 files changed, 0 insertions, 550 deletions
diff --git a/chrome/browser/ui/touch/frame/browser_non_client_frame_view_factory_touch.cc b/chrome/browser/ui/touch/frame/browser_non_client_frame_view_factory_touch.cc deleted file mode 100644 index 2154ac3..0000000 --- a/chrome/browser/ui/touch/frame/browser_non_client_frame_view_factory_touch.cc +++ /dev/null @@ -1,33 +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/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/touch/frame/touch_browser_frame_view.h" -#include "chrome/browser/ui/views/frame/browser_view.h" -#include "chrome/browser/ui/views/frame/popup_non_client_frame_view.h" -#include "chrome/common/chrome_switches.h" - -namespace browser { - -BrowserNonClientFrameView* CreateBrowserNonClientFrameView( - BrowserFrame* frame, BrowserView* browser_view) { - Browser::Type type = browser_view->browser()->type(); - switch (type) { - case Browser::TYPE_PANEL: - return new PanelBrowserFrameView( - frame, static_cast<PanelBrowserView*>(browser_view)); - case Browser::TYPE_POPUP: - // TODO(anicolao): implement popups for touch - NOTIMPLEMENTED(); - return new PopupNonClientFrameView(frame); - default: - return new TouchBrowserFrameView(frame, browser_view); - } -} - -} // browser diff --git a/chrome/browser/ui/touch/frame/touch_browser_frame_view.cc b/chrome/browser/ui/touch/frame/touch_browser_frame_view.cc deleted file mode 100644 index aea11b3..0000000 --- a/chrome/browser/ui/touch/frame/touch_browser_frame_view.cc +++ /dev/null @@ -1,48 +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/ui/touch/frame/touch_browser_frame_view.h" - -#include "ui/gfx/compositor/layer.h" -#include "views/controls/button/image_button.h" - -// static -const char TouchBrowserFrameView::kViewClassName[] = - "browser/ui/touch/frame/TouchBrowserFrameView"; - -/////////////////////////////////////////////////////////////////////////////// -// TouchBrowserFrameView, public: - -TouchBrowserFrameView::TouchBrowserFrameView(BrowserFrame* frame, - BrowserView* browser_view) - : OpaqueBrowserFrameView(frame, browser_view), - initialized_screen_rotation_(false) { -} - -TouchBrowserFrameView::~TouchBrowserFrameView() { -} - -std::string TouchBrowserFrameView::GetClassName() const { - return kViewClassName; -} - -bool TouchBrowserFrameView::HitTest(const gfx::Point& point) const { - if (OpaqueBrowserFrameView::HitTest(point)) - return true; - - if (close_button()->IsVisible() && - close_button()->GetMirroredBounds().Contains(point)) - return true; - if (restore_button()->IsVisible() && - restore_button()->GetMirroredBounds().Contains(point)) - return true; - if (maximize_button()->IsVisible() && - maximize_button()->GetMirroredBounds().Contains(point)) - return true; - if (minimize_button()->IsVisible() && - minimize_button()->GetMirroredBounds().Contains(point)) - return true; - - return false; -} diff --git a/chrome/browser/ui/touch/frame/touch_browser_frame_view.h b/chrome/browser/ui/touch/frame/touch_browser_frame_view.h deleted file mode 100644 index eee15e2..0000000 --- a/chrome/browser/ui/touch/frame/touch_browser_frame_view.h +++ /dev/null @@ -1,34 +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_UI_TOUCH_FRAME_TOUCH_BROWSER_FRAME_VIEW_H_ -#define CHROME_BROWSER_UI_TOUCH_FRAME_TOUCH_BROWSER_FRAME_VIEW_H_ -#pragma once - -#include "chrome/browser/ui/views/frame/opaque_browser_frame_view.h" - -class BrowserFrame; -class BrowserView; - -class TouchBrowserFrameView - : public OpaqueBrowserFrameView { - public: - // Internal class name. - static const char kViewClassName[]; - - // Constructs a non-client view for an BrowserFrame. - TouchBrowserFrameView(BrowserFrame* frame, BrowserView* browser_view); - virtual ~TouchBrowserFrameView(); - - private: - // Overridden from views::View - virtual std::string GetClassName() const OVERRIDE; - virtual bool HitTest(const gfx::Point& point) const OVERRIDE; - - bool initialized_screen_rotation_; - - DISALLOW_COPY_AND_ASSIGN(TouchBrowserFrameView); -}; - -#endif // CHROME_BROWSER_UI_TOUCH_FRAME_TOUCH_BROWSER_FRAME_VIEW_H_ diff --git a/chrome/browser/ui/touch/tabs/tab_strip_factory.cc b/chrome/browser/ui/touch/tabs/tab_strip_factory.cc deleted file mode 100644 index 5dbd533..0000000 --- a/chrome/browser/ui/touch/tabs/tab_strip_factory.cc +++ /dev/null @@ -1,26 +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. - -// This file is only compiled when touchui is defined. - -#include "chrome/browser/ui/views/tabs/tab_strip_factory.h" - -#include "chrome/browser/ui/touch/tabs/touch_tab_strip.h" -#include "chrome/browser/ui/touch/tabs/touch_tab_strip_controller.h" - -// The implementation of CreateTabStrip for touchui creates a TouchTabStrip -AbstractTabStripView* CreateTabStrip(Browser* browser, - views::View* parent, - TabStripModel* model) { - TouchTabStripController* tabstrip_controller = - new TouchTabStripController(browser, model); - // Ownership of this controller is given to a specific tabstrip when we - // construct it below. - - TouchTabStrip* tabstrip = new TouchTabStrip(tabstrip_controller); - parent->AddChildView(tabstrip); - tabstrip_controller->InitFromModel(tabstrip); - return tabstrip; -} - diff --git a/chrome/browser/ui/touch/tabs/touch_tab.cc b/chrome/browser/ui/touch/tabs/touch_tab.cc deleted file mode 100644 index 7372e8c..0000000 --- a/chrome/browser/ui/touch/tabs/touch_tab.cc +++ /dev/null @@ -1,20 +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/ui/touch/tabs/touch_tab.h" - -//////////////////////////////////////////////////////////////////////////////// -// TouchTab, public: - -TouchTab::TouchTab(TabController* controller) - : Tab(controller) { -} - -TouchTab::~TouchTab() { -} - -// We only show the close button for the active tab. -bool TouchTab::ShouldShowCloseBox() const { - return IsCloseable() && IsActive(); -} diff --git a/chrome/browser/ui/touch/tabs/touch_tab.h b/chrome/browser/ui/touch/tabs/touch_tab.h deleted file mode 100644 index 67ad7f9..0000000 --- a/chrome/browser/ui/touch/tabs/touch_tab.h +++ /dev/null @@ -1,45 +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_UI_TOUCH_TABS_TOUCH_TAB_H_ -#define CHROME_BROWSER_UI_TOUCH_TABS_TOUCH_TAB_H_ -#pragma once - -#include "chrome/browser/ui/views/tabs/tab.h" - -/////////////////////////////////////////////////////////////////////////////// -// -// TouchTab -// -// A View that renders a TouchTab in a TouchTabStrip -// -/////////////////////////////////////////////////////////////////////////////// -class TouchTab : public Tab { - public: - // The size of the favicon touch area. - static const int kTouchTargetIconSize = 32; - - explicit TouchTab(TabController* controller); - virtual ~TouchTab(); - - // get and set touch icon - void set_touch_icon(const SkBitmap& bitmap) { - touch_icon_ = bitmap; - } - const SkBitmap& touch_icon() const { - return touch_icon_; - } - - protected: - // Returns whether the Tab should display a close button. - virtual bool ShouldShowCloseBox() const OVERRIDE; - - private: - // The touch icon found - SkBitmap touch_icon_; - - DISALLOW_COPY_AND_ASSIGN(TouchTab); -}; - -#endif // CHROME_BROWSER_UI_TOUCH_TABS_TOUCH_TAB_H_ diff --git a/chrome/browser/ui/touch/tabs/touch_tab_strip.cc b/chrome/browser/ui/touch/tabs/touch_tab_strip.cc deleted file mode 100644 index 08bce47..0000000 --- a/chrome/browser/ui/touch/tabs/touch_tab_strip.cc +++ /dev/null @@ -1,47 +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/ui/touch/tabs/touch_tab_strip.h" - -#include "chrome/browser/ui/touch/tabs/touch_tab.h" -#include "ui/views/widget/widget.h" - -TouchTabStrip::TouchTabStrip(TabStripController* controller) - : TabStrip(controller) { -} - -TouchTabStrip::~TouchTabStrip() { -} - -void TouchTabStrip::OnDragEntered(const views::DropTargetEvent& event) { - // TODO(saintlou): To implement or to ignore? - NOTIMPLEMENTED(); -} - -int TouchTabStrip::OnDragUpdated(const views::DropTargetEvent& event) { - // TODO(saintlou): To implement or to ignore? - NOTIMPLEMENTED(); - return 0; -} - -void TouchTabStrip::OnDragExited() { - // TODO(saintlou): To implement or to ignore? - NOTIMPLEMENTED(); -} - -int TouchTabStrip::OnPerformDrop(const views::DropTargetEvent& event) { - // TODO(saintlou): To implement or to ignore? - NOTIMPLEMENTED(); - return 0; -} - -BaseTab* TouchTabStrip::CreateTab() { - return new TouchTab(this); -} - -ui::TouchStatus TouchTabStrip::OnTouchEvent(const views::TouchEvent& event) { - // TODO(saintlou): To implement. - NOTIMPLEMENTED(); - return ui::TOUCH_STATUS_UNKNOWN; -} diff --git a/chrome/browser/ui/touch/tabs/touch_tab_strip.h b/chrome/browser/ui/touch/tabs/touch_tab_strip.h deleted file mode 100644 index 830334b..0000000 --- a/chrome/browser/ui/touch/tabs/touch_tab_strip.h +++ /dev/null @@ -1,45 +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_UI_TOUCH_TABS_TOUCH_TAB_STRIP_H_ -#define CHROME_BROWSER_UI_TOUCH_TABS_TOUCH_TAB_STRIP_H_ -#pragma once - -#include "chrome/browser/ui/views/tabs/tab_strip.h" - -namespace ui { -enum TouchStatus; -} - -class TouchTab; - -/////////////////////////////////////////////////////////////////////////////// -// -// TouchTabStrip -// -// A View that overrides Touch specific behavior. -// -/////////////////////////////////////////////////////////////////////////////// -class TouchTabStrip : public TabStrip { - public: - explicit TouchTabStrip(TabStripController* controller); - virtual ~TouchTabStrip(); - - // views::View overrides: - virtual void OnDragEntered(const views::DropTargetEvent& event) OVERRIDE; - virtual int OnDragUpdated(const views::DropTargetEvent& event) OVERRIDE; - virtual void OnDragExited() OVERRIDE; - virtual int OnPerformDrop(const views::DropTargetEvent& event) OVERRIDE; - - protected: - // BaseTabStrip overrides: - virtual BaseTab* CreateTab() OVERRIDE; - - private: - virtual ui::TouchStatus OnTouchEvent(const views::TouchEvent& event) OVERRIDE; - - DISALLOW_COPY_AND_ASSIGN(TouchTabStrip); -}; - -#endif // CHROME_BROWSER_UI_TOUCH_TABS_TOUCH_TAB_STRIP_H_ diff --git a/chrome/browser/ui/touch/tabs/touch_tab_strip_controller.cc b/chrome/browser/ui/touch/tabs/touch_tab_strip_controller.cc deleted file mode 100644 index 50beb01..0000000 --- a/chrome/browser/ui/touch/tabs/touch_tab_strip_controller.cc +++ /dev/null @@ -1,178 +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/ui/touch/tabs/touch_tab_strip_controller.h" - -#include "base/bind.h" -#include "base/bind_helpers.h" -#include "chrome/browser/extensions/extension_tab_helper.h" -#include "chrome/browser/favicon/favicon_tab_helper.h" -#include "chrome/browser/profiles/profile.h" -#include "chrome/browser/ui/browser.h" -#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" -#include "chrome/browser/ui/touch/tabs/touch_tab.h" -#include "chrome/browser/ui/touch/tabs/touch_tab_strip.h" -#include "chrome/browser/ui/views/tabs/tab_renderer_data.h" -#include "skia/ext/image_operations.h" -#include "ui/gfx/codec/png_codec.h" -#include "ui/gfx/favicon_size.h" - -namespace { - -void CalcTouchIconTargetSize(int* width, int* height) { - if (*width > TouchTab::kTouchTargetIconSize || - *height > TouchTab::kTouchTargetIconSize) { - // Too big, resize it maintaining the aspect ratio. - float aspect_ratio = static_cast<float>(*width) / - static_cast<float>(*height); - *height = TouchTab::kTouchTargetIconSize; - *width = static_cast<int>(aspect_ratio * *height); - if (*width > TouchTab::kTouchTargetIconSize) { - *width = TouchTab::kTouchTargetIconSize; - *height = static_cast<int>(*width / aspect_ratio); - } - } -} - -GURL GetURLWithoutFragment(const GURL& gurl) { - url_canon::Replacements<char> replacements; - replacements.ClearUsername(); - replacements.ClearPassword(); - replacements.ClearQuery(); - replacements.ClearRef(); - return gurl.ReplaceComponents(replacements); -} - -} // namespace - -TouchTabStripController::TouchTabStripController(Browser* browser, - TabStripModel* model) - : BrowserTabStripController(browser, model) { -} - -TouchTabStripController::~TouchTabStripController() { -} - -void TouchTabStripController::TabDetachedAt(TabContentsWrapper* contents, - int model_index) { - if (consumer_.HasPendingRequests()) { - TouchTab* touch_tab = - static_cast<TouchTab*>(tabstrip()->GetBaseTabAtModelIndex(model_index)); - consumer_.CancelAllRequestsForClientData(touch_tab); - } - BrowserTabStripController::TabDetachedAt(contents, model_index); -} - -void TouchTabStripController::TabChangedAt(TabContentsWrapper* contents, - int model_index, - TabChangeType change_type) { - // Clear the large icon if we are loading a different URL in the same tab. - if (change_type == LOADING_ONLY) { - TouchTab* touch_tab = - static_cast<TouchTab*>(tabstrip()->GetBaseTabAtModelIndex(model_index)); - if (!touch_tab->touch_icon().isNull()) { - GURL existing_tab_url = GetURLWithoutFragment(touch_tab->data().url); - GURL page_url = GetURLWithoutFragment(contents->tab_contents()->GetURL()); - // Reset touch icon if the url are different. - if (existing_tab_url != page_url) { - touch_tab->set_touch_icon(SkBitmap()); - consumer_.CancelAllRequestsForClientData(touch_tab); - } - } - } - - // Always call parent's method. - BrowserTabStripController::TabChangedAt(contents, model_index, change_type); -} - -void TouchTabStripController::SetTabRendererDataFromModel( - TabContents* contents, - int model_index, - TabRendererData* data, - TabStatus tab_status) { - // Call parent first. - BrowserTabStripController::SetTabRendererDataFromModel(contents, model_index, - data, tab_status); - if (tab_status == NEW_TAB) - return; - - // Use the touch icon if any. - TouchTab* touch_tab = - static_cast<TouchTab*>(tabstrip()->GetBaseTabAtModelIndex(model_index)); - if (!touch_tab->touch_icon().isNull()) { - data->favicon = touch_tab->touch_icon(); - return; - } - - // In the case where we do not have a touch icon we scale up the small - // favicons (16x16) which originally are coming from NavigationEntry. - if (data->favicon.width() == gfx::kFaviconSize && - data->favicon.height() == gfx::kFaviconSize) { - data->favicon = skia::ImageOperations::Resize(data->favicon, - skia::ImageOperations::RESIZE_BEST, TouchTab::kTouchTargetIconSize, - TouchTab::kTouchTargetIconSize); - } - - // Check if we have an outstanding request for this tab. - if (consumer_.HasPendingRequests()) - consumer_.CancelAllRequestsForClientData(touch_tab); - - // Request touch icon. - GURL page_url = GetURLWithoutFragment(contents->GetURL()); - FaviconService* favicon_service = profile()->GetFaviconService( - Profile::EXPLICIT_ACCESS); - if (favicon_service) { - CancelableRequestProvider::Handle h = - favicon_service->GetFaviconForURL( - page_url, - history::TOUCH_ICON | history::TOUCH_PRECOMPOSED_ICON, - &consumer_, - base::Bind(&TouchTabStripController::OnTouchIconAvailable, - base::Unretained(this))); - consumer_.SetClientData(favicon_service, h, touch_tab); - } -} - -const TouchTabStrip* TouchTabStripController::tabstrip() const { - return static_cast<const TouchTabStrip*>( - BrowserTabStripController::tabstrip()); -} - -void TouchTabStripController::OnTouchIconAvailable( - FaviconService::Handle h, - history::FaviconData favicon) { - // Abandon the request when there is no valid favicon. - if (!favicon.is_valid()) - return; - - // Retrieve the model_index from the TouchTab pointer received. - TouchTab* touch_tab = consumer_.GetClientDataForCurrentRequest(); - int model_index = tabstrip()->GetModelIndexOfBaseTab(touch_tab); - if (!IsValidIndex(model_index)) - return; - - // Try to decode the favicon, return on failure. - SkBitmap bitmap; - gfx::PNGCodec::Decode(favicon.image_data->front(), - favicon.image_data->size(), - &bitmap); - if (bitmap.isNull()) - return; - - // Rescale output, if needed, and assign to the TouchTab instance. - int width = bitmap.width(); - int height = bitmap.height(); - if (width == TouchTab::kTouchTargetIconSize && - height == TouchTab::kTouchTargetIconSize) { - touch_tab->set_touch_icon(bitmap); - } else { - CalcTouchIconTargetSize(&width, &height); - touch_tab->set_touch_icon(skia::ImageOperations::Resize(bitmap, - skia::ImageOperations::RESIZE_BEST, width, height)); - } - - // Refresh UI since favicon changed. - browser()->GetTabContentsAt(model_index)->NotifyNavigationStateChanged( - TabContents::INVALIDATE_TAB); -} diff --git a/chrome/browser/ui/touch/tabs/touch_tab_strip_controller.h b/chrome/browser/ui/touch/tabs/touch_tab_strip_controller.h deleted file mode 100644 index 484b079..0000000 --- a/chrome/browser/ui/touch/tabs/touch_tab_strip_controller.h +++ /dev/null @@ -1,46 +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_UI_TOUCH_TABS_TOUCH_TAB_STRIP_CONTROLLER_H_ -#define CHROME_BROWSER_UI_TOUCH_TABS_TOUCH_TAB_STRIP_CONTROLLER_H_ -#pragma once - -#include "chrome/browser/favicon/favicon_service.h" -#include "chrome/browser/history/history.h" -#include "chrome/browser/ui/views/tabs/browser_tab_strip_controller.h" - -class TouchTab; -class TouchTabStrip; - -class TouchTabStripController : public BrowserTabStripController { - public: - TouchTabStripController(Browser* browser, TabStripModel* model); - virtual ~TouchTabStripController(); - - virtual void TabDetachedAt(TabContentsWrapper* contents, - int model_index) OVERRIDE; - - virtual void TabChangedAt(TabContentsWrapper* contents, - int model_index, - TabChangeType change_type) OVERRIDE; - - protected: - virtual void SetTabRendererDataFromModel(TabContents* contents, - int model_index, - TabRendererData* data, - TabStatus tab_status) OVERRIDE; - - const TouchTabStrip* tabstrip() const; - - private: - void OnTouchIconAvailable(FaviconService::Handle h, - history::FaviconData favicon); - - // Our consumer for touch icon requests. - CancelableRequestConsumerTSimple<TouchTab*> consumer_; - - DISALLOW_COPY_AND_ASSIGN(TouchTabStripController); -}; - -#endif // CHROME_BROWSER_UI_TOUCH_TABS_TOUCH_TAB_STRIP_CONTROLLER_H_ diff --git a/chrome/browser/ui/touch/tabs/touch_tab_strip_unittest.cc b/chrome/browser/ui/touch/tabs/touch_tab_strip_unittest.cc deleted file mode 100644 index 183cb0e..0000000 --- a/chrome/browser/ui/touch/tabs/touch_tab_strip_unittest.cc +++ /dev/null @@ -1,28 +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/ui/touch/tabs/touch_tab_strip.h" - -#include "chrome/browser/ui/views/tabs/base_tab_strip_test_fixture.h" -#include "chrome/browser/ui/views/tabs/fake_base_tab_strip_controller.h" -#include "testing/gtest/include/gtest/gtest.h" - -// BaseTabStrip unit tests using TouchTabStrip. -INSTANTIATE_TYPED_TEST_CASE_P(TouchTabStrip, - BaseTabStripTestFixture, - TouchTabStrip); - -class TouchTabStripTestFixture : public testing::Test { - public: - TouchTabStripTestFixture() - : tab_strip_(new FakeBaseTabStripController()) { - } - - protected: - TouchTabStrip* tab_strip() { return &tab_strip_; } - - private: - TouchTabStrip tab_strip_; -}; - |