diff options
author | Torne (Richard Coles) <torne@google.com> | 2013-08-30 15:14:49 +0100 |
---|---|---|
committer | Torne (Richard Coles) <torne@google.com> | 2013-08-30 15:14:49 +0100 |
commit | 424c4d7b64af9d0d8fd9624f381f469654d5e3d2 (patch) | |
tree | af8b16dc2ba7fc8c8bb1c9fa18b907c847f3883d /ui | |
parent | c70ef2906f891fe7d218980660e4cda465717916 (diff) | |
download | chromium_org-424c4d7b64af9d0d8fd9624f381f469654d5e3d2.tar.gz |
Merge from Chromium at DEPS revision r220549
This commit was generated by merge_to_master.py.
Change-Id: I8fcb82db764ec1eb0294280936c177bd9ba8a9e9
Diffstat (limited to 'ui')
243 files changed, 2676 insertions, 2583 deletions
diff --git a/ui/android/java/src/org/chromium/ui/WindowAndroid.java b/ui/android/java/src/org/chromium/ui/WindowAndroid.java index 3fec6007b3..c6b263cab3 100644 --- a/ui/android/java/src/org/chromium/ui/WindowAndroid.java +++ b/ui/android/java/src/org/chromium/ui/WindowAndroid.java @@ -34,6 +34,7 @@ public class WindowAndroid { private int mNextRequestCode = 0; protected Activity mActivity; + protected Context mApplicationContext; protected SparseArray<IntentCallback> mOutstandingIntents; protected HashMap<Integer, String> mIntentErrors; @@ -42,6 +43,7 @@ public class WindowAndroid { */ public WindowAndroid(Activity activity) { mActivity = activity; + mApplicationContext = mActivity.getApplicationContext(); mOutstandingIntents = new SparseArray<IntentCallback>(); mIntentErrors = new HashMap<Integer, String>(); @@ -107,6 +109,7 @@ public class WindowAndroid { /** * TODO(nileshagrawal): Stop returning Activity Context crbug.com/233440. * @return Activity context. + * @see #getApplicationContext() */ @Deprecated public Context getContext() { @@ -114,6 +117,13 @@ public class WindowAndroid { } /** + * @return The application context for this activity. + */ + public Context getApplicationContext() { + return mApplicationContext; + } + + /** * Saves the error messages that should be shown if any pending intents would return * after the application has been put onPause. * @param bundle The bundle to save the information in onPause diff --git a/ui/android/java/src/org/chromium/ui/gfx/SurfaceTextureListener.java b/ui/android/java/src/org/chromium/ui/gfx/SurfaceTextureListener.java index 8efe6dd7c9..1b77370e4b 100644 --- a/ui/android/java/src/org/chromium/ui/gfx/SurfaceTextureListener.java +++ b/ui/android/java/src/org/chromium/ui/gfx/SurfaceTextureListener.java @@ -6,7 +6,6 @@ package org.chromium.ui.gfx; import android.graphics.SurfaceTexture; -import org.chromium.base.CalledByNative; import org.chromium.base.JNINamespace; /** @@ -15,9 +14,9 @@ import org.chromium.base.JNINamespace; @JNINamespace("gfx") class SurfaceTextureListener implements SurfaceTexture.OnFrameAvailableListener { // Used to determine the class instance to dispatch the native call to. - private int mNativeSurfaceTextureListener = 0; + private final int mNativeSurfaceTextureListener; - private SurfaceTextureListener(int nativeSurfaceTextureListener) { + SurfaceTextureListener(int nativeSurfaceTextureListener) { assert nativeSurfaceTextureListener != 0; mNativeSurfaceTextureListener = nativeSurfaceTextureListener; } @@ -36,11 +35,6 @@ class SurfaceTextureListener implements SurfaceTexture.OnFrameAvailableListener } } - @CalledByNative - private static SurfaceTextureListener create(int nativeSurfaceTextureListener) { - return new SurfaceTextureListener(nativeSurfaceTextureListener); - } - private native void nativeFrameAvailable(int nativeSurfaceTextureListener); private native void nativeDestroy(int nativeSurfaceTextureListener); } diff --git a/ui/android/java/src/org/chromium/ui/gfx/SurfaceTexturePlatformWrapper.java b/ui/android/java/src/org/chromium/ui/gfx/SurfaceTexturePlatformWrapper.java new file mode 100644 index 0000000000..cd8e40744d --- /dev/null +++ b/ui/android/java/src/org/chromium/ui/gfx/SurfaceTexturePlatformWrapper.java @@ -0,0 +1,64 @@ +// Copyright 2013 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. + +package org.chromium.ui.gfx; + +import android.graphics.SurfaceTexture; +import android.os.Build; + +import org.chromium.base.CalledByNative; +import org.chromium.base.JNINamespace; + +/** + * Wrapper class for the underlying platform's SurfaceTexture in order to + * provide a stable JNI API. + */ +@JNINamespace("gfx") +class SurfaceTexturePlatformWrapper { + @CalledByNative + private static SurfaceTexture create(int textureId) { + return new SurfaceTexture(textureId); + } + + @CalledByNative + private static void destroy(SurfaceTexture surfaceTexture) { + surfaceTexture.setOnFrameAvailableListener(null); + surfaceTexture.release(); + } + + @CalledByNative + private static void setFrameAvailableCallback(SurfaceTexture surfaceTexture, + int nativeSurfaceTextureListener) { + surfaceTexture.setOnFrameAvailableListener( + new SurfaceTextureListener(nativeSurfaceTextureListener)); + } + + @CalledByNative + private static void updateTexImage(SurfaceTexture surfaceTexture) { + surfaceTexture.updateTexImage(); + } + + @CalledByNative + private static void setDefaultBufferSize(SurfaceTexture surfaceTexture, int width, + int height) { + surfaceTexture.setDefaultBufferSize(width, height); + } + + @CalledByNative + private static void getTransformMatrix(SurfaceTexture surfaceTexture, float[] matrix) { + surfaceTexture.getTransformMatrix(matrix); + } + + @CalledByNative + private static void attachToGLContext(SurfaceTexture surfaceTexture, int texName) { + assert Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN; + surfaceTexture.attachToGLContext(texName); + } + + @CalledByNative + private static void detachFromGLContext(SurfaceTexture surfaceTexture) { + assert Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN; + surfaceTexture.detachFromGLContext(); + } +}
\ No newline at end of file diff --git a/ui/app_list/app_list_item_model.h b/ui/app_list/app_list_item_model.h index d437564ef7..1fa8064033 100644 --- a/ui/app_list/app_list_item_model.h +++ b/ui/app_list/app_list_item_model.h @@ -49,7 +49,8 @@ class APP_LIST_EXPORT AppListItemModel { void AddObserver(AppListItemModelObserver* observer); void RemoveObserver(AppListItemModelObserver* observer); - // Returns the context menu model for this item. + // Returns the context menu model for this item, or NULL if there is currently + // no menu for the item (e.g. during install). // Note the returned menu model is owned by this item. virtual ui::MenuModel* GetContextMenuModel(); diff --git a/ui/app_list/cocoa/apps_grid_controller_unittest.mm b/ui/app_list/cocoa/apps_grid_controller_unittest.mm index dba006507f..2ee16515b3 100644 --- a/ui/app_list/cocoa/apps_grid_controller_unittest.mm +++ b/ui/app_list/cocoa/apps_grid_controller_unittest.mm @@ -122,17 +122,27 @@ class AppsGridControllerTest : public AppsGridControllerTestHelper { class AppListItemWithMenu : public AppListItemModel { public: - AppListItemWithMenu(const std::string& title) : menu_model_(NULL) { + AppListItemWithMenu(const std::string& title) + : menu_model_(NULL), + menu_ready_(true) { SetTitle(title); menu_model_.AddItem(0, UTF8ToUTF16("Menu For: " + title)); } + void SetMenuReadyForTesting(bool ready) { + menu_ready_ = ready; + } + virtual ui::MenuModel* GetContextMenuModel() OVERRIDE { + if (!menu_ready_) + return NULL; + return &menu_model_; } private: ui::SimpleMenuModel menu_model_; + bool menu_ready_; DISALLOW_COPY_AND_ASSIGN(AppListItemWithMenu); }; @@ -891,8 +901,9 @@ TEST_F(AppsGridControllerTest, ScrollingWhileDragging) { } TEST_F(AppsGridControllerTest, ContextMenus) { + AppListItemWithMenu* item_two_model = new AppListItemWithMenu("Item Two"); model()->apps()->AddAt(0, new AppListItemWithMenu("Item One")); - model()->apps()->AddAt(1, new AppListItemWithMenu("Item Two")); + model()->apps()->AddAt(1, item_two_model); EXPECT_EQ(2u, [apps_grid_controller_ itemCount]); NSCollectionView* page = [apps_grid_controller_ collectionViewAtPageIndex:0]; @@ -903,6 +914,12 @@ TEST_F(AppsGridControllerTest, ContextMenus) { EXPECT_EQ(1, [menu numberOfItems]); EXPECT_NSEQ(@"Menu For: Item One", [[menu itemAtIndex:0] title]); + // Test a context menu request while the item is still installing. + item_two_model->SetMenuReadyForTesting(false); + menu = [page menuForEvent:mouse_at_cell_1]; + EXPECT_EQ(nil, menu); + + item_two_model->SetMenuReadyForTesting(true); menu = [page menuForEvent:mouse_at_cell_1]; EXPECT_EQ(1, [menu numberOfItems]); EXPECT_NSEQ(@"Menu For: Item Two", [[menu itemAtIndex:0] title]); diff --git a/ui/app_list/cocoa/apps_grid_view_item.mm b/ui/app_list/cocoa/apps_grid_view_item.mm index 9d83d15eb1..d88fb26bac 100644 --- a/ui/app_list/cocoa/apps_grid_view_item.mm +++ b/ui/app_list/cocoa/apps_grid_view_item.mm @@ -99,8 +99,12 @@ ItemModelObserverBridge::~ItemModelObserverBridge() { NSMenu* ItemModelObserverBridge::GetContextMenu() { if (!context_menu_controller_) { + ui::MenuModel* menu_model = model_->GetContextMenuModel(); + if (!menu_model) + return nil; + context_menu_controller_.reset( - [[MenuController alloc] initWithModel:model_->GetContextMenuModel() + [[MenuController alloc] initWithModel:menu_model useWithPopUpButtonCell:NO]); } return [context_menu_controller_ menu]; diff --git a/ui/app_list/cocoa/apps_search_results_controller_unittest.mm b/ui/app_list/cocoa/apps_search_results_controller_unittest.mm index 218ad447ac..3645e1e19d 100644 --- a/ui/app_list/cocoa/apps_search_results_controller_unittest.mm +++ b/ui/app_list/cocoa/apps_search_results_controller_unittest.mm @@ -56,19 +56,28 @@ const int kDefaultResultsCount = 3; class SearchResultWithMenu : public SearchResult { public: - SearchResultWithMenu(const std::string& title, - const std::string& details) : menu_model_(NULL) { + SearchResultWithMenu(const std::string& title, const std::string& details) + : menu_model_(NULL), + menu_ready_(true) { set_title(ASCIIToUTF16(title)); set_details(ASCIIToUTF16(details)); menu_model_.AddItem(0, UTF8ToUTF16("Menu For: " + title)); } + void SetMenuReadyForTesting(bool ready) { + menu_ready_ = ready; + } + virtual ui::MenuModel* GetContextMenuModel() OVERRIDE { + if (!menu_ready_) + return NULL; + return &menu_model_; } private: ui::SimpleMenuModel menu_model_; + bool menu_ready_; DISALLOW_COPY_AND_ASSIGN(SearchResultWithMenu); }; @@ -95,6 +104,12 @@ class AppsSearchResultsControllerTest : public ui::CocoaTest { row:index]; } + void SetMenuReadyAt(size_t index, bool ready) { + SearchResultWithMenu* result = + static_cast<SearchResultWithMenu*>(ModelResultAt(index)); + result->SetMenuReadyForTesting(ready); + } + BOOL SimulateKeyAction(SEL c) { return [apps_search_results_controller_ handleCommandBySelector:c]; } @@ -268,6 +283,12 @@ TEST_F(AppsSearchResultsControllerTest, ContextMenus) { EXPECT_EQ(1, [menu numberOfItems]); EXPECT_NSEQ(@"Menu For: Result 0", [[menu itemAtIndex:0] title]); + // Test a context menu request while the item is still installing. + SetMenuReadyAt(1, false); + menu = [table_view menuForEvent:mouse_in_row_1]; + EXPECT_EQ(nil, menu); + + SetMenuReadyAt(1, true); menu = [table_view menuForEvent:mouse_in_row_1]; EXPECT_EQ(1, [menu numberOfItems]); EXPECT_NSEQ(@"Menu For: Result 1", [[menu itemAtIndex:0] title]); diff --git a/ui/app_list/cocoa/apps_search_results_model_bridge.mm b/ui/app_list/cocoa/apps_search_results_model_bridge.mm index 66d6f07749..69a3205ef0 100644 --- a/ui/app_list/cocoa/apps_search_results_model_bridge.mm +++ b/ui/app_list/cocoa/apps_search_results_model_bridge.mm @@ -31,8 +31,12 @@ class AppsSearchResultsModelBridge::ItemObserver : public SearchResultObserver { NSMenu* GetContextMenu() { if (!context_menu_controller_) { + ui::MenuModel* menu_model = result_->GetContextMenuModel(); + if (!menu_model) + return nil; + context_menu_controller_.reset( - [[MenuController alloc] initWithModel:result_->GetContextMenuModel() + [[MenuController alloc] initWithModel:menu_model useWithPopUpButtonCell:NO]); } return [context_menu_controller_ menu]; diff --git a/ui/app_list/search_result.h b/ui/app_list/search_result.h index 5baa50f557..012f9e3a69 100644 --- a/ui/app_list/search_result.h +++ b/ui/app_list/search_result.h @@ -106,7 +106,8 @@ class APP_LIST_EXPORT SearchResult { void AddObserver(SearchResultObserver* observer); void RemoveObserver(SearchResultObserver* observer); - // Returns the context menu model for this item. + // Returns the context menu model for this item, or NULL if there is currently + // no menu for the item (e.g. during install). // Note the returned menu model is owned by this item. virtual ui::MenuModel* GetContextMenuModel(); diff --git a/ui/app_list/views/app_list_main_view.cc b/ui/app_list/views/app_list_main_view.cc index d2df1dece4..7dc19ffcb6 100644 --- a/ui/app_list/views/app_list_main_view.cc +++ b/ui/app_list/views/app_list_main_view.cc @@ -6,8 +6,10 @@ #include <algorithm> +#include "base/bind.h" #include "base/callback.h" #include "base/files/file_path.h" +#include "base/message_loop/message_loop.h" #include "base/strings/string_util.h" #include "ui/app_list/app_list_constants.h" #include "ui/app_list/app_list_item_model.h" @@ -77,13 +79,14 @@ class AppListMainView::IconLoader : public AppListItemModelObserver { AppListMainView::AppListMainView(AppListViewDelegate* delegate, AppListModel* model, PaginationModel* pagination_model, - views::View* anchor) + gfx::NativeView parent) : delegate_(delegate), model_(model), search_box_view_(NULL), - contents_view_(NULL) { + contents_view_(NULL), + weak_ptr_factory_(this) { // Starts icon loading early. - PreloadIcons(pagination_model, anchor); + PreloadIcons(pagination_model, parent); SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, kInnerPadding, @@ -139,12 +142,10 @@ void AppListMainView::SetDragAndDropHostOfCurrentAppList( } void AppListMainView::PreloadIcons(PaginationModel* pagination_model, - views::View* anchor) { + gfx::NativeView parent) { ui::ScaleFactor scale_factor = ui::SCALE_FACTOR_100P; - if (anchor && anchor->GetWidget()) { - scale_factor = ui::GetScaleFactorForNativeView( - anchor->GetWidget()->GetNativeView()); - } + if (parent) + scale_factor = ui::GetScaleFactorForNativeView(parent); // |pagination_model| could have -1 as the initial selected page and // assumes first page (i.e. index 0) will be used in this case. @@ -230,7 +231,13 @@ void AppListMainView::OnResultInstalled(SearchResult* result) { } void AppListMainView::OnResultUninstalled(SearchResult* result) { - QueryChanged(search_box_view_); + // Resubmit the query via a posted task so that all observers for the + // uninstall notification are notified. + base::MessageLoop::current()->PostTask( + FROM_HERE, + base::Bind(&AppListMainView::QueryChanged, + weak_ptr_factory_.GetWeakPtr(), + search_box_view_)); } } // namespace app_list diff --git a/ui/app_list/views/app_list_main_view.h b/ui/app_list/views/app_list_main_view.h index 1bb69810a1..0c9a7383e1 100644 --- a/ui/app_list/views/app_list_main_view.h +++ b/ui/app_list/views/app_list_main_view.h @@ -8,6 +8,7 @@ #include <string> #include "base/memory/scoped_vector.h" +#include "base/memory/weak_ptr.h" #include "base/timer/timer.h" #include "ui/app_list/views/apps_grid_view_delegate.h" #include "ui/app_list/views/search_box_view_delegate.h" @@ -39,7 +40,7 @@ class AppListMainView : public views::View, explicit AppListMainView(AppListViewDelegate* delegate, AppListModel* model, PaginationModel* pagination_model, - views::View* anchor); + gfx::NativeView parent); virtual ~AppListMainView(); void ShowAppListWhenReady(); @@ -59,9 +60,9 @@ class AppListMainView : public views::View, class IconLoader; // Loads icon image for the apps in the selected page of |pagination_model|. - // |anchor| is used to determine the image scale factor to use. + // |parent| is used to determine the image scale factor to use. void PreloadIcons(PaginationModel* pagination_model, - views::View* anchor); + gfx::NativeView parent); // Invoked when |icon_loading_wait_timer_| fires. void OnIconLoadingWaitTimer(); @@ -99,6 +100,8 @@ class AppListMainView : public views::View, ScopedVector<IconLoader> pending_icon_loaders_; + base::WeakPtrFactory<AppListMainView> weak_ptr_factory_; + DISALLOW_COPY_AND_ASSIGN(AppListMainView); }; diff --git a/ui/app_list/views/app_list_view.cc b/ui/app_list/views/app_list_view.cc index 29b3f7ce64..a74e6e94d6 100644 --- a/ui/app_list/views/app_list_view.cc +++ b/ui/app_list/views/app_list_view.cc @@ -73,7 +73,7 @@ void AppListView::InitAsBubble(gfx::NativeView parent, app_list_main_view_ = new AppListMainView(delegate_.get(), model_.get(), pagination_model, - anchor); + parent); AddChildView(app_list_main_view_); #if defined(USE_AURA) app_list_main_view_->SetPaintToLayer(true); diff --git a/ui/aura/client/cursor_client.h b/ui/aura/client/cursor_client.h index c68c9aa7b6..e8740ac170 100644 --- a/ui/aura/client/cursor_client.h +++ b/ui/aura/client/cursor_client.h @@ -7,6 +7,7 @@ #include "base/strings/string16.h" #include "ui/aura/aura_export.h" +#include "ui/base/cursor/cursor.h" #include "ui/gfx/native_widget_types.h" namespace gfx { @@ -34,6 +35,9 @@ class AURA_EXPORT CursorClient { // Sets the scale of the mouse cursor icon. virtual void SetScale(float scale) = 0; + // Sets the type of the mouse cursor icon. + virtual void SetCursorSet(ui::CursorSetType cursor_set) = 0; + // Gets whether the cursor is visible. virtual bool IsCursorVisible() const = 0; diff --git a/ui/aura/root_window.cc b/ui/aura/root_window.cc index e65e2b293a..d5ab05b00b 100644 --- a/ui/aura/root_window.cc +++ b/ui/aura/root_window.cc @@ -6,7 +6,6 @@ #include <vector> -#include "base/auto_reset.h" #include "base/bind.h" #include "base/command_line.h" #include "base/debug/trace_event.h" @@ -654,6 +653,14 @@ bool RootWindow::CanReceiveEvents() const { void RootWindow::UpdateCapture(Window* old_capture, Window* new_capture) { + if (!new_capture && old_capture && old_capture->GetRootWindow() != this) { + // If we no longer contain the window that had capture make sure we clean + // state in the GestureRecognizer. Since we don't contain the window we'll + // never get notification of its destruction and clean up state. + // We do this early on as OnCaptureLost() may delete |old_capture|. + gesture_recognizer_->CleanupStateForConsumer(old_capture); + } + if (old_capture && old_capture->GetRootWindow() == this && old_capture->delegate()) { // Send a capture changed event with bogus location data. @@ -674,9 +681,8 @@ void RootWindow::UpdateCapture(Window* old_capture, } if (new_capture) { - // Make all subsequent mouse events and touch go to the capture window. We - // shouldn't need to send an event here as OnCaptureLost should take care of - // that. + // Make all subsequent mouse events go to the capture window. We shouldn't + // need to send an event here as OnCaptureLost() should take care of that. if (mouse_moved_handler_ || Env::GetInstance()->is_mouse_button_down()) mouse_moved_handler_ = new_capture; } else { @@ -827,7 +833,7 @@ void RootWindow::OnWindowHidden(Window* invisible, WindowHiddenReason reason) { void RootWindow::CleanupGestureRecognizerState(Window* window) { gesture_recognizer_->CleanupStateForConsumer(window); - Windows windows = window->children(); + const Windows& windows = window->children(); for (Windows::const_iterator iter = windows.begin(); iter != windows.end(); ++iter) { @@ -1051,19 +1057,28 @@ bool RootWindow::DispatchMouseEventToTarget(ui::MouseEvent* event, ui::EF_LEFT_MOUSE_BUTTON | ui::EF_MIDDLE_MOUSE_BUTTON | ui::EF_RIGHT_MOUSE_BUTTON; - base::AutoReset<Window*> reset(&mouse_event_dispatch_target_, target); + // WARNING: because of nested message loops |this| may be deleted after + // dispatching any event. Do not use AutoReset or the like here. + WindowTracker destroyed_tracker; + destroyed_tracker.Add(this); + Window* old_mouse_event_dispatch_target = mouse_event_dispatch_target_; + mouse_event_dispatch_target_ = target; SetLastMouseLocation(this, event->location()); synthesize_mouse_move_ = false; switch (event->type()) { case ui::ET_MOUSE_EXITED: if (!target) { DispatchMouseEnterOrExit(*event, ui::ET_MOUSE_EXITED); + if (!destroyed_tracker.Contains(this)) + return false; mouse_moved_handler_ = NULL; } break; case ui::ET_MOUSE_MOVED: mouse_event_dispatch_target_ = target; HandleMouseMoved(*event, target); + if (!destroyed_tracker.Contains(this)) + return false; if (mouse_event_dispatch_target_ != target) return false; break; @@ -1085,14 +1100,20 @@ bool RootWindow::DispatchMouseEventToTarget(ui::MouseEvent* event, default: break; } + bool result; if (target) { event->ConvertLocationToTarget(static_cast<Window*>(this), target); if (IsNonClientLocation(target, event->location())) event->set_flags(event->flags() | ui::EF_IS_NON_CLIENT); ProcessEvent(target, event); - return event->handled(); + if (!destroyed_tracker.Contains(this)) + return false; + result = event->handled(); + } else { + result = false; } - return false; + mouse_event_dispatch_target_ = old_mouse_event_dispatch_target; + return result; } bool RootWindow::DispatchTouchEventImpl(ui::TouchEvent* event) { diff --git a/ui/aura/test/event_generator.cc b/ui/aura/test/event_generator.cc index fd6c2c68c9..d111220ced 100644 --- a/ui/aura/test/event_generator.cc +++ b/ui/aura/test/event_generator.cc @@ -145,6 +145,14 @@ void EventGenerator::ReleaseRightButton() { ReleaseButton(ui::EF_RIGHT_MOUSE_BUTTON); } +void EventGenerator::SendMouseExit() { + gfx::Point exit_location(current_location_); + ConvertPointToTarget(current_root_window_, &exit_location); + ui::MouseEvent mouseev(ui::ET_MOUSE_EXITED, exit_location, exit_location, + flags_); + Dispatch(&mouseev); +} + void EventGenerator::MoveMouseToInHost(const gfx::Point& point_in_host) { const ui::EventType event_type = (flags_ & ui::EF_LEFT_MOUSE_BUTTON) ? ui::ET_MOUSE_DRAGGED : ui::ET_MOUSE_MOVED; diff --git a/ui/aura/test/event_generator.h b/ui/aura/test/event_generator.h index a4ffca76c3..511dd777e9 100644 --- a/ui/aura/test/event_generator.h +++ b/ui/aura/test/event_generator.h @@ -135,6 +135,9 @@ class EventGenerator { // Generates a right button release event. void ReleaseRightButton(); + // Generates a mouse exit. + void SendMouseExit(); + // Generates events to move mouse to be the given |point| in the // |current_root_window_|'s host window coordinates. void MoveMouseToInHost(const gfx::Point& point_in_host); diff --git a/ui/aura/test/test_cursor_client.cc b/ui/aura/test/test_cursor_client.cc index 463589f761..edf8ca0713 100644 --- a/ui/aura/test/test_cursor_client.cc +++ b/ui/aura/test/test_cursor_client.cc @@ -36,6 +36,9 @@ void TestCursorClient::HideCursor() { OnCursorVisibilityChanged(false)); } +void TestCursorClient::SetCursorSet(ui::CursorSetType cursor_set) { +} + void TestCursorClient::SetScale(float scale) { } diff --git a/ui/aura/test/test_cursor_client.h b/ui/aura/test/test_cursor_client.h index 850ff6835b..c10552aff0 100644 --- a/ui/aura/test/test_cursor_client.h +++ b/ui/aura/test/test_cursor_client.h @@ -21,6 +21,7 @@ class TestCursorClient : public aura::client::CursorClient { virtual void SetCursor(gfx::NativeCursor cursor) OVERRIDE; virtual void ShowCursor() OVERRIDE; virtual void HideCursor() OVERRIDE; + virtual void SetCursorSet(ui::CursorSetType cursor_set) OVERRIDE; virtual void SetScale(float scale) OVERRIDE; virtual bool IsCursorVisible() const OVERRIDE; virtual void EnableMouseEvents() OVERRIDE; diff --git a/ui/aura/test/test_screen.cc b/ui/aura/test/test_screen.cc index 13d1232b43..c43ffb490a 100644 --- a/ui/aura/test/test_screen.cc +++ b/ui/aura/test/test_screen.cc @@ -108,15 +108,22 @@ gfx::Point TestScreen::GetCursorScreenPoint() { return Env::GetInstance()->last_mouse_location(); } -gfx::NativeWindow TestScreen::GetWindowAtCursorScreenPoint() { - const gfx::Point point = GetCursorScreenPoint(); +gfx::NativeWindow TestScreen::GetWindowUnderCursor() { + return GetWindowAtScreenPoint(GetCursorScreenPoint()); +} + +gfx::NativeWindow TestScreen::GetWindowAtScreenPoint(const gfx::Point& point) { return root_window_->GetTopWindowContainingPoint(point); } -int TestScreen::GetNumDisplays() { +int TestScreen::GetNumDisplays() const { return 1; } +std::vector<gfx::Display> TestScreen::GetAllDisplays() const { + return std::vector<gfx::Display>(1, display_); +} + gfx::Display TestScreen::GetDisplayNearestWindow( gfx::NativeWindow window) const { return display_; diff --git a/ui/aura/test/test_screen.h b/ui/aura/test/test_screen.h index c4615c73fd..c9582794ad 100644 --- a/ui/aura/test/test_screen.h +++ b/ui/aura/test/test_screen.h @@ -47,8 +47,11 @@ class TestScreen : public gfx::Screen, // gfx::Screen overrides: virtual bool IsDIPEnabled() OVERRIDE; virtual gfx::Point GetCursorScreenPoint() OVERRIDE; - virtual gfx::NativeWindow GetWindowAtCursorScreenPoint() OVERRIDE; - virtual int GetNumDisplays() OVERRIDE; + virtual gfx::NativeWindow GetWindowUnderCursor() OVERRIDE; + virtual gfx::NativeWindow GetWindowAtScreenPoint(const gfx::Point& point) + OVERRIDE; + virtual int GetNumDisplays() const OVERRIDE; + virtual std::vector<gfx::Display> GetAllDisplays() const OVERRIDE; virtual gfx::Display GetDisplayNearestWindow( gfx::NativeView view) const OVERRIDE; virtual gfx::Display GetDisplayNearestPoint( diff --git a/ui/aura/window.cc b/ui/aura/window.cc index e5289e46a2..5c7007e6ee 100644 --- a/ui/aura/window.cc +++ b/ui/aura/window.cc @@ -224,9 +224,9 @@ void Window::SetName(const std::string& name) { } void Window::SetTransparent(bool transparent) { - // Cannot change transparent flag after the window is initialized. - DCHECK(!layer()); transparent_ = transparent; + if (layer()) + layer_->SetFillsBoundsOpaquely(!transparent_); } RootWindow* Window::GetRootWindow() { diff --git a/ui/base/base_window.cc b/ui/base/base_window.cc new file mode 100644 index 0000000000..231a177179 --- /dev/null +++ b/ui/base/base_window.cc @@ -0,0 +1,16 @@ +// Copyright 2013 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 "ui/base/base_window.h" + +namespace ui { + +bool BaseWindow::IsRestored(const BaseWindow& window) { + return !window.IsMaximized() && + !window.IsMinimized() && + !window.IsFullscreen(); +} + +} // namespace ui + diff --git a/ui/base/base_window.h b/ui/base/base_window.h index 4f847d1eeb..d5fd2fae1c 100644 --- a/ui/base/base_window.h +++ b/ui/base/base_window.h @@ -19,7 +19,7 @@ namespace ui { // Provides an interface to perform actions on windows, and query window // state. -class BaseWindow { +class UI_EXPORT BaseWindow { public: // Returns true if the window is currently the active/focused window. virtual bool IsActive() const = 0; @@ -33,6 +33,10 @@ class BaseWindow { // Returns true if the window is full screen. virtual bool IsFullscreen() const = 0; + // Returns true if the window is fully restored (not Fullscreen, Maximized, + // Minimized). + static bool IsRestored(const BaseWindow& window); + // Return a platform dependent identifier for this window. virtual gfx::NativeWindow GetNativeWindow() = 0; diff --git a/ui/base/cocoa/controls/hyperlink_button_cell.mm b/ui/base/cocoa/controls/hyperlink_button_cell.mm index c723b03a7c..57b70779cf 100644 --- a/ui/base/cocoa/controls/hyperlink_button_cell.mm +++ b/ui/base/cocoa/controls/hyperlink_button_cell.mm @@ -52,6 +52,14 @@ return self; } +- (id)copyWithZone:(NSZone*)zone { + NSColor* color = textColor_.release(); + HyperlinkButtonCell* cell = [super copyWithZone:zone]; + cell->textColor_.reset([color copy]); + textColor_.reset(color); + return cell; +} + // Because an NSButtonCell has multiple initializers, this method performs the // common cell customization code. - (void)customizeButtonCell { diff --git a/ui/base/cocoa/controls/hyperlink_button_cell_unittest.mm b/ui/base/cocoa/controls/hyperlink_button_cell_unittest.mm index 479141b723..3d24f01fa9 100644 --- a/ui/base/cocoa/controls/hyperlink_button_cell_unittest.mm +++ b/ui/base/cocoa/controls/hyperlink_button_cell_unittest.mm @@ -8,6 +8,7 @@ #include "base/mac/foundation_util.h" #include "base/mac/scoped_nsobject.h" +#import "testing/gtest_mac.h" #include "testing/gtest/include/gtest/gtest.h" #include "testing/platform_test.h" #import "ui/base/test/ui_cocoa_test_helper.h" @@ -115,6 +116,17 @@ TEST_F(HyperlinkButtonCellTest, UnderlineOnHover) { EXPECT_FALSE(HasUnderlineAttribute([cell_ linkAttributes])); } +TEST_F(HyperlinkButtonCellTest, Copy) { + base::scoped_nsobject<HyperlinkButtonCell> cell1([[HyperlinkButtonCell alloc] + initTextCell:@"Cell"]); + [cell1 setTextColor:[NSColor redColor]]; + + base::scoped_nsobject<HyperlinkButtonCell> cell2([cell1 copy]); + EXPECT_NSEQ([cell1 textColor], [cell2 textColor]); + [cell1 setTextColor:[NSColor purpleColor]]; + [cell2 setTextColor:[NSColor greenColor]]; +} + } // namespace } // namespace ui diff --git a/ui/base/cursor/cursor.h b/ui/base/cursor/cursor.h index 43c201db37..bb832fa963 100644 --- a/ui/base/cursor/cursor.h +++ b/ui/base/cursor/cursor.h @@ -82,6 +82,11 @@ const int kCursorGrab = 42; const int kCursorGrabbing = 43; const int kCursorCustom = 44; +enum CursorSetType { + CURSOR_SET_NORMAL, + CURSOR_SET_LARGE +}; + // Ref-counted cursor that supports both default and custom cursors. class UI_EXPORT Cursor { public: diff --git a/ui/base/cursor/cursors_aura.cc b/ui/base/cursor/cursors_aura.cc index 17349a7c45..bb5947a57e 100644 --- a/ui/base/cursor/cursors_aura.cc +++ b/ui/base/cursor/cursors_aura.cc @@ -5,7 +5,6 @@ #include "ui/base/cursor/cursors_aura.h" #include "grit/ui_resources.h" -#include "ui/base/cursor/cursor.h" #include "ui/base/resource/resource_bundle.h" #include "ui/gfx/point.h" @@ -24,7 +23,15 @@ struct CursorData { HotPoint hot_2x; }; -const CursorData kImageCursors[] = { +struct CursorSet { + const CursorSetType id; + const CursorData* cursors; + const int length; + const CursorData* animated_cursors; + const int animated_length; +}; + +const CursorData kNormalCursors[] = { {ui::kCursorNull, IDR_AURA_CURSOR_PTR, {4, 4}, {8, 9}}, {ui::kCursorPointer, IDR_AURA_CURSOR_PTR, {4, 4}, {8, 9}}, {ui::kCursorNoDrop, IDR_AURA_CURSOR_NO_DROP, {9, 9}, {18, 18}}, @@ -67,11 +74,80 @@ const CursorData kImageCursors[] = { {ui::kCursorGrabbing, IDR_AURA_CURSOR_GRABBING, {9, 9}, {18, 18}}, }; +const CursorData kLargeCursors[] = { + {ui::kCursorNull, IDR_AURA_CURSOR_BIG_PTR, {10, 10}, {10, 10}}, + {ui::kCursorPointer, IDR_AURA_CURSOR_BIG_PTR, {10, 10}, {10, 10}}, + {ui::kCursorNoDrop, IDR_AURA_CURSOR_BIG_NO_DROP, {23, 23}, {23, 23}}, + {ui::kCursorNotAllowed, IDR_AURA_CURSOR_BIG_NO_DROP, {23, 23}, {23, 23}}, + {ui::kCursorCopy, IDR_AURA_CURSOR_BIG_COPY, {23, 23}, {23, 23}}, + {ui::kCursorHand, IDR_AURA_CURSOR_BIG_HAND, {23, 10}, {23, 10}}, + {ui::kCursorMove, IDR_AURA_CURSOR_BIG_MOVE, {28, 28}, {28, 28}}, + {ui::kCursorNorthEastResize, IDR_AURA_CURSOR_BIG_NORTH_EAST_RESIZE, + {31, 28}, {31, 28}}, + {ui::kCursorSouthWestResize, IDR_AURA_CURSOR_BIG_SOUTH_WEST_RESIZE, + {31, 28}, {31, 28}}, + {ui::kCursorSouthEastResize, IDR_AURA_CURSOR_BIG_SOUTH_EAST_RESIZE, + {28, 28}, {28, 28}}, + {ui::kCursorNorthWestResize, IDR_AURA_CURSOR_BIG_NORTH_WEST_RESIZE, + {28, 28}, {28, 28}}, + {ui::kCursorNorthResize, IDR_AURA_CURSOR_BIG_NORTH_RESIZE, + {28, 31}, {28, 31}}, + {ui::kCursorSouthResize, IDR_AURA_CURSOR_BIG_SOUTH_RESIZE, + {28, 31}, {28, 31}}, + {ui::kCursorEastResize, IDR_AURA_CURSOR_BIG_EAST_RESIZE, {31, 28}, {31, 28}}, + {ui::kCursorWestResize, IDR_AURA_CURSOR_BIG_WEST_RESIZE, {31, 28}, {31, 28}}, + {ui::kCursorIBeam, IDR_AURA_CURSOR_BIG_IBEAM, {31, 31}, {31, 31}}, + {ui::kCursorAlias, IDR_AURA_CURSOR_BIG_ALIAS, {51, 15}, {51, 11}}, + {ui::kCursorCell, IDR_AURA_CURSOR_BIG_CELL, {28, 28}, {24, 23}}, + {ui::kCursorContextMenu, IDR_AURA_CURSOR_BIG_CONTEXT_MENU, {4, 4}, {8, 9}}, + {ui::kCursorCross, IDR_AURA_CURSOR_BIG_CROSSHAIR, {31, 31}, {31, 31}}, + {ui::kCursorHelp, IDR_AURA_CURSOR_BIG_HELP, {10, 10}, {8, 9}}, + {ui::kCursorVerticalText, IDR_AURA_CURSOR_BIG_XTERM_HORIZ, + {31, 28}, {31, 28}}, + {ui::kCursorZoomIn, IDR_AURA_CURSOR_BIG_ZOOM_IN, {26, 26}, {26, 26}}, + {ui::kCursorZoomOut, IDR_AURA_CURSOR_BIG_ZOOM_OUT, {26, 26}, {26, 26}}, + {ui::kCursorRowResize, IDR_AURA_CURSOR_BIG_ROW_RESIZE, {28, 31}, {28, 31}}, + {ui::kCursorColumnResize, IDR_AURA_CURSOR_BIG_COL_RESIZE, {31, 28}, {31, 28}}, + {ui::kCursorEastWestResize, IDR_AURA_CURSOR_BIG_EAST_WEST_RESIZE, + {31, 28}, {31, 28}}, + {ui::kCursorNorthSouthResize, IDR_AURA_CURSOR_BIG_NORTH_SOUTH_RESIZE, + {28, 31}, {28, 31}}, + {ui::kCursorNorthEastSouthWestResize, + IDR_AURA_CURSOR_BIG_NORTH_EAST_SOUTH_WEST_RESIZE, {31, 28}, {31, 28}}, + {ui::kCursorNorthWestSouthEastResize, + IDR_AURA_CURSOR_BIG_NORTH_WEST_SOUTH_EAST_RESIZE, {28, 28}, {28, 28}}, + {ui::kCursorGrab, IDR_AURA_CURSOR_BIG_GRAB, {20, 13}, {20, 13}}, + {ui::kCursorGrabbing, IDR_AURA_CURSOR_BIG_GRABBING, {23, 23}, {23, 23}}, +}; + const CursorData kAnimatedCursors[] = { {ui::kCursorWait, IDR_THROBBER, {7, 7}, {14, 14}}, {ui::kCursorProgress, IDR_THROBBER, {7, 7}, {14, 14}}, }; +const CursorSet kCursorSets[] = { + { + CURSOR_SET_NORMAL, + kNormalCursors, arraysize(kNormalCursors), + kAnimatedCursors, arraysize(kAnimatedCursors) + }, + { + CURSOR_SET_LARGE, + kLargeCursors, arraysize(kLargeCursors), + // TODO(yoshiki): Replace animated cursors with big assets. crbug.com/247254 + kAnimatedCursors, arraysize(kAnimatedCursors) + }, +}; + +const CursorSet* GetCursorSetByType(CursorSetType cursor_set_id) { + for (size_t i = 0; i < arraysize(kCursorSets); ++i) { + if (kCursorSets[i].id == cursor_set_id) + return &kCursorSets[i]; + } + + return NULL; +} + bool SearchTable(const CursorData* table, size_t table_length, int id, @@ -96,19 +172,45 @@ bool SearchTable(const CursorData* table, } // namespace -bool GetCursorDataFor(int id, +bool GetCursorDataFor(CursorSetType cursor_set_id, + int id, float scale_factor, int* resource_id, gfx::Point* point) { - return SearchTable(kImageCursors, arraysize(kImageCursors), + const CursorSet* cursor_set = GetCursorSetByType(cursor_set_id); + if (cursor_set && + SearchTable(cursor_set->cursors, + cursor_set->length, + id, scale_factor, resource_id, point)) { + return true; + } + + // Falls back to the default cursor set. + cursor_set = GetCursorSetByType(ui::CURSOR_SET_NORMAL); + DCHECK(cursor_set); + return SearchTable(cursor_set->cursors, + cursor_set->length, id, scale_factor, resource_id, point); } -bool GetAnimatedCursorDataFor(int id, +bool GetAnimatedCursorDataFor(CursorSetType cursor_set_id, + int id, float scale_factor, int* resource_id, gfx::Point* point) { - return SearchTable(kAnimatedCursors, arraysize(kAnimatedCursors), + const CursorSet* cursor_set = GetCursorSetByType(cursor_set_id); + if (cursor_set && + SearchTable(cursor_set->animated_cursors, + cursor_set->animated_length, + id, scale_factor, resource_id, point)) { + return true; + } + + // Falls back to the default cursor set. + cursor_set = GetCursorSetByType(ui::CURSOR_SET_NORMAL); + DCHECK(cursor_set); + return SearchTable(cursor_set->animated_cursors, + cursor_set->animated_length, id, scale_factor, resource_id, point); } diff --git a/ui/base/cursor/cursors_aura.h b/ui/base/cursor/cursors_aura.h index 4565a704e7..e916c28575 100644 --- a/ui/base/cursor/cursors_aura.h +++ b/ui/base/cursor/cursors_aura.h @@ -5,6 +5,7 @@ #ifndef UI_BASE_CURSOR_CURSORS_AURA_H_ #define UI_BASE_CURSOR_CURSORS_AURA_H_ +#include "ui/base/cursor/cursor.h" #include "ui/base/ui_export.h" namespace gfx { @@ -19,13 +20,15 @@ const int kAnimatedCursorFrameDelayMs = 25; // ui::kCursorHelp. The IDR will be placed in |resource_id| and the hotspots // for the different DPIs will be placed in |hot_1x| and |hot_2x|. Returns // false if |id| is invalid. -bool UI_EXPORT GetCursorDataFor(int id, +bool UI_EXPORT GetCursorDataFor(CursorSetType cursor_set_id, + int id, float scale_factor, int* resource_id, gfx::Point* point); // Like above, but for animated cursors. -bool UI_EXPORT GetAnimatedCursorDataFor(int id, +bool UI_EXPORT GetAnimatedCursorDataFor(CursorSetType cursor_set_id, + int id, float scale_factor, int* resource_id, gfx::Point* point); diff --git a/ui/base/default_theme_provider.cc b/ui/base/default_theme_provider.cc index e60c90029c..9777b39072 100644 --- a/ui/base/default_theme_provider.cc +++ b/ui/base/default_theme_provider.cc @@ -26,8 +26,8 @@ SkColor DefaultThemeProvider::GetColor(int id) const { return 0xff0000ff; } -bool DefaultThemeProvider::GetDisplayProperty(int id, int* result) const { - return false; +int DefaultThemeProvider::GetDisplayProperty(int id) const { + return -1; } bool DefaultThemeProvider::ShouldUseNativeFrame() const { diff --git a/ui/base/default_theme_provider.h b/ui/base/default_theme_provider.h index 2594dfbf66..15fa4a9f48 100644 --- a/ui/base/default_theme_provider.h +++ b/ui/base/default_theme_provider.h @@ -26,7 +26,7 @@ class UI_EXPORT DefaultThemeProvider : public ThemeProvider { // Overridden from ui::ThemeProvider: virtual gfx::ImageSkia* GetImageSkiaNamed(int id) const OVERRIDE; virtual SkColor GetColor(int id) const OVERRIDE; - virtual bool GetDisplayProperty(int id, int* result) const OVERRIDE; + virtual int GetDisplayProperty(int id) const OVERRIDE; virtual bool ShouldUseNativeFrame() const OVERRIDE; virtual bool HasCustomImage(int id) const OVERRIDE; virtual base::RefCountedMemory* GetRawData( diff --git a/ui/base/gestures/gesture_recognizer.h b/ui/base/gestures/gesture_recognizer.h index b32bade828..2affc7a81d 100644 --- a/ui/base/gestures/gesture_recognizer.h +++ b/ui/base/gestures/gesture_recognizer.h @@ -25,7 +25,7 @@ class UI_EXPORT GestureRecognizer { virtual ~GestureRecognizer() {} // Invoked for each touch event that could contribute to the current gesture. - // Returns list of zero or more GestureEvents identified after processing + // Returns list of zero or more GestureEvents identified after processing // TouchEvent. // Caller would be responsible for freeing up Gestures. virtual Gestures* ProcessTouchEventForGesture(const TouchEvent& event, diff --git a/ui/base/ime/dummy_input_method.cc b/ui/base/ime/dummy_input_method.cc index f762e3b0b9..b9f69418b0 100644 --- a/ui/base/ime/dummy_input_method.cc +++ b/ui/base/ime/dummy_input_method.cc @@ -72,6 +72,10 @@ TextInputType DummyInputMethod::GetTextInputType() const { return TEXT_INPUT_TYPE_NONE; } +TextInputMode DummyInputMethod::GetTextInputMode() const { + return TEXT_INPUT_MODE_DEFAULT; +} + bool DummyInputMethod::CanComposeInline() const { return true; } diff --git a/ui/base/ime/dummy_input_method.h b/ui/base/ime/dummy_input_method.h index 2276ae5d9a..165bc529d6 100644 --- a/ui/base/ime/dummy_input_method.h +++ b/ui/base/ime/dummy_input_method.h @@ -36,6 +36,7 @@ class DummyInputMethod : public InputMethod { virtual base::i18n::TextDirection GetInputTextDirection() OVERRIDE; virtual bool IsActive() OVERRIDE; virtual TextInputType GetTextInputType() const OVERRIDE; + virtual TextInputMode GetTextInputMode() const OVERRIDE; virtual bool CanComposeInline() const OVERRIDE; virtual bool IsCandidatePopupOpen() const OVERRIDE; virtual void AddObserver(InputMethodObserver* observer) OVERRIDE; diff --git a/ui/base/ime/fake_input_method.cc b/ui/base/ime/fake_input_method.cc index 1cf236de56..15f1283e19 100644 --- a/ui/base/ime/fake_input_method.cc +++ b/ui/base/ime/fake_input_method.cc @@ -141,8 +141,12 @@ bool FakeInputMethod::IsCandidatePopupOpen() const { return false; } -ui::TextInputType FakeInputMethod::GetTextInputType() const { - return ui::TEXT_INPUT_TYPE_NONE; +TextInputType FakeInputMethod::GetTextInputType() const { + return TEXT_INPUT_TYPE_NONE; +} + +TextInputMode FakeInputMethod::GetTextInputMode() const { + return TEXT_INPUT_MODE_DEFAULT; } bool FakeInputMethod::CanComposeInline() const { diff --git a/ui/base/ime/fake_input_method.h b/ui/base/ime/fake_input_method.h index 12f9aac018..e80d2bcbab 100644 --- a/ui/base/ime/fake_input_method.h +++ b/ui/base/ime/fake_input_method.h @@ -44,7 +44,8 @@ class UI_EXPORT FakeInputMethod : NON_EXPORTED_BASE(public InputMethod) { virtual std::string GetInputLocale() OVERRIDE; virtual base::i18n::TextDirection GetInputTextDirection() OVERRIDE; virtual bool IsActive() OVERRIDE; - virtual ui::TextInputType GetTextInputType() const OVERRIDE; + virtual TextInputType GetTextInputType() const OVERRIDE; + virtual TextInputMode GetTextInputMode() const OVERRIDE; virtual bool CanComposeInline() const OVERRIDE; virtual bool IsCandidatePopupOpen() const OVERRIDE; virtual void AddObserver(InputMethodObserver* observer) OVERRIDE; diff --git a/ui/base/ime/input_method.h b/ui/base/ime/input_method.h index 575cbcdb30..0d4046f3e3 100644 --- a/ui/base/ime/input_method.h +++ b/ui/base/ime/input_method.h @@ -10,6 +10,7 @@ #include "base/basictypes.h" #include "base/event_types.h" #include "base/i18n/rtl.h" +#include "ui/base/ime/text_input_mode.h" #include "ui/base/ime/text_input_type.h" #include "ui/base/keycodes/keyboard_codes.h" #include "ui/base/ui_export.h" @@ -140,10 +141,18 @@ class InputMethod { // is not active. virtual bool IsActive() = 0; + // TODO(yoichio): Following 3 methods(GetTextInputType, GetTextInputMode and + // CanComposeInline) calls client's same method and returns its value. It is + // not InputMethod itself's infomation. So rename these to + // GetClientTextInputType and so on. // Gets the text input type of the focused text input client. Returns // ui::TEXT_INPUT_TYPE_NONE if there is no focused client. virtual TextInputType GetTextInputType() const = 0; + // Gets the text input mode of the focused text input client. Returns + // ui::TEXT_INPUT_TYPE_DEFAULT if there is no focused client. + virtual TextInputMode GetTextInputMode() const = 0; + // Checks if the focused text input client supports inline composition. virtual bool CanComposeInline() const = 0; diff --git a/ui/base/ime/input_method_base.cc b/ui/base/ime/input_method_base.cc index 6972eed925..23d21ba461 100644 --- a/ui/base/ime/input_method_base.cc +++ b/ui/base/ime/input_method_base.cc @@ -67,6 +67,11 @@ TextInputType InputMethodBase::GetTextInputType() const { return client ? client->GetTextInputType() : TEXT_INPUT_TYPE_NONE; } +TextInputMode InputMethodBase::GetTextInputMode() const { + TextInputClient* client = GetTextInputClient(); + return client ? client->GetTextInputMode() : TEXT_INPUT_MODE_DEFAULT; +} + bool InputMethodBase::CanComposeInline() const { TextInputClient* client = GetTextInputClient(); return client ? client->CanComposeInline() : true; diff --git a/ui/base/ime/input_method_base.h b/ui/base/ime/input_method_base.h index e467e0bec8..655fd4abf0 100644 --- a/ui/base/ime/input_method_base.h +++ b/ui/base/ime/input_method_base.h @@ -44,6 +44,7 @@ class UI_EXPORT InputMethodBase : NON_EXPORTED_BASE(public InputMethod) { virtual void OnTextInputTypeChanged(const TextInputClient* client) OVERRIDE; virtual TextInputType GetTextInputType() const OVERRIDE; + virtual TextInputMode GetTextInputMode() const OVERRIDE; virtual bool CanComposeInline() const OVERRIDE; virtual void AddObserver(InputMethodObserver* observer) OVERRIDE; diff --git a/ui/base/ime/input_method_tsf.cc b/ui/base/ime/input_method_tsf.cc index 21a57a86e1..b9e6c7c768 100644 --- a/ui/base/ime/input_method_tsf.cc +++ b/ui/base/ime/input_method_tsf.cc @@ -117,13 +117,15 @@ void InputMethodTSF::CancelComposition(const TextInputClient* client) { void InputMethodTSF::SetFocusedTextInputClient(TextInputClient* client) { if (IsWindowFocused(client)) { - ui::TSFBridge::GetInstance()->SetFocusedClient( - GetAttachedWindowHandle(client), client); - } else if (!client) { - // SetFocusedTextInputClient(NULL) must be interpreted as - // "Remove the attached client". - ui::TSFBridge::GetInstance()->RemoveFocusedClient( - ui::TSFBridge::GetInstance()->GetFocusedTextInputClient()); + if (IsTextInputClientFocused(client)) { + ui::TSFBridge::GetInstance()->SetFocusedClient( + GetAttachedWindowHandle(client), client); + } else { + // SetFocusedTextInputClient(NULL) must be interpreted as + // "Remove the attached client". + ui::TSFBridge::GetInstance()->RemoveFocusedClient( + ui::TSFBridge::GetInstance()->GetFocusedTextInputClient()); + } } InputMethodWin::SetFocusedTextInputClient(client); } @@ -142,9 +144,10 @@ void InputMethodTSF::OnWillChangeFocusedClient(TextInputClient* focused_before, void InputMethodTSF::OnDidChangeFocusedClient(TextInputClient* focused_before, TextInputClient* focused) { - if (IsWindowFocused(focused)) { + if (IsWindowFocused(focused) && IsTextInputClientFocused(focused)) { ui::TSFBridge::GetInstance()->SetFocusedClient( GetAttachedWindowHandle(focused), focused); + // Force to update the input type since client's TextInputStateChanged() // function might not be called if text input types before the client loses // focus and after it acquires focus again are the same. @@ -162,8 +165,6 @@ void InputMethodTSF::ConfirmCompositionText() { } bool InputMethodTSF::IsWindowFocused(const TextInputClient* client) const { - if (!client) - return false; HWND attached_window_handle = GetAttachedWindowHandle(client); return attached_window_handle && GetFocus() == attached_window_handle; } diff --git a/ui/base/ime/mock_input_method.cc b/ui/base/ime/mock_input_method.cc index 7701b5c8f0..aed83c2ba7 100644 --- a/ui/base/ime/mock_input_method.cc +++ b/ui/base/ime/mock_input_method.cc @@ -83,8 +83,12 @@ bool MockInputMethod::IsActive() { return true; } -ui::TextInputType MockInputMethod::GetTextInputType() const { - return ui::TEXT_INPUT_TYPE_NONE; +TextInputType MockInputMethod::GetTextInputType() const { + return TEXT_INPUT_TYPE_NONE; +} + +TextInputMode MockInputMethod::GetTextInputMode() const { + return TEXT_INPUT_MODE_DEFAULT; } bool MockInputMethod::CanComposeInline() const { diff --git a/ui/base/ime/mock_input_method.h b/ui/base/ime/mock_input_method.h index f318ca40ff..fdeff5ee8c 100644 --- a/ui/base/ime/mock_input_method.h +++ b/ui/base/ime/mock_input_method.h @@ -60,6 +60,7 @@ class UI_EXPORT MockInputMethod : NON_EXPORTED_BASE(public InputMethod) { virtual base::i18n::TextDirection GetInputTextDirection() OVERRIDE; virtual bool IsActive() OVERRIDE; virtual TextInputType GetTextInputType() const OVERRIDE; + virtual TextInputMode GetTextInputMode() const OVERRIDE; virtual bool CanComposeInline() const OVERRIDE; virtual bool IsCandidatePopupOpen() const OVERRIDE; virtual void AddObserver(InputMethodObserver* observer) OVERRIDE; diff --git a/ui/base/ime/win/tsf_text_store.cc b/ui/base/ime/win/tsf_text_store.cc index 27739ad5be..ce566890b3 100644 --- a/ui/base/ime/win/tsf_text_store.cc +++ b/ui/base/ime/win/tsf_text_store.cc @@ -610,7 +610,8 @@ STDMETHODIMP TSFTextStore::RetrieveRequestedAttrs( attribute_buffer[0].idAttr = GUID_PROP_INPUTSCOPE; attribute_buffer[0].varValue.vt = VT_UNKNOWN; attribute_buffer[0].varValue.punkVal = tsf_inputscope::CreateInputScope( - text_input_client_->GetTextInputType(), TEXT_INPUT_MODE_DEFAULT); + text_input_client_->GetTextInputType(), + text_input_client_->GetTextInputMode()); attribute_buffer[0].varValue.punkVal->AddRef(); *attribute_buffer_copied = 1; return S_OK; diff --git a/ui/base/models/simple_menu_model.cc b/ui/base/models/simple_menu_model.cc index 2687822f1f..a2fa4bb546 100644 --- a/ui/base/models/simple_menu_model.cc +++ b/ui/base/models/simple_menu_model.cc @@ -135,6 +135,7 @@ void SimpleMenuModel::AddSeparator(MenuSeparatorType separator_type) { void SimpleMenuModel::RemoveTrailingSeparators() { while (!items_.empty() && items_.back().type == TYPE_SEPARATOR) items_.pop_back(); + MenuItemsChanged(); } void SimpleMenuModel::AddButtonItem(int command_id, @@ -227,14 +228,17 @@ void SimpleMenuModel::InsertSubMenuWithStringIdAt( void SimpleMenuModel::SetIcon(int index, const gfx::Image& icon) { items_[ValidateItemIndex(index)].icon = icon; + MenuItemsChanged(); } void SimpleMenuModel::SetSublabel(int index, const base::string16& sublabel) { items_[ValidateItemIndex(index)].sublabel = sublabel; + MenuItemsChanged(); } void SimpleMenuModel::Clear() { items_.clear(); + MenuItemsChanged(); } int SimpleMenuModel::GetIndexOfCommandId(int command_id) { @@ -390,6 +394,12 @@ void SimpleMenuModel::OnMenuClosed() { } //////////////////////////////////////////////////////////////////////////////// +// SimpleMenuModel, Protected: + +void SimpleMenuModel::MenuItemsChanged() { +} + +//////////////////////////////////////////////////////////////////////////////// // SimpleMenuModel, Private: int SimpleMenuModel::ValidateItemIndex(int index) const { @@ -401,11 +411,13 @@ int SimpleMenuModel::ValidateItemIndex(int index) const { void SimpleMenuModel::AppendItem(const Item& item) { ValidateItem(item); items_.push_back(item); + MenuItemsChanged(); } void SimpleMenuModel::InsertItemAtIndex(const Item& item, int index) { ValidateItem(item); items_.insert(items_.begin() + index, item); + MenuItemsChanged(); } void SimpleMenuModel::ValidateItem(const Item& item) { diff --git a/ui/base/models/simple_menu_model.h b/ui/base/models/simple_menu_model.h index 2204b982fa..6582dfecf6 100644 --- a/ui/base/models/simple_menu_model.h +++ b/ui/base/models/simple_menu_model.h @@ -164,6 +164,10 @@ class UI_EXPORT SimpleMenuModel : public MenuModel { void set_delegate(Delegate* delegate) { delegate_ = delegate; } Delegate* delegate() { return delegate_; } + // One or more of the menu menu items associated with the model has changed. + // Do any handling if necessary. + virtual void MenuItemsChanged(); + private: struct Item; diff --git a/ui/base/ozone/surface_factory_ozone.h b/ui/base/ozone/surface_factory_ozone.h index 5df6bd9547..0febe3614c 100644 --- a/ui/base/ozone/surface_factory_ozone.h +++ b/ui/base/ozone/surface_factory_ozone.h @@ -12,7 +12,7 @@ namespace gfx { class Screen; class VSyncProvider; -} // namespace gfx +} // namespace gfx namespace ui { diff --git a/ui/base/range/range.cc b/ui/base/range/range.cc index 75325646a7..a76ddba34b 100644 --- a/ui/base/range/range.cc +++ b/ui/base/range/range.cc @@ -80,4 +80,8 @@ std::string Range::ToString() const { return base::StringPrintf("{%" PRIuS ",%" PRIuS "}", start(), end()); } -} // namespace gfx +std::ostream& operator<<(std::ostream& os, const Range& range) { + return os << range.ToString(); +} + +} // namespace ui diff --git a/ui/base/range/range.h b/ui/base/range/range.h index b8bf478682..c425da779e 100644 --- a/ui/base/range/range.h +++ b/ui/base/range/range.h @@ -5,6 +5,7 @@ #ifndef UI_BASE_RANGE_RANGE_H_ #define UI_BASE_RANGE_RANGE_H_ +#include <ostream> #include <string> #include "base/basictypes.h" @@ -109,6 +110,8 @@ class UI_EXPORT Range { size_t end_; }; +UI_EXPORT std::ostream& operator<<(std::ostream& os, const Range& range); + } // namespace ui #endif // UI_BASE_RANGE_RANGE_H_ diff --git a/ui/base/strings/ui_strings.grd b/ui/base/strings/ui_strings.grd index fd4eb5a6c7..e412ed6499 100644 --- a/ui/base/strings/ui_strings.grd +++ b/ui/base/strings/ui_strings.grd @@ -1515,11 +1515,8 @@ need to be translated for each locale.--> <message name="IDS_MESSAGE_CENTER_ACCESSIBLE_NAME" desc="The accessible name for the Notification Center window."> Notification Center </message> - <message name="IDS_MESSAGE_CENTER_EXTENSIONS_DISABLE" desc="The menu entry for disabling extensions from a notification."> - Disable notifications from <ph name="extension_name">$1<ex>Notification Galore!</ex></ph> - </message> - <message name="IDS_MESSAGE_CENTER_SITE_DISABLE" desc="The menu entry for disabling notification from a site."> - Disable notifications from <ph name="site">$1<ex>mail.google.com</ex></ph> + <message name="IDS_MESSAGE_CENTER_NOTIFIER_DISABLE" desc="The menu entry for disabling a notifier from a notification."> + Disable notifications from <ph name="notifier_name">$1<ex>Notification Galore!</ex></ph> </message> <message name="IDS_MESSAGE_CENTER_FOOTER_TITLE" desc="The label in the footer of the message center"> Notifications diff --git a/ui/base/theme_provider.h b/ui/base/theme_provider.h index 22f70a0025..d12e265623 100644 --- a/ui/base/theme_provider.h +++ b/ui/base/theme_provider.h @@ -59,7 +59,7 @@ class UI_EXPORT ThemeProvider { // Get the property (e.g. an alignment expressed in an enum, or a width or // height) specified by |id|. - virtual bool GetDisplayProperty(int id, int* result) const = 0; + virtual int GetDisplayProperty(int id) const = 0; // Whether we should use the native system frame (typically Aero glass) or // a custom frame. diff --git a/ui/base/win/dpi.cc b/ui/base/win/dpi.cc index 63804594d8..cbb5890a6c 100644 --- a/ui/base/win/dpi.cc +++ b/ui/base/win/dpi.cc @@ -7,6 +7,7 @@ #include <windows.h> #include "base/command_line.h" #include "base/win/scoped_hdc.h" +#include "base/win/windows_version.h" #include "ui/base/layout.h" #include "base/win/registry.h" #include "ui/base/ui_base_switches.h" @@ -162,6 +163,15 @@ double GetUndocumentedDPIScale() { return scale; } + +double GetUndocumentedDPITouchScale() { + static double scale = + (base::win::GetVersion() < base::win::VERSION_WIN8_1) ? + GetUndocumentedDPIScale() : 1.0; + return scale; +} + + } // namespace win } // namespace ui diff --git a/ui/base/win/dpi.h b/ui/base/win/dpi.h index 90edc7ca39..86a38830e5 100644 --- a/ui/base/win/dpi.h +++ b/ui/base/win/dpi.h @@ -44,13 +44,19 @@ UI_EXPORT gfx::Size DIPToScreenSize(const gfx::Size& dip_size); // GetSystemMetrics for the given |metric|, then converts the result to DIP. UI_EXPORT int GetSystemMetricsInDIP(int metric); -// The OS secretly scales apps that are not DPIAware. This is not visible -// through standard OS calls like GetWindowPos(), or through GetDPIScale(). +// Sometimes the OS secretly scales apps that are not DPIAware. This is not +// visible through standard OS calls like GetWindowPos(), or through +// GetDPIScale(). // Returns the scale factor of the display, where 96 DPI is 1.0. // (Avoid this function... use GetDPIScale() instead.) // TODO(girard): Remove this once DPIAware is enabled - http://crbug.com/149881 UI_EXPORT double GetUndocumentedDPIScale(); +// Win7 and Win8 send touch events scaled according to the current DPI +// scaling. Win8.1 corrects this, and sends touch events in DPI units. +// This function returns the appropriate scaling factor for touch events. +UI_EXPORT double GetUndocumentedDPITouchScale(); + } // namespace win } // namespace ui diff --git a/ui/base/win/events_win.cc b/ui/base/win/events_win.cc index 6cabff9c22..bcd72727dd 100644 --- a/ui/base/win/events_win.cc +++ b/ui/base/win/events_win.cc @@ -357,6 +357,8 @@ int GetModifiersFromKeyState() { modifiers |= EF_CONTROL_DOWN; if (base::win::IsAltPressed()) modifiers |= EF_ALT_DOWN; + if (base::win::IsAltGrPressed()) + modifiers |= EF_ALTGR_DOWN; return modifiers; } diff --git a/ui/base/win/hwnd_subclass.cc b/ui/base/win/hwnd_subclass.cc index c1133f0543..fc4f6c9acb 100644 --- a/ui/base/win/hwnd_subclass.cc +++ b/ui/base/win/hwnd_subclass.cc @@ -143,8 +143,10 @@ LRESULT HWNDSubclass::OnWndProc(HWND hwnd, if (GetTouchInputInfoWrapper(reinterpret_cast<HTOUCHINPUT>(l_param), 1, &point, sizeof(TOUCHINPUT))) { POINT touch_location = { - TOUCH_COORD_TO_PIXEL(point.x) / ui::win::GetUndocumentedDPIScale(), - TOUCH_COORD_TO_PIXEL(point.y) / ui::win::GetUndocumentedDPIScale()}; + TOUCH_COORD_TO_PIXEL(point.x) / + ui::win::GetUndocumentedDPITouchScale(), + TOUCH_COORD_TO_PIXEL(point.y) / + ui::win::GetUndocumentedDPITouchScale()}; HWND actual_target = WindowFromPoint(touch_location); if (actual_target != hwnd) { return SendMessage(actual_target, message, w_param, l_param); diff --git a/ui/compositor/DEPS b/ui/compositor/DEPS index 66c3932cf5..7a2d98ba46 100644 --- a/ui/compositor/DEPS +++ b/ui/compositor/DEPS @@ -4,6 +4,5 @@ include_rules = [ "+cc", "+third_party/WebKit/public/platform/WebGraphicsContext3D.h", - "+third_party/WebKit/public/platform/WebString.h", "+webkit/common/gpu", ] diff --git a/ui/compositor/layer.cc b/ui/compositor/layer.cc index f5bf42c256..c464ed733d 100644 --- a/ui/compositor/layer.cc +++ b/ui/compositor/layer.cc @@ -444,6 +444,7 @@ void Layer::SwitchToLayer(scoped_refptr<cc::Layer> new_layer) { DCHECK(parent_->cc_layer_); parent_->cc_layer_->ReplaceChild(cc_layer_, new_layer); } + cc_layer_->SetLayerClient(NULL); cc_layer_->RemoveLayerAnimationEventObserver(this); new_layer->SetOpacity(cc_layer_->opacity()); new_layer->SetTransform(cc_layer_->transform()); @@ -460,6 +461,7 @@ void Layer::SwitchToLayer(scoped_refptr<cc::Layer> new_layer) { DCHECK(children_[i]->cc_layer_); cc_layer_->AddChild(children_[i]->cc_layer_); } + cc_layer_->SetLayerClient(this); cc_layer_->SetAnchorPoint(gfx::PointF()); cc_layer_->SetContentsOpaque(fills_bounds_opaquely_); cc_layer_->SetForceRenderSurface(force_render_surface_); @@ -675,6 +677,10 @@ void Layer::SetForceRenderSurface(bool force) { cc_layer_->SetForceRenderSurface(force_render_surface_); } +std::string Layer::DebugName() { + return name_; +} + void Layer::OnAnimationStarted(const cc::AnimationEvent& event) { if (animator_.get()) animator_->OnThreadedAnimationStarted(event); @@ -917,6 +923,7 @@ void Layer::CreateWebLayer() { cc_layer_->SetContentsOpaque(true); cc_layer_->SetIsDrawable(type_ != LAYER_NOT_DRAWN); cc_layer_->AddLayerAnimationEventObserver(this); + cc_layer_->SetLayerClient(this); RecomputePosition(); } diff --git a/ui/compositor/layer.h b/ui/compositor/layer.h index cd640b1a2b..1416f5f960 100644 --- a/ui/compositor/layer.h +++ b/ui/compositor/layer.h @@ -16,6 +16,7 @@ #include "cc/animation/layer_animation_event_observer.h" #include "cc/base/scoped_ptr_vector.h" #include "cc/layers/content_layer_client.h" +#include "cc/layers/layer_client.h" #include "cc/layers/texture_layer_client.h" #include "cc/resources/texture_mailbox.h" #include "third_party/skia/include/core/SkColor.h" @@ -62,6 +63,7 @@ class COMPOSITOR_EXPORT Layer : public LayerAnimationDelegate, NON_EXPORTED_BASE(public cc::ContentLayerClient), NON_EXPORTED_BASE(public cc::TextureLayerClient), + NON_EXPORTED_BASE(public cc::LayerClient), NON_EXPORTED_BASE(public cc::LayerAnimationEventObserver) { public: Layer(); @@ -330,6 +332,9 @@ class COMPOSITOR_EXPORT Layer void SetForceRenderSurface(bool force); bool force_render_surface() const { return force_render_surface_; } + // LayerClient + virtual std::string DebugName() OVERRIDE; + // LayerAnimationEventObserver virtual void OnAnimationStarted(const cc::AnimationEvent& event) OVERRIDE; diff --git a/ui/compositor/layer_animator_unittest.cc b/ui/compositor/layer_animator_unittest.cc index 8b4d792bf7..5cae43cb79 100644 --- a/ui/compositor/layer_animator_unittest.cc +++ b/ui/compositor/layer_animator_unittest.cc @@ -1764,13 +1764,13 @@ TEST(LayerAnimatorTest, ObserverReleasedBeforeAnimationSequenceEnds) { animator->StartAnimation(sequence); // |observer| should be attached to |sequence|. - EXPECT_EQ(static_cast<size_t>(1), sequence->observers_.size()); + EXPECT_TRUE(sequence->observers_.might_have_observers()); // Now, release |observer| observer.reset(); // And |sequence| should no longer be attached to |observer|. - EXPECT_EQ(static_cast<size_t>(0), sequence->observers_.size()); + EXPECT_FALSE(sequence->observers_.might_have_observers()); } TEST(LayerAnimatorTest, ObserverAttachedAfterAnimationStarted) { diff --git a/ui/gfx/codec/png_codec.cc b/ui/gfx/codec/png_codec.cc index ed503fbf0c..30e4eb6d65 100644 --- a/ui/gfx/codec/png_codec.cc +++ b/ui/gfx/codec/png_codec.cc @@ -472,7 +472,7 @@ bool PNGCodec::Decode(const unsigned char* input, size_t input_size, // static SkBitmap* PNGCodec::CreateSkBitmapFromBGRAFormat( - std::vector<unsigned char>& bgra, int width, int height) { + const std::vector<unsigned char>& bgra, int width, int height) { SkBitmap* bitmap = new SkBitmap(); bitmap->setConfig(SkBitmap::kARGB_8888_Config, width, height); bitmap->allocPixels(); @@ -654,29 +654,14 @@ bool DoLibpngWrite(png_struct* png_ptr, png_info* info_ptr, return true; } -} // namespace - -// static -bool PNGCodec::Encode(const unsigned char* input, ColorFormat format, - const Size& size, int row_byte_width, - bool discard_transparency, - const std::vector<Comment>& comments, - std::vector<unsigned char>* output) { - return PNGCodec::EncodeWithCompressionLevel(input, format, size, - row_byte_width, - discard_transparency, - comments, Z_DEFAULT_COMPRESSION, - output); -} - -// static -bool PNGCodec::EncodeWithCompressionLevel(const unsigned char* input, - ColorFormat format, const Size& size, - int row_byte_width, - bool discard_transparency, - const std::vector<Comment>& comments, - int compression_level, - std::vector<unsigned char>* output) { +bool EncodeWithCompressionLevel(const unsigned char* input, + PNGCodec::ColorFormat format, + const Size& size, + int row_byte_width, + bool discard_transparency, + const std::vector<PNGCodec::Comment>& comments, + int compression_level, + std::vector<unsigned char>* output) { // Run to convert an input row into the output row format, NULL means no // conversion is necessary. FormatConverter converter = NULL; @@ -684,13 +669,13 @@ bool PNGCodec::EncodeWithCompressionLevel(const unsigned char* input, int input_color_components, output_color_components; int png_output_color_type; switch (format) { - case FORMAT_RGB: + case PNGCodec::FORMAT_RGB: input_color_components = 3; output_color_components = 3; png_output_color_type = PNG_COLOR_TYPE_RGB; break; - case FORMAT_RGBA: + case PNGCodec::FORMAT_RGBA: input_color_components = 4; if (discard_transparency) { output_color_components = 3; @@ -703,7 +688,7 @@ bool PNGCodec::EncodeWithCompressionLevel(const unsigned char* input, } break; - case FORMAT_BGRA: + case PNGCodec::FORMAT_BGRA: input_color_components = 4; if (discard_transparency) { output_color_components = 3; @@ -716,7 +701,7 @@ bool PNGCodec::EncodeWithCompressionLevel(const unsigned char* input, } break; - case FORMAT_SkBitmap: + case PNGCodec::FORMAT_SkBitmap: input_color_components = 4; if (discard_transparency) { output_color_components = 3; @@ -758,18 +743,37 @@ bool PNGCodec::EncodeWithCompressionLevel(const unsigned char* input, return success; } + +} // namespace + +// static +bool PNGCodec::Encode(const unsigned char* input, ColorFormat format, + const Size& size, int row_byte_width, + bool discard_transparency, + const std::vector<Comment>& comments, + std::vector<unsigned char>* output) { + return EncodeWithCompressionLevel(input, + format, + size, + row_byte_width, + discard_transparency, + comments, + Z_DEFAULT_COMPRESSION, + output); +} + // static bool PNGCodec::EncodeBGRASkBitmap(const SkBitmap& input, bool discard_transparency, std::vector<unsigned char>* output) { static const int bbp = 4; - SkAutoLockPixels lock_input(input); if (input.empty()) return false; DCHECK_EQ(input.bytesPerPixel(), bbp); DCHECK_GE(static_cast<int>(input.rowBytes()), input.width() * bbp); + SkAutoLockPixels lock_input(input); return Encode(reinterpret_cast<unsigned char*>(input.getAddr32(0, 0)), FORMAT_SkBitmap, Size(input.width(), input.height()), static_cast<int>(input.rowBytes()), discard_transparency, @@ -782,12 +786,12 @@ bool PNGCodec::FastEncodeBGRASkBitmap(const SkBitmap& input, std::vector<unsigned char>* output) { static const int bbp = 4; - SkAutoLockPixels lock_input(input); if (input.empty()) return false; DCHECK_EQ(input.bytesPerPixel(), bbp); DCHECK_GE(static_cast<int>(input.rowBytes()), input.width() * bbp); + SkAutoLockPixels lock_input(input); return EncodeWithCompressionLevel( reinterpret_cast<unsigned char*>(input.getAddr32(0, 0)), FORMAT_SkBitmap, Size(input.width(), input.height()), diff --git a/ui/gfx/codec/png_codec.h b/ui/gfx/codec/png_codec.h index eec36ae3f6..0088bb3fb1 100644 --- a/ui/gfx/codec/png_codec.h +++ b/ui/gfx/codec/png_codec.h @@ -51,16 +51,6 @@ class UI_EXPORT PNGCodec { std::string text; }; - // Calls PNGCodec::EncodeWithCompressionLevel with the default compression - // level. - static bool Encode(const unsigned char* input, - ColorFormat format, - const Size& size, - int row_byte_width, - bool discard_transparency, - const std::vector<Comment>& comments, - std::vector<unsigned char>* output); - // Encodes the given raw 'input' data, with each pixel being represented as // given in 'format'. The encoded PNG data will be written into the supplied // vector and true will be returned on success. On failure (false), the @@ -78,16 +68,13 @@ class UI_EXPORT PNGCodec { // written to the resulting file. Otherwise, alpha values in the input // will be preserved. // comments: comments to be written in the png's metadata. - // compression_level: An integer between -1 and 9, corresponding to zlib's - // compression levels. -1 is the default. - static bool EncodeWithCompressionLevel(const unsigned char* input, - ColorFormat format, - const Size& size, - int row_byte_width, - bool discard_transparency, - const std::vector<Comment>& comments, - int compression_level, - std::vector<unsigned char>* output); + static bool Encode(const unsigned char* input, + ColorFormat format, + const Size& size, + int row_byte_width, + bool discard_transparency, + const std::vector<Comment>& comments, + std::vector<unsigned char>* output); // Call PNGCodec::Encode on the supplied SkBitmap |input|, which is assumed // to be BGRA, 32 bits per pixel. The params |discard_transparency| and @@ -130,7 +117,7 @@ class UI_EXPORT PNGCodec { // Create a SkBitmap from a decoded BGRA DIB. The caller owns the returned // SkBitmap. static SkBitmap* CreateSkBitmapFromBGRAFormat( - std::vector<unsigned char>& bgra, int width, int height); + const std::vector<unsigned char>& bgra, int width, int height); private: DISALLOW_COPY_AND_ASSIGN(PNGCodec); diff --git a/ui/gfx/codec/png_codec_unittest.cc b/ui/gfx/codec/png_codec_unittest.cc index e3540a2711..f1654d9d36 100644 --- a/ui/gfx/codec/png_codec_unittest.cc +++ b/ui/gfx/codec/png_codec_unittest.cc @@ -14,6 +14,7 @@ #include "third_party/zlib/zlib.h" #include "ui/gfx/codec/png_codec.h" #include "ui/gfx/size.h" +#include "ui/gfx/skia_util.h" namespace gfx { @@ -1119,43 +1120,31 @@ TEST(PNGCodec, EncodeDecodeWithVaryingCompressionLevels) { // create an image with known values, a must be opaque because it will be // lost during encoding - std::vector<unsigned char> original; - MakeRGBAImage(w, h, true, &original); + SkBitmap original_bitmap; + MakeTestSkBitmap(w, h, &original_bitmap); // encode - std::vector<unsigned char> encoded_fast; - EXPECT_TRUE(PNGCodec::EncodeWithCompressionLevel( - &original[0], PNGCodec::FORMAT_RGBA, Size(w, h), w * 4, false, - std::vector<PNGCodec::Comment>(), Z_BEST_SPEED, &encoded_fast)); + std::vector<unsigned char> encoded_normal; + EXPECT_TRUE( + PNGCodec::EncodeBGRASkBitmap(original_bitmap, false, &encoded_normal)); - std::vector<unsigned char> encoded_best; - EXPECT_TRUE(PNGCodec::EncodeWithCompressionLevel( - &original[0], PNGCodec::FORMAT_RGBA, Size(w, h), w * 4, false, - std::vector<PNGCodec::Comment>(), Z_BEST_COMPRESSION, &encoded_best)); + std::vector<unsigned char> encoded_fast; + EXPECT_TRUE( + PNGCodec::FastEncodeBGRASkBitmap(original_bitmap, false, &encoded_fast)); // Make sure the different compression settings actually do something; the // sizes should be different. - EXPECT_NE(encoded_fast.size(), encoded_best.size()); - - // decode, it should have the same size as the original - std::vector<unsigned char> decoded; - int outw, outh; - EXPECT_TRUE(PNGCodec::Decode(&encoded_fast[0], encoded_fast.size(), - PNGCodec::FORMAT_RGBA, &decoded, - &outw, &outh)); - ASSERT_EQ(w, outw); - ASSERT_EQ(h, outh); - ASSERT_EQ(original.size(), decoded.size()); + EXPECT_NE(encoded_normal.size(), encoded_fast.size()); - EXPECT_TRUE(PNGCodec::Decode(&encoded_best[0], encoded_best.size(), - PNGCodec::FORMAT_RGBA, &decoded, - &outw, &outh)); - ASSERT_EQ(w, outw); - ASSERT_EQ(h, outh); - ASSERT_EQ(original.size(), decoded.size()); + // decode, they should be identical to the original. + SkBitmap decoded; + EXPECT_TRUE( + PNGCodec::Decode(&encoded_normal[0], encoded_normal.size(), &decoded)); + EXPECT_TRUE(BitmapsAreEqual(decoded, original_bitmap)); - // Images must be exactly equal - ASSERT_TRUE(original == decoded); + EXPECT_TRUE( + PNGCodec::Decode(&encoded_fast[0], encoded_fast.size(), &decoded)); + EXPECT_TRUE(BitmapsAreEqual(decoded, original_bitmap)); } diff --git a/ui/gfx/image/image_family.h b/ui/gfx/image/image_family.h index b2a2c07550..902dedeb41 100644 --- a/ui/gfx/image/image_family.h +++ b/ui/gfx/image/image_family.h @@ -27,8 +27,16 @@ class Size; // include high-DPI representations). class UI_EXPORT ImageFamily { private: - // Forward declaration. - struct MapKey; + // An <aspect ratio, DIP width> pair. + // A 0x0 image has aspect ratio 1.0. 0xN and Nx0 images are treated as 0x0. + struct MapKey : std::pair<float, int> { + MapKey(float aspect, int width) + : std::pair<float, int>(aspect, width) {} + + float aspect() const { return first; } + + int width() const { return second; } + }; public: // Type for iterating over all images in the family, in order. @@ -127,17 +135,6 @@ class UI_EXPORT ImageFamily { const gfx::Image* GetBest(const gfx::Size& size) const; private: - // An <aspect ratio, DIP width> pair. - // A 0x0 image has aspect ratio 1.0. 0xN and Nx0 images are treated as 0x0. - struct MapKey : std::pair<float, int> { - MapKey(float aspect, int width) - : std::pair<float, int>(aspect, width) {} - - float aspect() const { return first; } - - int width() const { return second; } - }; - // Find the closest aspect ratio in the map to |desired_aspect|. // Ties are broken by the thinner aspect. // |map_| must not be empty. |desired_aspect| must be > 0.0. diff --git a/ui/gfx/screen.h b/ui/gfx/screen.h index 9410d02888..d94e3e02a6 100644 --- a/ui/gfx/screen.h +++ b/ui/gfx/screen.h @@ -5,6 +5,8 @@ #ifndef UI_GFX_SCREEN_H_ #define UI_GFX_SCREEN_H_ +#include <vector> + #include "base/basictypes.h" #include "ui/base/ui_export.h" #include "ui/gfx/display.h" @@ -50,17 +52,23 @@ class UI_EXPORT Screen { virtual gfx::Point GetCursorScreenPoint() = 0; // Returns the window under the cursor. - virtual gfx::NativeWindow GetWindowAtCursorScreenPoint() = 0; + virtual gfx::NativeWindow GetWindowUnderCursor() = 0; + + // Returns the window at the given screen coordinate |point|. + virtual gfx::NativeWindow GetWindowAtScreenPoint(const gfx::Point& point) = 0; // Returns the number of displays. // Mirrored displays are excluded; this method is intended to return the // number of distinct, usable displays. - virtual int GetNumDisplays() = 0; + virtual int GetNumDisplays() const = 0; + + // Returns the list of displays that are currently available. + virtual std::vector<gfx::Display> GetAllDisplays() const = 0; // Returns the display nearest the specified window. virtual gfx::Display GetDisplayNearestWindow(NativeView view) const = 0; - // Returns the the display nearest the specified point. + // Returns the display nearest the specified point. virtual gfx::Display GetDisplayNearestPoint( const gfx::Point& point) const = 0; diff --git a/ui/gfx/screen_android.cc b/ui/gfx/screen_android.cc index 6c4d63325d..e90bb76725 100644 --- a/ui/gfx/screen_android.cc +++ b/ui/gfx/screen_android.cc @@ -19,7 +19,13 @@ class ScreenAndroid : public Screen { virtual gfx::Point GetCursorScreenPoint() OVERRIDE { return gfx::Point(); } - virtual gfx::NativeWindow GetWindowAtCursorScreenPoint() OVERRIDE { + virtual gfx::NativeWindow GetWindowUnderCursor() OVERRIDE { + NOTIMPLEMENTED(); + return NULL; + } + + virtual gfx::NativeWindow GetWindowAtScreenPoint(const gfx::Point& point) + OVERRIDE { NOTIMPLEMENTED(); return NULL; } @@ -50,7 +56,11 @@ class ScreenAndroid : public Screen { return GetPrimaryDisplay(); } - virtual int GetNumDisplays() OVERRIDE { return 1; } + virtual int GetNumDisplays() const OVERRIDE { return 1; } + + virtual std::vector<gfx::Display> GetAllDisplays() const OVERRIDE { + return std::vector<gfx::Display>(1, GetPrimaryDisplay()); + } virtual gfx::Display GetDisplayMatching( const gfx::Rect& match_rect) const OVERRIDE { diff --git a/ui/gfx/screen_gtk.cc b/ui/gfx/screen_gtk.cc index 8ef803dca1..16a7873396 100644 --- a/ui/gfx/screen_gtk.cc +++ b/ui/gfx/screen_gtk.cc @@ -49,8 +49,9 @@ bool GetScreenWorkArea(gfx::Rect* out_rect) { gfx::Rect NativePrimaryMonitorBounds() { GdkScreen* screen = gdk_screen_get_default(); + gint primary_monitor_index = gdk_screen_get_primary_monitor(screen); GdkRectangle rect; - gdk_screen_get_monitor_geometry(screen, 0, &rect); + gdk_screen_get_monitor_geometry(screen, primary_monitor_index, &rect); return gfx::Rect(rect); } @@ -90,7 +91,7 @@ class ScreenGtk : public gfx::Screen { } // Returns the window under the cursor. - virtual gfx::NativeWindow GetWindowAtCursorScreenPoint() OVERRIDE { + virtual gfx::NativeWindow GetWindowUnderCursor() OVERRIDE { GdkWindow* window = gdk_window_at_pointer(NULL, NULL); if (!window) return NULL; @@ -104,16 +105,27 @@ class ScreenGtk : public gfx::Screen { return GTK_IS_WINDOW(widget) ? GTK_WINDOW(widget) : NULL; } + virtual gfx::NativeWindow GetWindowAtScreenPoint(const gfx::Point& point) + OVERRIDE { + NOTIMPLEMENTED(); + return NULL; + } + // Returns the number of displays. // Mirrored displays are excluded; this method is intended to return the // number of distinct, usable displays. - virtual int GetNumDisplays() OVERRIDE { + virtual int GetNumDisplays() const OVERRIDE { // This query is kinda bogus for Linux -- do we want number of X screens? // The number of monitors Xinerama has? We'll just use whatever GDK uses. GdkScreen* screen = gdk_screen_get_default(); return gdk_screen_get_n_monitors(screen); } + virtual std::vector<gfx::Display> GetAllDisplays() const OVERRIDE { + NOTIMPLEMENTED(); + return std::vector<gfx::Display>(1, GetPrimaryDisplay()); + } + // Returns the display nearest the specified window. virtual gfx::Display GetDisplayNearestWindow( gfx::NativeView view) const OVERRIDE { diff --git a/ui/gfx/screen_ios.mm b/ui/gfx/screen_ios.mm index dfb0d1b62b..a2770298ca 100644 --- a/ui/gfx/screen_ios.mm +++ b/ui/gfx/screen_ios.mm @@ -21,12 +21,18 @@ class ScreenIos : public gfx::Screen { return gfx::Point(0, 0); } - virtual gfx::NativeWindow GetWindowAtCursorScreenPoint() OVERRIDE { + virtual gfx::NativeWindow GetWindowUnderCursor() OVERRIDE { NOTIMPLEMENTED(); return gfx::NativeWindow(); } - virtual int GetNumDisplays() OVERRIDE { + virtual gfx::NativeWindow GetWindowAtScreenPoint(const gfx::Point& point) + OVERRIDE { + NOTIMPLEMENTED(); + return gfx::NativeWindow(); + } + + virtual int GetNumDisplays() const OVERRIDE { #if TARGET_IPHONE_SIMULATOR // UIScreen does not reliably return correct results on the simulator. return 1; @@ -35,6 +41,11 @@ class ScreenIos : public gfx::Screen { #endif } + virtual std::vector<gfx::Display> GetAllDisplays() const OVERRIDE { + NOTIMPLEMENTED(); + return std::vector<gfx::Display>(1, GetPrimaryDisplay()); + } + // Returns the display nearest the specified window. virtual gfx::Display GetDisplayNearestWindow( gfx::NativeView view) const OVERRIDE { diff --git a/ui/gfx/screen_mac.mm b/ui/gfx/screen_mac.mm index d9e1f0a71c..28707ca7ea 100644 --- a/ui/gfx/screen_mac.mm +++ b/ui/gfx/screen_mac.mm @@ -84,12 +84,18 @@ class ScreenMac : public gfx::Screen { return gfx::Point(mouseLocation.x, mouseLocation.y); } - virtual gfx::NativeWindow GetWindowAtCursorScreenPoint() OVERRIDE { + virtual gfx::NativeWindow GetWindowUnderCursor() OVERRIDE { NOTIMPLEMENTED(); return gfx::NativeWindow(); } - virtual int GetNumDisplays() OVERRIDE { + virtual gfx::NativeWindow GetWindowAtScreenPoint(const gfx::Point& point) + OVERRIDE { + NOTIMPLEMENTED(); + return gfx::NativeWindow(); + } + + virtual int GetNumDisplays() const OVERRIDE { // Don't just return the number of online displays. It includes displays // that mirror other displays, which are not desired in the count. It's // tempting to use the count returned by CGGetActiveDisplayList, but active @@ -123,6 +129,11 @@ class ScreenMac : public gfx::Screen { return display_count; } + virtual std::vector<gfx::Display> GetAllDisplays() const OVERRIDE { + NOTIMPLEMENTED(); + return std::vector<gfx::Display>(1, GetPrimaryDisplay()); + } + virtual gfx::Display GetDisplayNearestWindow( gfx::NativeView view) const OVERRIDE { NSWindow* window = [view window]; diff --git a/ui/gfx/screen_win.cc b/ui/gfx/screen_win.cc index 8bb1548289..95847c4acc 100644 --- a/ui/gfx/screen_win.cc +++ b/ui/gfx/screen_win.cc @@ -49,16 +49,25 @@ gfx::Point ScreenWin::GetCursorScreenPoint() { return gfx::Point(pt); } -gfx::NativeWindow ScreenWin::GetWindowAtCursorScreenPoint() { - POINT location; - HWND window_hwnd = GetCursorPos(&location) ? WindowFromPoint(location) : NULL; - return GetNativeWindowFromHWND(window_hwnd); +gfx::NativeWindow ScreenWin::GetWindowUnderCursor() { + POINT cursor_loc; + HWND hwnd = GetCursorPos(&cursor_loc) ? WindowFromPoint(cursor_loc) : NULL; + return GetNativeWindowFromHWND(hwnd); } -int ScreenWin::GetNumDisplays() { +gfx::NativeWindow ScreenWin::GetWindowAtScreenPoint(const gfx::Point& point) { + return GetNativeWindowFromHWND(WindowFromPoint(point.ToPOINT())); +} + +int ScreenWin::GetNumDisplays() const { return GetSystemMetrics(SM_CMONITORS); } +std::vector<gfx::Display> ScreenWin::GetAllDisplays() const { + NOTIMPLEMENTED(); + return std::vector<gfx::Display>(1, GetPrimaryDisplay()); +} + gfx::Display ScreenWin::GetDisplayNearestWindow(gfx::NativeView window) const { HWND window_hwnd = GetHWNDFromNativeView(window); if (!window_hwnd) { diff --git a/ui/gfx/screen_win.h b/ui/gfx/screen_win.h index f6b7d40ae8..8905d46e09 100644 --- a/ui/gfx/screen_win.h +++ b/ui/gfx/screen_win.h @@ -20,8 +20,11 @@ class UI_EXPORT ScreenWin : public gfx::Screen { // Overridden from gfx::Screen: virtual bool IsDIPEnabled() OVERRIDE; virtual gfx::Point GetCursorScreenPoint() OVERRIDE; - virtual gfx::NativeWindow GetWindowAtCursorScreenPoint() OVERRIDE; - virtual int GetNumDisplays() OVERRIDE; + virtual gfx::NativeWindow GetWindowUnderCursor() OVERRIDE; + virtual gfx::NativeWindow GetWindowAtScreenPoint(const gfx::Point& point) + OVERRIDE; + virtual int GetNumDisplays() const OVERRIDE; + virtual std::vector<gfx::Display> GetAllDisplays() const OVERRIDE; virtual gfx::Display GetDisplayNearestWindow( gfx::NativeView window) const OVERRIDE; virtual gfx::Display GetDisplayNearestPoint( diff --git a/ui/gl/android/gl_jni_registrar.cc b/ui/gl/android/gl_jni_registrar.cc index 997268cc54..91ae65f45a 100644 --- a/ui/gl/android/gl_jni_registrar.cc +++ b/ui/gl/android/gl_jni_registrar.cc @@ -6,6 +6,7 @@ #include "base/android/jni_android.h" #include "base/android/jni_registrar.h" +#include "ui/gl/android/surface_texture.h" #include "ui/gl/android/surface_texture_listener.h" namespace ui { @@ -13,6 +14,8 @@ namespace gl { namespace android { static base::android::RegistrationMethod kGLRegisteredMethods[] = { + { "SurfaceTexture", + gfx::SurfaceTexture::RegisterSurfaceTexture }, { "SurfaceTextureListener", gfx::SurfaceTextureListener::RegisterSurfaceTextureListener }, }; diff --git a/ui/gl/android/scoped_java_surface.cc b/ui/gl/android/scoped_java_surface.cc index fe6a75e9ac..36f635fe01 100644 --- a/ui/gl/android/scoped_java_surface.cc +++ b/ui/gl/android/scoped_java_surface.cc @@ -6,7 +6,7 @@ #include "base/logging.h" #include "jni/Surface_jni.h" -#include "ui/gl/android/surface_texture_bridge.h" +#include "ui/gl/android/surface_texture.h" namespace { @@ -37,7 +37,7 @@ ScopedJavaSurface::ScopedJavaSurface( } ScopedJavaSurface::ScopedJavaSurface( - const SurfaceTextureBridge* surface_texture) + const SurfaceTexture* surface_texture) : auto_release_(true), is_protected_(false) { JNIEnv* env = base::android::AttachCurrentThread(); diff --git a/ui/gl/android/scoped_java_surface.h b/ui/gl/android/scoped_java_surface.h index b50485b876..54ed2a4519 100644 --- a/ui/gl/android/scoped_java_surface.h +++ b/ui/gl/android/scoped_java_surface.h @@ -13,7 +13,7 @@ namespace gfx { -class SurfaceTextureBridge; +class SurfaceTexture; // A helper class for holding a scoped reference to a Java Surface instance. // When going out of scope, Surface.release() is called on the Java object to @@ -29,7 +29,7 @@ class GL_EXPORT ScopedJavaSurface { // Creates a Java Surface from a SurfaceTexture and wraps it in a // ScopedJavaSurface. - explicit ScopedJavaSurface(const SurfaceTextureBridge* surface_texture); + explicit ScopedJavaSurface(const SurfaceTexture* surface_texture); // Move constructor. Take the surface from another ScopedJavaSurface object, // the latter no longer owns the surface afterwards. diff --git a/ui/gl/android/surface_texture.cc b/ui/gl/android/surface_texture.cc new file mode 100644 index 0000000000..d900972c9d --- /dev/null +++ b/ui/gl/android/surface_texture.cc @@ -0,0 +1,116 @@ +// Copyright 2013 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 "ui/gl/android/surface_texture.h" + +#include <android/native_window_jni.h> + +// TODO(boliu): Remove this include when we move off ICS. +#include "base/android/build_info.h" +#include "base/android/jni_android.h" +#include "base/logging.h" +#include "jni/SurfaceTexturePlatformWrapper_jni.h" +#include "ui/gl/android/scoped_java_surface.h" +#include "ui/gl/android/surface_texture_listener.h" +#include "ui/gl/gl_bindings.h" + +// TODO(boliu): Remove this method when when we move off ICS. See +// http://crbug.com/161864. +bool GlContextMethodsAvailable() { + bool available = base::android::BuildInfo::GetInstance()->sdk_int() >= 16; + if (!available) + LOG(WARNING) << "Running on unsupported device: rendering may not work"; + return available; +} + +namespace gfx { + +SurfaceTexture::SurfaceTexture(int texture_id) { + JNIEnv* env = base::android::AttachCurrentThread(); + j_surface_texture_.Reset( + Java_SurfaceTexturePlatformWrapper_create(env, texture_id)); +} + +SurfaceTexture::~SurfaceTexture() { + JNIEnv* env = base::android::AttachCurrentThread(); + Java_SurfaceTexturePlatformWrapper_destroy(env, j_surface_texture_.obj()); +} + +void SurfaceTexture::SetFrameAvailableCallback( + const base::Closure& callback) { + JNIEnv* env = base::android::AttachCurrentThread(); + Java_SurfaceTexturePlatformWrapper_setFrameAvailableCallback( + env, + j_surface_texture_.obj(), + reinterpret_cast<int>(new SurfaceTextureListener(callback))); +} + +void SurfaceTexture::UpdateTexImage() { + JNIEnv* env = base::android::AttachCurrentThread(); + Java_SurfaceTexturePlatformWrapper_updateTexImage(env, + j_surface_texture_.obj()); +} + +void SurfaceTexture::GetTransformMatrix(float mtx[16]) { + JNIEnv* env = base::android::AttachCurrentThread(); + + base::android::ScopedJavaLocalRef<jfloatArray> jmatrix( + env, env->NewFloatArray(16)); + Java_SurfaceTexturePlatformWrapper_getTransformMatrix( + env, j_surface_texture_.obj(), jmatrix.obj()); + + jboolean is_copy; + jfloat* elements = env->GetFloatArrayElements(jmatrix.obj(), &is_copy); + for (int i = 0; i < 16; ++i) { + mtx[i] = static_cast<float>(elements[i]); + } + env->ReleaseFloatArrayElements(jmatrix.obj(), elements, JNI_ABORT); +} + +void SurfaceTexture::SetDefaultBufferSize(int width, int height) { + JNIEnv* env = base::android::AttachCurrentThread(); + + if (width > 0 && height > 0) { + Java_SurfaceTexturePlatformWrapper_setDefaultBufferSize( + env, j_surface_texture_.obj(), static_cast<jint>(width), + static_cast<jint>(height)); + } else { + LOG(WARNING) << "Not setting surface texture buffer size - " + "width or height is 0"; + } +} + +void SurfaceTexture::AttachToGLContext() { + if (GlContextMethodsAvailable()) { + int texture_id; + glGetIntegerv(GL_TEXTURE_BINDING_EXTERNAL_OES, &texture_id); + DCHECK(texture_id); + JNIEnv* env = base::android::AttachCurrentThread(); + Java_SurfaceTexturePlatformWrapper_attachToGLContext( + env, j_surface_texture_.obj(), texture_id); + } +} + +void SurfaceTexture::DetachFromGLContext() { + if (GlContextMethodsAvailable()) { + JNIEnv* env = base::android::AttachCurrentThread(); + Java_SurfaceTexturePlatformWrapper_detachFromGLContext( + env, j_surface_texture_.obj()); + } +} + +ANativeWindow* SurfaceTexture::CreateSurface() { + JNIEnv* env = base::android::AttachCurrentThread(); + ScopedJavaSurface surface(this); + ANativeWindow* native_window = ANativeWindow_fromSurface( + env, surface.j_surface().obj()); + return native_window; +} + +// static +bool SurfaceTexture::RegisterSurfaceTexture(JNIEnv* env) { + return RegisterNativesImpl(env); +} + +} // namespace gfx diff --git a/ui/gl/android/surface_texture_bridge.h b/ui/gl/android/surface_texture.h index fc7fb5416a..62e375f796 100644 --- a/ui/gl/android/surface_texture_bridge.h +++ b/ui/gl/android/surface_texture.h @@ -1,9 +1,9 @@ -// Copyright (c) 2013 The Chromium Authors. All rights reserved. +// Copyright 2013 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 UI_GL_ANDROID_SURFACE_TEXTURE_BRIDGE_H_ -#define UI_GL_ANDROID_SURFACE_TEXTURE_BRIDGE_H_ +#ifndef UI_GL_ANDROID_SURFACE_TEXTURE_H_ +#define UI_GL_ANDROID_SURFACE_TEXTURE_H_ #include <jni.h> @@ -18,10 +18,10 @@ namespace gfx { // This class serves as a bridge for native code to call java functions inside // android SurfaceTexture class. -class GL_EXPORT SurfaceTextureBridge - : public base::RefCountedThreadSafe<SurfaceTextureBridge>{ +class GL_EXPORT SurfaceTexture + : public base::RefCountedThreadSafe<SurfaceTexture>{ public: - explicit SurfaceTextureBridge(int texture_id); + explicit SurfaceTexture(int texture_id); // Set the listener callback, which will be invoked on the same thread that // is being called from here for registration. @@ -57,16 +57,18 @@ class GL_EXPORT SurfaceTextureBridge return j_surface_texture_; } + static bool RegisterSurfaceTexture(JNIEnv* env); + private: - friend class base::RefCountedThreadSafe<SurfaceTextureBridge>; - ~SurfaceTextureBridge(); + friend class base::RefCountedThreadSafe<SurfaceTexture>; + ~SurfaceTexture(); // Java SurfaceTexture instance. base::android::ScopedJavaGlobalRef<jobject> j_surface_texture_; - DISALLOW_COPY_AND_ASSIGN(SurfaceTextureBridge); + DISALLOW_COPY_AND_ASSIGN(SurfaceTexture); }; } // namespace gfx -#endif // UI_GL_ANDROID_SURFACE_TEXTURE_BRIDGE_H_ +#endif // UI_GL_ANDROID_SURFACE_TEXTURE_H_ diff --git a/ui/gl/android/surface_texture_bridge.cc b/ui/gl/android/surface_texture_bridge.cc deleted file mode 100644 index c4206a983e..0000000000 --- a/ui/gl/android/surface_texture_bridge.cc +++ /dev/null @@ -1,155 +0,0 @@ -// Copyright (c) 2013 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 "ui/gl/android/surface_texture_bridge.h" - -#include <android/native_window_jni.h> - -// TODO(boliu): Remove this include when we move off ICS. -#include "base/android/build_info.h" -#include "base/android/jni_android.h" -#include "base/logging.h" -#include "jni/SurfaceTexture_jni.h" -#include "ui/gl/android/scoped_java_surface.h" -#include "ui/gl/android/surface_texture_listener.h" -#include "ui/gl/gl_bindings.h" - -using base::android::AttachCurrentThread; -using base::android::CheckException; -using base::android::GetClass; -using base::android::ScopedJavaLocalRef; - -namespace { -bool g_jni_initialized = false; - -void RegisterNativesIfNeeded(JNIEnv* env) { - if (!g_jni_initialized) { - JNI_SurfaceTexture::RegisterNativesImpl(env); - g_jni_initialized = true; - } -} - -// TODO(boliu): Remove this method when when we move off ICS. See -// http://crbug.com/161864. -bool GlContextMethodsAvailable() { - bool available = base::android::BuildInfo::GetInstance()->sdk_int() >= 16; - if (!available) - LOG(WARNING) << "Running on unsupported device: rendering may not work"; - return available; -} - -} // namespace - -namespace gfx { - -SurfaceTextureBridge::SurfaceTextureBridge(int texture_id) { - JNIEnv* env = AttachCurrentThread(); - CHECK(env); - RegisterNativesIfNeeded(env); - - ScopedJavaLocalRef<jobject> tmp( - JNI_SurfaceTexture::Java_SurfaceTexture_Constructor( - env, texture_id)); - DCHECK(!tmp.is_null()); - j_surface_texture_.Reset(tmp); -} - -SurfaceTextureBridge::~SurfaceTextureBridge() { - JNIEnv* env = AttachCurrentThread(); - CHECK(env); - - // Release the listener. - JNI_SurfaceTexture::Java_SurfaceTexture_setOnFrameAvailableListener( - env, j_surface_texture_.obj(), NULL); - - // Release graphics memory. - JNI_SurfaceTexture::Java_SurfaceTexture_release( - env, j_surface_texture_.obj()); -} - -void SurfaceTextureBridge::SetFrameAvailableCallback( - const base::Closure& callback) { - JNIEnv* env = AttachCurrentThread(); - CHECK(env); - - // Since the listener is owned by the Java SurfaceTexture object, setting - // a new listener here will release an existing one at the same time. - ScopedJavaLocalRef<jobject> j_listener( - env, - SurfaceTextureListener::CreateSurfaceTextureListener(env, callback)); - DCHECK(!j_listener.is_null()); - - // Set it as the onFrameAvailableListener for our SurfaceTexture instance. - JNI_SurfaceTexture::Java_SurfaceTexture_setOnFrameAvailableListener( - env, j_surface_texture_.obj(), j_listener.obj()); -} - -void SurfaceTextureBridge::UpdateTexImage() { - JNIEnv* env = AttachCurrentThread(); - CHECK(env); - - JNI_SurfaceTexture::Java_SurfaceTexture_updateTexImage( - env, j_surface_texture_.obj()); -} - -void SurfaceTextureBridge::GetTransformMatrix(float mtx[16]) { - JNIEnv* env = AttachCurrentThread(); - CHECK(env); - - ScopedJavaLocalRef<jfloatArray> jmatrix(env, env->NewFloatArray(16)); - JNI_SurfaceTexture::Java_SurfaceTexture_getTransformMatrix( - env, j_surface_texture_.obj(), jmatrix.obj()); - - jboolean is_copy; - jfloat* elements = env->GetFloatArrayElements(jmatrix.obj(), &is_copy); - for (int i = 0; i < 16; ++i) { - mtx[i] = static_cast<float>(elements[i]); - } - env->ReleaseFloatArrayElements(jmatrix.obj(), elements, JNI_ABORT); -} - -void SurfaceTextureBridge::SetDefaultBufferSize(int width, int height) { - JNIEnv* env = AttachCurrentThread(); - CHECK(env); - - if (width > 0 && height > 0) { - JNI_SurfaceTexture::Java_SurfaceTexture_setDefaultBufferSize( - env, j_surface_texture_.obj(), static_cast<jint>(width), - static_cast<jint>(height)); - } else { - LOG(WARNING) << "Not setting surface texture buffer size - " - "width or height is 0"; - } -} - -void SurfaceTextureBridge::AttachToGLContext() { - if (GlContextMethodsAvailable()) { - int texture_id; - glGetIntegerv(GL_TEXTURE_BINDING_EXTERNAL_OES, &texture_id); - DCHECK(texture_id); - JNIEnv* env = AttachCurrentThread(); - // Note: This method is only available on JB and greater. - JNI_SurfaceTexture::Java_SurfaceTexture_attachToGLContext( - env, j_surface_texture_.obj(), texture_id); - } -} - -void SurfaceTextureBridge::DetachFromGLContext() { - if (GlContextMethodsAvailable()) { - JNIEnv* env = AttachCurrentThread(); - // Note: This method is only available on JB and greater. - JNI_SurfaceTexture::Java_SurfaceTexture_detachFromGLContext( - env, j_surface_texture_.obj()); - } -} - -ANativeWindow* SurfaceTextureBridge::CreateSurface() { - JNIEnv* env = AttachCurrentThread(); - ScopedJavaSurface surface(this); - ANativeWindow* native_window = - ANativeWindow_fromSurface(env, surface.j_surface().obj()); - return native_window; -} - -} // namespace gfx diff --git a/ui/gl/android/surface_texture_listener.cc b/ui/gl/android/surface_texture_listener.cc index 0547720202..8e2f89c525 100644 --- a/ui/gl/android/surface_texture_listener.cc +++ b/ui/gl/android/surface_texture_listener.cc @@ -8,23 +8,10 @@ #include "base/logging.h" #include "base/message_loop/message_loop_proxy.h" #include "jni/SurfaceTextureListener_jni.h" -#include "ui/gl/android/surface_texture_bridge.h" +#include "ui/gl/android/surface_texture.h" namespace gfx { -// static -jobject SurfaceTextureListener::CreateSurfaceTextureListener( - JNIEnv* env, - const base::Closure& callback) { - // The java listener object owns and releases the native instance. - // This is necessary to avoid races with incoming notifications. - ScopedJavaLocalRef<jobject> listener(Java_SurfaceTextureListener_create(env, - reinterpret_cast<int>(new SurfaceTextureListener(callback)))); - - DCHECK(!listener.is_null()); - return listener.Release(); -} - SurfaceTextureListener::SurfaceTextureListener(const base::Closure& callback) : callback_(callback), browser_loop_(base::MessageLoopProxy::current()) { diff --git a/ui/gl/android/surface_texture_listener.h b/ui/gl/android/surface_texture_listener.h index faab6be1eb..823bc30064 100644 --- a/ui/gl/android/surface_texture_listener.h +++ b/ui/gl/android/surface_texture_listener.h @@ -18,7 +18,7 @@ namespace gfx { // Listener class for all the callbacks from android SurfaceTexture. class GL_EXPORT SurfaceTextureListener { -public: + public: // Destroy this listener. void Destroy(JNIEnv* env, jobject obj); @@ -27,18 +27,13 @@ public: static bool RegisterSurfaceTextureListener(JNIEnv* env); -private: + private: + // Native code should not hold any reference to this object, and instead pass + // it up to Java for being referenced by a SurfaceTexture instance. SurfaceTextureListener(const base::Closure& callback); ~SurfaceTextureListener(); - friend class SurfaceTextureBridge; - - // Static factory method for the creation of a SurfaceTextureListener. - // The native code should not hold any reference to the returned object, - // but only use it to pass it up to Java for being referenced by a - // SurfaceTexture instance. - static jobject CreateSurfaceTextureListener(JNIEnv* env, - const base::Closure& callback); + friend class SurfaceTexture; base::Closure callback_; diff --git a/ui/gl/generate_bindings.py b/ui/gl/generate_bindings.py index 3b37a1708c..3e51dcb513 100755 --- a/ui/gl/generate_bindings.py +++ b/ui/gl/generate_bindings.py @@ -432,6 +432,13 @@ GL_FUNCTIONS = [ { 'return_type': 'void*', 'names': ['glMapBuffer', 'glMapBufferOES'], 'arguments': 'GLenum target, GLenum access', }, +{ 'return_type': 'void*', + 'names': ['glMapBufferRange'], + 'arguments': + 'GLenum target, GLintptr offset, GLsizeiptr length, GLenum access', }, +{ 'return_type': 'void', + 'names': ['glFlushMappedBufferRange'], + 'arguments': 'GLenum target, GLintptr offset, GLsizeiptr length', }, { 'return_type': 'void', 'names': ['glPixelStorei'], 'arguments': 'GLenum pname, GLint param', }, diff --git a/ui/gl/gl.gyp b/ui/gl/gl.gyp index 940578beeb..bee5874697 100644 --- a/ui/gl/gl.gyp +++ b/ui/gl/gl.gyp @@ -44,8 +44,8 @@ 'android/gl_jni_registrar.h', 'android/scoped_java_surface.cc', 'android/scoped_java_surface.h', - 'android/surface_texture_bridge.cc', - 'android/surface_texture_bridge.h', + 'android/surface_texture.cc', + 'android/surface_texture.h', 'android/surface_texture_listener.cc', 'android/surface_texture_listener.h', 'gl_bindings.h', @@ -313,15 +313,6 @@ ['OS=="android"' , { 'targets': [ { - 'target_name': 'surface_texture_jni_headers', - 'type': 'none', - 'variables': { - 'jni_gen_package': 'ui/gl', - 'input_java_class': 'android/graphics/SurfaceTexture.class', - }, - 'includes': [ '../../build/jar_file_jni_generator.gypi' ], - }, - { 'target_name': 'surface_jni_headers', 'type': 'none', 'variables': { @@ -334,10 +325,10 @@ 'target_name': 'gl_jni_headers', 'type': 'none', 'dependencies': [ - 'surface_texture_jni_headers', 'surface_jni_headers', ], 'sources': [ + '../android/java/src/org/chromium/ui/gfx/SurfaceTexturePlatformWrapper.java', '../android/java/src/org/chromium/ui/gfx/SurfaceTextureListener.java', ], 'variables': { diff --git a/ui/gl/gl.target.darwin-arm.mk b/ui/gl/gl.target.darwin-arm.mk index e3a29d84c2..1fae243162 100644 --- a/ui/gl/gl.target.darwin-arm.mk +++ b/ui/gl/gl.target.darwin-arm.mk @@ -105,7 +105,7 @@ GYP_COPIED_SOURCE_ORIGIN_DIRS := \ LOCAL_SRC_FILES := \ ui/gl/android/gl_jni_registrar.cc \ ui/gl/android/scoped_java_surface.cc \ - ui/gl/android/surface_texture_bridge.cc \ + ui/gl/android/surface_texture.cc \ ui/gl/android/surface_texture_listener.cc \ ui/gl/gl_bindings_skia_in_process.cc \ ui/gl/gl_context.cc \ diff --git a/ui/gl/gl.target.darwin-mips.mk b/ui/gl/gl.target.darwin-mips.mk index 0ff568489a..5c822e270f 100644 --- a/ui/gl/gl.target.darwin-mips.mk +++ b/ui/gl/gl.target.darwin-mips.mk @@ -105,7 +105,7 @@ GYP_COPIED_SOURCE_ORIGIN_DIRS := \ LOCAL_SRC_FILES := \ ui/gl/android/gl_jni_registrar.cc \ ui/gl/android/scoped_java_surface.cc \ - ui/gl/android/surface_texture_bridge.cc \ + ui/gl/android/surface_texture.cc \ ui/gl/android/surface_texture_listener.cc \ ui/gl/gl_bindings_skia_in_process.cc \ ui/gl/gl_context.cc \ diff --git a/ui/gl/gl.target.darwin-x86.mk b/ui/gl/gl.target.darwin-x86.mk index 9ddadf20b2..b859f37a51 100644 --- a/ui/gl/gl.target.darwin-x86.mk +++ b/ui/gl/gl.target.darwin-x86.mk @@ -105,7 +105,7 @@ GYP_COPIED_SOURCE_ORIGIN_DIRS := \ LOCAL_SRC_FILES := \ ui/gl/android/gl_jni_registrar.cc \ ui/gl/android/scoped_java_surface.cc \ - ui/gl/android/surface_texture_bridge.cc \ + ui/gl/android/surface_texture.cc \ ui/gl/android/surface_texture_listener.cc \ ui/gl/gl_bindings_skia_in_process.cc \ ui/gl/gl_context.cc \ diff --git a/ui/gl/gl.target.linux-arm.mk b/ui/gl/gl.target.linux-arm.mk index e3a29d84c2..1fae243162 100644 --- a/ui/gl/gl.target.linux-arm.mk +++ b/ui/gl/gl.target.linux-arm.mk @@ -105,7 +105,7 @@ GYP_COPIED_SOURCE_ORIGIN_DIRS := \ LOCAL_SRC_FILES := \ ui/gl/android/gl_jni_registrar.cc \ ui/gl/android/scoped_java_surface.cc \ - ui/gl/android/surface_texture_bridge.cc \ + ui/gl/android/surface_texture.cc \ ui/gl/android/surface_texture_listener.cc \ ui/gl/gl_bindings_skia_in_process.cc \ ui/gl/gl_context.cc \ diff --git a/ui/gl/gl.target.linux-mips.mk b/ui/gl/gl.target.linux-mips.mk index 0ff568489a..5c822e270f 100644 --- a/ui/gl/gl.target.linux-mips.mk +++ b/ui/gl/gl.target.linux-mips.mk @@ -105,7 +105,7 @@ GYP_COPIED_SOURCE_ORIGIN_DIRS := \ LOCAL_SRC_FILES := \ ui/gl/android/gl_jni_registrar.cc \ ui/gl/android/scoped_java_surface.cc \ - ui/gl/android/surface_texture_bridge.cc \ + ui/gl/android/surface_texture.cc \ ui/gl/android/surface_texture_listener.cc \ ui/gl/gl_bindings_skia_in_process.cc \ ui/gl/gl_context.cc \ diff --git a/ui/gl/gl.target.linux-x86.mk b/ui/gl/gl.target.linux-x86.mk index 9ddadf20b2..b859f37a51 100644 --- a/ui/gl/gl.target.linux-x86.mk +++ b/ui/gl/gl.target.linux-x86.mk @@ -105,7 +105,7 @@ GYP_COPIED_SOURCE_ORIGIN_DIRS := \ LOCAL_SRC_FILES := \ ui/gl/android/gl_jni_registrar.cc \ ui/gl/android/scoped_java_surface.cc \ - ui/gl/android/surface_texture_bridge.cc \ + ui/gl/android/surface_texture.cc \ ui/gl/android/surface_texture_listener.cc \ ui/gl/gl_bindings_skia_in_process.cc \ ui/gl/gl_context.cc \ diff --git a/ui/gl/gl_bindings.h b/ui/gl/gl_bindings.h index 987ec20347..debb074804 100644 --- a/ui/gl/gl_bindings.h +++ b/ui/gl/gl_bindings.h @@ -124,8 +124,8 @@ #define GL_LATENCY_QUERY_CHROMIUM 0x84F4 /* GL_CHROMIUM_async_pixel_transfers */ -#define GL_ASYNC_PIXEL_TRANSFERS_COMPLETED_CHROMIUM 0x84F5 -#define GL_ASYNC_READ_PIXELS_COMPLETED_CHROMIUM 0x84F6 +#define GL_ASYNC_PIXEL_UNPACK_COMPLETED_CHROMIUM 0x84F5 +#define GL_ASYNC_PIXEL_PACK_COMPLETED_CHROMIUM 0x84F6 // GL_OES_texure_3D #define GL_SAMPLER_3D_OES 0x8B5F diff --git a/ui/gl/gl_fence.cc b/ui/gl/gl_fence.cc index b9d9513f92..9b85300fab 100644 --- a/ui/gl/gl_fence.cc +++ b/ui/gl/gl_fence.cc @@ -80,6 +80,7 @@ class EGLFenceSync : public gfx::GLFence { EGLFenceSync() { display_ = eglGetCurrentDisplay(); sync_ = eglCreateSyncKHR(display_, EGL_SYNC_FENCE_KHR, NULL); + glFlush(); } virtual bool HasCompleted() OVERRIDE { @@ -90,7 +91,7 @@ class EGLFenceSync : public gfx::GLFence { } virtual void ClientWait() OVERRIDE { - EGLint flags = EGL_SYNC_FLUSH_COMMANDS_BIT_KHR; + EGLint flags = 0; EGLTimeKHR time = EGL_FOREVER_KHR; eglClientWaitSyncKHR(display_, sync_, flags, time); } diff --git a/ui/gl/gl_jni_headers.target.darwin-arm.mk b/ui/gl/gl_jni_headers.target.darwin-arm.mk index 497701a224..3af8ab0f6c 100644 --- a/ui/gl/gl_jni_headers.target.darwin-arm.mk +++ b/ui/gl/gl_jni_headers.target.darwin-arm.mk @@ -12,12 +12,21 @@ gyp_shared_intermediate_dir := $(call intermediates-dir-for,GYP,shared) # Make sure our deps are built first. GYP_TARGET_DEPENDENCIES := \ - $(call intermediates-dir-for,GYP,ui_gl_surface_texture_jni_headers_gyp)/surface_texture_jni_headers.stamp \ $(call intermediates-dir-for,GYP,ui_gl_surface_jni_headers_gyp)/surface_jni_headers.stamp ### Generated for rule "ui_gl_gl_gyp_gl_jni_headers_target_generate_jni_headers": -# "{'inputs': ['../../base/android/jni_generator/jni_generator.py', '../../android_webview/build/jarjar-rules.txt'], 'process_outputs_as_sources': '1', 'extension': 'java', 'outputs': ['$(gyp_shared_intermediate_dir)/ui/gl/jni/%(INPUT_ROOT)s_jni.h'], 'rule_name': 'generate_jni_headers', 'rule_sources': ['../android/java/src/org/chromium/ui/gfx/SurfaceTextureListener.java'], 'action': ['../../base/android/jni_generator/jni_generator.py', '--input_file', '$(RULE_SOURCES)', '--output_dir', '$(gyp_shared_intermediate_dir)/ui/gl/jni', '--optimize_generation', '0', '--jarjar', '../../android_webview/build/jarjar-rules.txt'], 'message': 'Generating JNI bindings from $(RULE_SOURCES)'}": +# "{'inputs': ['../../base/android/jni_generator/jni_generator.py', '../../android_webview/build/jarjar-rules.txt'], 'process_outputs_as_sources': '1', 'extension': 'java', 'outputs': ['$(gyp_shared_intermediate_dir)/ui/gl/jni/%(INPUT_ROOT)s_jni.h'], 'rule_name': 'generate_jni_headers', 'rule_sources': ['../android/java/src/org/chromium/ui/gfx/SurfaceTexturePlatformWrapper.java', '../android/java/src/org/chromium/ui/gfx/SurfaceTextureListener.java'], 'action': ['../../base/android/jni_generator/jni_generator.py', '--input_file', '$(RULE_SOURCES)', '--output_dir', '$(gyp_shared_intermediate_dir)/ui/gl/jni', '--optimize_generation', '0', '--jarjar', '../../android_webview/build/jarjar-rules.txt'], 'message': 'Generating JNI bindings from $(RULE_SOURCES)'}": +$(gyp_shared_intermediate_dir)/ui/gl/jni/SurfaceTexturePlatformWrapper_jni.h: gyp_local_path := $(LOCAL_PATH) +$(gyp_shared_intermediate_dir)/ui/gl/jni/SurfaceTexturePlatformWrapper_jni.h: gyp_intermediate_dir := $(abspath $(gyp_intermediate_dir)) +$(gyp_shared_intermediate_dir)/ui/gl/jni/SurfaceTexturePlatformWrapper_jni.h: gyp_shared_intermediate_dir := $(abspath $(gyp_shared_intermediate_dir)) +$(gyp_shared_intermediate_dir)/ui/gl/jni/SurfaceTexturePlatformWrapper_jni.h: export PATH := $(subst $(ANDROID_BUILD_PATHS),,$(PATH)) +$(gyp_shared_intermediate_dir)/ui/gl/jni/SurfaceTexturePlatformWrapper_jni.h: $(LOCAL_PATH)/ui/android/java/src/org/chromium/ui/gfx/SurfaceTexturePlatformWrapper.java $(LOCAL_PATH)/base/android/jni_generator/jni_generator.py $(LOCAL_PATH)/android_webview/build/jarjar-rules.txt $(GYP_TARGET_DEPENDENCIES) + mkdir -p $(gyp_shared_intermediate_dir)/ui/gl/jni; cd $(gyp_local_path)/ui/gl; ../../base/android/jni_generator/jni_generator.py --input_file ../android/java/src/org/chromium/ui/gfx/SurfaceTexturePlatformWrapper.java --output_dir "$(gyp_shared_intermediate_dir)/ui/gl/jni" --optimize_generation 0 --jarjar ../../android_webview/build/jarjar-rules.txt + +.PHONY: ui_gl_gl_jni_headers_gyp_rule_trigger +ui_gl_gl_jni_headers_gyp_rule_trigger: $(gyp_shared_intermediate_dir)/ui/gl/jni/SurfaceTexturePlatformWrapper_jni.h + $(gyp_shared_intermediate_dir)/ui/gl/jni/SurfaceTextureListener_jni.h: gyp_local_path := $(LOCAL_PATH) $(gyp_shared_intermediate_dir)/ui/gl/jni/SurfaceTextureListener_jni.h: gyp_intermediate_dir := $(abspath $(gyp_intermediate_dir)) $(gyp_shared_intermediate_dir)/ui/gl/jni/SurfaceTextureListener_jni.h: gyp_shared_intermediate_dir := $(abspath $(gyp_shared_intermediate_dir)) @@ -31,12 +40,14 @@ ui_gl_gl_jni_headers_gyp_rule_trigger: $(gyp_shared_intermediate_dir)/ui/gl/jni/ ### Finished generating for all rules GYP_GENERATED_OUTPUTS := \ + $(gyp_shared_intermediate_dir)/ui/gl/jni/SurfaceTexturePlatformWrapper_jni.h \ $(gyp_shared_intermediate_dir)/ui/gl/jni/SurfaceTextureListener_jni.h # Make sure our deps and generated files are built first. LOCAL_ADDITIONAL_DEPENDENCIES := $(GYP_TARGET_DEPENDENCIES) $(GYP_GENERATED_OUTPUTS) LOCAL_GENERATED_SOURCES := \ + $(gyp_shared_intermediate_dir)/ui/gl/jni/SurfaceTexturePlatformWrapper_jni.h \ $(gyp_shared_intermediate_dir)/ui/gl/jni/SurfaceTextureListener_jni.h \ ui_gl_gl_jni_headers_gyp_rule_trigger diff --git a/ui/gl/gl_jni_headers.target.darwin-mips.mk b/ui/gl/gl_jni_headers.target.darwin-mips.mk index ee2cba4996..bf1c2218fd 100644 --- a/ui/gl/gl_jni_headers.target.darwin-mips.mk +++ b/ui/gl/gl_jni_headers.target.darwin-mips.mk @@ -12,12 +12,21 @@ gyp_shared_intermediate_dir := $(call intermediates-dir-for,GYP,shared) # Make sure our deps are built first. GYP_TARGET_DEPENDENCIES := \ - $(call intermediates-dir-for,GYP,ui_gl_surface_texture_jni_headers_gyp)/surface_texture_jni_headers.stamp \ $(call intermediates-dir-for,GYP,ui_gl_surface_jni_headers_gyp)/surface_jni_headers.stamp ### Generated for rule "ui_gl_gl_gyp_gl_jni_headers_target_generate_jni_headers": -# "{'inputs': ['../../base/android/jni_generator/jni_generator.py', '../../android_webview/build/jarjar-rules.txt'], 'process_outputs_as_sources': '1', 'extension': 'java', 'outputs': ['$(gyp_shared_intermediate_dir)/ui/gl/jni/%(INPUT_ROOT)s_jni.h'], 'rule_name': 'generate_jni_headers', 'rule_sources': ['../android/java/src/org/chromium/ui/gfx/SurfaceTextureListener.java'], 'action': ['../../base/android/jni_generator/jni_generator.py', '--input_file', '$(RULE_SOURCES)', '--output_dir', '$(gyp_shared_intermediate_dir)/ui/gl/jni', '--optimize_generation', '0', '--jarjar', '../../android_webview/build/jarjar-rules.txt'], 'message': 'Generating JNI bindings from $(RULE_SOURCES)'}": +# "{'inputs': ['../../base/android/jni_generator/jni_generator.py', '../../android_webview/build/jarjar-rules.txt'], 'process_outputs_as_sources': '1', 'extension': 'java', 'outputs': ['$(gyp_shared_intermediate_dir)/ui/gl/jni/%(INPUT_ROOT)s_jni.h'], 'rule_name': 'generate_jni_headers', 'rule_sources': ['../android/java/src/org/chromium/ui/gfx/SurfaceTexturePlatformWrapper.java', '../android/java/src/org/chromium/ui/gfx/SurfaceTextureListener.java'], 'action': ['../../base/android/jni_generator/jni_generator.py', '--input_file', '$(RULE_SOURCES)', '--output_dir', '$(gyp_shared_intermediate_dir)/ui/gl/jni', '--optimize_generation', '0', '--jarjar', '../../android_webview/build/jarjar-rules.txt'], 'message': 'Generating JNI bindings from $(RULE_SOURCES)'}": +$(gyp_shared_intermediate_dir)/ui/gl/jni/SurfaceTexturePlatformWrapper_jni.h: gyp_local_path := $(LOCAL_PATH) +$(gyp_shared_intermediate_dir)/ui/gl/jni/SurfaceTexturePlatformWrapper_jni.h: gyp_intermediate_dir := $(abspath $(gyp_intermediate_dir)) +$(gyp_shared_intermediate_dir)/ui/gl/jni/SurfaceTexturePlatformWrapper_jni.h: gyp_shared_intermediate_dir := $(abspath $(gyp_shared_intermediate_dir)) +$(gyp_shared_intermediate_dir)/ui/gl/jni/SurfaceTexturePlatformWrapper_jni.h: export PATH := $(subst $(ANDROID_BUILD_PATHS),,$(PATH)) +$(gyp_shared_intermediate_dir)/ui/gl/jni/SurfaceTexturePlatformWrapper_jni.h: $(LOCAL_PATH)/ui/android/java/src/org/chromium/ui/gfx/SurfaceTexturePlatformWrapper.java $(LOCAL_PATH)/base/android/jni_generator/jni_generator.py $(LOCAL_PATH)/android_webview/build/jarjar-rules.txt $(GYP_TARGET_DEPENDENCIES) + mkdir -p $(gyp_shared_intermediate_dir)/ui/gl/jni; cd $(gyp_local_path)/ui/gl; ../../base/android/jni_generator/jni_generator.py --input_file ../android/java/src/org/chromium/ui/gfx/SurfaceTexturePlatformWrapper.java --output_dir "$(gyp_shared_intermediate_dir)/ui/gl/jni" --optimize_generation 0 --jarjar ../../android_webview/build/jarjar-rules.txt + +.PHONY: ui_gl_gl_jni_headers_gyp_rule_trigger +ui_gl_gl_jni_headers_gyp_rule_trigger: $(gyp_shared_intermediate_dir)/ui/gl/jni/SurfaceTexturePlatformWrapper_jni.h + $(gyp_shared_intermediate_dir)/ui/gl/jni/SurfaceTextureListener_jni.h: gyp_local_path := $(LOCAL_PATH) $(gyp_shared_intermediate_dir)/ui/gl/jni/SurfaceTextureListener_jni.h: gyp_intermediate_dir := $(abspath $(gyp_intermediate_dir)) $(gyp_shared_intermediate_dir)/ui/gl/jni/SurfaceTextureListener_jni.h: gyp_shared_intermediate_dir := $(abspath $(gyp_shared_intermediate_dir)) @@ -31,12 +40,14 @@ ui_gl_gl_jni_headers_gyp_rule_trigger: $(gyp_shared_intermediate_dir)/ui/gl/jni/ ### Finished generating for all rules GYP_GENERATED_OUTPUTS := \ + $(gyp_shared_intermediate_dir)/ui/gl/jni/SurfaceTexturePlatformWrapper_jni.h \ $(gyp_shared_intermediate_dir)/ui/gl/jni/SurfaceTextureListener_jni.h # Make sure our deps and generated files are built first. LOCAL_ADDITIONAL_DEPENDENCIES := $(GYP_TARGET_DEPENDENCIES) $(GYP_GENERATED_OUTPUTS) LOCAL_GENERATED_SOURCES := \ + $(gyp_shared_intermediate_dir)/ui/gl/jni/SurfaceTexturePlatformWrapper_jni.h \ $(gyp_shared_intermediate_dir)/ui/gl/jni/SurfaceTextureListener_jni.h \ ui_gl_gl_jni_headers_gyp_rule_trigger diff --git a/ui/gl/gl_jni_headers.target.darwin-x86.mk b/ui/gl/gl_jni_headers.target.darwin-x86.mk index c228a07dfd..4ad7243eed 100644 --- a/ui/gl/gl_jni_headers.target.darwin-x86.mk +++ b/ui/gl/gl_jni_headers.target.darwin-x86.mk @@ -12,12 +12,21 @@ gyp_shared_intermediate_dir := $(call intermediates-dir-for,GYP,shared) # Make sure our deps are built first. GYP_TARGET_DEPENDENCIES := \ - $(call intermediates-dir-for,GYP,ui_gl_surface_texture_jni_headers_gyp)/surface_texture_jni_headers.stamp \ $(call intermediates-dir-for,GYP,ui_gl_surface_jni_headers_gyp)/surface_jni_headers.stamp ### Generated for rule "ui_gl_gl_gyp_gl_jni_headers_target_generate_jni_headers": -# "{'inputs': ['../../base/android/jni_generator/jni_generator.py', '../../android_webview/build/jarjar-rules.txt'], 'process_outputs_as_sources': '1', 'extension': 'java', 'outputs': ['$(gyp_shared_intermediate_dir)/ui/gl/jni/%(INPUT_ROOT)s_jni.h'], 'rule_name': 'generate_jni_headers', 'rule_sources': ['../android/java/src/org/chromium/ui/gfx/SurfaceTextureListener.java'], 'action': ['../../base/android/jni_generator/jni_generator.py', '--input_file', '$(RULE_SOURCES)', '--output_dir', '$(gyp_shared_intermediate_dir)/ui/gl/jni', '--optimize_generation', '0', '--jarjar', '../../android_webview/build/jarjar-rules.txt'], 'message': 'Generating JNI bindings from $(RULE_SOURCES)'}": +# "{'inputs': ['../../base/android/jni_generator/jni_generator.py', '../../android_webview/build/jarjar-rules.txt'], 'process_outputs_as_sources': '1', 'extension': 'java', 'outputs': ['$(gyp_shared_intermediate_dir)/ui/gl/jni/%(INPUT_ROOT)s_jni.h'], 'rule_name': 'generate_jni_headers', 'rule_sources': ['../android/java/src/org/chromium/ui/gfx/SurfaceTexturePlatformWrapper.java', '../android/java/src/org/chromium/ui/gfx/SurfaceTextureListener.java'], 'action': ['../../base/android/jni_generator/jni_generator.py', '--input_file', '$(RULE_SOURCES)', '--output_dir', '$(gyp_shared_intermediate_dir)/ui/gl/jni', '--optimize_generation', '0', '--jarjar', '../../android_webview/build/jarjar-rules.txt'], 'message': 'Generating JNI bindings from $(RULE_SOURCES)'}": +$(gyp_shared_intermediate_dir)/ui/gl/jni/SurfaceTexturePlatformWrapper_jni.h: gyp_local_path := $(LOCAL_PATH) +$(gyp_shared_intermediate_dir)/ui/gl/jni/SurfaceTexturePlatformWrapper_jni.h: gyp_intermediate_dir := $(abspath $(gyp_intermediate_dir)) +$(gyp_shared_intermediate_dir)/ui/gl/jni/SurfaceTexturePlatformWrapper_jni.h: gyp_shared_intermediate_dir := $(abspath $(gyp_shared_intermediate_dir)) +$(gyp_shared_intermediate_dir)/ui/gl/jni/SurfaceTexturePlatformWrapper_jni.h: export PATH := $(subst $(ANDROID_BUILD_PATHS),,$(PATH)) +$(gyp_shared_intermediate_dir)/ui/gl/jni/SurfaceTexturePlatformWrapper_jni.h: $(LOCAL_PATH)/ui/android/java/src/org/chromium/ui/gfx/SurfaceTexturePlatformWrapper.java $(LOCAL_PATH)/base/android/jni_generator/jni_generator.py $(LOCAL_PATH)/android_webview/build/jarjar-rules.txt $(GYP_TARGET_DEPENDENCIES) + mkdir -p $(gyp_shared_intermediate_dir)/ui/gl/jni; cd $(gyp_local_path)/ui/gl; ../../base/android/jni_generator/jni_generator.py --input_file ../android/java/src/org/chromium/ui/gfx/SurfaceTexturePlatformWrapper.java --output_dir "$(gyp_shared_intermediate_dir)/ui/gl/jni" --optimize_generation 0 --jarjar ../../android_webview/build/jarjar-rules.txt + +.PHONY: ui_gl_gl_jni_headers_gyp_rule_trigger +ui_gl_gl_jni_headers_gyp_rule_trigger: $(gyp_shared_intermediate_dir)/ui/gl/jni/SurfaceTexturePlatformWrapper_jni.h + $(gyp_shared_intermediate_dir)/ui/gl/jni/SurfaceTextureListener_jni.h: gyp_local_path := $(LOCAL_PATH) $(gyp_shared_intermediate_dir)/ui/gl/jni/SurfaceTextureListener_jni.h: gyp_intermediate_dir := $(abspath $(gyp_intermediate_dir)) $(gyp_shared_intermediate_dir)/ui/gl/jni/SurfaceTextureListener_jni.h: gyp_shared_intermediate_dir := $(abspath $(gyp_shared_intermediate_dir)) @@ -31,12 +40,14 @@ ui_gl_gl_jni_headers_gyp_rule_trigger: $(gyp_shared_intermediate_dir)/ui/gl/jni/ ### Finished generating for all rules GYP_GENERATED_OUTPUTS := \ + $(gyp_shared_intermediate_dir)/ui/gl/jni/SurfaceTexturePlatformWrapper_jni.h \ $(gyp_shared_intermediate_dir)/ui/gl/jni/SurfaceTextureListener_jni.h # Make sure our deps and generated files are built first. LOCAL_ADDITIONAL_DEPENDENCIES := $(GYP_TARGET_DEPENDENCIES) $(GYP_GENERATED_OUTPUTS) LOCAL_GENERATED_SOURCES := \ + $(gyp_shared_intermediate_dir)/ui/gl/jni/SurfaceTexturePlatformWrapper_jni.h \ $(gyp_shared_intermediate_dir)/ui/gl/jni/SurfaceTextureListener_jni.h \ ui_gl_gl_jni_headers_gyp_rule_trigger diff --git a/ui/gl/gl_jni_headers.target.linux-arm.mk b/ui/gl/gl_jni_headers.target.linux-arm.mk index 497701a224..3af8ab0f6c 100644 --- a/ui/gl/gl_jni_headers.target.linux-arm.mk +++ b/ui/gl/gl_jni_headers.target.linux-arm.mk @@ -12,12 +12,21 @@ gyp_shared_intermediate_dir := $(call intermediates-dir-for,GYP,shared) # Make sure our deps are built first. GYP_TARGET_DEPENDENCIES := \ - $(call intermediates-dir-for,GYP,ui_gl_surface_texture_jni_headers_gyp)/surface_texture_jni_headers.stamp \ $(call intermediates-dir-for,GYP,ui_gl_surface_jni_headers_gyp)/surface_jni_headers.stamp ### Generated for rule "ui_gl_gl_gyp_gl_jni_headers_target_generate_jni_headers": -# "{'inputs': ['../../base/android/jni_generator/jni_generator.py', '../../android_webview/build/jarjar-rules.txt'], 'process_outputs_as_sources': '1', 'extension': 'java', 'outputs': ['$(gyp_shared_intermediate_dir)/ui/gl/jni/%(INPUT_ROOT)s_jni.h'], 'rule_name': 'generate_jni_headers', 'rule_sources': ['../android/java/src/org/chromium/ui/gfx/SurfaceTextureListener.java'], 'action': ['../../base/android/jni_generator/jni_generator.py', '--input_file', '$(RULE_SOURCES)', '--output_dir', '$(gyp_shared_intermediate_dir)/ui/gl/jni', '--optimize_generation', '0', '--jarjar', '../../android_webview/build/jarjar-rules.txt'], 'message': 'Generating JNI bindings from $(RULE_SOURCES)'}": +# "{'inputs': ['../../base/android/jni_generator/jni_generator.py', '../../android_webview/build/jarjar-rules.txt'], 'process_outputs_as_sources': '1', 'extension': 'java', 'outputs': ['$(gyp_shared_intermediate_dir)/ui/gl/jni/%(INPUT_ROOT)s_jni.h'], 'rule_name': 'generate_jni_headers', 'rule_sources': ['../android/java/src/org/chromium/ui/gfx/SurfaceTexturePlatformWrapper.java', '../android/java/src/org/chromium/ui/gfx/SurfaceTextureListener.java'], 'action': ['../../base/android/jni_generator/jni_generator.py', '--input_file', '$(RULE_SOURCES)', '--output_dir', '$(gyp_shared_intermediate_dir)/ui/gl/jni', '--optimize_generation', '0', '--jarjar', '../../android_webview/build/jarjar-rules.txt'], 'message': 'Generating JNI bindings from $(RULE_SOURCES)'}": +$(gyp_shared_intermediate_dir)/ui/gl/jni/SurfaceTexturePlatformWrapper_jni.h: gyp_local_path := $(LOCAL_PATH) +$(gyp_shared_intermediate_dir)/ui/gl/jni/SurfaceTexturePlatformWrapper_jni.h: gyp_intermediate_dir := $(abspath $(gyp_intermediate_dir)) +$(gyp_shared_intermediate_dir)/ui/gl/jni/SurfaceTexturePlatformWrapper_jni.h: gyp_shared_intermediate_dir := $(abspath $(gyp_shared_intermediate_dir)) +$(gyp_shared_intermediate_dir)/ui/gl/jni/SurfaceTexturePlatformWrapper_jni.h: export PATH := $(subst $(ANDROID_BUILD_PATHS),,$(PATH)) +$(gyp_shared_intermediate_dir)/ui/gl/jni/SurfaceTexturePlatformWrapper_jni.h: $(LOCAL_PATH)/ui/android/java/src/org/chromium/ui/gfx/SurfaceTexturePlatformWrapper.java $(LOCAL_PATH)/base/android/jni_generator/jni_generator.py $(LOCAL_PATH)/android_webview/build/jarjar-rules.txt $(GYP_TARGET_DEPENDENCIES) + mkdir -p $(gyp_shared_intermediate_dir)/ui/gl/jni; cd $(gyp_local_path)/ui/gl; ../../base/android/jni_generator/jni_generator.py --input_file ../android/java/src/org/chromium/ui/gfx/SurfaceTexturePlatformWrapper.java --output_dir "$(gyp_shared_intermediate_dir)/ui/gl/jni" --optimize_generation 0 --jarjar ../../android_webview/build/jarjar-rules.txt + +.PHONY: ui_gl_gl_jni_headers_gyp_rule_trigger +ui_gl_gl_jni_headers_gyp_rule_trigger: $(gyp_shared_intermediate_dir)/ui/gl/jni/SurfaceTexturePlatformWrapper_jni.h + $(gyp_shared_intermediate_dir)/ui/gl/jni/SurfaceTextureListener_jni.h: gyp_local_path := $(LOCAL_PATH) $(gyp_shared_intermediate_dir)/ui/gl/jni/SurfaceTextureListener_jni.h: gyp_intermediate_dir := $(abspath $(gyp_intermediate_dir)) $(gyp_shared_intermediate_dir)/ui/gl/jni/SurfaceTextureListener_jni.h: gyp_shared_intermediate_dir := $(abspath $(gyp_shared_intermediate_dir)) @@ -31,12 +40,14 @@ ui_gl_gl_jni_headers_gyp_rule_trigger: $(gyp_shared_intermediate_dir)/ui/gl/jni/ ### Finished generating for all rules GYP_GENERATED_OUTPUTS := \ + $(gyp_shared_intermediate_dir)/ui/gl/jni/SurfaceTexturePlatformWrapper_jni.h \ $(gyp_shared_intermediate_dir)/ui/gl/jni/SurfaceTextureListener_jni.h # Make sure our deps and generated files are built first. LOCAL_ADDITIONAL_DEPENDENCIES := $(GYP_TARGET_DEPENDENCIES) $(GYP_GENERATED_OUTPUTS) LOCAL_GENERATED_SOURCES := \ + $(gyp_shared_intermediate_dir)/ui/gl/jni/SurfaceTexturePlatformWrapper_jni.h \ $(gyp_shared_intermediate_dir)/ui/gl/jni/SurfaceTextureListener_jni.h \ ui_gl_gl_jni_headers_gyp_rule_trigger diff --git a/ui/gl/gl_jni_headers.target.linux-mips.mk b/ui/gl/gl_jni_headers.target.linux-mips.mk index ee2cba4996..bf1c2218fd 100644 --- a/ui/gl/gl_jni_headers.target.linux-mips.mk +++ b/ui/gl/gl_jni_headers.target.linux-mips.mk @@ -12,12 +12,21 @@ gyp_shared_intermediate_dir := $(call intermediates-dir-for,GYP,shared) # Make sure our deps are built first. GYP_TARGET_DEPENDENCIES := \ - $(call intermediates-dir-for,GYP,ui_gl_surface_texture_jni_headers_gyp)/surface_texture_jni_headers.stamp \ $(call intermediates-dir-for,GYP,ui_gl_surface_jni_headers_gyp)/surface_jni_headers.stamp ### Generated for rule "ui_gl_gl_gyp_gl_jni_headers_target_generate_jni_headers": -# "{'inputs': ['../../base/android/jni_generator/jni_generator.py', '../../android_webview/build/jarjar-rules.txt'], 'process_outputs_as_sources': '1', 'extension': 'java', 'outputs': ['$(gyp_shared_intermediate_dir)/ui/gl/jni/%(INPUT_ROOT)s_jni.h'], 'rule_name': 'generate_jni_headers', 'rule_sources': ['../android/java/src/org/chromium/ui/gfx/SurfaceTextureListener.java'], 'action': ['../../base/android/jni_generator/jni_generator.py', '--input_file', '$(RULE_SOURCES)', '--output_dir', '$(gyp_shared_intermediate_dir)/ui/gl/jni', '--optimize_generation', '0', '--jarjar', '../../android_webview/build/jarjar-rules.txt'], 'message': 'Generating JNI bindings from $(RULE_SOURCES)'}": +# "{'inputs': ['../../base/android/jni_generator/jni_generator.py', '../../android_webview/build/jarjar-rules.txt'], 'process_outputs_as_sources': '1', 'extension': 'java', 'outputs': ['$(gyp_shared_intermediate_dir)/ui/gl/jni/%(INPUT_ROOT)s_jni.h'], 'rule_name': 'generate_jni_headers', 'rule_sources': ['../android/java/src/org/chromium/ui/gfx/SurfaceTexturePlatformWrapper.java', '../android/java/src/org/chromium/ui/gfx/SurfaceTextureListener.java'], 'action': ['../../base/android/jni_generator/jni_generator.py', '--input_file', '$(RULE_SOURCES)', '--output_dir', '$(gyp_shared_intermediate_dir)/ui/gl/jni', '--optimize_generation', '0', '--jarjar', '../../android_webview/build/jarjar-rules.txt'], 'message': 'Generating JNI bindings from $(RULE_SOURCES)'}": +$(gyp_shared_intermediate_dir)/ui/gl/jni/SurfaceTexturePlatformWrapper_jni.h: gyp_local_path := $(LOCAL_PATH) +$(gyp_shared_intermediate_dir)/ui/gl/jni/SurfaceTexturePlatformWrapper_jni.h: gyp_intermediate_dir := $(abspath $(gyp_intermediate_dir)) +$(gyp_shared_intermediate_dir)/ui/gl/jni/SurfaceTexturePlatformWrapper_jni.h: gyp_shared_intermediate_dir := $(abspath $(gyp_shared_intermediate_dir)) +$(gyp_shared_intermediate_dir)/ui/gl/jni/SurfaceTexturePlatformWrapper_jni.h: export PATH := $(subst $(ANDROID_BUILD_PATHS),,$(PATH)) +$(gyp_shared_intermediate_dir)/ui/gl/jni/SurfaceTexturePlatformWrapper_jni.h: $(LOCAL_PATH)/ui/android/java/src/org/chromium/ui/gfx/SurfaceTexturePlatformWrapper.java $(LOCAL_PATH)/base/android/jni_generator/jni_generator.py $(LOCAL_PATH)/android_webview/build/jarjar-rules.txt $(GYP_TARGET_DEPENDENCIES) + mkdir -p $(gyp_shared_intermediate_dir)/ui/gl/jni; cd $(gyp_local_path)/ui/gl; ../../base/android/jni_generator/jni_generator.py --input_file ../android/java/src/org/chromium/ui/gfx/SurfaceTexturePlatformWrapper.java --output_dir "$(gyp_shared_intermediate_dir)/ui/gl/jni" --optimize_generation 0 --jarjar ../../android_webview/build/jarjar-rules.txt + +.PHONY: ui_gl_gl_jni_headers_gyp_rule_trigger +ui_gl_gl_jni_headers_gyp_rule_trigger: $(gyp_shared_intermediate_dir)/ui/gl/jni/SurfaceTexturePlatformWrapper_jni.h + $(gyp_shared_intermediate_dir)/ui/gl/jni/SurfaceTextureListener_jni.h: gyp_local_path := $(LOCAL_PATH) $(gyp_shared_intermediate_dir)/ui/gl/jni/SurfaceTextureListener_jni.h: gyp_intermediate_dir := $(abspath $(gyp_intermediate_dir)) $(gyp_shared_intermediate_dir)/ui/gl/jni/SurfaceTextureListener_jni.h: gyp_shared_intermediate_dir := $(abspath $(gyp_shared_intermediate_dir)) @@ -31,12 +40,14 @@ ui_gl_gl_jni_headers_gyp_rule_trigger: $(gyp_shared_intermediate_dir)/ui/gl/jni/ ### Finished generating for all rules GYP_GENERATED_OUTPUTS := \ + $(gyp_shared_intermediate_dir)/ui/gl/jni/SurfaceTexturePlatformWrapper_jni.h \ $(gyp_shared_intermediate_dir)/ui/gl/jni/SurfaceTextureListener_jni.h # Make sure our deps and generated files are built first. LOCAL_ADDITIONAL_DEPENDENCIES := $(GYP_TARGET_DEPENDENCIES) $(GYP_GENERATED_OUTPUTS) LOCAL_GENERATED_SOURCES := \ + $(gyp_shared_intermediate_dir)/ui/gl/jni/SurfaceTexturePlatformWrapper_jni.h \ $(gyp_shared_intermediate_dir)/ui/gl/jni/SurfaceTextureListener_jni.h \ ui_gl_gl_jni_headers_gyp_rule_trigger diff --git a/ui/gl/gl_jni_headers.target.linux-x86.mk b/ui/gl/gl_jni_headers.target.linux-x86.mk index c228a07dfd..4ad7243eed 100644 --- a/ui/gl/gl_jni_headers.target.linux-x86.mk +++ b/ui/gl/gl_jni_headers.target.linux-x86.mk @@ -12,12 +12,21 @@ gyp_shared_intermediate_dir := $(call intermediates-dir-for,GYP,shared) # Make sure our deps are built first. GYP_TARGET_DEPENDENCIES := \ - $(call intermediates-dir-for,GYP,ui_gl_surface_texture_jni_headers_gyp)/surface_texture_jni_headers.stamp \ $(call intermediates-dir-for,GYP,ui_gl_surface_jni_headers_gyp)/surface_jni_headers.stamp ### Generated for rule "ui_gl_gl_gyp_gl_jni_headers_target_generate_jni_headers": -# "{'inputs': ['../../base/android/jni_generator/jni_generator.py', '../../android_webview/build/jarjar-rules.txt'], 'process_outputs_as_sources': '1', 'extension': 'java', 'outputs': ['$(gyp_shared_intermediate_dir)/ui/gl/jni/%(INPUT_ROOT)s_jni.h'], 'rule_name': 'generate_jni_headers', 'rule_sources': ['../android/java/src/org/chromium/ui/gfx/SurfaceTextureListener.java'], 'action': ['../../base/android/jni_generator/jni_generator.py', '--input_file', '$(RULE_SOURCES)', '--output_dir', '$(gyp_shared_intermediate_dir)/ui/gl/jni', '--optimize_generation', '0', '--jarjar', '../../android_webview/build/jarjar-rules.txt'], 'message': 'Generating JNI bindings from $(RULE_SOURCES)'}": +# "{'inputs': ['../../base/android/jni_generator/jni_generator.py', '../../android_webview/build/jarjar-rules.txt'], 'process_outputs_as_sources': '1', 'extension': 'java', 'outputs': ['$(gyp_shared_intermediate_dir)/ui/gl/jni/%(INPUT_ROOT)s_jni.h'], 'rule_name': 'generate_jni_headers', 'rule_sources': ['../android/java/src/org/chromium/ui/gfx/SurfaceTexturePlatformWrapper.java', '../android/java/src/org/chromium/ui/gfx/SurfaceTextureListener.java'], 'action': ['../../base/android/jni_generator/jni_generator.py', '--input_file', '$(RULE_SOURCES)', '--output_dir', '$(gyp_shared_intermediate_dir)/ui/gl/jni', '--optimize_generation', '0', '--jarjar', '../../android_webview/build/jarjar-rules.txt'], 'message': 'Generating JNI bindings from $(RULE_SOURCES)'}": +$(gyp_shared_intermediate_dir)/ui/gl/jni/SurfaceTexturePlatformWrapper_jni.h: gyp_local_path := $(LOCAL_PATH) +$(gyp_shared_intermediate_dir)/ui/gl/jni/SurfaceTexturePlatformWrapper_jni.h: gyp_intermediate_dir := $(abspath $(gyp_intermediate_dir)) +$(gyp_shared_intermediate_dir)/ui/gl/jni/SurfaceTexturePlatformWrapper_jni.h: gyp_shared_intermediate_dir := $(abspath $(gyp_shared_intermediate_dir)) +$(gyp_shared_intermediate_dir)/ui/gl/jni/SurfaceTexturePlatformWrapper_jni.h: export PATH := $(subst $(ANDROID_BUILD_PATHS),,$(PATH)) +$(gyp_shared_intermediate_dir)/ui/gl/jni/SurfaceTexturePlatformWrapper_jni.h: $(LOCAL_PATH)/ui/android/java/src/org/chromium/ui/gfx/SurfaceTexturePlatformWrapper.java $(LOCAL_PATH)/base/android/jni_generator/jni_generator.py $(LOCAL_PATH)/android_webview/build/jarjar-rules.txt $(GYP_TARGET_DEPENDENCIES) + mkdir -p $(gyp_shared_intermediate_dir)/ui/gl/jni; cd $(gyp_local_path)/ui/gl; ../../base/android/jni_generator/jni_generator.py --input_file ../android/java/src/org/chromium/ui/gfx/SurfaceTexturePlatformWrapper.java --output_dir "$(gyp_shared_intermediate_dir)/ui/gl/jni" --optimize_generation 0 --jarjar ../../android_webview/build/jarjar-rules.txt + +.PHONY: ui_gl_gl_jni_headers_gyp_rule_trigger +ui_gl_gl_jni_headers_gyp_rule_trigger: $(gyp_shared_intermediate_dir)/ui/gl/jni/SurfaceTexturePlatformWrapper_jni.h + $(gyp_shared_intermediate_dir)/ui/gl/jni/SurfaceTextureListener_jni.h: gyp_local_path := $(LOCAL_PATH) $(gyp_shared_intermediate_dir)/ui/gl/jni/SurfaceTextureListener_jni.h: gyp_intermediate_dir := $(abspath $(gyp_intermediate_dir)) $(gyp_shared_intermediate_dir)/ui/gl/jni/SurfaceTextureListener_jni.h: gyp_shared_intermediate_dir := $(abspath $(gyp_shared_intermediate_dir)) @@ -31,12 +40,14 @@ ui_gl_gl_jni_headers_gyp_rule_trigger: $(gyp_shared_intermediate_dir)/ui/gl/jni/ ### Finished generating for all rules GYP_GENERATED_OUTPUTS := \ + $(gyp_shared_intermediate_dir)/ui/gl/jni/SurfaceTexturePlatformWrapper_jni.h \ $(gyp_shared_intermediate_dir)/ui/gl/jni/SurfaceTextureListener_jni.h # Make sure our deps and generated files are built first. LOCAL_ADDITIONAL_DEPENDENCIES := $(GYP_TARGET_DEPENDENCIES) $(GYP_GENERATED_OUTPUTS) LOCAL_GENERATED_SOURCES := \ + $(gyp_shared_intermediate_dir)/ui/gl/jni/SurfaceTexturePlatformWrapper_jni.h \ $(gyp_shared_intermediate_dir)/ui/gl/jni/SurfaceTextureListener_jni.h \ ui_gl_gl_jni_headers_gyp_rule_trigger diff --git a/ui/gl/surface_texture_jni_headers.target.darwin-arm.mk b/ui/gl/surface_texture_jni_headers.target.darwin-arm.mk deleted file mode 100644 index 100f19e123..0000000000 --- a/ui/gl/surface_texture_jni_headers.target.darwin-arm.mk +++ /dev/null @@ -1,218 +0,0 @@ -# This file is generated by gyp; do not edit. - -include $(CLEAR_VARS) - -LOCAL_MODULE_CLASS := GYP -LOCAL_MODULE := ui_gl_surface_texture_jni_headers_gyp -LOCAL_MODULE_STEM := surface_texture_jni_headers -LOCAL_MODULE_SUFFIX := .stamp -LOCAL_MODULE_TAGS := optional -gyp_intermediate_dir := $(call local-intermediates-dir) -gyp_shared_intermediate_dir := $(call intermediates-dir-for,GYP,shared) - -# Make sure our deps are built first. -GYP_TARGET_DEPENDENCIES := - -### Rules for action "generate_jni_headers_from_jar_file": -$(gyp_shared_intermediate_dir)/ui/gl/jni/SurfaceTexture_jni.h: gyp_local_path := $(LOCAL_PATH) -$(gyp_shared_intermediate_dir)/ui/gl/jni/SurfaceTexture_jni.h: gyp_intermediate_dir := $(abspath $(gyp_intermediate_dir)) -$(gyp_shared_intermediate_dir)/ui/gl/jni/SurfaceTexture_jni.h: gyp_shared_intermediate_dir := $(abspath $(gyp_shared_intermediate_dir)) -$(gyp_shared_intermediate_dir)/ui/gl/jni/SurfaceTexture_jni.h: export PATH := $(subst $(ANDROID_BUILD_PATHS),,$(PATH)) -$(gyp_shared_intermediate_dir)/ui/gl/jni/SurfaceTexture_jni.h: $(LOCAL_PATH)/base/android/jni_generator/jni_generator.py $(PWD)/prebuilts/sdk/17/android.jar $(GYP_TARGET_DEPENDENCIES) - @echo "Gyp action: Generating JNI bindings from $(PWD)/prebuilts/sdk/17/android.jar/android/graphics/SurfaceTexture.class ($@)" - $(hide)cd $(gyp_local_path)/ui/gl; mkdir -p $(gyp_shared_intermediate_dir)/ui/gl/jni; ../../base/android/jni_generator/jni_generator.py -j "$(PWD)/prebuilts/sdk/17/android.jar" --input_file android/graphics/SurfaceTexture.class --output_dir "$(gyp_shared_intermediate_dir)/ui/gl/jni" --optimize_generation 0 - - - -GYP_GENERATED_OUTPUTS := \ - $(gyp_shared_intermediate_dir)/ui/gl/jni/SurfaceTexture_jni.h - -# Make sure our deps and generated files are built first. -LOCAL_ADDITIONAL_DEPENDENCIES := $(GYP_TARGET_DEPENDENCIES) $(GYP_GENERATED_OUTPUTS) - -LOCAL_GENERATED_SOURCES := \ - $(gyp_shared_intermediate_dir)/ui/gl/jni/SurfaceTexture_jni.h - -GYP_COPIED_SOURCE_ORIGIN_DIRS := - -LOCAL_SRC_FILES := - - -# Flags passed to both C and C++ files. -MY_CFLAGS_Debug := \ - -fstack-protector \ - --param=ssp-buffer-size=4 \ - -Werror \ - -fno-exceptions \ - -fno-strict-aliasing \ - -Wall \ - -Wno-unused-parameter \ - -Wno-missing-field-initializers \ - -fvisibility=hidden \ - -pipe \ - -fPIC \ - -fno-tree-sra \ - -fuse-ld=gold \ - -Wno-psabi \ - -ffunction-sections \ - -funwind-tables \ - -g \ - -fstack-protector \ - -fno-short-enums \ - -finline-limit=64 \ - -Wa,--noexecstack \ - -U_FORTIFY_SOURCE \ - -Wno-extra \ - -Wno-ignored-qualifiers \ - -Wno-type-limits \ - -Os \ - -g \ - -fomit-frame-pointer \ - -fdata-sections \ - -ffunction-sections - -MY_DEFS_Debug := \ - '-DANGLE_DX11' \ - '-D_FILE_OFFSET_BITS=64' \ - '-DNO_TCMALLOC' \ - '-DDISCARDABLE_MEMORY_ALWAYS_SUPPORTED_NATIVELY' \ - '-DSYSTEM_NATIVELY_SIGNALS_MEMORY_PRESSURE' \ - '-DDISABLE_NACL' \ - '-DCHROMIUM_BUILD' \ - '-DUSE_LIBJPEG_TURBO=1' \ - '-DUSE_PROPRIETARY_CODECS' \ - '-DENABLE_CONFIGURATION_POLICY' \ - '-DENABLE_GPU=1' \ - '-DUSE_OPENSSL=1' \ - '-DENABLE_EGLIMAGE=1' \ - '-D__STDC_CONSTANT_MACROS' \ - '-D__STDC_FORMAT_MACROS' \ - '-DANDROID' \ - '-D__GNU_SOURCE=1' \ - '-DUSE_STLPORT=1' \ - '-D_STLP_USE_PTR_SPECIALIZATIONS=1' \ - '-DCHROME_BUILD_ID=""' \ - '-DDYNAMIC_ANNOTATIONS_ENABLED=1' \ - '-DWTF_USE_DYNAMIC_ANNOTATIONS=1' \ - '-D_DEBUG' - - -# Include paths placed before CFLAGS/CPPFLAGS -LOCAL_C_INCLUDES_Debug := \ - $(PWD)/frameworks/wilhelm/include \ - $(PWD)/bionic \ - $(PWD)/external/stlport/stlport - - -# Flags passed to only C++ (and not C) files. -LOCAL_CPPFLAGS_Debug := \ - -fno-rtti \ - -fno-threadsafe-statics \ - -fvisibility-inlines-hidden \ - -Wsign-compare \ - -Wno-abi \ - -Wno-error=c++0x-compat \ - -Wno-non-virtual-dtor \ - -Wno-sign-promo - - -# Flags passed to both C and C++ files. -MY_CFLAGS_Release := \ - -fstack-protector \ - --param=ssp-buffer-size=4 \ - -Werror \ - -fno-exceptions \ - -fno-strict-aliasing \ - -Wall \ - -Wno-unused-parameter \ - -Wno-missing-field-initializers \ - -fvisibility=hidden \ - -pipe \ - -fPIC \ - -fno-tree-sra \ - -fuse-ld=gold \ - -Wno-psabi \ - -ffunction-sections \ - -funwind-tables \ - -g \ - -fstack-protector \ - -fno-short-enums \ - -finline-limit=64 \ - -Wa,--noexecstack \ - -U_FORTIFY_SOURCE \ - -Wno-extra \ - -Wno-ignored-qualifiers \ - -Wno-type-limits \ - -Os \ - -fno-ident \ - -fdata-sections \ - -ffunction-sections \ - -fomit-frame-pointer - -MY_DEFS_Release := \ - '-DANGLE_DX11' \ - '-D_FILE_OFFSET_BITS=64' \ - '-DNO_TCMALLOC' \ - '-DDISCARDABLE_MEMORY_ALWAYS_SUPPORTED_NATIVELY' \ - '-DSYSTEM_NATIVELY_SIGNALS_MEMORY_PRESSURE' \ - '-DDISABLE_NACL' \ - '-DCHROMIUM_BUILD' \ - '-DUSE_LIBJPEG_TURBO=1' \ - '-DUSE_PROPRIETARY_CODECS' \ - '-DENABLE_CONFIGURATION_POLICY' \ - '-DENABLE_GPU=1' \ - '-DUSE_OPENSSL=1' \ - '-DENABLE_EGLIMAGE=1' \ - '-D__STDC_CONSTANT_MACROS' \ - '-D__STDC_FORMAT_MACROS' \ - '-DANDROID' \ - '-D__GNU_SOURCE=1' \ - '-DUSE_STLPORT=1' \ - '-D_STLP_USE_PTR_SPECIALIZATIONS=1' \ - '-DCHROME_BUILD_ID=""' \ - '-DNDEBUG' \ - '-DNVALGRIND' \ - '-DDYNAMIC_ANNOTATIONS_ENABLED=0' \ - '-D_FORTIFY_SOURCE=2' - - -# Include paths placed before CFLAGS/CPPFLAGS -LOCAL_C_INCLUDES_Release := \ - $(PWD)/frameworks/wilhelm/include \ - $(PWD)/bionic \ - $(PWD)/external/stlport/stlport - - -# Flags passed to only C++ (and not C) files. -LOCAL_CPPFLAGS_Release := \ - -fno-rtti \ - -fno-threadsafe-statics \ - -fvisibility-inlines-hidden \ - -Wsign-compare \ - -Wno-abi \ - -Wno-error=c++0x-compat \ - -Wno-non-virtual-dtor \ - -Wno-sign-promo - - -LOCAL_CFLAGS := $(MY_CFLAGS_$(GYP_CONFIGURATION)) $(MY_DEFS_$(GYP_CONFIGURATION)) -LOCAL_C_INCLUDES := $(GYP_COPIED_SOURCE_ORIGIN_DIRS) $(LOCAL_C_INCLUDES_$(GYP_CONFIGURATION)) -LOCAL_CPPFLAGS := $(LOCAL_CPPFLAGS_$(GYP_CONFIGURATION)) -### Rules for final target. -# Add target alias to "gyp_all_modules" target. -.PHONY: gyp_all_modules -gyp_all_modules: ui_gl_surface_texture_jni_headers_gyp - -# Alias gyp target name. -.PHONY: surface_texture_jni_headers -surface_texture_jni_headers: ui_gl_surface_texture_jni_headers_gyp - -LOCAL_MODULE_PATH := $(PRODUCT_OUT)/gyp_stamp -LOCAL_UNINSTALLABLE_MODULE := true - -include $(BUILD_SYSTEM)/base_rules.mk - -$(LOCAL_BUILT_MODULE): $(LOCAL_ADDITIONAL_DEPENDENCIES) - $(hide) echo "Gyp timestamp: $@" - $(hide) mkdir -p $(dir $@) - $(hide) touch $@ diff --git a/ui/gl/surface_texture_jni_headers.target.darwin-mips.mk b/ui/gl/surface_texture_jni_headers.target.darwin-mips.mk deleted file mode 100644 index c57e903190..0000000000 --- a/ui/gl/surface_texture_jni_headers.target.darwin-mips.mk +++ /dev/null @@ -1,216 +0,0 @@ -# This file is generated by gyp; do not edit. - -include $(CLEAR_VARS) - -LOCAL_MODULE_CLASS := GYP -LOCAL_MODULE := ui_gl_surface_texture_jni_headers_gyp -LOCAL_MODULE_STEM := surface_texture_jni_headers -LOCAL_MODULE_SUFFIX := .stamp -LOCAL_MODULE_TAGS := optional -gyp_intermediate_dir := $(call local-intermediates-dir) -gyp_shared_intermediate_dir := $(call intermediates-dir-for,GYP,shared) - -# Make sure our deps are built first. -GYP_TARGET_DEPENDENCIES := - -### Rules for action "generate_jni_headers_from_jar_file": -$(gyp_shared_intermediate_dir)/ui/gl/jni/SurfaceTexture_jni.h: gyp_local_path := $(LOCAL_PATH) -$(gyp_shared_intermediate_dir)/ui/gl/jni/SurfaceTexture_jni.h: gyp_intermediate_dir := $(abspath $(gyp_intermediate_dir)) -$(gyp_shared_intermediate_dir)/ui/gl/jni/SurfaceTexture_jni.h: gyp_shared_intermediate_dir := $(abspath $(gyp_shared_intermediate_dir)) -$(gyp_shared_intermediate_dir)/ui/gl/jni/SurfaceTexture_jni.h: export PATH := $(subst $(ANDROID_BUILD_PATHS),,$(PATH)) -$(gyp_shared_intermediate_dir)/ui/gl/jni/SurfaceTexture_jni.h: $(LOCAL_PATH)/base/android/jni_generator/jni_generator.py $(PWD)/prebuilts/sdk/17/android.jar $(GYP_TARGET_DEPENDENCIES) - @echo "Gyp action: Generating JNI bindings from $(PWD)/prebuilts/sdk/17/android.jar/android/graphics/SurfaceTexture.class ($@)" - $(hide)cd $(gyp_local_path)/ui/gl; mkdir -p $(gyp_shared_intermediate_dir)/ui/gl/jni; ../../base/android/jni_generator/jni_generator.py -j "$(PWD)/prebuilts/sdk/17/android.jar" --input_file android/graphics/SurfaceTexture.class --output_dir "$(gyp_shared_intermediate_dir)/ui/gl/jni" --optimize_generation 0 - - - -GYP_GENERATED_OUTPUTS := \ - $(gyp_shared_intermediate_dir)/ui/gl/jni/SurfaceTexture_jni.h - -# Make sure our deps and generated files are built first. -LOCAL_ADDITIONAL_DEPENDENCIES := $(GYP_TARGET_DEPENDENCIES) $(GYP_GENERATED_OUTPUTS) - -LOCAL_GENERATED_SOURCES := \ - $(gyp_shared_intermediate_dir)/ui/gl/jni/SurfaceTexture_jni.h - -GYP_COPIED_SOURCE_ORIGIN_DIRS := - -LOCAL_SRC_FILES := - - -# Flags passed to both C and C++ files. -MY_CFLAGS_Debug := \ - -fstack-protector \ - --param=ssp-buffer-size=4 \ - \ - -fno-exceptions \ - -fno-strict-aliasing \ - -Wall \ - -Wno-unused-parameter \ - -Wno-missing-field-initializers \ - -fvisibility=hidden \ - -pipe \ - -fPIC \ - -EL \ - -mhard-float \ - -ffunction-sections \ - -funwind-tables \ - -g \ - -fstack-protector \ - -fno-short-enums \ - -finline-limit=64 \ - -Wa,--noexecstack \ - -U_FORTIFY_SOURCE \ - -Wno-extra \ - -Wno-ignored-qualifiers \ - -Wno-type-limits \ - -Os \ - -g \ - -fomit-frame-pointer \ - -fdata-sections \ - -ffunction-sections - -MY_DEFS_Debug := \ - '-DANGLE_DX11' \ - '-D_FILE_OFFSET_BITS=64' \ - '-DNO_TCMALLOC' \ - '-DDISCARDABLE_MEMORY_ALWAYS_SUPPORTED_NATIVELY' \ - '-DSYSTEM_NATIVELY_SIGNALS_MEMORY_PRESSURE' \ - '-DDISABLE_NACL' \ - '-DCHROMIUM_BUILD' \ - '-DUSE_LIBJPEG_TURBO=1' \ - '-DUSE_PROPRIETARY_CODECS' \ - '-DENABLE_CONFIGURATION_POLICY' \ - '-DENABLE_GPU=1' \ - '-DUSE_OPENSSL=1' \ - '-DENABLE_EGLIMAGE=1' \ - '-D__STDC_CONSTANT_MACROS' \ - '-D__STDC_FORMAT_MACROS' \ - '-DANDROID' \ - '-D__GNU_SOURCE=1' \ - '-DUSE_STLPORT=1' \ - '-D_STLP_USE_PTR_SPECIALIZATIONS=1' \ - '-DCHROME_BUILD_ID=""' \ - '-DDYNAMIC_ANNOTATIONS_ENABLED=1' \ - '-DWTF_USE_DYNAMIC_ANNOTATIONS=1' \ - '-D_DEBUG' - - -# Include paths placed before CFLAGS/CPPFLAGS -LOCAL_C_INCLUDES_Debug := \ - $(PWD)/frameworks/wilhelm/include \ - $(PWD)/bionic \ - $(PWD)/external/stlport/stlport - - -# Flags passed to only C++ (and not C) files. -LOCAL_CPPFLAGS_Debug := \ - -fno-rtti \ - -fno-threadsafe-statics \ - -fvisibility-inlines-hidden \ - -Wsign-compare \ - -Wno-uninitialized \ - -Wno-error=c++0x-compat \ - -Wno-non-virtual-dtor \ - -Wno-sign-promo - - -# Flags passed to both C and C++ files. -MY_CFLAGS_Release := \ - -fstack-protector \ - --param=ssp-buffer-size=4 \ - \ - -fno-exceptions \ - -fno-strict-aliasing \ - -Wall \ - -Wno-unused-parameter \ - -Wno-missing-field-initializers \ - -fvisibility=hidden \ - -pipe \ - -fPIC \ - -EL \ - -mhard-float \ - -ffunction-sections \ - -funwind-tables \ - -g \ - -fstack-protector \ - -fno-short-enums \ - -finline-limit=64 \ - -Wa,--noexecstack \ - -U_FORTIFY_SOURCE \ - -Wno-extra \ - -Wno-ignored-qualifiers \ - -Wno-type-limits \ - -Os \ - -fno-ident \ - -fdata-sections \ - -ffunction-sections \ - -fomit-frame-pointer - -MY_DEFS_Release := \ - '-DANGLE_DX11' \ - '-D_FILE_OFFSET_BITS=64' \ - '-DNO_TCMALLOC' \ - '-DDISCARDABLE_MEMORY_ALWAYS_SUPPORTED_NATIVELY' \ - '-DSYSTEM_NATIVELY_SIGNALS_MEMORY_PRESSURE' \ - '-DDISABLE_NACL' \ - '-DCHROMIUM_BUILD' \ - '-DUSE_LIBJPEG_TURBO=1' \ - '-DUSE_PROPRIETARY_CODECS' \ - '-DENABLE_CONFIGURATION_POLICY' \ - '-DENABLE_GPU=1' \ - '-DUSE_OPENSSL=1' \ - '-DENABLE_EGLIMAGE=1' \ - '-D__STDC_CONSTANT_MACROS' \ - '-D__STDC_FORMAT_MACROS' \ - '-DANDROID' \ - '-D__GNU_SOURCE=1' \ - '-DUSE_STLPORT=1' \ - '-D_STLP_USE_PTR_SPECIALIZATIONS=1' \ - '-DCHROME_BUILD_ID=""' \ - '-DNDEBUG' \ - '-DNVALGRIND' \ - '-DDYNAMIC_ANNOTATIONS_ENABLED=0' \ - '-D_FORTIFY_SOURCE=2' - - -# Include paths placed before CFLAGS/CPPFLAGS -LOCAL_C_INCLUDES_Release := \ - $(PWD)/frameworks/wilhelm/include \ - $(PWD)/bionic \ - $(PWD)/external/stlport/stlport - - -# Flags passed to only C++ (and not C) files. -LOCAL_CPPFLAGS_Release := \ - -fno-rtti \ - -fno-threadsafe-statics \ - -fvisibility-inlines-hidden \ - -Wsign-compare \ - -Wno-uninitialized \ - -Wno-error=c++0x-compat \ - -Wno-non-virtual-dtor \ - -Wno-sign-promo - - -LOCAL_CFLAGS := $(MY_CFLAGS_$(GYP_CONFIGURATION)) $(MY_DEFS_$(GYP_CONFIGURATION)) -LOCAL_C_INCLUDES := $(GYP_COPIED_SOURCE_ORIGIN_DIRS) $(LOCAL_C_INCLUDES_$(GYP_CONFIGURATION)) -LOCAL_CPPFLAGS := $(LOCAL_CPPFLAGS_$(GYP_CONFIGURATION)) -### Rules for final target. -# Add target alias to "gyp_all_modules" target. -.PHONY: gyp_all_modules -gyp_all_modules: ui_gl_surface_texture_jni_headers_gyp - -# Alias gyp target name. -.PHONY: surface_texture_jni_headers -surface_texture_jni_headers: ui_gl_surface_texture_jni_headers_gyp - -LOCAL_MODULE_PATH := $(PRODUCT_OUT)/gyp_stamp -LOCAL_UNINSTALLABLE_MODULE := true - -include $(BUILD_SYSTEM)/base_rules.mk - -$(LOCAL_BUILT_MODULE): $(LOCAL_ADDITIONAL_DEPENDENCIES) - $(hide) echo "Gyp timestamp: $@" - $(hide) mkdir -p $(dir $@) - $(hide) touch $@ diff --git a/ui/gl/surface_texture_jni_headers.target.darwin-x86.mk b/ui/gl/surface_texture_jni_headers.target.darwin-x86.mk deleted file mode 100644 index e205dd3899..0000000000 --- a/ui/gl/surface_texture_jni_headers.target.darwin-x86.mk +++ /dev/null @@ -1,222 +0,0 @@ -# This file is generated by gyp; do not edit. - -include $(CLEAR_VARS) - -LOCAL_MODULE_CLASS := GYP -LOCAL_MODULE := ui_gl_surface_texture_jni_headers_gyp -LOCAL_MODULE_STEM := surface_texture_jni_headers -LOCAL_MODULE_SUFFIX := .stamp -LOCAL_MODULE_TAGS := optional -gyp_intermediate_dir := $(call local-intermediates-dir) -gyp_shared_intermediate_dir := $(call intermediates-dir-for,GYP,shared) - -# Make sure our deps are built first. -GYP_TARGET_DEPENDENCIES := - -### Rules for action "generate_jni_headers_from_jar_file": -$(gyp_shared_intermediate_dir)/ui/gl/jni/SurfaceTexture_jni.h: gyp_local_path := $(LOCAL_PATH) -$(gyp_shared_intermediate_dir)/ui/gl/jni/SurfaceTexture_jni.h: gyp_intermediate_dir := $(abspath $(gyp_intermediate_dir)) -$(gyp_shared_intermediate_dir)/ui/gl/jni/SurfaceTexture_jni.h: gyp_shared_intermediate_dir := $(abspath $(gyp_shared_intermediate_dir)) -$(gyp_shared_intermediate_dir)/ui/gl/jni/SurfaceTexture_jni.h: export PATH := $(subst $(ANDROID_BUILD_PATHS),,$(PATH)) -$(gyp_shared_intermediate_dir)/ui/gl/jni/SurfaceTexture_jni.h: $(LOCAL_PATH)/base/android/jni_generator/jni_generator.py $(PWD)/prebuilts/sdk/17/android.jar $(GYP_TARGET_DEPENDENCIES) - @echo "Gyp action: Generating JNI bindings from $(PWD)/prebuilts/sdk/17/android.jar/android/graphics/SurfaceTexture.class ($@)" - $(hide)cd $(gyp_local_path)/ui/gl; mkdir -p $(gyp_shared_intermediate_dir)/ui/gl/jni; ../../base/android/jni_generator/jni_generator.py -j "$(PWD)/prebuilts/sdk/17/android.jar" --input_file android/graphics/SurfaceTexture.class --output_dir "$(gyp_shared_intermediate_dir)/ui/gl/jni" --optimize_generation 0 - - - -GYP_GENERATED_OUTPUTS := \ - $(gyp_shared_intermediate_dir)/ui/gl/jni/SurfaceTexture_jni.h - -# Make sure our deps and generated files are built first. -LOCAL_ADDITIONAL_DEPENDENCIES := $(GYP_TARGET_DEPENDENCIES) $(GYP_GENERATED_OUTPUTS) - -LOCAL_GENERATED_SOURCES := \ - $(gyp_shared_intermediate_dir)/ui/gl/jni/SurfaceTexture_jni.h - -GYP_COPIED_SOURCE_ORIGIN_DIRS := - -LOCAL_SRC_FILES := - - -# Flags passed to both C and C++ files. -MY_CFLAGS_Debug := \ - --param=ssp-buffer-size=4 \ - -Werror \ - -fno-exceptions \ - -fno-strict-aliasing \ - -Wall \ - -Wno-unused-parameter \ - -Wno-missing-field-initializers \ - -fvisibility=hidden \ - -pipe \ - -fPIC \ - -m32 \ - -mmmx \ - -march=pentium4 \ - -msse2 \ - -mfpmath=sse \ - -fuse-ld=gold \ - -ffunction-sections \ - -funwind-tables \ - -g \ - -fno-short-enums \ - -finline-limit=64 \ - -Wa,--noexecstack \ - -U_FORTIFY_SOURCE \ - -Wno-extra \ - -Wno-ignored-qualifiers \ - -Wno-type-limits \ - -fno-stack-protector \ - -Os \ - -g \ - -fomit-frame-pointer \ - -fdata-sections \ - -ffunction-sections - -MY_DEFS_Debug := \ - '-DANGLE_DX11' \ - '-D_FILE_OFFSET_BITS=64' \ - '-DNO_TCMALLOC' \ - '-DDISCARDABLE_MEMORY_ALWAYS_SUPPORTED_NATIVELY' \ - '-DSYSTEM_NATIVELY_SIGNALS_MEMORY_PRESSURE' \ - '-DDISABLE_NACL' \ - '-DCHROMIUM_BUILD' \ - '-DUSE_LIBJPEG_TURBO=1' \ - '-DUSE_PROPRIETARY_CODECS' \ - '-DENABLE_CONFIGURATION_POLICY' \ - '-DENABLE_GPU=1' \ - '-DUSE_OPENSSL=1' \ - '-DENABLE_EGLIMAGE=1' \ - '-D__STDC_CONSTANT_MACROS' \ - '-D__STDC_FORMAT_MACROS' \ - '-DANDROID' \ - '-D__GNU_SOURCE=1' \ - '-DUSE_STLPORT=1' \ - '-D_STLP_USE_PTR_SPECIALIZATIONS=1' \ - '-DCHROME_BUILD_ID=""' \ - '-DDYNAMIC_ANNOTATIONS_ENABLED=1' \ - '-DWTF_USE_DYNAMIC_ANNOTATIONS=1' \ - '-D_DEBUG' - - -# Include paths placed before CFLAGS/CPPFLAGS -LOCAL_C_INCLUDES_Debug := \ - $(PWD)/frameworks/wilhelm/include \ - $(PWD)/bionic \ - $(PWD)/external/stlport/stlport - - -# Flags passed to only C++ (and not C) files. -LOCAL_CPPFLAGS_Debug := \ - -fno-rtti \ - -fno-threadsafe-statics \ - -fvisibility-inlines-hidden \ - -Wsign-compare \ - -Wno-error=c++0x-compat \ - -Wno-non-virtual-dtor \ - -Wno-sign-promo - - -# Flags passed to both C and C++ files. -MY_CFLAGS_Release := \ - --param=ssp-buffer-size=4 \ - -Werror \ - -fno-exceptions \ - -fno-strict-aliasing \ - -Wall \ - -Wno-unused-parameter \ - -Wno-missing-field-initializers \ - -fvisibility=hidden \ - -pipe \ - -fPIC \ - -m32 \ - -mmmx \ - -march=pentium4 \ - -msse2 \ - -mfpmath=sse \ - -fuse-ld=gold \ - -ffunction-sections \ - -funwind-tables \ - -g \ - -fno-short-enums \ - -finline-limit=64 \ - -Wa,--noexecstack \ - -U_FORTIFY_SOURCE \ - -Wno-extra \ - -Wno-ignored-qualifiers \ - -Wno-type-limits \ - -fno-stack-protector \ - -Os \ - -fno-ident \ - -fdata-sections \ - -ffunction-sections \ - -fomit-frame-pointer \ - -fno-unwind-tables \ - -fno-asynchronous-unwind-tables - -MY_DEFS_Release := \ - '-DANGLE_DX11' \ - '-D_FILE_OFFSET_BITS=64' \ - '-DNO_TCMALLOC' \ - '-DDISCARDABLE_MEMORY_ALWAYS_SUPPORTED_NATIVELY' \ - '-DSYSTEM_NATIVELY_SIGNALS_MEMORY_PRESSURE' \ - '-DDISABLE_NACL' \ - '-DCHROMIUM_BUILD' \ - '-DUSE_LIBJPEG_TURBO=1' \ - '-DUSE_PROPRIETARY_CODECS' \ - '-DENABLE_CONFIGURATION_POLICY' \ - '-DENABLE_GPU=1' \ - '-DUSE_OPENSSL=1' \ - '-DENABLE_EGLIMAGE=1' \ - '-D__STDC_CONSTANT_MACROS' \ - '-D__STDC_FORMAT_MACROS' \ - '-DANDROID' \ - '-D__GNU_SOURCE=1' \ - '-DUSE_STLPORT=1' \ - '-D_STLP_USE_PTR_SPECIALIZATIONS=1' \ - '-DCHROME_BUILD_ID=""' \ - '-DNDEBUG' \ - '-DNVALGRIND' \ - '-DDYNAMIC_ANNOTATIONS_ENABLED=0' \ - '-D_FORTIFY_SOURCE=2' - - -# Include paths placed before CFLAGS/CPPFLAGS -LOCAL_C_INCLUDES_Release := \ - $(PWD)/frameworks/wilhelm/include \ - $(PWD)/bionic \ - $(PWD)/external/stlport/stlport - - -# Flags passed to only C++ (and not C) files. -LOCAL_CPPFLAGS_Release := \ - -fno-rtti \ - -fno-threadsafe-statics \ - -fvisibility-inlines-hidden \ - -Wsign-compare \ - -Wno-error=c++0x-compat \ - -Wno-non-virtual-dtor \ - -Wno-sign-promo - - -LOCAL_CFLAGS := $(MY_CFLAGS_$(GYP_CONFIGURATION)) $(MY_DEFS_$(GYP_CONFIGURATION)) -LOCAL_C_INCLUDES := $(GYP_COPIED_SOURCE_ORIGIN_DIRS) $(LOCAL_C_INCLUDES_$(GYP_CONFIGURATION)) -LOCAL_CPPFLAGS := $(LOCAL_CPPFLAGS_$(GYP_CONFIGURATION)) -### Rules for final target. -# Add target alias to "gyp_all_modules" target. -.PHONY: gyp_all_modules -gyp_all_modules: ui_gl_surface_texture_jni_headers_gyp - -# Alias gyp target name. -.PHONY: surface_texture_jni_headers -surface_texture_jni_headers: ui_gl_surface_texture_jni_headers_gyp - -LOCAL_MODULE_PATH := $(PRODUCT_OUT)/gyp_stamp -LOCAL_UNINSTALLABLE_MODULE := true - -include $(BUILD_SYSTEM)/base_rules.mk - -$(LOCAL_BUILT_MODULE): $(LOCAL_ADDITIONAL_DEPENDENCIES) - $(hide) echo "Gyp timestamp: $@" - $(hide) mkdir -p $(dir $@) - $(hide) touch $@ diff --git a/ui/gl/surface_texture_jni_headers.target.linux-arm.mk b/ui/gl/surface_texture_jni_headers.target.linux-arm.mk deleted file mode 100644 index 100f19e123..0000000000 --- a/ui/gl/surface_texture_jni_headers.target.linux-arm.mk +++ /dev/null @@ -1,218 +0,0 @@ -# This file is generated by gyp; do not edit. - -include $(CLEAR_VARS) - -LOCAL_MODULE_CLASS := GYP -LOCAL_MODULE := ui_gl_surface_texture_jni_headers_gyp -LOCAL_MODULE_STEM := surface_texture_jni_headers -LOCAL_MODULE_SUFFIX := .stamp -LOCAL_MODULE_TAGS := optional -gyp_intermediate_dir := $(call local-intermediates-dir) -gyp_shared_intermediate_dir := $(call intermediates-dir-for,GYP,shared) - -# Make sure our deps are built first. -GYP_TARGET_DEPENDENCIES := - -### Rules for action "generate_jni_headers_from_jar_file": -$(gyp_shared_intermediate_dir)/ui/gl/jni/SurfaceTexture_jni.h: gyp_local_path := $(LOCAL_PATH) -$(gyp_shared_intermediate_dir)/ui/gl/jni/SurfaceTexture_jni.h: gyp_intermediate_dir := $(abspath $(gyp_intermediate_dir)) -$(gyp_shared_intermediate_dir)/ui/gl/jni/SurfaceTexture_jni.h: gyp_shared_intermediate_dir := $(abspath $(gyp_shared_intermediate_dir)) -$(gyp_shared_intermediate_dir)/ui/gl/jni/SurfaceTexture_jni.h: export PATH := $(subst $(ANDROID_BUILD_PATHS),,$(PATH)) -$(gyp_shared_intermediate_dir)/ui/gl/jni/SurfaceTexture_jni.h: $(LOCAL_PATH)/base/android/jni_generator/jni_generator.py $(PWD)/prebuilts/sdk/17/android.jar $(GYP_TARGET_DEPENDENCIES) - @echo "Gyp action: Generating JNI bindings from $(PWD)/prebuilts/sdk/17/android.jar/android/graphics/SurfaceTexture.class ($@)" - $(hide)cd $(gyp_local_path)/ui/gl; mkdir -p $(gyp_shared_intermediate_dir)/ui/gl/jni; ../../base/android/jni_generator/jni_generator.py -j "$(PWD)/prebuilts/sdk/17/android.jar" --input_file android/graphics/SurfaceTexture.class --output_dir "$(gyp_shared_intermediate_dir)/ui/gl/jni" --optimize_generation 0 - - - -GYP_GENERATED_OUTPUTS := \ - $(gyp_shared_intermediate_dir)/ui/gl/jni/SurfaceTexture_jni.h - -# Make sure our deps and generated files are built first. -LOCAL_ADDITIONAL_DEPENDENCIES := $(GYP_TARGET_DEPENDENCIES) $(GYP_GENERATED_OUTPUTS) - -LOCAL_GENERATED_SOURCES := \ - $(gyp_shared_intermediate_dir)/ui/gl/jni/SurfaceTexture_jni.h - -GYP_COPIED_SOURCE_ORIGIN_DIRS := - -LOCAL_SRC_FILES := - - -# Flags passed to both C and C++ files. -MY_CFLAGS_Debug := \ - -fstack-protector \ - --param=ssp-buffer-size=4 \ - -Werror \ - -fno-exceptions \ - -fno-strict-aliasing \ - -Wall \ - -Wno-unused-parameter \ - -Wno-missing-field-initializers \ - -fvisibility=hidden \ - -pipe \ - -fPIC \ - -fno-tree-sra \ - -fuse-ld=gold \ - -Wno-psabi \ - -ffunction-sections \ - -funwind-tables \ - -g \ - -fstack-protector \ - -fno-short-enums \ - -finline-limit=64 \ - -Wa,--noexecstack \ - -U_FORTIFY_SOURCE \ - -Wno-extra \ - -Wno-ignored-qualifiers \ - -Wno-type-limits \ - -Os \ - -g \ - -fomit-frame-pointer \ - -fdata-sections \ - -ffunction-sections - -MY_DEFS_Debug := \ - '-DANGLE_DX11' \ - '-D_FILE_OFFSET_BITS=64' \ - '-DNO_TCMALLOC' \ - '-DDISCARDABLE_MEMORY_ALWAYS_SUPPORTED_NATIVELY' \ - '-DSYSTEM_NATIVELY_SIGNALS_MEMORY_PRESSURE' \ - '-DDISABLE_NACL' \ - '-DCHROMIUM_BUILD' \ - '-DUSE_LIBJPEG_TURBO=1' \ - '-DUSE_PROPRIETARY_CODECS' \ - '-DENABLE_CONFIGURATION_POLICY' \ - '-DENABLE_GPU=1' \ - '-DUSE_OPENSSL=1' \ - '-DENABLE_EGLIMAGE=1' \ - '-D__STDC_CONSTANT_MACROS' \ - '-D__STDC_FORMAT_MACROS' \ - '-DANDROID' \ - '-D__GNU_SOURCE=1' \ - '-DUSE_STLPORT=1' \ - '-D_STLP_USE_PTR_SPECIALIZATIONS=1' \ - '-DCHROME_BUILD_ID=""' \ - '-DDYNAMIC_ANNOTATIONS_ENABLED=1' \ - '-DWTF_USE_DYNAMIC_ANNOTATIONS=1' \ - '-D_DEBUG' - - -# Include paths placed before CFLAGS/CPPFLAGS -LOCAL_C_INCLUDES_Debug := \ - $(PWD)/frameworks/wilhelm/include \ - $(PWD)/bionic \ - $(PWD)/external/stlport/stlport - - -# Flags passed to only C++ (and not C) files. -LOCAL_CPPFLAGS_Debug := \ - -fno-rtti \ - -fno-threadsafe-statics \ - -fvisibility-inlines-hidden \ - -Wsign-compare \ - -Wno-abi \ - -Wno-error=c++0x-compat \ - -Wno-non-virtual-dtor \ - -Wno-sign-promo - - -# Flags passed to both C and C++ files. -MY_CFLAGS_Release := \ - -fstack-protector \ - --param=ssp-buffer-size=4 \ - -Werror \ - -fno-exceptions \ - -fno-strict-aliasing \ - -Wall \ - -Wno-unused-parameter \ - -Wno-missing-field-initializers \ - -fvisibility=hidden \ - -pipe \ - -fPIC \ - -fno-tree-sra \ - -fuse-ld=gold \ - -Wno-psabi \ - -ffunction-sections \ - -funwind-tables \ - -g \ - -fstack-protector \ - -fno-short-enums \ - -finline-limit=64 \ - -Wa,--noexecstack \ - -U_FORTIFY_SOURCE \ - -Wno-extra \ - -Wno-ignored-qualifiers \ - -Wno-type-limits \ - -Os \ - -fno-ident \ - -fdata-sections \ - -ffunction-sections \ - -fomit-frame-pointer - -MY_DEFS_Release := \ - '-DANGLE_DX11' \ - '-D_FILE_OFFSET_BITS=64' \ - '-DNO_TCMALLOC' \ - '-DDISCARDABLE_MEMORY_ALWAYS_SUPPORTED_NATIVELY' \ - '-DSYSTEM_NATIVELY_SIGNALS_MEMORY_PRESSURE' \ - '-DDISABLE_NACL' \ - '-DCHROMIUM_BUILD' \ - '-DUSE_LIBJPEG_TURBO=1' \ - '-DUSE_PROPRIETARY_CODECS' \ - '-DENABLE_CONFIGURATION_POLICY' \ - '-DENABLE_GPU=1' \ - '-DUSE_OPENSSL=1' \ - '-DENABLE_EGLIMAGE=1' \ - '-D__STDC_CONSTANT_MACROS' \ - '-D__STDC_FORMAT_MACROS' \ - '-DANDROID' \ - '-D__GNU_SOURCE=1' \ - '-DUSE_STLPORT=1' \ - '-D_STLP_USE_PTR_SPECIALIZATIONS=1' \ - '-DCHROME_BUILD_ID=""' \ - '-DNDEBUG' \ - '-DNVALGRIND' \ - '-DDYNAMIC_ANNOTATIONS_ENABLED=0' \ - '-D_FORTIFY_SOURCE=2' - - -# Include paths placed before CFLAGS/CPPFLAGS -LOCAL_C_INCLUDES_Release := \ - $(PWD)/frameworks/wilhelm/include \ - $(PWD)/bionic \ - $(PWD)/external/stlport/stlport - - -# Flags passed to only C++ (and not C) files. -LOCAL_CPPFLAGS_Release := \ - -fno-rtti \ - -fno-threadsafe-statics \ - -fvisibility-inlines-hidden \ - -Wsign-compare \ - -Wno-abi \ - -Wno-error=c++0x-compat \ - -Wno-non-virtual-dtor \ - -Wno-sign-promo - - -LOCAL_CFLAGS := $(MY_CFLAGS_$(GYP_CONFIGURATION)) $(MY_DEFS_$(GYP_CONFIGURATION)) -LOCAL_C_INCLUDES := $(GYP_COPIED_SOURCE_ORIGIN_DIRS) $(LOCAL_C_INCLUDES_$(GYP_CONFIGURATION)) -LOCAL_CPPFLAGS := $(LOCAL_CPPFLAGS_$(GYP_CONFIGURATION)) -### Rules for final target. -# Add target alias to "gyp_all_modules" target. -.PHONY: gyp_all_modules -gyp_all_modules: ui_gl_surface_texture_jni_headers_gyp - -# Alias gyp target name. -.PHONY: surface_texture_jni_headers -surface_texture_jni_headers: ui_gl_surface_texture_jni_headers_gyp - -LOCAL_MODULE_PATH := $(PRODUCT_OUT)/gyp_stamp -LOCAL_UNINSTALLABLE_MODULE := true - -include $(BUILD_SYSTEM)/base_rules.mk - -$(LOCAL_BUILT_MODULE): $(LOCAL_ADDITIONAL_DEPENDENCIES) - $(hide) echo "Gyp timestamp: $@" - $(hide) mkdir -p $(dir $@) - $(hide) touch $@ diff --git a/ui/gl/surface_texture_jni_headers.target.linux-mips.mk b/ui/gl/surface_texture_jni_headers.target.linux-mips.mk deleted file mode 100644 index c57e903190..0000000000 --- a/ui/gl/surface_texture_jni_headers.target.linux-mips.mk +++ /dev/null @@ -1,216 +0,0 @@ -# This file is generated by gyp; do not edit. - -include $(CLEAR_VARS) - -LOCAL_MODULE_CLASS := GYP -LOCAL_MODULE := ui_gl_surface_texture_jni_headers_gyp -LOCAL_MODULE_STEM := surface_texture_jni_headers -LOCAL_MODULE_SUFFIX := .stamp -LOCAL_MODULE_TAGS := optional -gyp_intermediate_dir := $(call local-intermediates-dir) -gyp_shared_intermediate_dir := $(call intermediates-dir-for,GYP,shared) - -# Make sure our deps are built first. -GYP_TARGET_DEPENDENCIES := - -### Rules for action "generate_jni_headers_from_jar_file": -$(gyp_shared_intermediate_dir)/ui/gl/jni/SurfaceTexture_jni.h: gyp_local_path := $(LOCAL_PATH) -$(gyp_shared_intermediate_dir)/ui/gl/jni/SurfaceTexture_jni.h: gyp_intermediate_dir := $(abspath $(gyp_intermediate_dir)) -$(gyp_shared_intermediate_dir)/ui/gl/jni/SurfaceTexture_jni.h: gyp_shared_intermediate_dir := $(abspath $(gyp_shared_intermediate_dir)) -$(gyp_shared_intermediate_dir)/ui/gl/jni/SurfaceTexture_jni.h: export PATH := $(subst $(ANDROID_BUILD_PATHS),,$(PATH)) -$(gyp_shared_intermediate_dir)/ui/gl/jni/SurfaceTexture_jni.h: $(LOCAL_PATH)/base/android/jni_generator/jni_generator.py $(PWD)/prebuilts/sdk/17/android.jar $(GYP_TARGET_DEPENDENCIES) - @echo "Gyp action: Generating JNI bindings from $(PWD)/prebuilts/sdk/17/android.jar/android/graphics/SurfaceTexture.class ($@)" - $(hide)cd $(gyp_local_path)/ui/gl; mkdir -p $(gyp_shared_intermediate_dir)/ui/gl/jni; ../../base/android/jni_generator/jni_generator.py -j "$(PWD)/prebuilts/sdk/17/android.jar" --input_file android/graphics/SurfaceTexture.class --output_dir "$(gyp_shared_intermediate_dir)/ui/gl/jni" --optimize_generation 0 - - - -GYP_GENERATED_OUTPUTS := \ - $(gyp_shared_intermediate_dir)/ui/gl/jni/SurfaceTexture_jni.h - -# Make sure our deps and generated files are built first. -LOCAL_ADDITIONAL_DEPENDENCIES := $(GYP_TARGET_DEPENDENCIES) $(GYP_GENERATED_OUTPUTS) - -LOCAL_GENERATED_SOURCES := \ - $(gyp_shared_intermediate_dir)/ui/gl/jni/SurfaceTexture_jni.h - -GYP_COPIED_SOURCE_ORIGIN_DIRS := - -LOCAL_SRC_FILES := - - -# Flags passed to both C and C++ files. -MY_CFLAGS_Debug := \ - -fstack-protector \ - --param=ssp-buffer-size=4 \ - \ - -fno-exceptions \ - -fno-strict-aliasing \ - -Wall \ - -Wno-unused-parameter \ - -Wno-missing-field-initializers \ - -fvisibility=hidden \ - -pipe \ - -fPIC \ - -EL \ - -mhard-float \ - -ffunction-sections \ - -funwind-tables \ - -g \ - -fstack-protector \ - -fno-short-enums \ - -finline-limit=64 \ - -Wa,--noexecstack \ - -U_FORTIFY_SOURCE \ - -Wno-extra \ - -Wno-ignored-qualifiers \ - -Wno-type-limits \ - -Os \ - -g \ - -fomit-frame-pointer \ - -fdata-sections \ - -ffunction-sections - -MY_DEFS_Debug := \ - '-DANGLE_DX11' \ - '-D_FILE_OFFSET_BITS=64' \ - '-DNO_TCMALLOC' \ - '-DDISCARDABLE_MEMORY_ALWAYS_SUPPORTED_NATIVELY' \ - '-DSYSTEM_NATIVELY_SIGNALS_MEMORY_PRESSURE' \ - '-DDISABLE_NACL' \ - '-DCHROMIUM_BUILD' \ - '-DUSE_LIBJPEG_TURBO=1' \ - '-DUSE_PROPRIETARY_CODECS' \ - '-DENABLE_CONFIGURATION_POLICY' \ - '-DENABLE_GPU=1' \ - '-DUSE_OPENSSL=1' \ - '-DENABLE_EGLIMAGE=1' \ - '-D__STDC_CONSTANT_MACROS' \ - '-D__STDC_FORMAT_MACROS' \ - '-DANDROID' \ - '-D__GNU_SOURCE=1' \ - '-DUSE_STLPORT=1' \ - '-D_STLP_USE_PTR_SPECIALIZATIONS=1' \ - '-DCHROME_BUILD_ID=""' \ - '-DDYNAMIC_ANNOTATIONS_ENABLED=1' \ - '-DWTF_USE_DYNAMIC_ANNOTATIONS=1' \ - '-D_DEBUG' - - -# Include paths placed before CFLAGS/CPPFLAGS -LOCAL_C_INCLUDES_Debug := \ - $(PWD)/frameworks/wilhelm/include \ - $(PWD)/bionic \ - $(PWD)/external/stlport/stlport - - -# Flags passed to only C++ (and not C) files. -LOCAL_CPPFLAGS_Debug := \ - -fno-rtti \ - -fno-threadsafe-statics \ - -fvisibility-inlines-hidden \ - -Wsign-compare \ - -Wno-uninitialized \ - -Wno-error=c++0x-compat \ - -Wno-non-virtual-dtor \ - -Wno-sign-promo - - -# Flags passed to both C and C++ files. -MY_CFLAGS_Release := \ - -fstack-protector \ - --param=ssp-buffer-size=4 \ - \ - -fno-exceptions \ - -fno-strict-aliasing \ - -Wall \ - -Wno-unused-parameter \ - -Wno-missing-field-initializers \ - -fvisibility=hidden \ - -pipe \ - -fPIC \ - -EL \ - -mhard-float \ - -ffunction-sections \ - -funwind-tables \ - -g \ - -fstack-protector \ - -fno-short-enums \ - -finline-limit=64 \ - -Wa,--noexecstack \ - -U_FORTIFY_SOURCE \ - -Wno-extra \ - -Wno-ignored-qualifiers \ - -Wno-type-limits \ - -Os \ - -fno-ident \ - -fdata-sections \ - -ffunction-sections \ - -fomit-frame-pointer - -MY_DEFS_Release := \ - '-DANGLE_DX11' \ - '-D_FILE_OFFSET_BITS=64' \ - '-DNO_TCMALLOC' \ - '-DDISCARDABLE_MEMORY_ALWAYS_SUPPORTED_NATIVELY' \ - '-DSYSTEM_NATIVELY_SIGNALS_MEMORY_PRESSURE' \ - '-DDISABLE_NACL' \ - '-DCHROMIUM_BUILD' \ - '-DUSE_LIBJPEG_TURBO=1' \ - '-DUSE_PROPRIETARY_CODECS' \ - '-DENABLE_CONFIGURATION_POLICY' \ - '-DENABLE_GPU=1' \ - '-DUSE_OPENSSL=1' \ - '-DENABLE_EGLIMAGE=1' \ - '-D__STDC_CONSTANT_MACROS' \ - '-D__STDC_FORMAT_MACROS' \ - '-DANDROID' \ - '-D__GNU_SOURCE=1' \ - '-DUSE_STLPORT=1' \ - '-D_STLP_USE_PTR_SPECIALIZATIONS=1' \ - '-DCHROME_BUILD_ID=""' \ - '-DNDEBUG' \ - '-DNVALGRIND' \ - '-DDYNAMIC_ANNOTATIONS_ENABLED=0' \ - '-D_FORTIFY_SOURCE=2' - - -# Include paths placed before CFLAGS/CPPFLAGS -LOCAL_C_INCLUDES_Release := \ - $(PWD)/frameworks/wilhelm/include \ - $(PWD)/bionic \ - $(PWD)/external/stlport/stlport - - -# Flags passed to only C++ (and not C) files. -LOCAL_CPPFLAGS_Release := \ - -fno-rtti \ - -fno-threadsafe-statics \ - -fvisibility-inlines-hidden \ - -Wsign-compare \ - -Wno-uninitialized \ - -Wno-error=c++0x-compat \ - -Wno-non-virtual-dtor \ - -Wno-sign-promo - - -LOCAL_CFLAGS := $(MY_CFLAGS_$(GYP_CONFIGURATION)) $(MY_DEFS_$(GYP_CONFIGURATION)) -LOCAL_C_INCLUDES := $(GYP_COPIED_SOURCE_ORIGIN_DIRS) $(LOCAL_C_INCLUDES_$(GYP_CONFIGURATION)) -LOCAL_CPPFLAGS := $(LOCAL_CPPFLAGS_$(GYP_CONFIGURATION)) -### Rules for final target. -# Add target alias to "gyp_all_modules" target. -.PHONY: gyp_all_modules -gyp_all_modules: ui_gl_surface_texture_jni_headers_gyp - -# Alias gyp target name. -.PHONY: surface_texture_jni_headers -surface_texture_jni_headers: ui_gl_surface_texture_jni_headers_gyp - -LOCAL_MODULE_PATH := $(PRODUCT_OUT)/gyp_stamp -LOCAL_UNINSTALLABLE_MODULE := true - -include $(BUILD_SYSTEM)/base_rules.mk - -$(LOCAL_BUILT_MODULE): $(LOCAL_ADDITIONAL_DEPENDENCIES) - $(hide) echo "Gyp timestamp: $@" - $(hide) mkdir -p $(dir $@) - $(hide) touch $@ diff --git a/ui/gl/surface_texture_jni_headers.target.linux-x86.mk b/ui/gl/surface_texture_jni_headers.target.linux-x86.mk deleted file mode 100644 index e205dd3899..0000000000 --- a/ui/gl/surface_texture_jni_headers.target.linux-x86.mk +++ /dev/null @@ -1,222 +0,0 @@ -# This file is generated by gyp; do not edit. - -include $(CLEAR_VARS) - -LOCAL_MODULE_CLASS := GYP -LOCAL_MODULE := ui_gl_surface_texture_jni_headers_gyp -LOCAL_MODULE_STEM := surface_texture_jni_headers -LOCAL_MODULE_SUFFIX := .stamp -LOCAL_MODULE_TAGS := optional -gyp_intermediate_dir := $(call local-intermediates-dir) -gyp_shared_intermediate_dir := $(call intermediates-dir-for,GYP,shared) - -# Make sure our deps are built first. -GYP_TARGET_DEPENDENCIES := - -### Rules for action "generate_jni_headers_from_jar_file": -$(gyp_shared_intermediate_dir)/ui/gl/jni/SurfaceTexture_jni.h: gyp_local_path := $(LOCAL_PATH) -$(gyp_shared_intermediate_dir)/ui/gl/jni/SurfaceTexture_jni.h: gyp_intermediate_dir := $(abspath $(gyp_intermediate_dir)) -$(gyp_shared_intermediate_dir)/ui/gl/jni/SurfaceTexture_jni.h: gyp_shared_intermediate_dir := $(abspath $(gyp_shared_intermediate_dir)) -$(gyp_shared_intermediate_dir)/ui/gl/jni/SurfaceTexture_jni.h: export PATH := $(subst $(ANDROID_BUILD_PATHS),,$(PATH)) -$(gyp_shared_intermediate_dir)/ui/gl/jni/SurfaceTexture_jni.h: $(LOCAL_PATH)/base/android/jni_generator/jni_generator.py $(PWD)/prebuilts/sdk/17/android.jar $(GYP_TARGET_DEPENDENCIES) - @echo "Gyp action: Generating JNI bindings from $(PWD)/prebuilts/sdk/17/android.jar/android/graphics/SurfaceTexture.class ($@)" - $(hide)cd $(gyp_local_path)/ui/gl; mkdir -p $(gyp_shared_intermediate_dir)/ui/gl/jni; ../../base/android/jni_generator/jni_generator.py -j "$(PWD)/prebuilts/sdk/17/android.jar" --input_file android/graphics/SurfaceTexture.class --output_dir "$(gyp_shared_intermediate_dir)/ui/gl/jni" --optimize_generation 0 - - - -GYP_GENERATED_OUTPUTS := \ - $(gyp_shared_intermediate_dir)/ui/gl/jni/SurfaceTexture_jni.h - -# Make sure our deps and generated files are built first. -LOCAL_ADDITIONAL_DEPENDENCIES := $(GYP_TARGET_DEPENDENCIES) $(GYP_GENERATED_OUTPUTS) - -LOCAL_GENERATED_SOURCES := \ - $(gyp_shared_intermediate_dir)/ui/gl/jni/SurfaceTexture_jni.h - -GYP_COPIED_SOURCE_ORIGIN_DIRS := - -LOCAL_SRC_FILES := - - -# Flags passed to both C and C++ files. -MY_CFLAGS_Debug := \ - --param=ssp-buffer-size=4 \ - -Werror \ - -fno-exceptions \ - -fno-strict-aliasing \ - -Wall \ - -Wno-unused-parameter \ - -Wno-missing-field-initializers \ - -fvisibility=hidden \ - -pipe \ - -fPIC \ - -m32 \ - -mmmx \ - -march=pentium4 \ - -msse2 \ - -mfpmath=sse \ - -fuse-ld=gold \ - -ffunction-sections \ - -funwind-tables \ - -g \ - -fno-short-enums \ - -finline-limit=64 \ - -Wa,--noexecstack \ - -U_FORTIFY_SOURCE \ - -Wno-extra \ - -Wno-ignored-qualifiers \ - -Wno-type-limits \ - -fno-stack-protector \ - -Os \ - -g \ - -fomit-frame-pointer \ - -fdata-sections \ - -ffunction-sections - -MY_DEFS_Debug := \ - '-DANGLE_DX11' \ - '-D_FILE_OFFSET_BITS=64' \ - '-DNO_TCMALLOC' \ - '-DDISCARDABLE_MEMORY_ALWAYS_SUPPORTED_NATIVELY' \ - '-DSYSTEM_NATIVELY_SIGNALS_MEMORY_PRESSURE' \ - '-DDISABLE_NACL' \ - '-DCHROMIUM_BUILD' \ - '-DUSE_LIBJPEG_TURBO=1' \ - '-DUSE_PROPRIETARY_CODECS' \ - '-DENABLE_CONFIGURATION_POLICY' \ - '-DENABLE_GPU=1' \ - '-DUSE_OPENSSL=1' \ - '-DENABLE_EGLIMAGE=1' \ - '-D__STDC_CONSTANT_MACROS' \ - '-D__STDC_FORMAT_MACROS' \ - '-DANDROID' \ - '-D__GNU_SOURCE=1' \ - '-DUSE_STLPORT=1' \ - '-D_STLP_USE_PTR_SPECIALIZATIONS=1' \ - '-DCHROME_BUILD_ID=""' \ - '-DDYNAMIC_ANNOTATIONS_ENABLED=1' \ - '-DWTF_USE_DYNAMIC_ANNOTATIONS=1' \ - '-D_DEBUG' - - -# Include paths placed before CFLAGS/CPPFLAGS -LOCAL_C_INCLUDES_Debug := \ - $(PWD)/frameworks/wilhelm/include \ - $(PWD)/bionic \ - $(PWD)/external/stlport/stlport - - -# Flags passed to only C++ (and not C) files. -LOCAL_CPPFLAGS_Debug := \ - -fno-rtti \ - -fno-threadsafe-statics \ - -fvisibility-inlines-hidden \ - -Wsign-compare \ - -Wno-error=c++0x-compat \ - -Wno-non-virtual-dtor \ - -Wno-sign-promo - - -# Flags passed to both C and C++ files. -MY_CFLAGS_Release := \ - --param=ssp-buffer-size=4 \ - -Werror \ - -fno-exceptions \ - -fno-strict-aliasing \ - -Wall \ - -Wno-unused-parameter \ - -Wno-missing-field-initializers \ - -fvisibility=hidden \ - -pipe \ - -fPIC \ - -m32 \ - -mmmx \ - -march=pentium4 \ - -msse2 \ - -mfpmath=sse \ - -fuse-ld=gold \ - -ffunction-sections \ - -funwind-tables \ - -g \ - -fno-short-enums \ - -finline-limit=64 \ - -Wa,--noexecstack \ - -U_FORTIFY_SOURCE \ - -Wno-extra \ - -Wno-ignored-qualifiers \ - -Wno-type-limits \ - -fno-stack-protector \ - -Os \ - -fno-ident \ - -fdata-sections \ - -ffunction-sections \ - -fomit-frame-pointer \ - -fno-unwind-tables \ - -fno-asynchronous-unwind-tables - -MY_DEFS_Release := \ - '-DANGLE_DX11' \ - '-D_FILE_OFFSET_BITS=64' \ - '-DNO_TCMALLOC' \ - '-DDISCARDABLE_MEMORY_ALWAYS_SUPPORTED_NATIVELY' \ - '-DSYSTEM_NATIVELY_SIGNALS_MEMORY_PRESSURE' \ - '-DDISABLE_NACL' \ - '-DCHROMIUM_BUILD' \ - '-DUSE_LIBJPEG_TURBO=1' \ - '-DUSE_PROPRIETARY_CODECS' \ - '-DENABLE_CONFIGURATION_POLICY' \ - '-DENABLE_GPU=1' \ - '-DUSE_OPENSSL=1' \ - '-DENABLE_EGLIMAGE=1' \ - '-D__STDC_CONSTANT_MACROS' \ - '-D__STDC_FORMAT_MACROS' \ - '-DANDROID' \ - '-D__GNU_SOURCE=1' \ - '-DUSE_STLPORT=1' \ - '-D_STLP_USE_PTR_SPECIALIZATIONS=1' \ - '-DCHROME_BUILD_ID=""' \ - '-DNDEBUG' \ - '-DNVALGRIND' \ - '-DDYNAMIC_ANNOTATIONS_ENABLED=0' \ - '-D_FORTIFY_SOURCE=2' - - -# Include paths placed before CFLAGS/CPPFLAGS -LOCAL_C_INCLUDES_Release := \ - $(PWD)/frameworks/wilhelm/include \ - $(PWD)/bionic \ - $(PWD)/external/stlport/stlport - - -# Flags passed to only C++ (and not C) files. -LOCAL_CPPFLAGS_Release := \ - -fno-rtti \ - -fno-threadsafe-statics \ - -fvisibility-inlines-hidden \ - -Wsign-compare \ - -Wno-error=c++0x-compat \ - -Wno-non-virtual-dtor \ - -Wno-sign-promo - - -LOCAL_CFLAGS := $(MY_CFLAGS_$(GYP_CONFIGURATION)) $(MY_DEFS_$(GYP_CONFIGURATION)) -LOCAL_C_INCLUDES := $(GYP_COPIED_SOURCE_ORIGIN_DIRS) $(LOCAL_C_INCLUDES_$(GYP_CONFIGURATION)) -LOCAL_CPPFLAGS := $(LOCAL_CPPFLAGS_$(GYP_CONFIGURATION)) -### Rules for final target. -# Add target alias to "gyp_all_modules" target. -.PHONY: gyp_all_modules -gyp_all_modules: ui_gl_surface_texture_jni_headers_gyp - -# Alias gyp target name. -.PHONY: surface_texture_jni_headers -surface_texture_jni_headers: ui_gl_surface_texture_jni_headers_gyp - -LOCAL_MODULE_PATH := $(PRODUCT_OUT)/gyp_stamp -LOCAL_UNINSTALLABLE_MODULE := true - -include $(BUILD_SYSTEM)/base_rules.mk - -$(LOCAL_BUILT_MODULE): $(LOCAL_ADDITIONAL_DEPENDENCIES) - $(hide) echo "Gyp timestamp: $@" - $(hide) mkdir -p $(dir $@) - $(hide) touch $@ diff --git a/ui/keyboard/keyboard_ui_handler.cc b/ui/keyboard/keyboard_ui_handler.cc index 0c412675d3..398d2f4c08 100644 --- a/ui/keyboard/keyboard_ui_handler.cc +++ b/ui/keyboard/keyboard_ui_handler.cc @@ -12,7 +12,11 @@ #include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents_view.h" #include "content/public/browser/web_ui.h" +#include "ui/aura/client/aura_constants.h" +#include "ui/aura/root_window.h" #include "ui/aura/window.h" +#include "ui/base/ime/input_method.h" +#include "ui/base/ime/text_input_client.h" #include "ui/keyboard/keyboard_util.h" namespace keyboard { @@ -28,6 +32,10 @@ void KeyboardUIHandler::RegisterMessages() { "insertText", base::Bind(&KeyboardUIHandler::HandleInsertTextMessage, base::Unretained(this))); + web_ui()->RegisterMessageCallback( + "getInputContext", + base::Bind(&KeyboardUIHandler::HandleGetInputContextMessage, + base::Unretained(this))); } void KeyboardUIHandler::HandleInsertTextMessage(const base::ListValue* args) { @@ -48,4 +56,35 @@ void KeyboardUIHandler::HandleInsertTextMessage(const base::ListValue* args) { LOG(ERROR) << "insertText failed"; } +void KeyboardUIHandler::HandleGetInputContextMessage( + const base::ListValue* args) { + int request_id; + if (!args->GetInteger(0, &request_id)) { + LOG(ERROR) << "getInputContext failed: bad argument"; + return; + } + base::DictionaryValue results; + results.SetInteger("requestId", request_id); + + aura::RootWindow* root_window = + web_ui()->GetWebContents()->GetView()->GetNativeView()->GetRootWindow(); + if (!root_window) { + LOG(ERROR) << "getInputContext failed: no root window"; + return; + } + ui::InputMethod* input_method = + root_window->GetProperty(aura::client::kRootWindowInputMethodKey); + if (!input_method) { + LOG(ERROR) << "getInputContext failed: no input method"; + return; + } + + ui::TextInputClient* tic = input_method->GetTextInputClient(); + results.SetInteger("type", + tic ? tic->GetTextInputType() : ui::TEXT_INPUT_TYPE_NONE); + + web_ui()->CallJavascriptFunction("GetInputContextCallback", + results); +} + } // namespace keyboard diff --git a/ui/keyboard/keyboard_ui_handler.h b/ui/keyboard/keyboard_ui_handler.h index 0800453192..5ff05a05a8 100644 --- a/ui/keyboard/keyboard_ui_handler.h +++ b/ui/keyboard/keyboard_ui_handler.h @@ -25,6 +25,10 @@ class KeyboardUIHandler : public content::WebUIMessageHandler { // Callback for the "insertText" message. void HandleInsertTextMessage(const base::ListValue* args); + // Callback for the "getInputContext" message. The first element in + // |args| should be an integer representing request ID. + void HandleGetInputContextMessage(const base::ListValue* args); + DISALLOW_COPY_AND_ASSIGN(KeyboardUIHandler); }; diff --git a/ui/keyboard/resources/elements/kb-keyboard.html b/ui/keyboard/resources/elements/kb-keyboard.html index e6b8c5d1a4..58bc2af3a7 100644 --- a/ui/keyboard/resources/elements/kb-keyboard.html +++ b/ui/keyboard/resources/elements/kb-keyboard.html @@ -1,5 +1,5 @@ <!-- - -- Copyright (c) 2013 The Chromium Authors. All rights reserved. + -- Copyright 2013 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. --> @@ -179,6 +179,19 @@ dblTimer_: null, swipeHandler: null, + /** + * Handles the state of the shift key. + */ + keysetChanged: function() { + var keysetId = '#' + this.layout + '-' + this.keyset; + var keyset = this.querySelector(keysetId); + + // Unlocks the keyboard if the current keyset is not lockable. + if (!keyset.getAttribute('lockable')) + this.classList.remove('locked'); + + }, + ready: function() { this.voiceInput_ = new VoiceInput(this); this.swipeHandler = this.onSwipeUpdate.bind(this); @@ -330,9 +343,15 @@ this.dblDetail_.clickCount++; if (this.dblDetail_.clickCount == 2) { this.keyset = this.dblDetail_.toKeyset; - var keysetId = '#' + this.layout + '-' + this.keyset - this.querySelector(keysetId).nextKeyset = this.dblTimer_.nextKeyset; + var keysetId = '#' + this.layout + '-' + this.keyset; + var keyset = this.querySelector(keysetId); + keyset.nextKeyset = this.dblTimer_.nextKeyset; clearTimeout(this.dblTimer_); + + // Checks if shift is capitalized. + if (keyset.getAttribute('lockable')) + this.classList.add('locked'); + this.dblDetail_ = null; } } @@ -417,6 +436,9 @@ this.keyset = toKeyset; this.querySelector('#' + this.layout + '-' + this.keyset).nextKeyset = detail.nextKeyset; + + // Locks the keyset before removing active to prevent flicker. + this.classList.add('locked'); // Makes last pressed key inactive if transit to a new keyset on long // press. this.lastPressedKey.classList.remove('active'); @@ -424,7 +446,7 @@ }, /** - * Handles a change in the keyboard layout. Auto-selects the default + * Handles a change in the keyboard layout. Auto-selects the default * keyset for the new layout. */ layoutChanged: function() { @@ -442,7 +464,7 @@ /** * Selects the default keyset for a layout. - * @return {boolean} True if successful. This method can fail if the + * @return {boolean} True if successful. This method can fail if the * keysets corresponding to the layout have not been injected. */ selectDefaultKeyset: function() { diff --git a/ui/keyboard/resources/layouts/dvorak.html b/ui/keyboard/resources/layouts/dvorak.html index 2f90470a8d..3c41ba3f25 100644 --- a/ui/keyboard/resources/layouts/dvorak.html +++ b/ui/keyboard/resources/layouts/dvorak.html @@ -9,7 +9,7 @@ <link id="spacebar-row" rel="import" href="spacebar-row.html"> <template> - <kb-keyset id="dvorak-upper"> + <kb-keyset id="dvorak-upper" lockable="true"> <kb-row> <kb-key class="tab dark" char="	" align="left">tab</kb-key> <kb-key-sequence keys="",.PYFGCRL" superscripts="1234567890"></kb-key-sequence> diff --git a/ui/keyboard/resources/layouts/qwerty.html b/ui/keyboard/resources/layouts/qwerty.html index 0f19ebf80f..0ead7910f8 100644 --- a/ui/keyboard/resources/layouts/qwerty.html +++ b/ui/keyboard/resources/layouts/qwerty.html @@ -9,7 +9,7 @@ <link id="spacebar-row" rel="import" href="spacebar-row.html"> <template> - <kb-keyset id="qwerty-upper"> + <kb-keyset id="qwerty-upper" lockable="true"> <kb-row> <kb-key class="tab dark" char="	" align="left">tab</kb-key> <kb-key-sequence keys="QWERTYUIOP" superscripts="1234567890"></kb-key-sequence> diff --git a/ui/keyboard/resources/layouts/webui_qwerty.html b/ui/keyboard/resources/layouts/webui_qwerty.html index 9abd2e67c8..160c6f5e6c 100644 --- a/ui/keyboard/resources/layouts/webui_qwerty.html +++ b/ui/keyboard/resources/layouts/webui_qwerty.html @@ -5,7 +5,7 @@ --> <template> - <kb-keyset id="qwerty-upper"> + <kb-keyset id="qwerty-upper" lockable="true"> <kb-row class="top"> <kb-key>Q</kb-key><kb-key>W</kb-key><kb-key>E</kb-key><kb-key>R</kb-key> <kb-key>T</kb-key><kb-key>Y</kb-key><kb-key>U</kb-key> diff --git a/ui/keyboard/resources/main.css b/ui/keyboard/resources/main.css index 149384f8e6..afebccc439 100644 --- a/ui/keyboard/resources/main.css +++ b/ui/keyboard/resources/main.css @@ -68,6 +68,14 @@ kb-key::x-superscript[inverted] { color: #ffffff; } +/** +* Controls whether the shift key should be highlighted or not. +* Only highlights if we are in a lockable keyboard which is not locked. +*/ +kb-keyboard:not(.locked) kb-keyset[lockable] kb-shift-key { + color: lightblue; +} + kb-shift-key.dark, kb-layout-selector.dark, kb-key.dark { @@ -87,6 +95,7 @@ kb-altkey::x-key { text-align: center; } +.locked kb-shift-key, .active { background-color: #848490 !important; border-top: 2px solid #A9A9AF !important; @@ -158,4 +167,4 @@ kb-altkey::x-key { .layout-selector { background-image: url('images/keyboard.svg'); -} +}
\ No newline at end of file diff --git a/ui/keyboard/resources/webui/api_adapter.js b/ui/keyboard/resources/webui/api_adapter.js index 1d24ba68bc..3072775e34 100644 --- a/ui/keyboard/resources/webui/api_adapter.js +++ b/ui/keyboard/resources/webui/api_adapter.js @@ -5,3 +5,59 @@ function insertText(text) { chrome.send('insertText', [ text ]); } + +(function(exports) { + /** + * An array to save callbacks of each request. + * @type {Array.<function(Object)>} + */ + var requestIdCallbackMap = []; + + /** + * An incremental integer that represents a unique requestId. + * @type {number} + */ + var requestId = 0; + + /** + * Gets the context of the focused input field. The context is returned as a + * paramter in the |callback|. + * @param {function(Object)} callback The callback function after the webui + * function finished. + * @return {number} The ID of the new request. + */ + function GetInputContext(callback) { + var id = requestId; + requestIdCallbackMap[id] = callback; + chrome.send('getInputContext', [ id ]); + requestId++; + return id; + } + + /** + * Cancel the callback specified by requestId. + * @param {number} requestId The requestId of the callback that about to + * cancel. + */ + function CancelRequest(requestId) { + requestIdCallbackMap[requestId] = undefined; + } + + /** + * Webui function callback. Any call to chrome.send('getInputContext', [id]) + * should trigger this function being called with the parameter + * inputContext.requestId == id. + * @param {Object} inputContext The context of focused input field. Note we + * only have type(input box type) and requestId fields now. + */ + function GetInputContextCallback(inputContext) { + var requestId = inputContext.requestId; + if (!requestIdCallbackMap[requestId]) + return; + requestIdCallbackMap[requestId](inputContext); + } + + exports.getInputContext = GetInputContext; + exports.cancelRequest = CancelRequest; + exports.GetInputContextCallback = GetInputContextCallback; +})(this); diff --git a/ui/linux_ui/status_icon_linux.cc b/ui/linux_ui/status_icon_linux.cc index 1e273d3589..0e28771bdd 100644 --- a/ui/linux_ui/status_icon_linux.cc +++ b/ui/linux_ui/status_icon_linux.cc @@ -12,3 +12,6 @@ StatusIconLinux::StatusIconLinux() : delegate_(NULL) { StatusIconLinux::~StatusIconLinux() { } + +void StatusIconLinux::RefreshPlatformContextMenu() { +} diff --git a/ui/linux_ui/status_icon_linux.h b/ui/linux_ui/status_icon_linux.h index fbbf28f304..2e3d3a9345 100644 --- a/ui/linux_ui/status_icon_linux.h +++ b/ui/linux_ui/status_icon_linux.h @@ -19,7 +19,7 @@ class MenuModel; // Since liblinux_ui cannot have dependencies on any chrome browser components // we cannot inherit from StatusIcon. So we implement the necessary methods // and let a wrapper class implement the StatusIcon interface and defer the -// callbacks to a delegate. +// callbacks to a delegate. For the same reason, do not use StatusIconMenuModel. class LINUX_UI_EXPORT StatusIconLinux { public: class Delegate { @@ -43,6 +43,11 @@ class LINUX_UI_EXPORT StatusIconLinux { // subclass should destroy the existing native context menu on this call. virtual void UpdatePlatformContextMenu(ui::MenuModel* model) = 0; + // Update all the enabled/checked states and the dynamic labels. Some status + // icon implementations do not refresh the native menu before showing so we + // need to manually refresh it when the menu model changes. + virtual void RefreshPlatformContextMenu(); + Delegate* delegate() { return delegate_; } void set_delegate(Delegate* delegate) { delegate_ = delegate; } diff --git a/ui/message_center/cocoa/notification_controller_unittest.mm b/ui/message_center/cocoa/notification_controller_unittest.mm index ea7968e96e..87aced2fc8 100644 --- a/ui/message_center/cocoa/notification_controller_unittest.mm +++ b/ui/message_center/cocoa/notification_controller_unittest.mm @@ -105,7 +105,7 @@ TEST_F(NotificationControllerTest, BasicLayout) { ASCIIToUTF16("Jonathan and 5 others"), gfx::Image(), string16(), - std::string(), + message_center::NotifierId(), message_center::RichNotificationData(), NULL)); notification->set_icon(gfx::Image([TestIcon() retain])); @@ -135,7 +135,7 @@ TEST_F(NotificationControllerTest, OverflowText) { "entire thing?"), gfx::Image(), string16(), - std::string(), + message_center::NotifierId(), message_center::RichNotificationData(), NULL)); base::scoped_nsobject<MCNotificationController> controller( @@ -156,7 +156,7 @@ TEST_F(NotificationControllerTest, Close) { string16(), gfx::Image(), string16(), - std::string(), + message_center::NotifierId(), message_center::RichNotificationData(), NULL)); MockMessageCenter message_center; @@ -183,7 +183,7 @@ TEST_F(NotificationControllerTest, Update) { "default bounds."), gfx::Image(), string16(), - std::string(), + message_center::NotifierId(), message_center::RichNotificationData(), NULL)); base::scoped_nsobject<MCNotificationController> controller( @@ -219,7 +219,7 @@ TEST_F(NotificationControllerTest, Buttons) { string16(), gfx::Image(), string16(), - std::string(), + message_center::NotifierId(), optional, NULL)); MockMessageCenter message_center; @@ -244,7 +244,7 @@ TEST_F(NotificationControllerTest, Image) { string16(), gfx::Image(), string16(), - std::string(), + message_center::NotifierId(), message_center::RichNotificationData(), NULL)); NSImage* image = [NSImage imageNamed:NSImageNameFolder]; @@ -281,7 +281,7 @@ TEST_F(NotificationControllerTest, List) { UTF8ToUTF16("Notification Message - should be hidden"), gfx::Image(), string16(), - std::string(), + message_center::NotifierId(), optional, NULL)); diff --git a/ui/message_center/cocoa/popup_collection_unittest.mm b/ui/message_center/cocoa/popup_collection_unittest.mm index 105c824e87..2b8d140e15 100644 --- a/ui/message_center/cocoa/popup_collection_unittest.mm +++ b/ui/message_center/cocoa/popup_collection_unittest.mm @@ -51,7 +51,7 @@ class PopupCollectionTest : public ui::CocoaTest { " be displayed"), gfx::Image(), string16(), - std::string(), + message_center::NotifierId(), message_center::RichNotificationData(), NULL)); center_->AddNotification(notification.Pass()); @@ -63,7 +63,7 @@ class PopupCollectionTest : public ui::CocoaTest { ASCIIToUTF16("This is the second notification."), gfx::Image(), string16(), - std::string(), + message_center::NotifierId(), message_center::RichNotificationData(), NULL)); center_->AddNotification(notification.Pass()); @@ -79,7 +79,7 @@ class PopupCollectionTest : public ui::CocoaTest { "set the screen size too small."), gfx::Image(), string16(), - std::string(), + message_center::NotifierId(), message_center::RichNotificationData(), NULL)); center_->AddNotification(notification.Pass()); @@ -134,7 +134,7 @@ TEST_F(PopupCollectionTest, AttemptFourOneOffscreen) { ASCIIToUTF16("This is the fourth notification."), gfx::Image(), string16(), - std::string(), + message_center::NotifierId(), message_center::RichNotificationData(), NULL)); center_->AddNotification(notification.Pass()); @@ -183,7 +183,7 @@ TEST_F(PopupCollectionTest, LayoutSpacing) { ASCIIToUTF16("This is the fourth notification."), gfx::Image(), string16(), - std::string(), + message_center::NotifierId(), optional, NULL)); center_->AddNotification(notification.Pass()); @@ -221,7 +221,7 @@ TEST_F(PopupCollectionTest, TinyScreen) { " be displayed"), gfx::Image(), string16(), - std::string(), + message_center::NotifierId(), message_center::RichNotificationData(), NULL)); center_->AddNotification(notification.Pass()); @@ -243,7 +243,7 @@ TEST_F(PopupCollectionTest, TinyScreen) { "long notification."), gfx::Image(), string16(), - std::string(), + message_center::NotifierId(), message_center::RichNotificationData(), NULL)); center_->UpdateNotification("1", notification.Pass()); @@ -287,7 +287,7 @@ TEST_F(PopupCollectionTest, UpdateIconAndBody) { "longer body"), gfx::Image(), string16(), - std::string(), + message_center::NotifierId(), message_center::RichNotificationData(), NULL)); center_->AddNotification(notification.Pass()); @@ -316,7 +316,7 @@ TEST_F(PopupCollectionTest, CloseCollectionBeforeNewPopupAnimationEnds) { " be displayed"), gfx::Image(), string16(), - std::string(), + message_center::NotifierId(), message_center::RichNotificationData(), NULL)); center_->AddNotification(notification.Pass()); @@ -349,7 +349,7 @@ TEST_F(PopupCollectionTest, CloseCollectionBeforeUpdatePopupAnimationEnds) { ASCIIToUTF16("New message."), gfx::Image(), string16(), - std::string(), + message_center::NotifierId(), message_center::RichNotificationData(), NULL)); center_->UpdateNotification("1", notification.Pass()); diff --git a/ui/message_center/cocoa/popup_controller_unittest.mm b/ui/message_center/cocoa/popup_controller_unittest.mm index 41f627937e..c39d163128 100644 --- a/ui/message_center/cocoa/popup_controller_unittest.mm +++ b/ui/message_center/cocoa/popup_controller_unittest.mm @@ -23,7 +23,7 @@ TEST_F(PopupControllerTest, Creation) { ASCIIToUTF16("Jonathan and 5 others"), gfx::Image(), string16(), - std::string(), + message_center::NotifierId(), message_center::RichNotificationData(), NULL)); diff --git a/ui/message_center/cocoa/tray_view_controller_unittest.mm b/ui/message_center/cocoa/tray_view_controller_unittest.mm index 6c82777be9..ce9b080a31 100644 --- a/ui/message_center/cocoa/tray_view_controller_unittest.mm +++ b/ui/message_center/cocoa/tray_view_controller_unittest.mm @@ -71,7 +71,7 @@ TEST_F(TrayViewControllerTest, AddRemoveOne) { ASCIIToUTF16("This is a simple test."), gfx::Image(), string16(), - std::string(), + message_center::NotifierId(), message_center::RichNotificationData(), NULL)); center_->AddNotification(notification_data.Pass()); @@ -105,7 +105,7 @@ TEST_F(TrayViewControllerTest, AddThreeClearAll) { ASCIIToUTF16("This is a simple test."), gfx::Image(), string16(), - std::string(), + message_center::NotifierId(), message_center::RichNotificationData(), NULL)); center_->AddNotification(notification.Pass()); @@ -116,7 +116,7 @@ TEST_F(TrayViewControllerTest, AddThreeClearAll) { ASCIIToUTF16("This is a simple test."), gfx::Image(), string16(), - std::string(), + message_center::NotifierId(), message_center::RichNotificationData(), NULL)); center_->AddNotification(notification.Pass()); @@ -127,7 +127,7 @@ TEST_F(TrayViewControllerTest, AddThreeClearAll) { ASCIIToUTF16("This is a simple test."), gfx::Image(), string16(), - std::string(), + message_center::NotifierId(), message_center::RichNotificationData(), NULL)); center_->AddNotification(notification.Pass()); @@ -160,7 +160,7 @@ TEST_F(TrayViewControllerTest, NoClearAllWhenNoNotifications) { ASCIIToUTF16("This is a simple test."), gfx::Image(), string16(), - std::string(), + message_center::NotifierId(), message_center::RichNotificationData(), NULL)); center_->AddNotification(notification.Pass()); @@ -179,7 +179,7 @@ TEST_F(TrayViewControllerTest, NoClearAllWhenNoNotifications) { ASCIIToUTF16("This is a simple test."), gfx::Image(), string16(), - std::string(), + message_center::NotifierId(), message_center::RichNotificationData(), NULL)); center_->AddNotification(notification.Pass()); diff --git a/ui/message_center/fake_message_center.cc b/ui/message_center/fake_message_center.cc index 4deff26b13..c397475811 100644 --- a/ui/message_center/fake_message_center.cc +++ b/ui/message_center/fake_message_center.cc @@ -83,10 +83,8 @@ void FakeMessageCenter::SetNotificationButtonIcon( const gfx::Image& image) { } -void FakeMessageCenter::DisableNotificationsByExtension(const std::string& id) { -} - -void FakeMessageCenter::DisableNotificationsByUrl(const std::string& id) { +void FakeMessageCenter::DisableNotificationsByNotifier( + const NotifierId& notifier_id) { } void FakeMessageCenter::ShowNotificationSettings(const std::string& id) { diff --git a/ui/message_center/fake_message_center.h b/ui/message_center/fake_message_center.h index ebb9be210d..40ad90ec3a 100644 --- a/ui/message_center/fake_message_center.h +++ b/ui/message_center/fake_message_center.h @@ -45,8 +45,8 @@ class FakeMessageCenter : public MessageCenter { virtual void SetNotificationButtonIcon(const std::string& notification_id, int button_index, const gfx::Image& image) OVERRIDE; - virtual void DisableNotificationsByExtension(const std::string& id) OVERRIDE; - virtual void DisableNotificationsByUrl(const std::string& id) OVERRIDE; + virtual void DisableNotificationsByNotifier( + const NotifierId& notifier_id) OVERRIDE; virtual void ShowNotificationSettings(const std::string& id) OVERRIDE; virtual void ExpandNotification(const std::string& id) OVERRIDE; virtual void ClickOnNotification(const std::string& id) OVERRIDE; diff --git a/ui/message_center/fake_notifier_settings_provider.cc b/ui/message_center/fake_notifier_settings_provider.cc index d8054cab2e..f593ed9820 100644 --- a/ui/message_center/fake_notifier_settings_provider.cc +++ b/ui/message_center/fake_notifier_settings_provider.cc @@ -15,7 +15,9 @@ FakeNotifierSettingsProvider::NotifierGroupItem::NotifierGroupItem() { FakeNotifierSettingsProvider::NotifierGroupItem::~NotifierGroupItem() { } -FakeNotifierSettingsProvider::FakeNotifierSettingsProvider() { +FakeNotifierSettingsProvider::FakeNotifierSettingsProvider() + : closed_called_count_(0), + active_item_index_(0) { } FakeNotifierSettingsProvider::FakeNotifierSettingsProvider( diff --git a/ui/message_center/fake_notifier_settings_provider.h b/ui/message_center/fake_notifier_settings_provider.h index 85348f7592..b71a7e9fb2 100644 --- a/ui/message_center/fake_notifier_settings_provider.h +++ b/ui/message_center/fake_notifier_settings_provider.h @@ -14,7 +14,8 @@ namespace message_center { class FakeNotifierSettingsProvider : public NotifierSettingsProvider { public: FakeNotifierSettingsProvider(); - FakeNotifierSettingsProvider(const std::vector<Notifier*>& notifiers); + explicit FakeNotifierSettingsProvider( + const std::vector<Notifier*>& notifiers); virtual ~FakeNotifierSettingsProvider(); virtual size_t GetNotifierGroupCount() const OVERRIDE; diff --git a/ui/message_center/message_center.h b/ui/message_center/message_center.h index c055664714..880540d9e7 100644 --- a/ui/message_center/message_center.h +++ b/ui/message_center/message_center.h @@ -49,13 +49,6 @@ class MESSAGE_CENTER_EXPORT MessageCenter { public: virtual ~Delegate(); - // Request to disable the extension associated with |notification_id|. - virtual void DisableExtension(const std::string& notification_id) = 0; - - // Request to disable notifications from the source of |notification_id|. - virtual void DisableNotificationsFromSource( - const std::string& notification_id) = 0; - // Request to show the notification settings (|notification_id| is used // to identify the requesting browser context). virtual void ShowSettings(const std::string& notification_id) = 0; @@ -115,12 +108,8 @@ class MESSAGE_CENTER_EXPORT MessageCenter { // and settings. // Searches through the notifications and disables any that match the // extension id given. - virtual void DisableNotificationsByExtension(const std::string& id) = 0; - - // Disables all notifications that match the given url by querying the - // delegate and also by matching display_source. - // TODO(dewittj): Is display_source matching necessary? - virtual void DisableNotificationsByUrl(const std::string& url) = 0; + virtual void DisableNotificationsByNotifier( + const NotifierId& notifier_id) = 0; // TODO(mukai): settings can be in another class? // Shows the settings for a web notification (profile is identified by the diff --git a/ui/message_center/message_center_impl.cc b/ui/message_center/message_center_impl.cc index c1d0179dc0..3188e8093b 100644 --- a/ui/message_center/message_center_impl.cc +++ b/ui/message_center/message_center_impl.cc @@ -335,6 +335,9 @@ void MessageCenterImpl::RemoveAllNotifications(bool by_user) { for (NotificationList::Notifications::const_iterator iter = notifications.begin(); iter != notifications.end(); ++iter) { ids.insert((*iter)->id()); + NotificationDelegate* delegate = (*iter)->delegate(); + if (delegate) + delegate->Close(by_user); } notification_list_->RemoveAllNotifications(); @@ -374,27 +377,16 @@ void MessageCenterImpl::SetNotificationButtonIcon( } } -void MessageCenterImpl::DisableNotificationsByExtension( - const std::string& id) { - if (delegate_) - delegate_->DisableExtension(id); - - NotificationList::Notifications notifications = - notification_list_->GetNotificationsByExtension(id); - for (NotificationList::Notifications::const_iterator iter = - notifications.begin(); iter != notifications.end();) { - std::string id = (*iter)->id(); - iter++; - RemoveNotification(id, false); +void MessageCenterImpl::DisableNotificationsByNotifier( + const NotifierId& notifier_id) { + if (settings_provider_) { + // TODO(mukai): SetNotifierEnabled can just accept notifier_id? + Notifier notifier(notifier_id, base::string16(), true); + settings_provider_->SetNotifierEnabled(notifier, false); } -} - -void MessageCenterImpl::DisableNotificationsByUrl(const std::string& id) { - if (delegate_) - delegate_->DisableNotificationsFromSource(id); NotificationList::Notifications notifications = - notification_list_->GetNotificationsBySource(id); + notification_list_->GetNotificationsByNotifierId(notifier_id); for (NotificationList::Notifications::const_iterator iter = notifications.begin(); iter != notifications.end();) { std::string id = (*iter)->id(); @@ -477,12 +469,33 @@ NotifierSettingsProvider* MessageCenterImpl::GetNotifierSettingsProvider() { } void MessageCenterImpl::SetQuietMode(bool in_quiet_mode) { - notification_list_->SetQuietMode(in_quiet_mode); + if (in_quiet_mode != notification_list_->quiet_mode()) { + notification_list_->SetQuietMode(in_quiet_mode); + FOR_EACH_OBSERVER(MessageCenterObserver, + observer_list_, + OnQuietModeChanged(in_quiet_mode)); + } + quiet_mode_timer_.reset(); } void MessageCenterImpl::EnterQuietModeWithExpire( const base::TimeDelta& expires_in) { - notification_list_->EnterQuietModeWithExpire(expires_in); + if (quiet_mode_timer_.get()) { + // Note that the capital Reset() is the method to restart the timer, not + // scoped_ptr::reset(). + quiet_mode_timer_->Reset(); + } else { + notification_list_->SetQuietMode(true); + FOR_EACH_OBSERVER( + MessageCenterObserver, observer_list_, OnQuietModeChanged(true)); + + quiet_mode_timer_.reset(new base::OneShotTimer<MessageCenterImpl>); + quiet_mode_timer_->Start( + FROM_HERE, + expires_in, + base::Bind( + &MessageCenterImpl::SetQuietMode, base::Unretained(this), false)); + } } void MessageCenterImpl::RestartPopupTimers() { diff --git a/ui/message_center/message_center_impl.h b/ui/message_center/message_center_impl.h index 412e0b3b15..b278cc211b 100644 --- a/ui/message_center/message_center_impl.h +++ b/ui/message_center/message_center_impl.h @@ -161,8 +161,8 @@ class MessageCenterImpl : public MessageCenter { virtual void SetNotificationButtonIcon(const std::string& notification_id, int button_index, const gfx::Image& image) OVERRIDE; - virtual void DisableNotificationsByExtension(const std::string& id) OVERRIDE; - virtual void DisableNotificationsByUrl(const std::string& id) OVERRIDE; + virtual void DisableNotificationsByNotifier( + const NotifierId& notifier_id) OVERRIDE; virtual void ShowNotificationSettings(const std::string& id) OVERRIDE; virtual void ExpandNotification(const std::string& id) OVERRIDE; virtual void ClickOnNotification(const std::string& id) OVERRIDE; @@ -187,6 +187,7 @@ class MessageCenterImpl : public MessageCenter { scoped_ptr<NotificationList> notification_list_; ObserverList<MessageCenterObserver> observer_list_; scoped_ptr<internal::PopupTimersController> popup_timers_controller_; + scoped_ptr<base::OneShotTimer<MessageCenterImpl> > quiet_mode_timer_; Delegate* delegate_; NotifierSettingsProvider* settings_provider_; diff --git a/ui/message_center/message_center_observer.h b/ui/message_center/message_center_observer.h index 8a52792731..da7da21fcb 100644 --- a/ui/message_center/message_center_observer.h +++ b/ui/message_center/message_center_observer.h @@ -45,6 +45,10 @@ class MESSAGE_CENTER_EXPORT MessageCenterObserver { // Called when the notification list is no longer being displayed as a // notification center. virtual void OnNotificationCenterClosed() {} + + // Called whenever the quiet mode changes as a result of user action or when + // quiet mode expires. + virtual void OnQuietModeChanged(bool in_quiet_mode) {} }; } // namespace message_center diff --git a/ui/message_center/message_center_tray.cc b/ui/message_center/message_center_tray.cc index 7a1fee8d26..a571a23193 100644 --- a/ui/message_center/message_center_tray.cc +++ b/ui/message_center/message_center_tray.cc @@ -12,14 +12,6 @@ #include "ui/message_center/message_center_tray_delegate.h" namespace message_center { -namespace { - -// Menu commands -const int kToggleQuietMode = 0; -const int kEnableQuietModeHour = 1; -const int kEnableQuietModeDay = 2; - -} MessageCenterTray::MessageCenterTray( MessageCenterTrayDelegate* delegate, @@ -107,18 +99,6 @@ void MessageCenterTray::ShowNotifierSettingsBubble() { message_center_visible_ = delegate_->ShowNotifierSettings(); } -ui::MenuModel* MessageCenterTray::CreateQuietModeMenu() { - ui::SimpleMenuModel* menu = new ui::SimpleMenuModel(this); - - menu->AddCheckItem(kToggleQuietMode, - l10n_util::GetStringUTF16(IDS_MESSAGE_CENTER_QUIET_MODE)); - menu->AddItem(kEnableQuietModeHour, - l10n_util::GetStringUTF16(IDS_MESSAGE_CENTER_QUIET_MODE_1HOUR)); - menu->AddItem(kEnableQuietModeDay, - l10n_util::GetStringUTF16(IDS_MESSAGE_CENTER_QUIET_MODE_1DAY)); - return menu; -} - void MessageCenterTray::OnNotificationAdded( const std::string& notification_id) { OnMessageCenterChanged(); @@ -153,6 +133,10 @@ void MessageCenterTray::OnNotificationDisplayed( NotifyMessageCenterTrayChanged(); } +void MessageCenterTray::OnQuietModeChanged(bool in_quiet_mode) { + NotifyMessageCenterTrayChanged(); +} + void MessageCenterTray::OnMessageCenterChanged() { if (message_center_visible_) { if (message_center_->NotificationCount() == 0) @@ -167,36 +151,6 @@ void MessageCenterTray::OnMessageCenterChanged() { NotifyMessageCenterTrayChanged(); } -bool MessageCenterTray::IsCommandIdChecked(int command_id) const { - if (command_id != kToggleQuietMode) - return false; - return message_center()->IsQuietMode(); -} - -bool MessageCenterTray::IsCommandIdEnabled(int command_id) const { - return true; -} - -bool MessageCenterTray::GetAcceleratorForCommandId( - int command_id, - ui::Accelerator* accelerator) { - return false; -} - -void MessageCenterTray::ExecuteCommand(int command_id, int event_flags) { - if (command_id == kToggleQuietMode) { - bool in_quiet_mode = message_center()->IsQuietMode(); - message_center()->SetQuietMode(!in_quiet_mode); - NotifyMessageCenterTrayChanged(); - return; - } - base::TimeDelta expires_in = command_id == kEnableQuietModeDay ? - base::TimeDelta::FromDays(1): - base::TimeDelta::FromHours(1); - message_center()->EnterQuietModeWithExpire(expires_in); - NotifyMessageCenterTrayChanged(); -} - void MessageCenterTray::NotifyMessageCenterTrayChanged() { delegate_->OnMessageCenterTrayChanged(); } diff --git a/ui/message_center/message_center_tray.h b/ui/message_center/message_center_tray.h index 03b86e9391..80a6513a15 100644 --- a/ui/message_center/message_center_tray.h +++ b/ui/message_center/message_center_tray.h @@ -6,7 +6,6 @@ #define UI_MESSAGE_CENTER_MESSAGE_CENTER_TRAY_H_ #include "base/observer_list.h" -#include "ui/base/models/simple_menu_model.h" #include "ui/message_center/message_center_export.h" #include "ui/message_center/message_center_observer.h" #include "ui/message_center/message_center_tray_delegate.h" @@ -25,9 +24,7 @@ MessageCenterTrayDelegate* CreateMessageCenterTray(); // Class that observes a MessageCenter. Manages the popup and message center // bubbles. Tells the MessageCenterTrayHost when the tray is changed, as well // as when bubbles are shown and hidden. -class MESSAGE_CENTER_EXPORT MessageCenterTray - : public MessageCenterObserver, - public ui::SimpleMenuModel::Delegate { +class MESSAGE_CENTER_EXPORT MessageCenterTray : public MessageCenterObserver { public: MessageCenterTray(MessageCenterTrayDelegate* delegate, message_center::MessageCenter* message_center); @@ -57,10 +54,6 @@ class MESSAGE_CENTER_EXPORT MessageCenterTray // Toggles the visibility of the settings view in the message center bubble. void ShowNotifierSettingsBubble(); - // Creates the menu model for quiet mode and returns it. The caller must - // take the ownership of the return value. - ui::MenuModel* CreateQuietModeMenu(); - bool message_center_visible() { return message_center_visible_; } bool popups_visible() { return popups_visible_; } MessageCenterTrayDelegate* delegate() { return delegate_; } @@ -82,14 +75,7 @@ class MESSAGE_CENTER_EXPORT MessageCenterTray int button_index) OVERRIDE; virtual void OnNotificationDisplayed( const std::string& notification_id) OVERRIDE; - - // Overridden from SimpleMenuModel::Delegate. - virtual bool IsCommandIdChecked(int command_id) const OVERRIDE; - virtual bool IsCommandIdEnabled(int command_id) const OVERRIDE; - virtual bool GetAcceleratorForCommandId( - int command_id, - ui::Accelerator* accelerator) OVERRIDE; - virtual void ExecuteCommand(int command_id, int event_flags) OVERRIDE; + virtual void OnQuietModeChanged(bool in_quiet_mode) OVERRIDE; private: void OnMessageCenterChanged(); diff --git a/ui/message_center/message_center_tray_unittest.cc b/ui/message_center/message_center_tray_unittest.cc index 108cee7aa2..7517507b63 100644 --- a/ui/message_center/message_center_tray_unittest.cc +++ b/ui/message_center/message_center_tray_unittest.cc @@ -71,7 +71,7 @@ class MessageCenterTrayTest : public testing::Test { ASCIIToUTF16("Notification message body."), gfx::Image(), ASCIIToUTF16("www.test.org"), - "" /* extension id */, + NotifierId(), message_center::RichNotificationData(), NULL /* delegate */)); message_center_->AddNotification(notification.Pass()); @@ -171,7 +171,7 @@ TEST_F(MessageCenterTrayTest, MessageCenterReopenPopupsForSystemPriority) { ASCIIToUTF16("Notification message body."), gfx::Image(), ASCIIToUTF16("www.test.org"), - "" /* extension id */, + NotifierId(), message_center::RichNotificationData(), NULL /* delegate */)); notification->SetSystemPriority(); diff --git a/ui/message_center/notification.cc b/ui/message_center/notification.cc index 692d1406e3..6a90e30a05 100644 --- a/ui/message_center/notification.cc +++ b/ui/message_center/notification.cc @@ -28,7 +28,8 @@ RichNotificationData::RichNotificationData() : priority(DEFAULT_PRIORITY), never_timeout(false), timestamp(base::Time::Now()), - progress(0) {} + progress(0), + should_make_spoken_feedback_for_popup_updates(true) {} RichNotificationData::RichNotificationData(const RichNotificationData& other) : priority(other.priority), @@ -38,7 +39,9 @@ RichNotificationData::RichNotificationData(const RichNotificationData& other) image(other.image), items(other.items), progress(other.progress), - buttons(other.buttons) {} + buttons(other.buttons), + should_make_spoken_feedback_for_popup_updates( + other.should_make_spoken_feedback_for_popup_updates) {} RichNotificationData::~RichNotificationData() {} @@ -48,7 +51,7 @@ Notification::Notification(NotificationType type, const string16& message, const gfx::Image& icon, const string16& display_source, - const std::string& extension_id, + const NotifierId& notifier_id, const RichNotificationData& optional_fields, NotificationDelegate* delegate) : type_(type), @@ -57,7 +60,7 @@ Notification::Notification(NotificationType type, message_(message), icon_(icon), display_source_(display_source), - extension_id_(extension_id), + notifier_id_(notifier_id), serial_number_(g_next_serial_number_++), optional_fields_(optional_fields), shown_as_popup_(false), @@ -72,7 +75,7 @@ Notification::Notification(const Notification& other) message_(other.message_), icon_(other.icon_), display_source_(other.display_source_), - extension_id_(other.extension_id_), + notifier_id_(other.notifier_id_), serial_number_(other.serial_number_), optional_fields_(other.optional_fields_), shown_as_popup_(other.shown_as_popup_), @@ -87,7 +90,7 @@ Notification& Notification::operator=(const Notification& other) { message_ = other.message_; icon_ = other.icon_; display_source_ = other.display_source_; - extension_id_ = other.extension_id_; + notifier_id_ = other.notifier_id_; serial_number_ = other.serial_number_; optional_fields_ = other.optional_fields_; shown_as_popup_ = other.shown_as_popup_; @@ -126,6 +129,7 @@ scoped_ptr<Notification> Notification::CreateSystemNotification( const base::string16& title, const base::string16& message, const gfx::Image& icon, + int system_component_id, const base::Closure& click_callback) { scoped_ptr<Notification> notification( new Notification( @@ -135,7 +139,7 @@ scoped_ptr<Notification> Notification::CreateSystemNotification( message, icon, base::string16() /* display_source */, - std::string() /* extension_id */, + NotifierId(system_component_id), RichNotificationData(), new HandleNotificationClickedDelegate(click_callback))); notification->SetSystemPriority(); diff --git a/ui/message_center/notification.h b/ui/message_center/notification.h index cfcef433a2..915f812292 100644 --- a/ui/message_center/notification.h +++ b/ui/message_center/notification.h @@ -15,6 +15,7 @@ #include "ui/message_center/message_center_export.h" #include "ui/message_center/notification_delegate.h" #include "ui/message_center/notification_types.h" +#include "ui/message_center/notifier_settings.h" namespace message_center { @@ -46,6 +47,7 @@ class MESSAGE_CENTER_EXPORT RichNotificationData { std::vector<NotificationItem> items; int progress; std::vector<ButtonInfo> buttons; + bool should_make_spoken_feedback_for_popup_updates; }; class MESSAGE_CENTER_EXPORT Notification { @@ -56,7 +58,7 @@ class MESSAGE_CENTER_EXPORT Notification { const string16& message, const gfx::Image& icon, const string16& display_source, - const std::string& extension_id, + const NotifierId& notifier_id, const RichNotificationData& optional_fields, NotificationDelegate* delegate); @@ -81,10 +83,8 @@ class MESSAGE_CENTER_EXPORT Notification { // A display string for the source of the notification. const string16& display_source() const { return display_source_; } - const std::string& extension_id() const { return extension_id_; } - void set_extension_id(const std::string& extension_id) { - extension_id_ = extension_id; - } + + const NotifierId& notifier_id() const { return notifier_id_; } // Begin unpacked values from optional_fields. int priority() const { return optional_fields_.priority; } @@ -174,6 +174,7 @@ class MESSAGE_CENTER_EXPORT Notification { const base::string16& title, const base::string16& message, const gfx::Image& icon, + int system_component_id, const base::Closure& click_callback); protected: @@ -192,7 +193,7 @@ class MESSAGE_CENTER_EXPORT Notification { string16 display_source_; private: - std::string extension_id_; + NotifierId notifier_id_; unsigned serial_number_; RichNotificationData optional_fields_; bool shown_as_popup_; // True if this has been shown as a popup. diff --git a/ui/message_center/notification_list.cc b/ui/message_center/notification_list.cc index d0527922b8..4477d9c739 100644 --- a/ui/message_center/notification_list.cc +++ b/ui/message_center/notification_list.cc @@ -114,33 +114,12 @@ void NotificationList::RemoveAllNotifications() { unread_count_ = 0; } -NotificationList::Notifications NotificationList::GetNotificationsBySource( - const std::string& id) { - Notifications notifications; - Notifications::iterator source_iter = GetNotification(id); - if (source_iter == notifications_.end()) - return notifications; - - string16 display_source = (*source_iter)->display_source(); - for (Notifications::iterator iter = notifications_.begin(); - iter != notifications_.end(); ++iter) { - if ((*iter)->display_source() == display_source) - notifications.insert(*iter); - } - return notifications; -} - -NotificationList::Notifications NotificationList::GetNotificationsByExtension( - const std::string& id) { +NotificationList::Notifications NotificationList::GetNotificationsByNotifierId( + const NotifierId& notifier_id) { Notifications notifications; - Notifications::iterator source_iter = GetNotification(id); - if (source_iter == notifications_.end()) - return notifications; - - std::string extension_id = (*source_iter)->extension_id(); for (Notifications::iterator iter = notifications_.begin(); iter != notifications_.end(); ++iter) { - if ((*iter)->extension_id() == extension_id) + if ((*iter)->notifier_id() == notifier_id) notifications.insert(*iter); } return notifications; @@ -285,21 +264,13 @@ NotificationDelegate* NotificationList::GetNotificationDelegate( } void NotificationList::SetQuietMode(bool quiet_mode) { - SetQuietModeInternal(quiet_mode); - quiet_mode_timer_.reset(); -} - -void NotificationList::EnterQuietModeWithExpire( - const base::TimeDelta& expires_in) { - if (quiet_mode_timer_.get()) { - // Note that the capital Reset() is the method to restart the timer, not - // scoped_ptr::reset(). - quiet_mode_timer_->Reset(); - } else { - SetQuietModeInternal(true); - quiet_mode_timer_.reset(new base::OneShotTimer<NotificationList>); - quiet_mode_timer_->Start(FROM_HERE, expires_in, base::Bind( - &NotificationList::SetQuietMode, base::Unretained(this), false)); + quiet_mode_ = quiet_mode; + if (quiet_mode_) { + for (Notifications::iterator iter = notifications_.begin(); + iter != notifications_.end(); + ++iter) { + (*iter)->set_shown_as_popup(true); + } } } @@ -311,19 +282,8 @@ size_t NotificationList::NotificationCount() const { return notifications_.size(); } -void NotificationList::SetQuietModeInternal(bool quiet_mode) { - quiet_mode_ = quiet_mode; - if (quiet_mode_) { - for (Notifications::iterator iter = notifications_.begin(); - iter != notifications_.end(); - ++iter) { - (*iter)->set_shown_as_popup(true); - } - } -} - -NotificationList::Notifications::iterator - NotificationList::GetNotification(const std::string& id) { +NotificationList::Notifications::iterator NotificationList::GetNotification( + const std::string& id) { for (Notifications::iterator iter = notifications_.begin(); iter != notifications_.end(); ++iter) { if ((*iter)->id() == id) diff --git a/ui/message_center/notification_list.h b/ui/message_center/notification_list.h index ce24498d7e..ab8b4a0842 100644 --- a/ui/message_center/notification_list.h +++ b/ui/message_center/notification_list.h @@ -67,8 +67,7 @@ class MESSAGE_CENTER_EXPORT NotificationList { void RemoveAllNotifications(); - Notifications GetNotificationsBySource(const std::string& id); - Notifications GetNotificationsByExtension(const std::string& id); + Notifications GetNotificationsByNotifierId(const NotifierId& notifier_id); // Returns true if the notification exists and was updated. bool SetNotificationIcon(const std::string& notification_id, @@ -114,8 +113,7 @@ class MESSAGE_CENTER_EXPORT NotificationList { bool quiet_mode() const { return quiet_mode_; } - // Sets the current quiet mode status to |quiet_mode|. The new status is not - // expired. + // Sets the current quiet mode status to |quiet_mode|. void SetQuietMode(bool quiet_mode); // Sets the current quiet mode to true. The quiet mode will expire in the @@ -139,14 +137,10 @@ class MESSAGE_CENTER_EXPORT NotificationList { void PushNotification(scoped_ptr<Notification> notification); - // Sets the current quiet mode status to |quiet_mode|. - void SetQuietModeInternal(bool quiet_mode); - Notifications notifications_; bool message_center_visible_; size_t unread_count_; bool quiet_mode_; - scoped_ptr<base::OneShotTimer<NotificationList> > quiet_mode_timer_; DISALLOW_COPY_AND_ASSIGN(NotificationList); }; diff --git a/ui/message_center/notification_list_unittest.cc b/ui/message_center/notification_list_unittest.cc index cdd6ad4283..8195d0ab58 100644 --- a/ui/message_center/notification_list_unittest.cc +++ b/ui/message_center/notification_list_unittest.cc @@ -40,7 +40,7 @@ class NotificationListTest : public testing::Test { UTF8ToUTF16(base::StringPrintf(kMessageFormat, counter_)), gfx::Image(), UTF8ToUTF16(kDisplaySource), - kExtensionId, + NotifierId(NotifierId::APPLICATION, kExtensionId), optional_fields, NULL)); notification_list_->AddNotification(notification.Pass()); @@ -172,7 +172,7 @@ TEST_F(NotificationListTest, UpdateNotification) { UTF8ToUTF16("newbody"), gfx::Image(), UTF8ToUTF16(kDisplaySource), - kExtensionId, + NotifierId(NotifierId::APPLICATION, kExtensionId), message_center::RichNotificationData(), NULL)); notification_list()->UpdateNotificationMessage(id0, notification.Pass()); @@ -184,7 +184,11 @@ TEST_F(NotificationListTest, UpdateNotification) { EXPECT_EQ(UTF8ToUTF16("newbody"), (*notifications.begin())->message()); } -TEST_F(NotificationListTest, GetNotificationsBySourceOrExtensions) { +TEST_F(NotificationListTest, GetNotificationsByNotifierId) { + NotifierId id0(NotifierId::APPLICATION, "ext0"); + NotifierId id1(NotifierId::APPLICATION, "ext1"); + NotifierId id2(GURL("http://example.com")); + NotifierId id3(0); scoped_ptr<Notification> notification( new Notification(message_center::NOTIFICATION_TYPE_SIMPLE, "id0", @@ -192,7 +196,7 @@ TEST_F(NotificationListTest, GetNotificationsBySourceOrExtensions) { UTF8ToUTF16("message0"), gfx::Image(), UTF8ToUTF16("source0"), - "ext0", + id0, message_center::RichNotificationData(), NULL)); notification_list()->AddNotification(notification.Pass()); @@ -202,7 +206,7 @@ TEST_F(NotificationListTest, GetNotificationsBySourceOrExtensions) { UTF8ToUTF16("message1"), gfx::Image(), UTF8ToUTF16("source0"), - "ext0", + id0, message_center::RichNotificationData(), NULL)); notification_list()->AddNotification(notification.Pass()); @@ -212,7 +216,7 @@ TEST_F(NotificationListTest, GetNotificationsBySourceOrExtensions) { UTF8ToUTF16("message1"), gfx::Image(), UTF8ToUTF16("source1"), - "ext0", + id0, message_center::RichNotificationData(), NULL)); notification_list()->AddNotification(notification.Pass()); @@ -222,24 +226,63 @@ TEST_F(NotificationListTest, GetNotificationsBySourceOrExtensions) { UTF8ToUTF16("message1"), gfx::Image(), UTF8ToUTF16("source2"), - "ext1", + id1, + message_center::RichNotificationData(), + NULL)); + notification_list()->AddNotification(notification.Pass()); + notification.reset(new Notification(message_center::NOTIFICATION_TYPE_SIMPLE, + "id4", + UTF8ToUTF16("title1"), + UTF8ToUTF16("message1"), + gfx::Image(), + UTF8ToUTF16("source2"), + id2, + message_center::RichNotificationData(), + NULL)); + notification_list()->AddNotification(notification.Pass()); + notification.reset(new Notification(message_center::NOTIFICATION_TYPE_SIMPLE, + "id5", + UTF8ToUTF16("title1"), + UTF8ToUTF16("message1"), + gfx::Image(), + UTF8ToUTF16("source2"), + id3, message_center::RichNotificationData(), NULL)); notification_list()->AddNotification(notification.Pass()); - NotificationList::Notifications by_source = - notification_list()->GetNotificationsBySource("id0"); - EXPECT_TRUE(IsInNotifications(by_source, "id0")); - EXPECT_TRUE(IsInNotifications(by_source, "id1")); - EXPECT_FALSE(IsInNotifications(by_source, "id2")); - EXPECT_FALSE(IsInNotifications(by_source, "id3")); - - NotificationList::Notifications by_extension = - notification_list()->GetNotificationsByExtension("id0"); - EXPECT_TRUE(IsInNotifications(by_extension, "id0")); - EXPECT_TRUE(IsInNotifications(by_extension, "id1")); - EXPECT_TRUE(IsInNotifications(by_extension, "id2")); - EXPECT_FALSE(IsInNotifications(by_extension, "id3")); + NotificationList::Notifications by_notifier_id = + notification_list()->GetNotificationsByNotifierId(id0); + EXPECT_TRUE(IsInNotifications(by_notifier_id, "id0")); + EXPECT_TRUE(IsInNotifications(by_notifier_id, "id1")); + EXPECT_TRUE(IsInNotifications(by_notifier_id, "id2")); + EXPECT_FALSE(IsInNotifications(by_notifier_id, "id3")); + EXPECT_FALSE(IsInNotifications(by_notifier_id, "id4")); + EXPECT_FALSE(IsInNotifications(by_notifier_id, "id5")); + + by_notifier_id = notification_list()->GetNotificationsByNotifierId(id1); + EXPECT_FALSE(IsInNotifications(by_notifier_id, "id0")); + EXPECT_FALSE(IsInNotifications(by_notifier_id, "id1")); + EXPECT_FALSE(IsInNotifications(by_notifier_id, "id2")); + EXPECT_TRUE(IsInNotifications(by_notifier_id, "id3")); + EXPECT_FALSE(IsInNotifications(by_notifier_id, "id4")); + EXPECT_FALSE(IsInNotifications(by_notifier_id, "id5")); + + by_notifier_id = notification_list()->GetNotificationsByNotifierId(id2); + EXPECT_FALSE(IsInNotifications(by_notifier_id, "id0")); + EXPECT_FALSE(IsInNotifications(by_notifier_id, "id1")); + EXPECT_FALSE(IsInNotifications(by_notifier_id, "id2")); + EXPECT_FALSE(IsInNotifications(by_notifier_id, "id3")); + EXPECT_TRUE(IsInNotifications(by_notifier_id, "id4")); + EXPECT_FALSE(IsInNotifications(by_notifier_id, "id5")); + + by_notifier_id = notification_list()->GetNotificationsByNotifierId(id3); + EXPECT_FALSE(IsInNotifications(by_notifier_id, "id0")); + EXPECT_FALSE(IsInNotifications(by_notifier_id, "id1")); + EXPECT_FALSE(IsInNotifications(by_notifier_id, "id2")); + EXPECT_FALSE(IsInNotifications(by_notifier_id, "id3")); + EXPECT_FALSE(IsInNotifications(by_notifier_id, "id4")); + EXPECT_TRUE(IsInNotifications(by_notifier_id, "id5")); } TEST_F(NotificationListTest, OldPopupShouldNotBeHidden) { @@ -355,7 +398,7 @@ TEST_F(NotificationListTest, PriorityPromotion) { UTF8ToUTF16("newbody"), gfx::Image(), UTF8ToUTF16(kDisplaySource), - kExtensionId, + NotifierId(NotifierId::APPLICATION, kExtensionId), optional, NULL)); notification_list()->UpdateNotificationMessage(id0, notification.Pass()); @@ -386,7 +429,7 @@ TEST_F(NotificationListTest, PriorityPromotionWithPopups) { UTF8ToUTF16("newbody"), gfx::Image(), UTF8ToUTF16(kDisplaySource), - kExtensionId, + NotifierId(NotifierId::APPLICATION, kExtensionId), priority, NULL)); notification_list()->UpdateNotificationMessage(id0, notification.Pass()); @@ -401,7 +444,8 @@ TEST_F(NotificationListTest, PriorityPromotionWithPopups) { UTF8ToUTF16("newbody2"), gfx::Image(), UTF8ToUTF16(kDisplaySource), - kExtensionId, + NotifierId(NotifierId::APPLICATION, + kExtensionId), priority, NULL)); notification_list()->UpdateNotificationMessage(id0, notification.Pass()); @@ -415,7 +459,8 @@ TEST_F(NotificationListTest, PriorityPromotionWithPopups) { UTF8ToUTF16("newbody"), gfx::Image(), UTF8ToUTF16(kDisplaySource), - kExtensionId, + NotifierId(NotifierId::APPLICATION, + kExtensionId), priority, NULL)); notification_list()->UpdateNotificationMessage(id1, notification.Pass()); @@ -431,7 +476,8 @@ TEST_F(NotificationListTest, PriorityPromotionWithPopups) { UTF8ToUTF16("newbody2"), gfx::Image(), UTF8ToUTF16(kDisplaySource), - kExtensionId, + NotifierId(NotifierId::APPLICATION, + kExtensionId), priority, NULL)); notification_list()->UpdateNotificationMessage(id1, notification.Pass()); @@ -447,7 +493,8 @@ TEST_F(NotificationListTest, PriorityPromotionWithPopups) { UTF8ToUTF16("newbody3"), gfx::Image(), UTF8ToUTF16(kDisplaySource), - kExtensionId, + NotifierId(NotifierId::APPLICATION, + kExtensionId), priority, NULL)); notification_list()->UpdateNotificationMessage(id1, notification.Pass()); @@ -588,7 +635,7 @@ TEST_F(NotificationListTest, UpdateAfterMarkedAsShown) { UTF8ToUTF16("newbody"), gfx::Image(), UTF8ToUTF16(kDisplaySource), - kExtensionId, + NotifierId(NotifierId::APPLICATION, kExtensionId), message_center::RichNotificationData(), NULL)); notification_list()->UpdateNotificationMessage(id1, notification.Pass()); @@ -634,7 +681,7 @@ TEST_F(NotificationListTest, UnreadCountNoNegative) { UTF8ToUTF16("updated"), gfx::Image(), base::string16(), - std::string(), + NotifierId(), RichNotificationData(), NULL)); notification_list()->AddNotification(updated_notification.Pass()); diff --git a/ui/message_center/notifier_settings.cc b/ui/message_center/notifier_settings.cc index 4355b9459f..861e65b651 100644 --- a/ui/message_center/notifier_settings.cc +++ b/ui/message_center/notifier_settings.cc @@ -11,15 +11,26 @@ NotifierId::NotifierId(NotifierType type, const std::string& id) : type(type), id(id), - system_component_type(NONE) { + system_component_type(-1) { DCHECK(type == APPLICATION || type == SYNCED_NOTIFICATION_SERVICE); + DCHECK(!id.empty()); } NotifierId::NotifierId(const GURL& url) - : type(WEB_PAGE), url(url), system_component_type(NONE) {} + : type(WEB_PAGE), + url(url), + system_component_type(-1) {} -NotifierId::NotifierId(SystemComponentNotifierType system_component_type) - : type(SYSTEM_COMPONENT), system_component_type(system_component_type) {} +NotifierId::NotifierId(int type) + : type(SYSTEM_COMPONENT), + system_component_type(type) { + DCHECK_LE(0, system_component_type); +} + +NotifierId::NotifierId() + : type(SYSTEM_COMPONENT), + system_component_type(-1) { +} bool NotifierId::operator==(const NotifierId& other) const { if (type != other.type) @@ -58,23 +69,4 @@ NotifierGroup::NotifierGroup(const gfx::Image& icon, NotifierGroup::~NotifierGroup() {} -std::string ToString(NotifierId::SystemComponentNotifierType type) { - switch (type) { - case NotifierId::SCREENSHOT: - return "screenshot"; - default: - NOTREACHED(); - return ""; - } -} - -NotifierId::SystemComponentNotifierType -ParseSystemComponentName(const std::string& name) { - if (name == "screenshot") { - return NotifierId::SCREENSHOT; - } else { - NOTREACHED(); - return NotifierId::NONE; - } -} } // namespace message_center diff --git a/ui/message_center/notifier_settings.h b/ui/message_center/notifier_settings.h index b8771a399c..6188599e20 100644 --- a/ui/message_center/notifier_settings.h +++ b/ui/message_center/notifier_settings.h @@ -33,19 +33,17 @@ struct MESSAGE_CENTER_EXPORT NotifierId { SYNCED_NOTIFICATION_SERVICE, }; - enum SystemComponentNotifierType { - NONE, - SCREENSHOT, - }; - // Constructor for APPLICATION and SYNCED_NOTIFICATION_SERVICE type. NotifierId(NotifierType type, const std::string& id); // Constructor for WEB_PAGE type. explicit NotifierId(const GURL& url); - // Constructor for SYSTEM_COMPONENT type. - explicit NotifierId(SystemComponentNotifierType type); + // Constructor for system component types. The type should be positive. + explicit NotifierId(int type); + + // The default constructor which doesn't specify the notifier. Used for tests. + NotifierId(); bool operator==(const NotifierId& other) const; @@ -58,8 +56,9 @@ struct MESSAGE_CENTER_EXPORT NotifierId { // The URL pattern of the notifer. GURL url; - // The type of system component notifier. - SystemComponentNotifierType system_component_type; + // The type of system component notifier, usually used in ash. -1 if it's not + // the system component. See also: ash/system/system_notifier.h + int system_component_type; }; // The struct to hold the information of notifiers. The information will be @@ -108,11 +107,6 @@ struct MESSAGE_CENTER_EXPORT NotifierGroup { DISALLOW_COPY_AND_ASSIGN(NotifierGroup); }; -MESSAGE_CENTER_EXPORT std::string ToString( - NotifierId::SystemComponentNotifierType type); -MESSAGE_CENTER_EXPORT NotifierId::SystemComponentNotifierType - ParseSystemComponentName(const std::string& name); - // An observer class implemented by the view of the NotifierSettings to get // notified when the controller has changed data. class MESSAGE_CENTER_EXPORT NotifierSettingsObserver { diff --git a/ui/message_center/views/message_center_view_unittest.cc b/ui/message_center/views/message_center_view_unittest.cc index f6e05f4e30..b9e34a1ebd 100644 --- a/ui/message_center/views/message_center_view_unittest.cc +++ b/ui/message_center/views/message_center_view_unittest.cc @@ -133,7 +133,7 @@ void MessageCenterViewTest::SetUp() { UTF8ToUTF16("message"), gfx::Image(), UTF8ToUTF16("display source"), - std::string("extension id"), + NotifierId(NotifierId::APPLICATION, "extension_id"), message_center::RichNotificationData(), NULL); diff --git a/ui/message_center/views/message_popup_collection_unittest.cc b/ui/message_center/views/message_popup_collection_unittest.cc index 942c09daa1..f43199755e 100644 --- a/ui/message_center/views/message_popup_collection_unittest.cc +++ b/ui/message_center/views/message_popup_collection_unittest.cc @@ -83,7 +83,7 @@ class MessagePopupCollectionTest : public views::ViewsTestBase { UTF8ToUTF16("test message"), gfx::Image(), string16() /* display_source */, - "" /* extension_id */, + NotifierId(), message_center::RichNotificationData(), NULL /* delegate */)); MessageCenter::Get()->AddNotification(notification.Pass()); diff --git a/ui/message_center/views/message_view.cc b/ui/message_center/views/message_view.cc index 7eb9838e24..93a5dd3769 100644 --- a/ui/message_center/views/message_view.cc +++ b/ui/message_center/views/message_view.cc @@ -35,8 +35,7 @@ const int kShadowBlur = 4; // Menu constants const int kTogglePermissionCommand = 0; -const int kToggleExtensionCommand = 1; -const int kShowSettingsCommand = 2; +const int kShowSettingsCommand = 1; // ControlButtons are ImageButtons whose image can be padded within the button. // This allows the creation of buttons like the notification close and expand @@ -170,7 +169,7 @@ class MenuModel : public ui::SimpleMenuModel, message_center::MessageCenterTray* tray, const std::string& notification_id, const string16& display_source, - const std::string& extension_id); + const message_center::NotifierId& notifier_id); virtual ~MenuModel(); // Overridden from ui::SimpleMenuModel::Delegate: @@ -186,6 +185,7 @@ class MenuModel : public ui::SimpleMenuModel, message_center::MessageCenter* message_center_; // Weak reference. message_center::MessageCenterTray* tray_; // Weak reference. std::string notification_id_; + message_center::NotifierId notifier_id_; DISALLOW_COPY_AND_ASSIGN(MenuModel); }; @@ -194,19 +194,16 @@ MenuModel::MenuModel(message_center::MessageCenter* message_center, message_center::MessageCenterTray* tray, const std::string& notification_id, const string16& display_source, - const std::string& extension_id) + const message_center::NotifierId& notifier_id) : ui::SimpleMenuModel(this), message_center_(message_center), tray_(tray), - notification_id_(notification_id) { + notification_id_(notification_id), + notifier_id_(notifier_id) { // Add 'disable notifications' menu item. - if (!extension_id.empty() && !display_source.empty()) { - AddItem(kToggleExtensionCommand, - l10n_util::GetStringFUTF16(IDS_MESSAGE_CENTER_EXTENSIONS_DISABLE, - display_source)); - } else if (!display_source.empty()) { + if (!display_source.empty()) { AddItem(kTogglePermissionCommand, - l10n_util::GetStringFUTF16(IDS_MESSAGE_CENTER_SITE_DISABLE, + l10n_util::GetStringFUTF16(IDS_MESSAGE_CENTER_NOTIFIER_DISABLE, display_source)); } // Add settings menu item. @@ -236,11 +233,8 @@ bool MenuModel::GetAcceleratorForCommandId(int command_id, void MenuModel::ExecuteCommand(int command_id, int event_flags) { switch (command_id) { - case kToggleExtensionCommand: - message_center_->DisableNotificationsByExtension(notification_id_); - break; case kTogglePermissionCommand: - message_center_->DisableNotificationsByUrl(notification_id_); + message_center_->DisableNotificationsByNotifier(notifier_id_); break; case kShowSettingsCommand: // |tray_| may be NULL in tests. @@ -276,7 +270,7 @@ class MessageViewContextMenuController : public views::ContextMenuController { MessageCenterTray* tray_; // Weak reference. std::string notification_id_; string16 display_source_; - std::string extension_id_; + NotifierId notifier_id_; }; MessageViewContextMenuController::MessageViewContextMenuController( @@ -287,7 +281,7 @@ MessageViewContextMenuController::MessageViewContextMenuController( tray_(tray), notification_id_(notification.id()), display_source_(notification.display_source()), - extension_id_(notification.extension_id()) { + notifier_id_(notification.notifier_id()) { } MessageViewContextMenuController::~MessageViewContextMenuController() { @@ -298,7 +292,7 @@ void MessageViewContextMenuController::ShowContextMenuForView( const gfx::Point& point, ui::MenuSourceType source_type) { MenuModel menu_model(message_center_, tray_, notification_id_, - display_source_, extension_id_); + display_source_, notifier_id_); if (menu_model.GetItemCount() == 0) return; diff --git a/ui/message_center/views/toast_contents_view.cc b/ui/message_center/views/toast_contents_view.cc index 6db7f2112a..93cd95325a 100644 --- a/ui/message_center/views/toast_contents_view.cc +++ b/ui/message_center/views/toast_contents_view.cc @@ -93,8 +93,20 @@ void ToastContentsView::SetContents(MessageView* view) { // popup toast, and the new contents should be read through a11y feature. // The notification type should be ALERT, otherwise the accessibility message // won't be read for this view which returns ROLE_WINDOW. - if (already_has_contents) - NotifyAccessibilityEvent(ui::AccessibilityTypes::EVENT_ALERT, false); + if (already_has_contents) { + const NotificationList::Notifications& notifications = + message_center_->GetNotifications(); + for (NotificationList::Notifications::const_iterator iter = + notifications.begin(); iter != notifications.end(); ++iter) { + if ((*iter)->id() != id_) + continue; + + const RichNotificationData& optional = (*iter)->rich_notification_data(); + if (optional.should_make_spoken_feedback_for_popup_updates) + NotifyAccessibilityEvent(ui::AccessibilityTypes::EVENT_ALERT, false); + break; + } + } } void ToastContentsView::RevealWithAnimation(gfx::Point origin) { diff --git a/ui/resources/default_100_percent/common/pointers/alias_big.png b/ui/resources/default_100_percent/common/pointers/alias_big.png Binary files differnew file mode 100644 index 0000000000..283bf7f48f --- /dev/null +++ b/ui/resources/default_100_percent/common/pointers/alias_big.png diff --git a/ui/resources/default_100_percent/common/pointers/cell_big.png b/ui/resources/default_100_percent/common/pointers/cell_big.png Binary files differnew file mode 100644 index 0000000000..3dec5e5d82 --- /dev/null +++ b/ui/resources/default_100_percent/common/pointers/cell_big.png diff --git a/ui/resources/default_100_percent/common/pointers/context_menu_big.png b/ui/resources/default_100_percent/common/pointers/context_menu_big.png Binary files differnew file mode 100644 index 0000000000..7c9e250d48 --- /dev/null +++ b/ui/resources/default_100_percent/common/pointers/context_menu_big.png diff --git a/ui/resources/default_100_percent/common/pointers/copy_big.png b/ui/resources/default_100_percent/common/pointers/copy_big.png Binary files differnew file mode 100644 index 0000000000..3e38e45d4e --- /dev/null +++ b/ui/resources/default_100_percent/common/pointers/copy_big.png diff --git a/ui/resources/default_100_percent/common/pointers/crosshair_big.png b/ui/resources/default_100_percent/common/pointers/crosshair_big.png Binary files differnew file mode 100644 index 0000000000..ea1f5fc07f --- /dev/null +++ b/ui/resources/default_100_percent/common/pointers/crosshair_big.png diff --git a/ui/resources/default_100_percent/common/pointers/fleur_big.png b/ui/resources/default_100_percent/common/pointers/fleur_big.png Binary files differnew file mode 100644 index 0000000000..2e327661d6 --- /dev/null +++ b/ui/resources/default_100_percent/common/pointers/fleur_big.png diff --git a/ui/resources/default_100_percent/common/pointers/hand2_big.png b/ui/resources/default_100_percent/common/pointers/hand2_big.png Binary files differnew file mode 100644 index 0000000000..63bb9594d8 --- /dev/null +++ b/ui/resources/default_100_percent/common/pointers/hand2_big.png diff --git a/ui/resources/default_100_percent/common/pointers/hand3_big.png b/ui/resources/default_100_percent/common/pointers/hand3_big.png Binary files differnew file mode 100644 index 0000000000..3c54751739 --- /dev/null +++ b/ui/resources/default_100_percent/common/pointers/hand3_big.png diff --git a/ui/resources/default_100_percent/common/pointers/help_big.png b/ui/resources/default_100_percent/common/pointers/help_big.png Binary files differnew file mode 100644 index 0000000000..6552f9bb33 --- /dev/null +++ b/ui/resources/default_100_percent/common/pointers/help_big.png diff --git a/ui/resources/default_100_percent/common/pointers/left_ptr_big.png b/ui/resources/default_100_percent/common/pointers/left_ptr_big.png Binary files differnew file mode 100644 index 0000000000..c5604c7491 --- /dev/null +++ b/ui/resources/default_100_percent/common/pointers/left_ptr_big.png diff --git a/ui/resources/default_100_percent/common/pointers/move_big.png b/ui/resources/default_100_percent/common/pointers/move_big.png Binary files differnew file mode 100644 index 0000000000..c29db87027 --- /dev/null +++ b/ui/resources/default_100_percent/common/pointers/move_big.png diff --git a/ui/resources/default_100_percent/common/pointers/nodrop_big.png b/ui/resources/default_100_percent/common/pointers/nodrop_big.png Binary files differnew file mode 100644 index 0000000000..da981df3de --- /dev/null +++ b/ui/resources/default_100_percent/common/pointers/nodrop_big.png diff --git a/ui/resources/default_100_percent/common/pointers/sb_h_double_arrow_big.png b/ui/resources/default_100_percent/common/pointers/sb_h_double_arrow_big.png Binary files differnew file mode 100644 index 0000000000..49dc3d303b --- /dev/null +++ b/ui/resources/default_100_percent/common/pointers/sb_h_double_arrow_big.png diff --git a/ui/resources/default_100_percent/common/pointers/sb_v_double_arrow_big.png b/ui/resources/default_100_percent/common/pointers/sb_v_double_arrow_big.png Binary files differnew file mode 100644 index 0000000000..7b2135d25b --- /dev/null +++ b/ui/resources/default_100_percent/common/pointers/sb_v_double_arrow_big.png diff --git a/ui/resources/default_100_percent/common/pointers/top_left_corner_big.png b/ui/resources/default_100_percent/common/pointers/top_left_corner_big.png Binary files differnew file mode 100644 index 0000000000..eecaa89204 --- /dev/null +++ b/ui/resources/default_100_percent/common/pointers/top_left_corner_big.png diff --git a/ui/resources/default_100_percent/common/pointers/top_right_corner_big.png b/ui/resources/default_100_percent/common/pointers/top_right_corner_big.png Binary files differnew file mode 100644 index 0000000000..9d47ecf793 --- /dev/null +++ b/ui/resources/default_100_percent/common/pointers/top_right_corner_big.png diff --git a/ui/resources/default_100_percent/common/pointers/xterm_big.png b/ui/resources/default_100_percent/common/pointers/xterm_big.png Binary files differnew file mode 100644 index 0000000000..2fba190552 --- /dev/null +++ b/ui/resources/default_100_percent/common/pointers/xterm_big.png diff --git a/ui/resources/default_100_percent/common/pointers/xterm_horiz_big.png b/ui/resources/default_100_percent/common/pointers/xterm_horiz_big.png Binary files differnew file mode 100644 index 0000000000..94f5ddc59a --- /dev/null +++ b/ui/resources/default_100_percent/common/pointers/xterm_horiz_big.png diff --git a/ui/resources/default_100_percent/common/pointers/zoom_in_big.png b/ui/resources/default_100_percent/common/pointers/zoom_in_big.png Binary files differnew file mode 100644 index 0000000000..923ad79226 --- /dev/null +++ b/ui/resources/default_100_percent/common/pointers/zoom_in_big.png diff --git a/ui/resources/default_100_percent/common/pointers/zoom_out_big.png b/ui/resources/default_100_percent/common/pointers/zoom_out_big.png Binary files differnew file mode 100644 index 0000000000..aa47eb94fb --- /dev/null +++ b/ui/resources/default_100_percent/common/pointers/zoom_out_big.png diff --git a/ui/resources/default_100_percent/mac/notification_tray_attention.png b/ui/resources/default_100_percent/mac/notification_tray_attention.png Binary files differindex f6fe8298b6..6e4910943c 100644 --- a/ui/resources/default_100_percent/mac/notification_tray_attention.png +++ b/ui/resources/default_100_percent/mac/notification_tray_attention.png diff --git a/ui/resources/default_100_percent/mac/notification_tray_attention_pressed.png b/ui/resources/default_100_percent/mac/notification_tray_attention_pressed.png Binary files differindex e4f8cdb5dd..931a4abcaf 100644 --- a/ui/resources/default_100_percent/mac/notification_tray_attention_pressed.png +++ b/ui/resources/default_100_percent/mac/notification_tray_attention_pressed.png diff --git a/ui/resources/default_100_percent/mac/notification_tray_do_not_disturb_attention.png b/ui/resources/default_100_percent/mac/notification_tray_do_not_disturb_attention.png Binary files differindex 042673f535..335a302712 100644 --- a/ui/resources/default_100_percent/mac/notification_tray_do_not_disturb_attention.png +++ b/ui/resources/default_100_percent/mac/notification_tray_do_not_disturb_attention.png diff --git a/ui/resources/default_100_percent/mac/notification_tray_do_not_disturb_attention_pressed.png b/ui/resources/default_100_percent/mac/notification_tray_do_not_disturb_attention_pressed.png Binary files differindex 324e373cda..7ab9ee0b75 100644 --- a/ui/resources/default_100_percent/mac/notification_tray_do_not_disturb_attention_pressed.png +++ b/ui/resources/default_100_percent/mac/notification_tray_do_not_disturb_attention_pressed.png diff --git a/ui/resources/default_100_percent/mac/notification_tray_do_not_disturb_empty.png b/ui/resources/default_100_percent/mac/notification_tray_do_not_disturb_empty.png Binary files differindex 57474d5acc..3c9149e6f1 100644 --- a/ui/resources/default_100_percent/mac/notification_tray_do_not_disturb_empty.png +++ b/ui/resources/default_100_percent/mac/notification_tray_do_not_disturb_empty.png diff --git a/ui/resources/default_100_percent/mac/notification_tray_do_not_disturb_empty_pressed.png b/ui/resources/default_100_percent/mac/notification_tray_do_not_disturb_empty_pressed.png Binary files differindex bd40cfdfa2..87acf99e3d 100644 --- a/ui/resources/default_100_percent/mac/notification_tray_do_not_disturb_empty_pressed.png +++ b/ui/resources/default_100_percent/mac/notification_tray_do_not_disturb_empty_pressed.png diff --git a/ui/resources/default_100_percent/mac/notification_tray_empty.png b/ui/resources/default_100_percent/mac/notification_tray_empty.png Binary files differindex 7a92998607..db17be9255 100644 --- a/ui/resources/default_100_percent/mac/notification_tray_empty.png +++ b/ui/resources/default_100_percent/mac/notification_tray_empty.png diff --git a/ui/resources/default_100_percent/mac/notification_tray_empty_pressed.png b/ui/resources/default_100_percent/mac/notification_tray_empty_pressed.png Binary files differindex 15d30bf68f..2f3d8fca7c 100644 --- a/ui/resources/default_100_percent/mac/notification_tray_empty_pressed.png +++ b/ui/resources/default_100_percent/mac/notification_tray_empty_pressed.png diff --git a/ui/resources/default_200_percent/mac/notification_tray_attention.png b/ui/resources/default_200_percent/mac/notification_tray_attention.png Binary files differindex c0b374bd17..6587f34bb8 100644 --- a/ui/resources/default_200_percent/mac/notification_tray_attention.png +++ b/ui/resources/default_200_percent/mac/notification_tray_attention.png diff --git a/ui/resources/default_200_percent/mac/notification_tray_attention_pressed.png b/ui/resources/default_200_percent/mac/notification_tray_attention_pressed.png Binary files differindex 43c496ff8c..7d2521c790 100644 --- a/ui/resources/default_200_percent/mac/notification_tray_attention_pressed.png +++ b/ui/resources/default_200_percent/mac/notification_tray_attention_pressed.png diff --git a/ui/resources/default_200_percent/mac/notification_tray_do_not_disturb_attention.png b/ui/resources/default_200_percent/mac/notification_tray_do_not_disturb_attention.png Binary files differindex 27dc58ad12..f0584e4335 100644 --- a/ui/resources/default_200_percent/mac/notification_tray_do_not_disturb_attention.png +++ b/ui/resources/default_200_percent/mac/notification_tray_do_not_disturb_attention.png diff --git a/ui/resources/default_200_percent/mac/notification_tray_do_not_disturb_attention_pressed.png b/ui/resources/default_200_percent/mac/notification_tray_do_not_disturb_attention_pressed.png Binary files differindex e8e1e2454e..8f922347de 100644 --- a/ui/resources/default_200_percent/mac/notification_tray_do_not_disturb_attention_pressed.png +++ b/ui/resources/default_200_percent/mac/notification_tray_do_not_disturb_attention_pressed.png diff --git a/ui/resources/default_200_percent/mac/notification_tray_do_not_disturb_empty.png b/ui/resources/default_200_percent/mac/notification_tray_do_not_disturb_empty.png Binary files differindex b0b799a277..2370e7acde 100644 --- a/ui/resources/default_200_percent/mac/notification_tray_do_not_disturb_empty.png +++ b/ui/resources/default_200_percent/mac/notification_tray_do_not_disturb_empty.png diff --git a/ui/resources/default_200_percent/mac/notification_tray_do_not_disturb_empty_pressed.png b/ui/resources/default_200_percent/mac/notification_tray_do_not_disturb_empty_pressed.png Binary files differindex 74e0958206..1c6a7af60e 100644 --- a/ui/resources/default_200_percent/mac/notification_tray_do_not_disturb_empty_pressed.png +++ b/ui/resources/default_200_percent/mac/notification_tray_do_not_disturb_empty_pressed.png diff --git a/ui/resources/default_200_percent/mac/notification_tray_empty.png b/ui/resources/default_200_percent/mac/notification_tray_empty.png Binary files differindex 32f817e208..e3fc1f3bfb 100644 --- a/ui/resources/default_200_percent/mac/notification_tray_empty.png +++ b/ui/resources/default_200_percent/mac/notification_tray_empty.png diff --git a/ui/resources/default_200_percent/mac/notification_tray_empty_pressed.png b/ui/resources/default_200_percent/mac/notification_tray_empty_pressed.png Binary files differindex e44934c02a..21492e85dc 100644 --- a/ui/resources/default_200_percent/mac/notification_tray_empty_pressed.png +++ b/ui/resources/default_200_percent/mac/notification_tray_empty_pressed.png diff --git a/ui/resources/ui_resources.grd b/ui/resources/ui_resources.grd index 2cb91bea5d..dd510db015 100644 --- a/ui/resources/ui_resources.grd +++ b/ui/resources/ui_resources.grd @@ -36,6 +36,37 @@ <structure type="chrome_scaled_image" name="IDR_APP_TOP_RIGHT" file="app_top_right.png" /> </if> <if expr="is_linux and pp_ifdef('use_aura')"> + <structure type="chrome_scaled_image" name="IDR_AURA_CURSOR_BIG_ALIAS" file="common/pointers/alias_big.png" /> + <structure type="chrome_scaled_image" name="IDR_AURA_CURSOR_BIG_CELL" file="common/pointers/cell_big.png" /> + <structure type="chrome_scaled_image" name="IDR_AURA_CURSOR_BIG_COL_RESIZE" file="common/pointers/sb_h_double_arrow_big.png" /> + <structure type="chrome_scaled_image" name="IDR_AURA_CURSOR_BIG_CONTEXT_MENU" file="common/pointers/context_menu_big.png" /> + <structure type="chrome_scaled_image" name="IDR_AURA_CURSOR_BIG_COPY" file="common/pointers/copy_big.png" /> + <structure type="chrome_scaled_image" name="IDR_AURA_CURSOR_BIG_CROSSHAIR" file="common/pointers/crosshair_big.png" /> + <structure type="chrome_scaled_image" name="IDR_AURA_CURSOR_BIG_EAST_RESIZE" file="common/pointers/sb_h_double_arrow_big.png" /> + <structure type="chrome_scaled_image" name="IDR_AURA_CURSOR_BIG_EAST_WEST_RESIZE" file="common/pointers/sb_h_double_arrow_big.png" /> + <structure type="chrome_scaled_image" name="IDR_AURA_CURSOR_BIG_FLEUR" file="common/pointers/fleur_big.png" /> + <structure type="chrome_scaled_image" name="IDR_AURA_CURSOR_BIG_HAND" file="common/pointers/hand2_big.png" /> + <structure type="chrome_scaled_image" name="IDR_AURA_CURSOR_BIG_HELP" file="common/pointers/help_big.png" /> + <structure type="chrome_scaled_image" name="IDR_AURA_CURSOR_BIG_IBEAM" file="common/pointers/xterm_big.png" /> + <structure type="chrome_scaled_image" name="IDR_AURA_CURSOR_BIG_MOVE" file="common/pointers/move_big.png" /> + <structure type="chrome_scaled_image" name="IDR_AURA_CURSOR_BIG_NORTH_EAST_RESIZE" file="common/pointers/top_right_corner_big.png" /> + <structure type="chrome_scaled_image" name="IDR_AURA_CURSOR_BIG_NORTH_EAST_SOUTH_WEST_RESIZE" file="common/pointers/top_right_corner_big.png" /> + <structure type="chrome_scaled_image" name="IDR_AURA_CURSOR_BIG_NORTH_RESIZE" file="common/pointers/sb_v_double_arrow_big.png" /> + <structure type="chrome_scaled_image" name="IDR_AURA_CURSOR_BIG_NORTH_SOUTH_RESIZE" file="common/pointers/sb_v_double_arrow_big.png" /> + <structure type="chrome_scaled_image" name="IDR_AURA_CURSOR_BIG_NORTH_WEST_RESIZE" file="common/pointers/top_left_corner_big.png" /> + <structure type="chrome_scaled_image" name="IDR_AURA_CURSOR_BIG_NORTH_WEST_SOUTH_EAST_RESIZE" file="common/pointers/top_left_corner_big.png" /> + <structure type="chrome_scaled_image" name="IDR_AURA_CURSOR_BIG_NO_DROP" file="common/pointers/nodrop_big.png" /> + <structure type="chrome_scaled_image" name="IDR_AURA_CURSOR_BIG_PTR" file="common/pointers/left_ptr_big.png" /> + <structure type="chrome_scaled_image" name="IDR_AURA_CURSOR_BIG_ROW_RESIZE" file="common/pointers/sb_v_double_arrow_big.png" /> + <structure type="chrome_scaled_image" name="IDR_AURA_CURSOR_BIG_SOUTH_EAST_RESIZE" file="common/pointers/top_left_corner_big.png" /> + <structure type="chrome_scaled_image" name="IDR_AURA_CURSOR_BIG_SOUTH_RESIZE" file="common/pointers/sb_v_double_arrow_big.png" /> + <structure type="chrome_scaled_image" name="IDR_AURA_CURSOR_BIG_SOUTH_WEST_RESIZE" file="common/pointers/top_right_corner_big.png" /> + <structure type="chrome_scaled_image" name="IDR_AURA_CURSOR_BIG_WEST_RESIZE" file="common/pointers/sb_h_double_arrow_big.png" /> + <structure type="chrome_scaled_image" name="IDR_AURA_CURSOR_BIG_XTERM_HORIZ" file="common/pointers/xterm_horiz_big.png" /> + <structure type="chrome_scaled_image" name="IDR_AURA_CURSOR_BIG_ZOOM_IN" file="common/pointers/zoom_in_big.png" /> + <structure type="chrome_scaled_image" name="IDR_AURA_CURSOR_BIG_ZOOM_OUT" file="common/pointers/zoom_out_big.png" /> + <structure type="chrome_scaled_image" name="IDR_AURA_CURSOR_BIG_GRAB" file="common/pointers/fleur_big.png" /> + <structure type="chrome_scaled_image" name="IDR_AURA_CURSOR_BIG_GRABBING" file="common/pointers/hand3_big.png" /> <structure type="chrome_scaled_image" name="IDR_AURA_CURSOR_ALIAS" file="common/pointers/alias.png" /> <structure type="chrome_scaled_image" name="IDR_AURA_CURSOR_CELL" file="common/pointers/cell.png" /> <structure type="chrome_scaled_image" name="IDR_AURA_CURSOR_COL_RESIZE" file="common/pointers/sb_h_double_arrow.png" /> diff --git a/ui/shell_dialogs/select_file_dialog_win.cc b/ui/shell_dialogs/select_file_dialog_win.cc index eff7a493c1..c028d22c7a 100644 --- a/ui/shell_dialogs/select_file_dialog_win.cc +++ b/ui/shell_dialogs/select_file_dialog_win.cc @@ -414,7 +414,7 @@ class SelectFileDialogImpl : public ui::SelectFileDialog, ui::SelectFilePolicy* policy); // BaseShellDialog implementation: - virtual bool IsRunning(gfx::NativeWindow owning_hwnd) const OVERRIDE; + virtual bool IsRunning(gfx::NativeWindow owning_window) const OVERRIDE; virtual void ListenerDestroyed() OVERRIDE; protected: @@ -598,7 +598,7 @@ void SelectFileDialogImpl::SelectFileImpl( return; } } - HWND owner = owning_window + HWND owner = owning_window && owning_window->GetRootWindow() ? owning_window->GetRootWindow()->GetAcceleratedWidget() : NULL; #else HWND owner = owning_window; @@ -617,11 +617,13 @@ bool SelectFileDialogImpl::HasMultipleFileTypeChoicesImpl() { return has_multiple_file_type_choices_; } -bool SelectFileDialogImpl::IsRunning(gfx::NativeWindow owning_hwnd) const { +bool SelectFileDialogImpl::IsRunning(gfx::NativeWindow owning_window) const { #if defined(USE_AURA) - HWND owner = owning_hwnd->GetRootWindow()->GetAcceleratedWidget(); + if (!owning_window->GetRootWindow()) + return false; + HWND owner = owning_window->GetRootWindow()->GetAcceleratedWidget(); #else - HWND owner = owning_hwnd; + HWND owner = owning_window; #endif return listener_ && IsRunningDialogForOwner(owner); } diff --git a/ui/surface/accelerated_surface_win.cc b/ui/surface/accelerated_surface_win.cc index 74ebdac6b1..2ec63821a2 100644 --- a/ui/surface/accelerated_surface_win.cc +++ b/ui/surface/accelerated_surface_win.cc @@ -8,8 +8,8 @@ #include <algorithm> #include "base/bind.h" -#include "base/bind_helpers.h" #include "base/callback.h" +#include "base/callback_helpers.h" #include "base/command_line.h" #include "base/debug/trace_event.h" #include "base/files/file_path.h" @@ -79,6 +79,7 @@ 'base/animation/throb_animation.h', 'base/animation/tween.cc', 'base/animation/tween.h', + 'base/base_window.cc', 'base/base_window.h', 'base/clipboard/clipboard.cc', 'base/clipboard/clipboard.h', diff --git a/ui/ui.target.darwin-arm.mk b/ui/ui.target.darwin-arm.mk index 238d397afa..a2587bca2e 100644 --- a/ui/ui.target.darwin-arm.mk +++ b/ui/ui.target.darwin-arm.mk @@ -45,6 +45,7 @@ LOCAL_SRC_FILES := \ ui/base/animation/slide_animation.cc \ ui/base/animation/throb_animation.cc \ ui/base/animation/tween.cc \ + ui/base/base_window.cc \ ui/base/clipboard/clipboard.cc \ ui/base/clipboard/clipboard_android.cc \ ui/base/clipboard/clipboard_constants.cc \ diff --git a/ui/ui.target.darwin-mips.mk b/ui/ui.target.darwin-mips.mk index ece97a9626..ae38b10e9a 100644 --- a/ui/ui.target.darwin-mips.mk +++ b/ui/ui.target.darwin-mips.mk @@ -45,6 +45,7 @@ LOCAL_SRC_FILES := \ ui/base/animation/slide_animation.cc \ ui/base/animation/throb_animation.cc \ ui/base/animation/tween.cc \ + ui/base/base_window.cc \ ui/base/clipboard/clipboard.cc \ ui/base/clipboard/clipboard_android.cc \ ui/base/clipboard/clipboard_constants.cc \ diff --git a/ui/ui.target.darwin-x86.mk b/ui/ui.target.darwin-x86.mk index aa55166754..7e63800f99 100644 --- a/ui/ui.target.darwin-x86.mk +++ b/ui/ui.target.darwin-x86.mk @@ -45,6 +45,7 @@ LOCAL_SRC_FILES := \ ui/base/animation/slide_animation.cc \ ui/base/animation/throb_animation.cc \ ui/base/animation/tween.cc \ + ui/base/base_window.cc \ ui/base/clipboard/clipboard.cc \ ui/base/clipboard/clipboard_android.cc \ ui/base/clipboard/clipboard_constants.cc \ diff --git a/ui/ui.target.linux-arm.mk b/ui/ui.target.linux-arm.mk index 238d397afa..a2587bca2e 100644 --- a/ui/ui.target.linux-arm.mk +++ b/ui/ui.target.linux-arm.mk @@ -45,6 +45,7 @@ LOCAL_SRC_FILES := \ ui/base/animation/slide_animation.cc \ ui/base/animation/throb_animation.cc \ ui/base/animation/tween.cc \ + ui/base/base_window.cc \ ui/base/clipboard/clipboard.cc \ ui/base/clipboard/clipboard_android.cc \ ui/base/clipboard/clipboard_constants.cc \ diff --git a/ui/ui.target.linux-mips.mk b/ui/ui.target.linux-mips.mk index ece97a9626..ae38b10e9a 100644 --- a/ui/ui.target.linux-mips.mk +++ b/ui/ui.target.linux-mips.mk @@ -45,6 +45,7 @@ LOCAL_SRC_FILES := \ ui/base/animation/slide_animation.cc \ ui/base/animation/throb_animation.cc \ ui/base/animation/tween.cc \ + ui/base/base_window.cc \ ui/base/clipboard/clipboard.cc \ ui/base/clipboard/clipboard_android.cc \ ui/base/clipboard/clipboard_constants.cc \ diff --git a/ui/ui.target.linux-x86.mk b/ui/ui.target.linux-x86.mk index aa55166754..7e63800f99 100644 --- a/ui/ui.target.linux-x86.mk +++ b/ui/ui.target.linux-x86.mk @@ -45,6 +45,7 @@ LOCAL_SRC_FILES := \ ui/base/animation/slide_animation.cc \ ui/base/animation/throb_animation.cc \ ui/base/animation/tween.cc \ + ui/base/base_window.cc \ ui/base/clipboard/clipboard.cc \ ui/base/clipboard/clipboard_android.cc \ ui/base/clipboard/clipboard_constants.cc \ diff --git a/ui/views/bubble/bubble_border.cc b/ui/views/bubble/bubble_border.cc index 3c9a3206df..6494c7b2f4 100644 --- a/ui/views/bubble/bubble_border.cc +++ b/ui/views/bubble/bubble_border.cc @@ -73,25 +73,53 @@ namespace { // The border and arrow stroke size used in image assets, in pixels. const int kStroke = 1; -// Macros to define arrays of IDR constants used with CreateImageGridPainter. -#define IMAGE_BORDER(x) { x ## _TOP_LEFT, x ## _TOP, x ## _TOP_RIGHT, \ - x ## _LEFT, 0, x ## _RIGHT, \ - x ## _BOTTOM_LEFT, x ## _BOTTOM, x ## _BOTTOM_RIGHT, } -#define IMAGE_BORDER_ACRONYM(x) { x ## _TL, x ## _T, x ## _TR, \ - x ## _L, 0, x ## _R, \ - x ## _BL, x ## _B, x ## _BR, } -#define ARROWS(x) { x ## _LEFT, x ## _TOP, x ## _RIGHT, x ## _BOTTOM, } - -// Bubble border and arrow image resource ids. -const int kShadowImages[] = IMAGE_BORDER_ACRONYM(IDR_BUBBLE_SHADOW); +// Bubble border and arrow image resource ids. They don't use the IMAGE_GRID +// macro because there is no center image. +const int kShadowImages[] = { + IDR_BUBBLE_SHADOW_TL, IDR_BUBBLE_SHADOW_T, IDR_BUBBLE_SHADOW_TR, + IDR_BUBBLE_SHADOW_L, 0, IDR_BUBBLE_SHADOW_R, + IDR_BUBBLE_SHADOW_BL, IDR_BUBBLE_SHADOW_B, IDR_BUBBLE_SHADOW_BR }; const int kShadowArrows[] = { 0, 0, 0, 0 }; -const int kNoShadowImages[] = IMAGE_BORDER_ACRONYM(IDR_BUBBLE); -const int kNoShadowArrows[] = { IDR_BUBBLE_L_ARROW, IDR_BUBBLE_T_ARROW, - IDR_BUBBLE_R_ARROW, IDR_BUBBLE_B_ARROW, }; -const int kBigShadowImages[] = IMAGE_BORDER(IDR_WINDOW_BUBBLE_SHADOW_BIG); -const int kBigShadowArrows[] = ARROWS(IDR_WINDOW_BUBBLE_SHADOW_SPIKE_BIG); -const int kSmallShadowImages[] = IMAGE_BORDER(IDR_WINDOW_BUBBLE_SHADOW_SMALL); -const int kSmallShadowArrows[] = ARROWS(IDR_WINDOW_BUBBLE_SHADOW_SPIKE_SMALL); + +const int kNoShadowImages[] = { + IDR_BUBBLE_TL, IDR_BUBBLE_T, IDR_BUBBLE_TR, + IDR_BUBBLE_L, 0, IDR_BUBBLE_R, + IDR_BUBBLE_BL, IDR_BUBBLE_B, IDR_BUBBLE_BR }; +const int kNoShadowArrows[] = { + IDR_BUBBLE_L_ARROW, IDR_BUBBLE_T_ARROW, + IDR_BUBBLE_R_ARROW, IDR_BUBBLE_B_ARROW, }; + +const int kBigShadowImages[] = { + IDR_WINDOW_BUBBLE_SHADOW_BIG_TOP_LEFT, + IDR_WINDOW_BUBBLE_SHADOW_BIG_TOP, + IDR_WINDOW_BUBBLE_SHADOW_BIG_TOP_RIGHT, + IDR_WINDOW_BUBBLE_SHADOW_BIG_LEFT, + 0, + IDR_WINDOW_BUBBLE_SHADOW_BIG_RIGHT, + IDR_WINDOW_BUBBLE_SHADOW_BIG_BOTTOM_LEFT, + IDR_WINDOW_BUBBLE_SHADOW_BIG_BOTTOM, + IDR_WINDOW_BUBBLE_SHADOW_BIG_BOTTOM_RIGHT }; +const int kBigShadowArrows[] = { + IDR_WINDOW_BUBBLE_SHADOW_SPIKE_BIG_LEFT, + IDR_WINDOW_BUBBLE_SHADOW_SPIKE_BIG_TOP, + IDR_WINDOW_BUBBLE_SHADOW_SPIKE_BIG_RIGHT, + IDR_WINDOW_BUBBLE_SHADOW_SPIKE_BIG_BOTTOM }; + +const int kSmallShadowImages[] = { + IDR_WINDOW_BUBBLE_SHADOW_SMALL_TOP_LEFT, + IDR_WINDOW_BUBBLE_SHADOW_SMALL_TOP, + IDR_WINDOW_BUBBLE_SHADOW_SMALL_TOP_RIGHT, + IDR_WINDOW_BUBBLE_SHADOW_SMALL_LEFT, + 0, + IDR_WINDOW_BUBBLE_SHADOW_SMALL_RIGHT, + IDR_WINDOW_BUBBLE_SHADOW_SMALL_BOTTOM_LEFT, + IDR_WINDOW_BUBBLE_SHADOW_SMALL_BOTTOM, + IDR_WINDOW_BUBBLE_SHADOW_SMALL_BOTTOM_RIGHT }; +const int kSmallShadowArrows[] = { + IDR_WINDOW_BUBBLE_SHADOW_SPIKE_SMALL_LEFT, + IDR_WINDOW_BUBBLE_SHADOW_SPIKE_SMALL_TOP, + IDR_WINDOW_BUBBLE_SHADOW_SPIKE_SMALL_RIGHT, + IDR_WINDOW_BUBBLE_SHADOW_SPIKE_SMALL_BOTTOM }; using internal::BorderImages; diff --git a/ui/views/controls/button/menu_button.cc b/ui/views/controls/button/menu_button.cc index 5a20d52b12..c43267629c 100644 --- a/ui/views/controls/button/menu_button.cc +++ b/ui/views/controls/button/menu_button.cc @@ -18,6 +18,7 @@ #include "ui/gfx/screen.h" #include "ui/views/controls/button/button.h" #include "ui/views/controls/button/menu_button_listener.h" +#include "ui/views/mouse_constants.h" #include "ui/views/widget/root_view.h" #include "ui/views/widget/widget.h" @@ -32,7 +33,6 @@ static const int kDefaultMenuOffsetY = -4; // static const char MenuButton::kViewClassName[] = "MenuButton"; -const int64 MenuButton::kMinimumTimeBetweenButtonClicks = 100; const int MenuButton::kMenuMarkerPaddingLeft = 3; const int MenuButton::kMenuMarkerPaddingRight = -1; @@ -182,10 +182,8 @@ bool MenuButton::OnMousePressed(const ui::MouseEvent& event) { HitTestPoint(event.location()) && GetDragOperations(event.location()) == ui::DragDropTypes::DRAG_NONE) { TimeDelta delta = Time::Now() - menu_closed_time_; - int64 delta_in_milliseconds = delta.InMilliseconds(); - if (delta_in_milliseconds > kMinimumTimeBetweenButtonClicks) { + if (delta.InMilliseconds() > kMinimumMsBetweenButtonClicks) return Activate(); - } } } return true; diff --git a/ui/views/controls/button/menu_button.h b/ui/views/controls/button/menu_button.h index 575942b158..20cdb83316 100644 --- a/ui/views/controls/button/menu_button.h +++ b/ui/views/controls/button/menu_button.h @@ -28,10 +28,6 @@ class VIEWS_EXPORT MenuButton : public TextButton { public: static const char kViewClassName[]; - // The amount of time, in milliseconds, we wait before allowing another mouse - // pressed event to show the menu. - static const int64 kMinimumTimeBetweenButtonClicks; - // How much padding to put on the left and right of the menu marker. static const int kMenuMarkerPaddingLeft; static const int kMenuMarkerPaddingRight; diff --git a/ui/views/controls/combobox/native_combobox_views.cc b/ui/views/controls/combobox/native_combobox_views.cc index 3cb3a5c52a..9a80ec60dd 100644 --- a/ui/views/controls/combobox/native_combobox_views.cc +++ b/ui/views/controls/combobox/native_combobox_views.cc @@ -19,11 +19,11 @@ #include "ui/views/background.h" #include "ui/views/border.h" #include "ui/views/color_constants.h" -#include "ui/views/controls/button/menu_button.h" #include "ui/views/controls/combobox/combobox.h" #include "ui/views/controls/focusable_border.h" #include "ui/views/controls/menu/menu_runner.h" #include "ui/views/controls/menu/submenu_view.h" +#include "ui/views/mouse_constants.h" #include "ui/views/widget/root_view.h" #include "ui/views/widget/widget.h" @@ -100,7 +100,7 @@ bool NativeComboboxViews::OnMousePressed(const ui::MouseEvent& mouse_event) { combobox_->RequestFocus(); const base::TimeDelta delta = base::Time::Now() - closed_time_; if (mouse_event.IsLeftMouseButton() && - (delta.InMilliseconds() > MenuButton::kMinimumTimeBetweenButtonClicks)) { + delta.InMilliseconds() > kMinimumMsBetweenButtonClicks) { UpdateFromModel(); ShowDropDownMenu(ui::MENU_SOURCE_MOUSE); } diff --git a/ui/views/controls/menu/menu_controller.cc b/ui/views/controls/menu/menu_controller.cc index afbd6b0f04..f261973712 100644 --- a/ui/views/controls/menu/menu_controller.cc +++ b/ui/views/controls/menu/menu_controller.cc @@ -20,14 +20,20 @@ #include "ui/base/keycodes/keyboard_codes.h" #include "ui/base/l10n/l10n_util.h" #include "ui/gfx/canvas.h" +#include "ui/gfx/native_widget_types.h" #include "ui/gfx/screen.h" +#include "ui/gfx/vector2d.h" #include "ui/native_theme/native_theme.h" #include "ui/views/controls/button/menu_button.h" #include "ui/views/controls/menu/menu_config.h" #include "ui/views/controls/menu/menu_controller_delegate.h" +#include "ui/views/controls/menu/menu_host_root_view.h" #include "ui/views/controls/menu/menu_scroll_view_container.h" #include "ui/views/controls/menu/submenu_view.h" #include "ui/views/drag_utils.h" +#include "ui/views/event_utils.h" +#include "ui/views/focus/view_storage.h" +#include "ui/views/mouse_constants.h" #include "ui/views/view_constants.h" #include "ui/views/views_delegate.h" #include "ui/views/widget/root_view.h" @@ -36,7 +42,6 @@ #if defined(USE_AURA) #include "ui/aura/env.h" #include "ui/aura/root_window.h" -#include "ui/aura/window.h" #endif #if defined(OS_WIN) @@ -68,12 +73,17 @@ namespace { // When showing context menu on mouse down, the user might accidentally select // the menu item on the subsequent mouse up. To prevent this, we add the // following delay before the user is able to select an item. -static int context_menu_selection_hold_time_ms = 200; +static int menu_selection_hold_time_ms = kMinimumMsPressedToActivate; // The spacing offset for the bubble tip. const int kBubbleTipSizeLeftRight = 12; const int kBubbleTipSizeTopBottom = 11; +// The maximum distance (in DIPS) that the mouse can be moved before it should +// trigger a mouse menu item activation (regardless of how long the menu has +// been showing). +const float kMaximumLengthMovedToActivate = 4.0f; + // Returns true if the mnemonic of |menu| matches key. bool MatchesMnemonic(MenuItemView* menu, char16 key) { return menu->GetMnemonic() == key; @@ -268,7 +278,7 @@ struct MenuController::SelectByCharDetails { MenuController::State::State() : item(NULL), submenu_open(false), - anchor(views::MenuItemView::TOPLEFT), + anchor(MenuItemView::TOPLEFT), context_menu(false) {} MenuController::State::~State() {} @@ -295,12 +305,26 @@ MenuItemView* MenuController::Run(Widget* parent, drag_in_progress_ = false; closing_event_time_ = base::TimeDelta(); menu_start_time_ = base::TimeTicks::Now(); + menu_start_mouse_press_loc_ = gfx::Point(); // If we are shown on mouse press, we will eat the subsequent mouse down and // the parent widget will not be able to reset its state (it might have mouse // capture from the mouse down). So we clear its state here. - if (parent && parent->GetRootView()) - parent->GetRootView()->SetMouseHandler(NULL); + if (parent) { + View* root_view = parent->GetRootView(); + if (root_view) { + root_view->SetMouseHandler(NULL); + const ui::Event* event = + static_cast<internal::RootView*>(root_view)->current_event(); + if (event && event->type() == ui::ET_MOUSE_PRESSED) { + gfx::Point screen_loc( + static_cast<const ui::MouseEvent*>(event)->location()); + View::ConvertPointToScreen( + static_cast<View*>(event->target()), &screen_loc); + menu_start_mouse_press_loc_ = screen_loc; + } + } + } bool nested_menu = showing_; if (showing_) { @@ -485,9 +509,9 @@ void MenuController::OnMouseReleased(SubmenuView* source, // If it is from an empty menu, use parent context menu instead of that. if (menu == NULL && part.submenu->child_count() == 1 && - part.submenu->child_at(0)->id() - == views::MenuItemView::kEmptyMenuItemViewID) + part.submenu->child_at(0)->id() == MenuItemView::kEmptyMenuItemViewID) { menu = part.parent; + } if (menu != NULL && ShowContextMenu(menu, source, event, ui::MENU_SOURCE_MOUSE)) @@ -500,10 +524,23 @@ void MenuController::OnMouseReleased(SubmenuView* source, if (!part.is_scroll() && part.menu && !(part.menu->HasSubmenu() && (event.flags() & ui::EF_LEFT_MOUSE_BUTTON))) { - if (active_mouse_view_) { + if (GetActiveMouseView()) { SendMouseReleaseToActiveView(source, event); return; } + // If a mouse release was received quickly after showing. + base::TimeDelta time_shown = base::TimeTicks::Now() - menu_start_time_; + if (time_shown.InMilliseconds() < menu_selection_hold_time_ms) { + // And it wasn't far from the mouse press location. + gfx::Point screen_loc(event.location()); + View::ConvertPointToScreen(source->GetScrollViewContainer(), &screen_loc); + gfx::Vector2d moved = screen_loc - menu_start_mouse_press_loc_; + if (moved.Length() < kMaximumLengthMovedToActivate) { + // Ignore the mouse release as it was likely this menu was shown under + // the mouse and the action was just a normal click. + return; + } + } if (part.menu->GetDelegate()->ShouldExecuteCommandWithoutClosingMenu( part.menu->GetCommand(), event)) { part.menu->GetDelegate()->ExecuteCommand(part.menu->GetCommand(), @@ -512,11 +549,11 @@ void MenuController::OnMouseReleased(SubmenuView* source, } if (!part.menu->NonIconChildViewsCount() && part.menu->GetDelegate()->IsTriggerableEvent(part.menu, event)) { - int64 time_since_menu_start = - (base::TimeTicks::Now() - menu_start_time_).InMilliseconds(); + base::TimeDelta shown_time = base::TimeTicks::Now() - menu_start_time_; if (!state_.context_menu || !View::ShouldShowContextMenuOnMousePress() || - time_since_menu_start > context_menu_selection_hold_time_ms) + shown_time.InMilliseconds() > menu_selection_hold_time_ms) { Accept(part.menu, event.flags()); + } return; } } else if (part.type == MenuPart::MENU_ITEM) { @@ -740,7 +777,7 @@ void MenuController::UpdateSubmenuSelection(SubmenuView* submenu) { gfx::Point point = GetScreen()->GetCursorScreenPoint(); const SubmenuView* root_submenu = submenu->GetMenuItem()->GetRootMenuItem()->GetSubmenu(); - views::View::ConvertPointFromScreen( + View::ConvertPointFromScreen( root_submenu->GetWidget()->GetRootView(), &point); HandleMouseLocation(submenu, point); } @@ -753,8 +790,8 @@ void MenuController::OnWidgetDestroying(Widget* widget) { } // static -void MenuController::TurnOffContextMenuSelectionHoldForTest() { - context_menu_selection_hold_time_ms = -1; +void MenuController::TurnOffMenuSelectionHoldForTest() { + menu_selection_hold_time_ms = -1; } void MenuController::SetSelection(MenuItemView* menu_item, @@ -828,7 +865,7 @@ void MenuController::SetSelectionOnPointerDown(SubmenuView* source, if (!blocking_run_) return; - DCHECK(!active_mouse_view_); + DCHECK(!GetActiveMouseView()); MenuPart part = GetMenuPart(source, event.location()); if (part.is_scroll()) @@ -855,9 +892,15 @@ void MenuController::SetSelectionOnPointerDown(SubmenuView* source, #if defined(OS_WIN) // We're going to close and we own the mouse capture. We need to repost the - // mouse down, otherwise the window the user clicked on won't get the - // event. - RepostEvent(source, event); + // mouse down, otherwise the window the user clicked on won't get the event. + if (!state_.item) { + // We some times get an event after closing all the menus. Ignore it. Make + // sure the menu is in fact not visible. If the menu is visible, then + // we're in a bad state where we think the menu isn't visibile but it is. + DCHECK(!source->GetWidget()->IsVisible()); + } else { + RepostEvent(source, event); + } #endif // And close. @@ -914,7 +957,7 @@ void MenuController::StartDrag(SubmenuView* source, View::ConvertPointToTarget(NULL, item, &press_loc); gfx::Point widget_loc(press_loc); View::ConvertPointToWidget(item, &widget_loc); - scoped_ptr<gfx::Canvas> canvas(views::GetCanvasForDragImage( + scoped_ptr<gfx::Canvas> canvas(GetCanvasForDragImage( source->GetWidget(), gfx::Size(item->width(), item->height()))); item->PaintButton(canvas.get(), MenuItemView::PB_FOR_DRAG); @@ -1119,7 +1162,7 @@ MenuController::MenuController(ui::NativeTheme* theme, last_drop_operation_(MenuDelegate::DROP_UNKNOWN), showing_submenu_(false), menu_button_(NULL), - active_mouse_view_(NULL), + active_mouse_view_id_(ViewStorage::GetInstance()->CreateStorageID()), delegate_(delegate), message_loop_depth_(0), menu_config_(theme), @@ -1218,8 +1261,7 @@ bool MenuController::ShowSiblingMenu(SubmenuView* source, return false; } - gfx::NativeWindow window_under_mouse = - GetScreen()->GetWindowAtCursorScreenPoint(); + gfx::NativeWindow window_under_mouse = GetScreen()->GetWindowUnderCursor(); // TODO(oshima): Replace with views only API. if (!owner_ || window_under_mouse != owner_->GetNativeWindow()) return false; @@ -1541,7 +1583,7 @@ void MenuController::OpenMenuImpl(MenuItemView* item, bool show) { void MenuController::MenuChildrenChanged(MenuItemView* item) { DCHECK(item); // Menu shouldn't be updated during drag operation. - DCHECK(!active_mouse_view_); + DCHECK(!GetActiveMouseView()); // If the current item or pending item is a descendant of the item // that changed, move the selection back to the changed item. @@ -2058,94 +2100,52 @@ bool MenuController::SelectByChar(char16 character) { return false; } -#if defined(OS_WIN) void MenuController::RepostEvent(SubmenuView* source, const ui::LocatedEvent& event) { - if (!state_.item) { - // We some times get an event after closing all the menus. Ignore it. - // Make sure the menu is in fact not visible. If the menu is visible, then - // we're in a bad state where we think the menu isn't visibile but it is. - DCHECK(!source->GetWidget()->IsVisible()); - return; - } - gfx::Point screen_loc(event.location()); View::ConvertPointToScreen(source->GetScrollViewContainer(), &screen_loc); - HWND window = WindowFromPoint(screen_loc.ToPOINT()); - if (window) { - // Release the capture. - SubmenuView* submenu = state_.item->GetRootMenuItem()->GetSubmenu(); - submenu->ReleaseCapture(); - - if (submenu->GetWidget()->GetNativeView() && - GetWindowThreadProcessId( - views::HWNDForNativeView(submenu->GetWidget()->GetNativeView()), - NULL) != GetWindowThreadProcessId(window, NULL)) { - // Even though we have mouse capture, windows generates a mouse event - // if the other window is in a separate thread. Don't generate an event in - // this case else the target window can get double events leading to bad - // behavior. - return; - } - // Convert the coordinates to the target window. - RECT window_bounds; - GetWindowRect(window, &window_bounds); - int window_x = screen_loc.x() - window_bounds.left; - int window_y = screen_loc.y() - window_bounds.top; - - // Determine whether the click was in the client area or not. - // NOTE: WM_NCHITTEST coordinates are relative to the screen. - LRESULT nc_hit_result = SendMessage(window, WM_NCHITTEST, 0, - MAKELPARAM(screen_loc.x(), - screen_loc.y())); - const bool in_client_area = (nc_hit_result == HTCLIENT); - - // TODO(sky): this isn't right. The event to generate should correspond - // with the event we just got. MouseEvent only tells us what is down, - // which may differ. Need to add ability to get changed button from - // MouseEvent. - int event_type; - int flags = event.flags(); - if (flags & ui::EF_LEFT_MOUSE_BUTTON) - event_type = in_client_area ? WM_LBUTTONDOWN : WM_NCLBUTTONDOWN; - else if (flags & ui::EF_MIDDLE_MOUSE_BUTTON) - event_type = in_client_area ? WM_MBUTTONDOWN : WM_NCMBUTTONDOWN; - else if (flags & ui::EF_RIGHT_MOUSE_BUTTON) - event_type = in_client_area ? WM_RBUTTONDOWN : WM_NCRBUTTONDOWN; - else - event_type = 0; // Unknown mouse press. + gfx::NativeView native_view = source->GetWidget()->GetNativeView(); + gfx::Screen* screen = gfx::Screen::GetScreenFor(native_view); + gfx::NativeWindow window = screen->GetWindowAtScreenPoint(screen_loc); - if (event_type) { - if (in_client_area) { - PostMessage(window, event_type, event.native_event().wParam, - MAKELPARAM(window_x, window_y)); - } else { - PostMessage(window, event_type, nc_hit_result, - MAKELPARAM(screen_loc.x(), screen_loc.y())); - } - } else if (event.type() == ui::ET_GESTURE_TAP_DOWN) { -#if defined(USE_AURA) - // Gesture events need to be posted to the target root window. In - // desktop chrome there could be multiple root windows. - aura::RootWindow* target_root = - aura::RootWindow::GetForAcceleratedWidget(window); - if (target_root) - target_root->RepostEvent(event); -#endif + if (!window) + return; + +#if defined(OS_WIN) + // Release the capture. + SubmenuView* submenu = state_.item->GetRootMenuItem()->GetSubmenu(); + submenu->ReleaseCapture(); + + gfx::NativeView view = submenu->GetWidget()->GetNativeView(); + if (view) { + DWORD view_tid = GetWindowThreadProcessId(HWNDForNativeView(view), NULL); + if (view_tid != GetWindowThreadProcessId(HWNDForNativeView(window), NULL)) { + // Even though we have mouse capture, windows generates a mouse event if + // the other window is in a separate thread. Only repost an event if + // |view| was created on the same thread, else the target window can get + // double events leading to bad behavior. + return; } } -} -#elif defined(USE_AURA) -void MenuController::RepostEvent(SubmenuView* source, - const ui::LocatedEvent& event) { - aura::RootWindow* root_window = - source->GetWidget()->GetNativeWindow()->GetRootWindow(); - DCHECK(root_window); - root_window->RepostEvent(event); -} #endif + scoped_ptr<ui::LocatedEvent> clone; + if (event.IsMouseEvent()) { + clone.reset(new ui::MouseEvent(static_cast<const ui::MouseEvent&>(event))); + } else if (event.IsGestureEvent()) { + const ui::GestureEvent& ge = static_cast<const ui::GestureEvent&>(event); + clone.reset(new ui::GestureEvent(ge)); + } else { + NOTREACHED(); + return; + } + clone->set_location(screen_loc); + + RepostLocatedEvent(window, *clone); +} + + void MenuController::SetDropMenuItem( MenuItemView* new_target, MenuDelegate::DropPosition new_position) { @@ -2194,63 +2194,75 @@ void MenuController::UpdateActiveMouseView(SubmenuView* event_source, if (target == target_menu || !target->enabled()) target = NULL; } - if (target != active_mouse_view_) { + View* active_mouse_view = GetActiveMouseView(); + if (target != active_mouse_view) { SendMouseCaptureLostToActiveView(); - active_mouse_view_ = target; - if (active_mouse_view_) { + active_mouse_view = target; + SetActiveMouseView(active_mouse_view); + if (active_mouse_view) { gfx::Point target_point(target_menu_loc); View::ConvertPointToTarget( - target_menu, active_mouse_view_, &target_point); + target_menu, active_mouse_view, &target_point); ui::MouseEvent mouse_entered_event(ui::ET_MOUSE_ENTERED, target_point, target_point, 0); - active_mouse_view_->OnMouseEntered(mouse_entered_event); + active_mouse_view->OnMouseEntered(mouse_entered_event); ui::MouseEvent mouse_pressed_event(ui::ET_MOUSE_PRESSED, target_point, target_point, event.flags()); - active_mouse_view_->OnMousePressed(mouse_pressed_event); + active_mouse_view->OnMousePressed(mouse_pressed_event); } } - if (active_mouse_view_) { + if (active_mouse_view) { gfx::Point target_point(target_menu_loc); - View::ConvertPointToTarget(target_menu, active_mouse_view_, &target_point); + View::ConvertPointToTarget(target_menu, active_mouse_view, &target_point); ui::MouseEvent mouse_dragged_event(ui::ET_MOUSE_DRAGGED, target_point, target_point, event.flags()); - active_mouse_view_->OnMouseDragged(mouse_dragged_event); + active_mouse_view->OnMouseDragged(mouse_dragged_event); } } void MenuController::SendMouseReleaseToActiveView(SubmenuView* event_source, const ui::MouseEvent& event) { - if (!active_mouse_view_) + View* active_mouse_view = GetActiveMouseView(); + if (!active_mouse_view) return; gfx::Point target_loc(event.location()); View::ConvertPointToScreen(event_source->GetScrollViewContainer(), &target_loc); - View::ConvertPointToTarget(NULL, active_mouse_view_, &target_loc); - ui::MouseEvent release_event(ui::ET_MOUSE_RELEASED, - target_loc, target_loc, - event.flags()); - // Reset the active_mouse_view_ before sending mouse released. That way if it - // calls back to us, we aren't in a weird state. - View* active_view = active_mouse_view_; - active_mouse_view_ = NULL; - active_view->OnMouseReleased(release_event); + View::ConvertPointToTarget(NULL, active_mouse_view, &target_loc); + ui::MouseEvent release_event(ui::ET_MOUSE_RELEASED, target_loc, target_loc, + event.flags()); + // Reset active mouse view before sending mouse released. That way if it calls + // back to us, we aren't in a weird state. + SetActiveMouseView(NULL); + active_mouse_view->OnMouseReleased(release_event); } void MenuController::SendMouseCaptureLostToActiveView() { - if (!active_mouse_view_) + View* active_mouse_view = GetActiveMouseView(); + if (!active_mouse_view) return; // Reset the active_mouse_view_ before sending mouse capture lost. That way if // it calls back to us, we aren't in a weird state. - View* active_view = active_mouse_view_; - active_mouse_view_ = NULL; - active_view->OnMouseCaptureLost(); + SetActiveMouseView(NULL); + active_mouse_view->OnMouseCaptureLost(); +} + +void MenuController::SetActiveMouseView(View* view) { + if (view) + ViewStorage::GetInstance()->StoreView(active_mouse_view_id_, view); + else + ViewStorage::GetInstance()->RemoveView(active_mouse_view_id_); +} + +View* MenuController::GetActiveMouseView() { + return ViewStorage::GetInstance()->RetrieveView(active_mouse_view_id_); } void MenuController::SetExitType(ExitType type) { diff --git a/ui/views/controls/menu/menu_controller.h b/ui/views/controls/menu/menu_controller.h index 6dfdd528e9..3037289efd 100644 --- a/ui/views/controls/menu/menu_controller.h +++ b/ui/views/controls/menu/menu_controller.h @@ -137,7 +137,7 @@ class VIEWS_EXPORT MenuController : public base::MessageLoop::Dispatcher, virtual void OnWidgetDestroying(Widget* widget) OVERRIDE; // Only used for testing. - static void TurnOffContextMenuSelectionHoldForTest(); + static void TurnOffMenuSelectionHoldForTest(); private: friend class internal::MenuRunnerImpl; @@ -445,7 +445,7 @@ class VIEWS_EXPORT MenuController : public base::MessageLoop::Dispatcher, // Stops scrolling. void StopScrolling(); - // Updates |active_mouse_view_| from the location of the event and sends it + // Updates active mouse view from the location of the event and sends it // the appropriate events. This is used to send mouse events to child views so // that they react to click-drag-release as if the user clicked on the view // itself. @@ -453,15 +453,19 @@ class VIEWS_EXPORT MenuController : public base::MessageLoop::Dispatcher, const ui::MouseEvent& event, View* target_menu); - // Sends a mouse release event to the current |active_mouse_view_| and sets + // Sends a mouse release event to the current active mouse view and sets // it to null. void SendMouseReleaseToActiveView(SubmenuView* event_source, const ui::MouseEvent& event); - // Sends a mouse capture lost event to the current |active_mouse_view_| and - // sets it to null. + // Sends a mouse capture lost event to the current active mouse view and sets + // it to null. void SendMouseCaptureLostToActiveView(); + // Sets/gets the active mouse view. See UpdateActiveMouseView() for details. + void SetActiveMouseView(View* view); + View* GetActiveMouseView(); + // Sets exit type. void SetExitType(ExitType type); @@ -556,9 +560,9 @@ class VIEWS_EXPORT MenuController : public base::MessageLoop::Dispatcher, MenuButton* menu_button_; - // If non-null mouse drag events are forwarded to this view. See - // UpdateActiveMouseView for details. - View* active_mouse_view_; + // ViewStorage id used to store the view mouse drag events are forwarded to. + // See UpdateActiveMouseView() for details. + const int active_mouse_view_id_; internal::MenuControllerDelegate* delegate_; @@ -574,6 +578,10 @@ class VIEWS_EXPORT MenuController : public base::MessageLoop::Dispatcher, // Time when the menu is first shown. base::TimeTicks menu_start_time_; + // If a mouse press triggered this menu, this will have its location (in + // screen coordinates). Otherwise this will be (0, 0). + gfx::Point menu_start_mouse_press_loc_; + DISALLOW_COPY_AND_ASSIGN(MenuController); }; diff --git a/ui/views/controls/native/native_view_host_unittest.cc b/ui/views/controls/native/native_view_host_unittest.cc index 0f8eca122b..f30980bca8 100644 --- a/ui/views/controls/native/native_view_host_unittest.cc +++ b/ui/views/controls/native/native_view_host_unittest.cc @@ -72,33 +72,23 @@ namespace { // times NativeViewHierarchyChanged() is invoked. class NativeViewHierarchyChangedTestView : public View { public: - NativeViewHierarchyChangedTestView() - : attached_count_(0), - detached_count_(0) { + NativeViewHierarchyChangedTestView() : notification_count_(0) { } - void ResetCounts() { - attached_count_ = detached_count_ = 0; + void ResetCount() { + notification_count_ = 0; } - int attached_count() const { return attached_count_; } - int detached_count() const { return detached_count_; } + int notification_count() const { return notification_count_; } // Overriden from View: - virtual void NativeViewHierarchyChanged( - bool attached, - gfx::NativeView native_view, - internal::RootView* root_view) OVERRIDE { - if (attached) - attached_count_++; - else - detached_count_++; - View::NativeViewHierarchyChanged(attached, native_view, root_view); + virtual void NativeViewHierarchyChanged() OVERRIDE { + ++notification_count_; + View::NativeViewHierarchyChanged(); } private: - int attached_count_; - int detached_count_; + int notification_count_; DISALLOW_COPY_AND_ASSIGN(NativeViewHierarchyChangedTestView); }; @@ -158,22 +148,21 @@ TEST_F(NativeViewHostTest, NativeViewHierarchyChanged) { test_view, host)); - EXPECT_EQ(0, test_view->attached_count()); - EXPECT_EQ(0, test_view->detached_count()); - test_view->ResetCounts(); + EXPECT_EQ(0, test_view->notification_count()); + test_view->ResetCount(); - // Detach should send both an attach and detach as well as changing parent. + // Detaching should send a NativeViewHierarchyChanged() notification and + // change the parent. host->Detach(); - EXPECT_EQ(1, test_view->attached_count()); - EXPECT_EQ(1, test_view->detached_count()); + EXPECT_EQ(1, test_view->notification_count()); EXPECT_NE(toplevel()->GetNativeView(), GetNativeParent(child->GetNativeView())); - test_view->ResetCounts(); + test_view->ResetCount(); - // Attaching should send both an attach and detach and reset parent. + // Attaching should send a NativeViewHierarchyChanged() notification and + // reset the parent. host->Attach(child->GetNativeView()); - EXPECT_EQ(1, test_view->attached_count()); - EXPECT_EQ(1, test_view->detached_count()); + EXPECT_EQ(1, test_view->notification_count()); EXPECT_EQ(toplevel()->GetNativeView(), GetNativeParent(child->GetNativeView())); } diff --git a/ui/views/controls/textfield/native_textfield_views.cc b/ui/views/controls/textfield/native_textfield_views.cc index d572a72458..76ba3cb457 100644 --- a/ui/views/controls/textfield/native_textfield_views.cc +++ b/ui/views/controls/textfield/native_textfield_views.cc @@ -744,6 +744,8 @@ bool NativeTextfieldViews::IsCommandIdEnabled(int command_id) const { bool editable = !textfield_->read_only(); string16 result; switch (command_id) { + case IDS_APP_UNDO: + return editable && model_->CanUndo(); case IDS_APP_CUT: return editable && model_->HasSelection() && !textfield_->IsObscured(); case IDS_APP_COPY: @@ -787,6 +789,12 @@ void NativeTextfieldViews::ExecuteCommand(int command_id, int event_flags) { } else { bool text_changed = false; switch (command_id) { + case IDS_APP_UNDO: + OnBeforeUserAction(); + text_changed = model_->Undo(); + UpdateAfterChange(text_changed, text_changed); + OnAfterUserAction(); + break; case IDS_APP_CUT: OnBeforeUserAction(); text_changed = Cut(); @@ -1321,6 +1329,8 @@ void NativeTextfieldViews::UpdateAfterChange(bool text_changed, void NativeTextfieldViews::UpdateContextMenu() { if (!context_menu_contents_.get()) { context_menu_contents_.reset(new ui::SimpleMenuModel(this)); + context_menu_contents_->AddItemWithStringId(IDS_APP_UNDO, IDS_APP_UNDO); + context_menu_contents_->AddSeparator(ui::NORMAL_SEPARATOR); context_menu_contents_->AddItemWithStringId(IDS_APP_CUT, IDS_APP_CUT); context_menu_contents_->AddItemWithStringId(IDS_APP_COPY, IDS_APP_COPY); context_menu_contents_->AddItemWithStringId(IDS_APP_PASTE, IDS_APP_PASTE); diff --git a/ui/views/controls/textfield/native_textfield_views_unittest.cc b/ui/views/controls/textfield/native_textfield_views_unittest.cc index 5e8c689785..51c0bf53bd 100644 --- a/ui/views/controls/textfield/native_textfield_views_unittest.cc +++ b/ui/views/controls/textfield/native_textfield_views_unittest.cc @@ -319,14 +319,16 @@ class NativeTextfieldViewsTest : public ViewsTestBase, } void VerifyTextfieldContextMenuContents(bool textfield_has_selection, - ui::MenuModel* menu_model) { - EXPECT_TRUE(menu_model->IsEnabledAt(4 /* Separator */)); - EXPECT_TRUE(menu_model->IsEnabledAt(5 /* SELECT ALL */)); - EXPECT_EQ(textfield_has_selection, menu_model->IsEnabledAt(0 /* CUT */)); - EXPECT_EQ(textfield_has_selection, menu_model->IsEnabledAt(1 /* COPY */)); - EXPECT_EQ(textfield_has_selection, menu_model->IsEnabledAt(3 /* DELETE */)); - string16 str(GetClipboardText()); - EXPECT_NE(str.empty(), menu_model->IsEnabledAt(2 /* PASTE */)); + bool can_undo, + ui::MenuModel* menu) { + EXPECT_EQ(can_undo, menu->IsEnabledAt(0 /* UNDO */)); + EXPECT_TRUE(menu->IsEnabledAt(1 /* Separator */)); + EXPECT_EQ(textfield_has_selection, menu->IsEnabledAt(2 /* CUT */)); + EXPECT_EQ(textfield_has_selection, menu->IsEnabledAt(3 /* COPY */)); + EXPECT_NE(GetClipboardText().empty(), menu->IsEnabledAt(4 /* PASTE */)); + EXPECT_EQ(textfield_has_selection, menu->IsEnabledAt(5 /* DELETE */)); + EXPECT_TRUE(menu->IsEnabledAt(6 /* Separator */)); + EXPECT_TRUE(menu->IsEnabledAt(7 /* SELECT ALL */)); } // We need widget to populate wrapper class. @@ -790,11 +792,23 @@ TEST_F(NativeTextfieldViewsTest, FocusTraversalTest) { TEST_F(NativeTextfieldViewsTest, ContextMenuDisplayTest) { InitTextfield(Textfield::STYLE_DEFAULT); textfield_->SetText(ASCIIToUTF16("hello world")); + ui::Clipboard::GetForCurrentThread()->Clear(ui::Clipboard::BUFFER_STANDARD); + textfield_view_->ClearEditHistory(); EXPECT_TRUE(GetContextMenuModel()); - VerifyTextfieldContextMenuContents(false, GetContextMenuModel()); + VerifyTextfieldContextMenuContents(false, false, GetContextMenuModel()); textfield_->SelectAll(false); - VerifyTextfieldContextMenuContents(true, GetContextMenuModel()); + VerifyTextfieldContextMenuContents(true, false, GetContextMenuModel()); + + SendKeyEvent(ui::VKEY_T); + VerifyTextfieldContextMenuContents(false, true, GetContextMenuModel()); + + textfield_->SelectAll(false); + VerifyTextfieldContextMenuContents(true, true, GetContextMenuModel()); + + // Exercise the "paste enabled?" check in the verifier. + SetClipboardText("Test"); + VerifyTextfieldContextMenuContents(true, true, GetContextMenuModel()); } TEST_F(NativeTextfieldViewsTest, DoubleAndTripleClickTest) { diff --git a/ui/views/corewm/capture_controller_unittest.cc b/ui/views/corewm/capture_controller_unittest.cc index 395c6f672e..32a1955607 100644 --- a/ui/views/corewm/capture_controller_unittest.cc +++ b/ui/views/corewm/capture_controller_unittest.cc @@ -8,9 +8,11 @@ #include "ui/aura/env.h" #include "ui/aura/root_window.h" #include "ui/aura/test/aura_test_base.h" +#include "ui/aura/test/event_generator.h" #include "ui/aura/test/test_screen.h" #include "ui/aura/test/test_window_delegate.h" #include "ui/base/events/event.h" +#include "ui/base/events/event_utils.h" #include "ui/views/test/views_test_base.h" #include "ui/views/view.h" #include "ui/views/widget/root_view.h" @@ -132,4 +134,36 @@ TEST_F(CaptureControllerTest, ResetOtherWindowCaptureOnCapture) { EXPECT_EQ(w2.get(), GetSecondCaptureWindow()); } +// Verifies the touch target for the RootWindow gets reset on releasing capture. +TEST_F(CaptureControllerTest, TouchTargetResetOnCaptureChange) { + // Create a window inside the RootWindow. + scoped_ptr<aura::Window> w1(CreateNormalWindow(1, root_window(), NULL)); + aura::test::EventGenerator event_generator1(root_window()); + event_generator1.PressTouch(); + w1->SetCapture(); + // Both capture clients should return the same capture window. + EXPECT_EQ(w1.get(), GetCaptureWindow()); + EXPECT_EQ(w1.get(), GetSecondCaptureWindow()); + + // Build a window in the second RootWindow and give it capture. Both capture + // clients should return the same capture window. + scoped_ptr<aura::Window> w2(CreateNormalWindow(2, second_root_.get(), NULL)); + w2->SetCapture(); + EXPECT_EQ(w2.get(), GetCaptureWindow()); + EXPECT_EQ(w2.get(), GetSecondCaptureWindow()); + + // Release capture on the window. Releasing capture should reset the touch + // target of the first RootWindow (as it no longer contains the capture + // target). + w2->ReleaseCapture(); + EXPECT_EQ(static_cast<aura::Window*>(NULL), GetCaptureWindow()); + EXPECT_EQ(static_cast<aura::Window*>(NULL), GetSecondCaptureWindow()); + ui::TouchEvent touch_event( + ui::ET_TOUCH_PRESSED, gfx::Point(), 0, 0, ui::EventTimeForNow(), 1.0f, + 1.0f, 1.0f, 1.0f); + EXPECT_EQ(static_cast<ui::GestureConsumer*>(NULL), + root_window()->gesture_recognizer()->GetTouchLockedTarget( + &touch_event)); +} + } // namespace views diff --git a/ui/views/corewm/cursor_manager.cc b/ui/views/corewm/cursor_manager.cc index 07a71dc388..97a19ba93c 100644 --- a/ui/views/corewm/cursor_manager.cc +++ b/ui/views/corewm/cursor_manager.cc @@ -23,6 +23,7 @@ class CursorState { : cursor_(ui::kCursorNone), visible_(true), scale_(1.f), + cursor_set_(ui::CURSOR_SET_NORMAL), mouse_events_enabled_(true), visible_on_mouse_events_enabled_(true) { } @@ -42,6 +43,11 @@ class CursorState { scale_ = scale; } + ui::CursorSetType cursor_set() const { return cursor_set_; } + void set_cursor_set(ui::CursorSetType cursor_set) { + cursor_set_ = cursor_set; + } + bool mouse_events_enabled() const { return mouse_events_enabled_; } void SetMouseEventsEnabled(bool enabled) { if (mouse_events_enabled_ == enabled) @@ -61,6 +67,7 @@ class CursorState { gfx::NativeCursor cursor_; bool visible_; float scale_; + ui::CursorSetType cursor_set_; bool mouse_events_enabled_; // The visibility to set when mouse events are enabled. @@ -119,10 +126,20 @@ void CursorManager::SetScale(float scale) { delegate_->SetScale(state_on_unlock_->scale(), this); } +void CursorManager::SetCursorSet(ui::CursorSetType cursor_set) { + state_on_unlock_->set_cursor_set(cursor_set); + if (GetCurrentCursorSet() != state_on_unlock_->cursor_set()) + delegate_->SetCursorSet(state_on_unlock_->cursor_set(), this); +} + float CursorManager::GetCurrentScale() const { return current_state_->scale(); } +ui::CursorSetType CursorManager::GetCurrentCursorSet() const { + return current_state_->cursor_set(); +} + void CursorManager::EnableMouseEvents() { state_on_unlock_->SetMouseEventsEnabled(true); if (cursor_lock_count_ == 0 && @@ -212,6 +229,10 @@ void CursorManager::CommitScale(float scale) { current_state_->set_scale(scale); } +void CursorManager::CommitCursorSet(ui::CursorSetType cursor_set) { + current_state_->set_cursor_set(cursor_set); +} + void CursorManager::CommitMouseEventsEnabled(bool enabled) { current_state_->SetMouseEventsEnabled(enabled); } diff --git a/ui/views/corewm/cursor_manager.h b/ui/views/corewm/cursor_manager.h index 659992b679..1706ed8f7a 100644 --- a/ui/views/corewm/cursor_manager.h +++ b/ui/views/corewm/cursor_manager.h @@ -10,6 +10,7 @@ #include "base/memory/scoped_ptr.h" #include "base/observer_list.h" #include "ui/aura/client/cursor_client.h" +#include "ui/base/cursor/cursor.h" #include "ui/gfx/native_widget_types.h" #include "ui/gfx/point.h" #include "ui/views/corewm/native_cursor_manager_delegate.h" @@ -45,6 +46,8 @@ class VIEWS_EXPORT CursorManager : public aura::client::CursorClient, virtual bool IsCursorVisible() const OVERRIDE; virtual void SetScale(float scale) OVERRIDE; virtual float GetCurrentScale() const OVERRIDE; + virtual void SetCursorSet(ui::CursorSetType cursor_set) OVERRIDE; + virtual ui::CursorSetType GetCurrentCursorSet() const OVERRIDE; virtual void EnableMouseEvents() OVERRIDE; virtual void DisableMouseEvents() OVERRIDE; virtual bool IsMouseEventsEnabled() const OVERRIDE; @@ -65,6 +68,7 @@ class VIEWS_EXPORT CursorManager : public aura::client::CursorClient, virtual void CommitCursor(gfx::NativeCursor cursor) OVERRIDE; virtual void CommitVisibility(bool visible) OVERRIDE; virtual void CommitScale(float scale) OVERRIDE; + virtual void CommitCursorSet(ui::CursorSetType cursor_set) OVERRIDE; virtual void CommitMouseEventsEnabled(bool enabled) OVERRIDE; scoped_ptr<NativeCursorManager> delegate_; diff --git a/ui/views/corewm/cursor_manager_unittest.cc b/ui/views/corewm/cursor_manager_unittest.cc index 650d5b842b..1e6a165090 100644 --- a/ui/views/corewm/cursor_manager_unittest.cc +++ b/ui/views/corewm/cursor_manager_unittest.cc @@ -38,6 +38,12 @@ class TestingCursorManager : public views::corewm::NativeCursorManager { delegate->CommitMouseEventsEnabled(enabled); } + virtual void SetCursorSet( + ui::CursorSetType cursor_set, + views::corewm::NativeCursorManagerDelegate* delegate) OVERRIDE { + delegate->CommitCursorSet(cursor_set); + } + virtual void SetScale( float scale, views::corewm::NativeCursorManagerDelegate* delegate) OVERRIDE { @@ -186,6 +192,19 @@ TEST_F(CursorManagerTest, EnableDisableMouseEvents) { EXPECT_FALSE(cursor_manager_.IsMouseEventsEnabled()); } +TEST_F(CursorManagerTest, SetCursorSet) { + EXPECT_EQ(ui::CURSOR_SET_NORMAL, cursor_manager_.GetCurrentCursorSet()); + + cursor_manager_.SetCursorSet(ui::CURSOR_SET_NORMAL); + EXPECT_EQ(ui::CURSOR_SET_NORMAL, cursor_manager_.GetCurrentCursorSet()); + + cursor_manager_.SetCursorSet(ui::CURSOR_SET_LARGE); + EXPECT_EQ(ui::CURSOR_SET_LARGE, cursor_manager_.GetCurrentCursorSet()); + + cursor_manager_.SetCursorSet(ui::CURSOR_SET_NORMAL); + EXPECT_EQ(ui::CURSOR_SET_NORMAL, cursor_manager_.GetCurrentCursorSet()); +} + TEST_F(CursorManagerTest, SetScale) { EXPECT_EQ(1.f, cursor_manager_.GetCurrentScale()); cursor_manager_.SetScale(2.f); diff --git a/ui/views/corewm/native_cursor_manager.h b/ui/views/corewm/native_cursor_manager.h index c38fb34405..75e4c8580a 100644 --- a/ui/views/corewm/native_cursor_manager.h +++ b/ui/views/corewm/native_cursor_manager.h @@ -48,6 +48,11 @@ class VIEWS_EXPORT NativeCursorManager { float scale, views::corewm::NativeCursorManagerDelegate* delegate) = 0; + // A request to set the scale of the cursor icon. + virtual void SetCursorSet( + ui::CursorSetType cursor_set, + views::corewm::NativeCursorManagerDelegate* delegate) = 0; + // A request to set whether mouse events are disabled. At minimum, // implementer should call NativeCursorManagerDelegate:: // CommitMouseEventsEnabled() with whether mouse events are actually enabled. diff --git a/ui/views/corewm/native_cursor_manager_delegate.h b/ui/views/corewm/native_cursor_manager_delegate.h index 1e6d46a83d..ea3788f883 100644 --- a/ui/views/corewm/native_cursor_manager_delegate.h +++ b/ui/views/corewm/native_cursor_manager_delegate.h @@ -5,6 +5,7 @@ #ifndef UI_VIEWS_COREWM_NATIVE_CURSOR_MANAGER_DELEGATE_H_ #define UI_VIEWS_COREWM_NATIVE_CURSOR_MANAGER_DELEGATE_H_ +#include "ui/base/cursor/cursor.h" #include "ui/gfx/native_widget_types.h" #include "ui/views/views_export.h" @@ -21,11 +22,13 @@ class VIEWS_EXPORT NativeCursorManagerDelegate { virtual gfx::NativeCursor GetCurrentCursor() const = 0; virtual bool GetCurrentVisibility() const = 0; virtual float GetCurrentScale() const = 0; + virtual ui::CursorSetType GetCurrentCursorSet() const = 0; virtual bool GetMouseEventsEnabled() const = 0; virtual void CommitCursor(gfx::NativeCursor cursor) = 0; virtual void CommitVisibility(bool visible) = 0; virtual void CommitScale(float scale) = 0; + virtual void CommitCursorSet(ui::CursorSetType cursor_set) = 0; virtual void CommitMouseEventsEnabled(bool enabled) = 0; }; diff --git a/ui/views/corewm/tooltip_controller.cc b/ui/views/corewm/tooltip_controller.cc index 7e3d262b4f..1c17d916bb 100644 --- a/ui/views/corewm/tooltip_controller.cc +++ b/ui/views/corewm/tooltip_controller.cc @@ -256,13 +256,17 @@ void TooltipController::OnKeyEvent(ui::KeyEvent* event) { void TooltipController::OnMouseEvent(ui::MouseEvent* event) { aura::Window* target = static_cast<aura::Window*>(event->target()); switch (event->type()) { + case ui::ET_MOUSE_EXITED: + target = NULL; + // Fall through. case ui::ET_MOUSE_MOVED: case ui::ET_MOUSE_DRAGGED: if (tooltip_window_ != target) { if (tooltip_window_) tooltip_window_->RemoveObserver(this); tooltip_window_ = target; - tooltip_window_->AddObserver(this); + if (tooltip_window_) + tooltip_window_->AddObserver(this); } curr_mouse_loc_ = event->location(); if (tooltip_timer_.IsRunning()) diff --git a/ui/views/corewm/tooltip_controller_unittest.cc b/ui/views/corewm/tooltip_controller_unittest.cc index 5cb3fe6b9d..2ea2129f78 100644 --- a/ui/views/corewm/tooltip_controller_unittest.cc +++ b/ui/views/corewm/tooltip_controller_unittest.cc @@ -409,6 +409,23 @@ TEST_F(TooltipControllerTest, TooltipHidesOnTimeoutAndStaysHiddenUntilChange) { EXPECT_EQ(window, helper_->GetTooltipWindow()); } +// Verifies a mouse exit event hides the tooltips. +TEST_F(TooltipControllerTest, HideOnExit) { + view_->set_tooltip_text(ASCIIToUTF16("Tooltip Text")); + generator_->MoveMouseToCenterOf(GetWindow()); + string16 expected_tooltip = ASCIIToUTF16("Tooltip Text"); + EXPECT_EQ(expected_tooltip, aura::client::GetTooltipText(GetWindow())); + EXPECT_EQ(string16(), helper_->GetTooltipText()); + EXPECT_EQ(GetWindow(), helper_->GetTooltipWindow()); + + // Fire tooltip timer so tooltip becomes visible. + helper_->FireTooltipTimer(); + + EXPECT_TRUE(helper_->IsTooltipVisible()); + generator_->SendMouseExit(); + EXPECT_FALSE(helper_->IsTooltipVisible()); +} + } // namespace test } // namespace corewm } // namespace views diff --git a/ui/views/event_utils.h b/ui/views/event_utils.h new file mode 100644 index 0000000000..3527c507d4 --- /dev/null +++ b/ui/views/event_utils.h @@ -0,0 +1,25 @@ +// Copyright 2013 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 UI_VIEWS_EVENT_UTILS_H_ +#define UI_VIEWS_EVENT_UTILS_H_ + +#include "ui/gfx/native_widget_types.h" +#include "ui/views/views_export.h" + +namespace ui { +class LocatedEvent; +} + +namespace views { + +// Reposts a located event natively. Returns false when |event| could not be +// reposted. |event| should be in screen coordinates. |window| is the target +// window that the event will be forwarded to. Only some events are supported. +VIEWS_EXPORT bool RepostLocatedEvent(gfx::NativeWindow window, + const ui::LocatedEvent& event); + +} // namespace views + +#endif // UI_VIEWS_EVENT_UTILS_H_ diff --git a/ui/views/event_utils_aura.cc b/ui/views/event_utils_aura.cc new file mode 100644 index 0000000000..37aeb8817c --- /dev/null +++ b/ui/views/event_utils_aura.cc @@ -0,0 +1,49 @@ +// Copyright 2013 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 "ui/views/event_utils.h" + +#include "base/logging.h" +#include "base/memory/scoped_ptr.h" +#include "ui/aura/client/screen_position_client.h" +#include "ui/aura/root_window.h" +#include "ui/base/events/event.h" +#include "ui/gfx/point.h" + +using aura::client::ScreenPositionClient; + +namespace views { + +bool RepostLocatedEvent(gfx::NativeWindow window, + const ui::LocatedEvent& event) { + if (!window) + return false; + + aura::RootWindow* root_window = window->GetRootWindow(); + + gfx::Point root_loc(event.location()); + ScreenPositionClient* spc = GetScreenPositionClient(root_window); + if (!spc) + return false; + + spc->ConvertPointFromScreen(root_window, &root_loc); + + scoped_ptr<ui::LocatedEvent> relocated; + if (event.IsMouseEvent()) { + const ui::MouseEvent& orig = static_cast<const ui::MouseEvent&>(event); + relocated.reset(new ui::MouseEvent(orig)); + } else if (event.IsGestureEvent()) { + const ui::GestureEvent& orig = static_cast<const ui::GestureEvent&>(event); + relocated.reset(new ui::GestureEvent(orig)); + } else { + NOTREACHED(); + return false; + } + relocated->set_location(root_loc); + + root_window->RepostEvent(*relocated); + return true; +} + +} // namespace views diff --git a/ui/views/event_utils_win.cc b/ui/views/event_utils_win.cc new file mode 100644 index 0000000000..d9417a2e27 --- /dev/null +++ b/ui/views/event_utils_win.cc @@ -0,0 +1,59 @@ +// Copyright 2013 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 "ui/views/event_utils.h" + +#include <windowsx.h> + +#include "base/logging.h" +#include "ui/base/events/event.h" +#include "ui/base/events/event_constants.h" +#include "ui/gfx/point.h" + +namespace views { + +bool RepostLocatedEvent(gfx::NativeWindow window, + const ui::LocatedEvent& event) { + if (!window) + return false; + + // Determine whether the click was in the client area or not. + // NOTE: WM_NCHITTEST coordinates are relative to the screen. + const gfx::Point screen_loc = event.location(); + LRESULT nc_hit_result = SendMessage(window, WM_NCHITTEST, 0, + MAKELPARAM(screen_loc.x(), + screen_loc.y())); + const bool in_client_area = nc_hit_result == HTCLIENT; + + // TODO(sky): this isn't right. The event to generate should correspond with + // the event we just got. MouseEvent only tells us what is down, which may + // differ. Need to add ability to get changed button from MouseEvent. + int event_type; + int flags = event.flags(); + if (flags & ui::EF_LEFT_MOUSE_BUTTON) { + event_type = in_client_area ? WM_LBUTTONDOWN : WM_NCLBUTTONDOWN; + } else if (flags & ui::EF_MIDDLE_MOUSE_BUTTON) { + event_type = in_client_area ? WM_MBUTTONDOWN : WM_NCMBUTTONDOWN; + } else if (flags & ui::EF_RIGHT_MOUSE_BUTTON) { + event_type = in_client_area ? WM_RBUTTONDOWN : WM_NCRBUTTONDOWN; + } else { + NOTREACHED(); + return false; + } + + int window_x = screen_loc.x(); + int window_y = screen_loc.y(); + if (in_client_area) { + RECT window_bounds; + GetWindowRect(window, &window_bounds); + window_x -= window_bounds.left; + window_y -= window_bounds.top; + } + + WPARAM target = in_client_area ? event.native_event().wParam : nc_hit_result; + PostMessage(window, event_type, target, MAKELPARAM(window_x, window_y)); + return true; +} + +} // namespace views diff --git a/ui/views/mouse_constants.cc b/ui/views/mouse_constants.cc new file mode 100644 index 0000000000..b2f3b964af --- /dev/null +++ b/ui/views/mouse_constants.cc @@ -0,0 +1,12 @@ +// Copyright 2013 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 "ui/views/mouse_constants.h" + +namespace views { + +const int kMinimumMsPressedToActivate = 200; +const int kMinimumMsBetweenButtonClicks = 100; + +} // namespace views diff --git a/ui/views/mouse_constants.h b/ui/views/mouse_constants.h new file mode 100644 index 0000000000..e22c75cdd6 --- /dev/null +++ b/ui/views/mouse_constants.h @@ -0,0 +1,25 @@ +// Copyright 2013 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 UI_VIEWS_MOUSE_CONSTANTS_H_ +#define UI_VIEWS_MOUSE_CONSTANTS_H_ + +#include "base/basictypes.h" +#include "ui/views/views_export.h" + +namespace views { + +// The amount of time the mouse should be down before a mouse release is +// considered intentional. This is to prevent spurious mouse releases from +// activating controls, especially when some UI element is revealed under the +// source of the activation (ex. menus showing underneath menu buttons). +VIEWS_EXPORT extern const int kMinimumMsPressedToActivate; + +// The amount of time, in milliseconds, between clicks until they're considered +// intentionally different. +VIEWS_EXPORT extern const int kMinimumMsBetweenButtonClicks; + +} // namespace views + +#endif // UI_VIEWS_MOUSE_CONSTANTS_H_ diff --git a/ui/views/mouse_watcher_view_host.cc b/ui/views/mouse_watcher_view_host.cc index 1d420fa1cb..54412cf10d 100644 --- a/ui/views/mouse_watcher_view_host.cc +++ b/ui/views/mouse_watcher_view_host.cc @@ -50,7 +50,7 @@ bool MouseWatcherViewHost::IsMouseOverWindow() { return false; return gfx::Screen::GetScreenFor(widget->GetNativeView())-> - GetWindowAtCursorScreenPoint() == widget->GetNativeWindow(); + GetWindowUnderCursor() == widget->GetNativeWindow(); } } // namespace views diff --git a/ui/views/view.cc b/ui/views/view.cc index 73b1e4ef2f..81f0207bec 100644 --- a/ui/views/view.cc +++ b/ui/views/view.cc @@ -9,7 +9,6 @@ #include <algorithm> #include <cmath> -#include "base/auto_reset.h" #include "base/debug/trace_event.h" #include "base/logging.h" #include "base/memory/scoped_ptr.h" @@ -177,7 +176,6 @@ View::View() focus_border_(FocusBorder::CreateDashedFocusBorder()), flip_canvas_on_paint_for_rtl_ui_(false), paint_to_layer_(false), - accelerator_registration_delayed_(false), accelerator_focus_manager_(NULL), registered_accelerator_count_(0), next_focusable_view_(NULL), @@ -186,7 +184,6 @@ View::View() accessibility_focusable_(false), context_menu_controller_(NULL), drag_controller_(NULL), - currently_dragging_(false), post_dispatch_handler_(new internal::PostEventDispatchHandler(this)), native_view_accessibility_(NULL) { AddPostTargetHandler(post_dispatch_handler_.get()); @@ -196,10 +193,6 @@ View::~View() { if (parent_) parent_->RemoveChildView(this); - // If we destroy the view during a drag, AutoReset will probably write to - // freed memory. - DCHECK(!currently_dragging_); - for (Views::const_iterator i(children_.begin()); i != children_.end(); ++i) { (*i)->parent_ = NULL; if (!(*i)->owned_by_client_) @@ -1305,21 +1298,13 @@ void View::ViewHierarchyChanged(const ViewHierarchyChangedDetails& details) { void View::VisibilityChanged(View* starting_from, bool is_visible) { } -void View::NativeViewHierarchyChanged(bool attached, - gfx::NativeView native_view, - internal::RootView* root_view) { +void View::NativeViewHierarchyChanged() { FocusManager* focus_manager = GetFocusManager(); - if (!accelerator_registration_delayed_ && - accelerator_focus_manager_ && - accelerator_focus_manager_ != focus_manager) { + if (accelerator_focus_manager_ != focus_manager) { UnregisterAccelerators(true); - accelerator_registration_delayed_ = true; - } - if (accelerator_registration_delayed_ && attached) { - if (focus_manager) { + + if (focus_manager) RegisterPendingAccelerators(); - accelerator_registration_delayed_ = false; - } } } @@ -1821,14 +1806,10 @@ void View::PropagateAddNotifications( ViewHierarchyChangedImpl(true, details); } -void View::PropagateNativeViewHierarchyChanged(bool attached, - gfx::NativeView native_view, - internal::RootView* root_view) { +void View::PropagateNativeViewHierarchyChanged() { for (int i = 0, count = child_count(); i < count; ++i) - child_at(i)->PropagateNativeViewHierarchyChanged(attached, - native_view, - root_view); - NativeViewHierarchyChanged(attached, native_view, root_view); + child_at(i)->PropagateNativeViewHierarchyChanged(); + NativeViewHierarchyChanged(); } void View::ViewHierarchyChangedImpl( @@ -1838,13 +1819,8 @@ void View::ViewHierarchyChangedImpl( if (details.is_add) { // If you get this registration, you are part of a subtree that has been // added to the view hierarchy. - if (GetFocusManager()) { + if (GetFocusManager()) RegisterPendingAccelerators(); - } else { - // Delay accelerator registration until visible as we do not have - // focus manager until then. - accelerator_registration_delayed_ = true; - } } else { if (details.child == this) UnregisterAccelerators(true); @@ -1857,7 +1833,7 @@ void View::ViewHierarchyChangedImpl( if (widget) widget->UpdateRootLayers(); } else if (!details.is_add && details.child == this) { - // Make sure the layers beloning to the subtree rooted at |child| get + // Make sure the layers belonging to the subtree rooted at |child| get // removed from layers that do not belong in the same subtree. OrphanLayers(); if (use_acceleration_when_possible) { @@ -2235,9 +2211,6 @@ void View::UnregisterAccelerators(bool leave_data_intact) { if (GetWidget()) { if (accelerator_focus_manager_) { - // We may not have a FocusManager if the window containing us is being - // closed, in which case the FocusManager is being deleted so there is - // nothing to unregister. accelerator_focus_manager_->UnregisterAccelerators(this); accelerator_focus_manager_ = NULL; } @@ -2324,14 +2297,20 @@ bool View::DoDrag(const ui::LocatedEvent& event, const gfx::Point& press_pt, ui::DragDropTypes::DragEventSource source) { #if !defined(OS_MACOSX) - if (currently_dragging_) - return false; - int drag_operations = GetDragOperations(press_pt); if (drag_operations == ui::DragDropTypes::DRAG_NONE) return false; - base::AutoReset<bool> updating_focus(¤tly_dragging_, true); + Widget* widget = GetWidget(); + // We should only start a drag from an event, implying we have a widget. + DCHECK(widget); + + // Don't attempt to start a drag while in the process of dragging. This is + // especially important on X where we can get multiple mouse move events when + // we start the drag. + if (widget->dragged_view()) + return false; + OSExchangeData data; WriteDragData(press_pt, &data); @@ -2339,9 +2318,8 @@ bool View::DoDrag(const ui::LocatedEvent& event, // the RootView can detect it and avoid calling us back. gfx::Point widget_location(event.location()); ConvertPointToWidget(this, &widget_location); - GetWidget()->RunShellDrag(this, data, widget_location, drag_operations, - source); - + widget->RunShellDrag(this, data, widget_location, drag_operations, source); + // WARNING: we may have been deleted. return true; #else return false; diff --git a/ui/views/view.h b/ui/views/view.h index 337012c053..0935c51193 100644 --- a/ui/views/view.h +++ b/ui/views/view.h @@ -1032,17 +1032,13 @@ class VIEWS_EXPORT View : public ui::LayerDelegate, // invoked for that view as well as all the children recursively. virtual void VisibilityChanged(View* starting_from, bool is_visible); - // Called when the native view hierarchy changed. - // |attached| is true if that view has been attached to a new NativeView - // hierarchy, false if it has been detached. - // |native_view| is the NativeView this view was attached/detached from, and - // |root_view| is the root view associated with the NativeView. - // Views created without a native view parent don't have a focus manager. - // When this function is called they could do the processing that requires - // it - like registering accelerators, for example. - virtual void NativeViewHierarchyChanged(bool attached, - gfx::NativeView native_view, - internal::RootView* root_view); + // This method is invoked when the parent NativeView of the widget that the + // view is attached to has changed and the view hierarchy has not changed. + // ViewHierarchyChanged() is called when the parent NativeView of the widget + // that the view is attached to is changed as a result of changing the view + // hierarchy. Overriding this method is useful for tracking which + // FocusManager manages this view. + virtual void NativeViewHierarchyChanged(); // Painting ------------------------------------------------------------------ @@ -1260,9 +1256,7 @@ class VIEWS_EXPORT View : public ui::LayerDelegate, // Propagates NativeViewHierarchyChanged() notification through all the // children. - void PropagateNativeViewHierarchyChanged(bool attached, - gfx::NativeView native_view, - internal::RootView* root_view); + void PropagateNativeViewHierarchyChanged(); // Takes care of registering/unregistering accelerators if // |register_accelerators| true and calls ViewHierarchyChanged(). @@ -1503,10 +1497,6 @@ class VIEWS_EXPORT View : public ui::LayerDelegate, // Accelerators -------------------------------------------------------------- - // true if when we were added to hierarchy we were without focus manager - // attempt addition when ancestor chain changed. - bool accelerator_registration_delayed_; - // Focus manager accelerators registered on. FocusManager* accelerator_focus_manager_; @@ -1540,11 +1530,6 @@ class VIEWS_EXPORT View : public ui::LayerDelegate, DragController* drag_controller_; - // True while we're performing DoDrag(). On X11, we can have multiple mouse - // move events in our event queue when we start a drag, so we need a way to - // ignore events after the first one. - bool currently_dragging_; - // Input -------------------------------------------------------------------- scoped_ptr<internal::PostEventDispatchHandler> post_dispatch_handler_; diff --git a/ui/views/view_unittest.cc b/ui/views/view_unittest.cc index dfb604ec5c..6cd2a002a3 100644 --- a/ui/views/view_unittest.cc +++ b/ui/views/view_unittest.cc @@ -1545,98 +1545,71 @@ TEST_F(ViewTest, DISABLED_RerouteMouseWheelTest) { //////////////////////////////////////////////////////////////////////////////// // Native view hierachy //////////////////////////////////////////////////////////////////////////////// -class TestNativeViewHierarchy : public View { +class ToplevelWidgetObserverView : public View { public: - TestNativeViewHierarchy() { + ToplevelWidgetObserverView() : toplevel_(NULL) { } - - virtual void NativeViewHierarchyChanged( - bool attached, - gfx::NativeView native_view, - internal::RootView* root_view) OVERRIDE { - NotificationInfo info; - info.attached = attached; - info.native_view = native_view; - info.root_view = root_view; - notifications_.push_back(info); - }; - struct NotificationInfo { - bool attached; - gfx::NativeView native_view; - internal::RootView* root_view; - }; - static const size_t kTotalViews = 2; - std::vector<NotificationInfo> notifications_; -}; - -class TestChangeNativeViewHierarchy { - public: - explicit TestChangeNativeViewHierarchy(ViewTest *view_test) { - view_test_ = view_test; - native_host_ = new NativeViewHost(); - host_ = new Widget; - Widget::InitParams params = - view_test->CreateParams(Widget::InitParams::TYPE_POPUP); - params.bounds = gfx::Rect(0, 0, 500, 300); - host_->Init(params); - host_->GetRootView()->AddChildView(native_host_); - for (size_t i = 0; i < TestNativeViewHierarchy::kTotalViews; ++i) { - windows_[i] = new Widget; - Widget::InitParams params(Widget::InitParams::TYPE_CONTROL); - params.parent = host_->GetNativeView(); - params.bounds = gfx::Rect(0, 0, 500, 300); - windows_[i]->Init(params); - root_views_[i] = windows_[i]->GetRootView(); - test_views_[i] = new TestNativeViewHierarchy; - root_views_[i]->AddChildView(test_views_[i]); - } + virtual ~ToplevelWidgetObserverView() { } - ~TestChangeNativeViewHierarchy() { - for (size_t i = 0; i < TestNativeViewHierarchy::kTotalViews; ++i) { - windows_[i]->Close(); + // View overrides: + virtual void ViewHierarchyChanged( + const ViewHierarchyChangedDetails& details) OVERRIDE { + if (details.is_add) { + toplevel_ = GetWidget() ? GetWidget()->GetTopLevelWidget() : NULL; + } else { + toplevel_ = NULL; } - host_->Close(); - // Will close and self-delete widgets - no need to manually delete them. - view_test_->RunPendingMessages(); } - - void CheckChangingHierarhy() { - size_t i; - for (i = 0; i < TestNativeViewHierarchy::kTotalViews; ++i) { - // TODO(georgey): use actual hierarchy changes to send notifications. - static_cast<internal::RootView*>(root_views_[i])-> - NotifyNativeViewHierarchyChanged(false, host_->GetNativeView()); - static_cast<internal::RootView*>(root_views_[i])-> - NotifyNativeViewHierarchyChanged(true, host_->GetNativeView()); - } - for (i = 0; i < TestNativeViewHierarchy::kTotalViews; ++i) { - ASSERT_EQ(static_cast<size_t>(2), test_views_[i]->notifications_.size()); - EXPECT_FALSE(test_views_[i]->notifications_[0].attached); - EXPECT_EQ(host_->GetNativeView(), - test_views_[i]->notifications_[0].native_view); - EXPECT_EQ(root_views_[i], test_views_[i]->notifications_[0].root_view); - EXPECT_TRUE(test_views_[i]->notifications_[1].attached); - EXPECT_EQ(host_->GetNativeView(), - test_views_[i]->notifications_[1].native_view); - EXPECT_EQ(root_views_[i], test_views_[i]->notifications_[1].root_view); - } + virtual void NativeViewHierarchyChanged() OVERRIDE { + toplevel_ = GetWidget() ? GetWidget()->GetTopLevelWidget() : NULL; } - NativeViewHost* native_host_; - Widget* host_; - Widget* windows_[TestNativeViewHierarchy::kTotalViews]; - View* root_views_[TestNativeViewHierarchy::kTotalViews]; - TestNativeViewHierarchy* test_views_[TestNativeViewHierarchy::kTotalViews]; - ViewTest* view_test_; + Widget* toplevel() { return toplevel_; } + + private: + Widget* toplevel_; + + DISALLOW_COPY_AND_ASSIGN(ToplevelWidgetObserverView); }; -TEST_F(ViewTest, ChangeNativeViewHierarchyChangeHierarchy) { - // TODO(georgey): Fix the test for Linux -#if defined(OS_WIN) - TestChangeNativeViewHierarchy test(this); - test.CheckChangingHierarhy(); -#endif +// Test that a view can track the current top level widget by overriding +// View::ViewHierarchyChanged() and View::NativeViewHierarchyChanged(). +TEST_F(ViewTest, NativeViewHierarchyChanged) { + scoped_ptr<Widget> toplevel1(new Widget); + Widget::InitParams toplevel1_params = + CreateParams(Widget::InitParams::TYPE_POPUP); + toplevel1_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; + toplevel1->Init(toplevel1_params); + + scoped_ptr<Widget> toplevel2(new Widget); + Widget::InitParams toplevel2_params = + CreateParams(Widget::InitParams::TYPE_POPUP); + toplevel2_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; + toplevel2->Init(toplevel2_params); + + Widget* child = new Widget; + Widget::InitParams child_params(Widget::InitParams::TYPE_CONTROL); + child_params.parent = toplevel1->GetNativeView(); + child->Init(child_params); + + ToplevelWidgetObserverView* observer_view = + new ToplevelWidgetObserverView(); + EXPECT_EQ(NULL, observer_view->toplevel()); + + child->SetContentsView(observer_view); + EXPECT_EQ(toplevel1, observer_view->toplevel()); + + Widget::ReparentNativeView(child->GetNativeView(), + toplevel2->GetNativeView()); + EXPECT_EQ(toplevel2, observer_view->toplevel()); + + observer_view->parent()->RemoveChildView(observer_view); + EXPECT_EQ(NULL, observer_view->toplevel()); + + // Make |observer_view| |child|'s contents view again so that it gets deleted + // with the widget. + child->SetContentsView(observer_view); } //////////////////////////////////////////////////////////////////////////////// diff --git a/ui/views/views.gyp b/ui/views/views.gyp index a8d444c004..34e837a7e2 100644 --- a/ui/views/views.gyp +++ b/ui/views/views.gyp @@ -275,6 +275,9 @@ 'drag_controller.h', 'drag_utils.cc', 'drag_utils.h', + 'event_utils.h', + 'event_utils_aura.cc', + 'event_utils_win.cc', 'focus/accelerator_handler.h', 'focus/accelerator_handler_aura.cc', 'focus/accelerator_handler_win.cc', @@ -314,6 +317,8 @@ 'metrics.h', 'metrics_aura.cc', 'metrics_win.cc', + 'mouse_constants.cc', + 'mouse_constants.h', 'mouse_watcher.cc', 'mouse_watcher.h', 'mouse_watcher_view_host.cc', @@ -362,6 +367,8 @@ 'widget/desktop_aura/desktop_drag_drop_client_win.h', 'widget/desktop_aura/desktop_drop_target_win.cc', 'widget/desktop_aura/desktop_drop_target_win.h', + 'widget/desktop_aura/desktop_factory_ozone.cc', + 'widget/desktop_aura/desktop_factory_ozone.h', 'widget/desktop_aura/desktop_focus_rules.cc', 'widget/desktop_aura/desktop_focus_rules.h', 'widget/desktop_aura/desktop_layout_manager.cc', @@ -371,6 +378,7 @@ 'widget/desktop_aura/desktop_native_widget_aura.cc', 'widget/desktop_aura/desktop_native_widget_aura.h', 'widget/desktop_aura/desktop_root_window_host.h', + 'widget/desktop_aura/desktop_root_window_host_ozone.cc', 'widget/desktop_aura/desktop_root_window_host_win.cc', 'widget/desktop_aura/desktop_root_window_host_win.h', 'widget/desktop_aura/desktop_root_window_host_x11.cc', @@ -382,6 +390,8 @@ 'widget/desktop_aura/desktop_screen_win.cc', 'widget/desktop_aura/desktop_screen_win.h', 'widget/desktop_aura/desktop_screen_x11.cc', + 'widget/desktop_aura/scoped_tooltip_client.cc', + 'widget/desktop_aura/scoped_tooltip_client.h', 'widget/desktop_aura/x11_desktop_handler.cc', 'widget/desktop_aura/x11_desktop_handler.h', 'widget/desktop_aura/x11_desktop_window_move_client.cc', @@ -615,6 +625,7 @@ 'test/test_widget_observer.h', 'test/views_test_base.cc', 'test/views_test_base.h', + 'widget/root_view_test_helper.h', ], 'conditions': [ ['use_aura==1', { @@ -732,19 +743,21 @@ 'ime/input_method_bridge_unittest.cc', 'layout/box_layout_unittest.cc', 'layout/grid_layout_unittest.cc', + 'run_all_unittests.cc', 'touchui/touch_selection_controller_impl_unittest.cc', 'view_model_unittest.cc', 'view_model_utils_unittest.cc', 'view_unittest.cc', - 'window/dialog_client_view_unittest.cc', - 'window/dialog_delegate_unittest.cc', + 'widget/desktop_aura/desktop_native_widget_aura_unittest.cc', 'widget/desktop_aura/desktop_screen_position_client_unittest.cc', 'widget/native_widget_aura_unittest.cc', 'widget/native_widget_unittest.cc', 'widget/native_widget_win_unittest.cc', + 'widget/root_view_unittest.cc', 'widget/widget_unittest.cc', 'widget/window_reorderer_unittest.cc', - 'run_all_unittests.cc', + 'window/dialog_client_view_unittest.cc', + 'window/dialog_delegate_unittest.cc', ], 'conditions': [ ['chromeos==0', { @@ -798,6 +811,11 @@ ['exclude', 'widget/window_reorderer_unittest.cc'] ], }], + ['use_ozone==1', { + 'sources!': [ + 'corewm/capture_controller_unittest.cc', + ], + }], ], }, # target_name: views_unittests { diff --git a/ui/views/widget/desktop_aura/desktop_cursor_loader_updater_aurax11.cc b/ui/views/widget/desktop_aura/desktop_cursor_loader_updater_aurax11.cc index e771f69be2..88f219300e 100644 --- a/ui/views/widget/desktop_aura/desktop_cursor_loader_updater_aurax11.cc +++ b/ui/views/widget/desktop_aura/desktop_cursor_loader_updater_aurax11.cc @@ -35,8 +35,12 @@ void LoadImageCursors(float device_scale_factor, ui::CursorLoader* loader) { int resource_id; gfx::Point point; for (size_t i = 0; i < arraysize(kImageCursorIds); ++i) { - bool success = ui::GetCursorDataFor(kImageCursorIds[i], device_scale_factor, - &resource_id, &point); + bool success = ui::GetCursorDataFor( + ui::CURSOR_SET_NORMAL, // Not support custom cursor set. + kImageCursorIds[i], + device_scale_factor, + &resource_id, + &point); DCHECK(success); loader->LoadImageCursor(kImageCursorIds[i], resource_id, point); } diff --git a/ui/views/widget/desktop_aura/desktop_factory_ozone.cc b/ui/views/widget/desktop_aura/desktop_factory_ozone.cc new file mode 100644 index 0000000000..e0a44890bc --- /dev/null +++ b/ui/views/widget/desktop_aura/desktop_factory_ozone.cc @@ -0,0 +1,29 @@ +// Copyright 2013 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 "ui/views/widget/desktop_aura/desktop_factory_ozone.h" + +#include "base/logging.h" + +namespace views { + +// static +DesktopFactoryOzone* DesktopFactoryOzone::impl_ = NULL; + +DesktopFactoryOzone::DesktopFactoryOzone() { +} + +DesktopFactoryOzone::~DesktopFactoryOzone() { +} + +DesktopFactoryOzone* DesktopFactoryOzone::GetInstance() { + CHECK(impl_) << "DesktopFactoryOzone accessed before constructed"; + return impl_; +} + +void DesktopFactoryOzone::SetInstance(DesktopFactoryOzone* impl) { + impl_ = impl; +} + +} // namespace views diff --git a/ui/views/widget/desktop_aura/desktop_factory_ozone.h b/ui/views/widget/desktop_aura/desktop_factory_ozone.h new file mode 100644 index 0000000000..18cf36e869 --- /dev/null +++ b/ui/views/widget/desktop_aura/desktop_factory_ozone.h @@ -0,0 +1,46 @@ +// Copyright 2013 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 UI_VIEWS_WIDGET_DESKTOP_AURA_DESKTOP_FACTORY_OZONE_H_ +#define UI_VIEWS_WIDGET_DESKTOP_AURA_DESKTOP_FACTORY_OZONE_H_ + +#include "ui/views/views_export.h" + +namespace gfx { +class Rect; +} + +namespace views { +class DesktopNativeWidgetAura; +class DesktopRootWindowHost; + +namespace internal { +class NativeWidgetDelegate; +} + +class VIEWS_EXPORT DesktopFactoryOzone { + public: + DesktopFactoryOzone(); + virtual ~DesktopFactoryOzone(); + + // Returns the instance. + static DesktopFactoryOzone* GetInstance(); + + // Sets the implementation delegate. Ownership is retained by the caller. + static void SetInstance(DesktopFactoryOzone* impl); + + // Delegates implementation of DesktopRootWindowHost::Create externally to + // Ozone implementation. + virtual DesktopRootWindowHost* CreateRootWindowHost( + internal::NativeWidgetDelegate* native_widget_delegate, + DesktopNativeWidgetAura* desktop_native_widget_aura, + const gfx::Rect& initial_bounds) = 0; + + private: + static DesktopFactoryOzone* impl_; // not owned +}; + +} // namespace views + +#endif // UI_VIEWS_WIDGET_DESKTOP_AURA_DESKTOP_FACTORY_OZONE_H_ diff --git a/ui/views/widget/desktop_aura/desktop_native_cursor_manager.cc b/ui/views/widget/desktop_aura/desktop_native_cursor_manager.cc index a9b902dee4..eed97f32af 100644 --- a/ui/views/widget/desktop_aura/desktop_native_cursor_manager.cc +++ b/ui/views/widget/desktop_aura/desktop_native_cursor_manager.cc @@ -68,6 +68,11 @@ void DesktopNativeCursorManager::SetVisibility( root_window_->OnCursorVisibilityChanged(visible); } +void DesktopNativeCursorManager::SetCursorSet( + ui::CursorSetType cursor_set, + views::corewm::NativeCursorManagerDelegate* delegate) { + NOTIMPLEMENTED(); +} void DesktopNativeCursorManager::SetScale( float scale, diff --git a/ui/views/widget/desktop_aura/desktop_native_cursor_manager.h b/ui/views/widget/desktop_aura/desktop_native_cursor_manager.h index f6a800bfb9..563131d92c 100644 --- a/ui/views/widget/desktop_aura/desktop_native_cursor_manager.h +++ b/ui/views/widget/desktop_aura/desktop_native_cursor_manager.h @@ -49,6 +49,9 @@ class VIEWS_EXPORT DesktopNativeCursorManager virtual void SetVisibility( bool visible, views::corewm::NativeCursorManagerDelegate* delegate) OVERRIDE; + virtual void SetCursorSet( + ui::CursorSetType cursor_set, + views::corewm::NativeCursorManagerDelegate* delegate) OVERRIDE; virtual void SetScale( float scale, views::corewm::NativeCursorManagerDelegate* delegate) OVERRIDE; diff --git a/ui/views/widget/desktop_aura/desktop_native_widget_aura.cc b/ui/views/widget/desktop_aura/desktop_native_widget_aura.cc index 859decc988..cf068755f5 100644 --- a/ui/views/widget/desktop_aura/desktop_native_widget_aura.cc +++ b/ui/views/widget/desktop_aura/desktop_native_widget_aura.cc @@ -29,13 +29,13 @@ #include "ui/views/corewm/input_method_event_filter.h" #include "ui/views/corewm/shadow_controller.h" #include "ui/views/corewm/shadow_types.h" -#include "ui/views/corewm/tooltip_controller.h" #include "ui/views/corewm/visibility_controller.h" #include "ui/views/corewm/window_modality_controller.h" #include "ui/views/drag_utils.h" #include "ui/views/ime/input_method.h" #include "ui/views/ime/input_method_bridge.h" #include "ui/views/widget/desktop_aura/desktop_root_window_host.h" +#include "ui/views/widget/desktop_aura/scoped_tooltip_client.h" #include "ui/views/widget/drop_helper.h" #include "ui/views/widget/native_widget_aura.h" #include "ui/views/widget/native_widget_aura_window_observer.h" @@ -56,38 +56,41 @@ DEFINE_WINDOW_PROPERTY_KEY(DesktopNativeWidgetAura*, namespace { -// This class provides functionality to create a top level fullscreen widget to -// host a child window. -class DesktopNativeWidgetFullscreenHandler : public aura::WindowObserver { +// This class provides functionality to create a top level widget to host a +// child window. +class DesktopNativeWidgetTopLevelHandler : public aura::WindowObserver { public: - // This function creates a full screen widget with the bounds passed in - // which eventually becomes the parent of the child window passed in. + // This function creates a widget with the bounds passed in which eventually + // becomes the parent of the child window passed in. static aura::Window* CreateParentWindow(aura::Window* child_window, - const gfx::Rect& bounds) { - // This instance will get deleted when the fullscreen widget is destroyed. - DesktopNativeWidgetFullscreenHandler* full_screen_handler = - new DesktopNativeWidgetFullscreenHandler; + const gfx::Rect& bounds, + bool full_screen) { + // This instance will get deleted when the widget is destroyed. + DesktopNativeWidgetTopLevelHandler* top_level_handler = + new DesktopNativeWidgetTopLevelHandler; child_window->SetBounds(gfx::Rect(bounds.size())); Widget::InitParams init_params; - init_params.type = Widget::InitParams::TYPE_WINDOW; + init_params.type = full_screen ? Widget::InitParams::TYPE_WINDOW : + Widget::InitParams::TYPE_POPUP; init_params.bounds = bounds; init_params.ownership = Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET; init_params.layer_type = ui::LAYER_NOT_DRAWN; + init_params.accept_events = full_screen; - // This widget instance will get deleted when the fullscreen window is + // This widget instance will get deleted when the window is // destroyed. - full_screen_handler->full_screen_widget_ = new Widget(); - full_screen_handler->full_screen_widget_->Init(init_params); + top_level_handler->top_level_widget_ = new Widget(); + top_level_handler->top_level_widget_->Init(init_params); - full_screen_handler->full_screen_widget_->SetFullscreen(true); - full_screen_handler->full_screen_widget_->Show(); + top_level_handler->top_level_widget_->SetFullscreen(full_screen); + top_level_handler->top_level_widget_->Show(); aura::Window* native_window = - full_screen_handler->full_screen_widget_->GetNativeView(); - child_window->AddObserver(full_screen_handler); - native_window->AddObserver(full_screen_handler); + top_level_handler->top_level_widget_->GetNativeView(); + child_window->AddObserver(top_level_handler); + native_window->AddObserver(top_level_handler); return native_window; } @@ -97,33 +100,33 @@ class DesktopNativeWidgetFullscreenHandler : public aura::WindowObserver { // If the widget is being destroyed by the OS then we should not try and // destroy it again. - if (full_screen_widget_ && - window == full_screen_widget_->GetNativeView()) { - full_screen_widget_ = NULL; + if (top_level_widget_ && + window == top_level_widget_->GetNativeView()) { + top_level_widget_ = NULL; return; } - if (full_screen_widget_) { - DCHECK(full_screen_widget_->GetNativeView()); - full_screen_widget_->GetNativeView()->RemoveObserver(this); - // When we receive a notification that the child of the fullscreen window - // created above is being destroyed we go ahead and initiate the - // destruction of the corresponding widget. - full_screen_widget_->Close(); - full_screen_widget_ = NULL; + if (top_level_widget_) { + DCHECK(top_level_widget_->GetNativeView()); + top_level_widget_->GetNativeView()->RemoveObserver(this); + // When we receive a notification that the child of the window created + // above is being destroyed we go ahead and initiate the destruction of + // the corresponding widget. + top_level_widget_->Close(); + top_level_widget_ = NULL; } delete this; } private: - DesktopNativeWidgetFullscreenHandler() - : full_screen_widget_(NULL) {} + DesktopNativeWidgetTopLevelHandler() + : top_level_widget_(NULL) {} - virtual ~DesktopNativeWidgetFullscreenHandler() {} + virtual ~DesktopNativeWidgetTopLevelHandler() {} - Widget* full_screen_widget_; + Widget* top_level_widget_; - DISALLOW_COPY_AND_ASSIGN(DesktopNativeWidgetFullscreenHandler); + DISALLOW_COPY_AND_ASSIGN(DesktopNativeWidgetTopLevelHandler); }; class DesktopNativeWidgetAuraStackingClient : @@ -141,10 +144,11 @@ class DesktopNativeWidgetAuraStackingClient : virtual aura::Window* GetDefaultParent(aura::Window* context, aura::Window* window, const gfx::Rect& bounds) OVERRIDE { - if (window->GetProperty(aura::client::kShowStateKey) == - ui::SHOW_STATE_FULLSCREEN) { - return DesktopNativeWidgetFullscreenHandler::CreateParentWindow(window, - bounds); + bool full_screen = window->GetProperty(aura::client::kShowStateKey) == + ui::SHOW_STATE_FULLSCREEN; + if (full_screen || window->type() == aura::client::WINDOW_TYPE_MENU) { + return DesktopNativeWidgetTopLevelHandler::CreateParentWindow( + window, bounds, full_screen); } return root_window_; } @@ -256,11 +260,8 @@ void DesktopNativeWidgetAura::InitNativeWidget( aura::client::SetDragDropDelegate(window_, this); tooltip_manager_.reset(new views::TooltipManagerAura(window_, GetWidget())); - tooltip_controller_.reset( - new corewm::TooltipController(gfx::SCREEN_TYPE_NATIVE)); - aura::client::SetTooltipClient(root_window_.get(), - tooltip_controller_.get()); - root_window_->AddPreTargetHandler(tooltip_controller_.get()); + + scoped_tooltip_client_.reset(new ScopedTooltipClient(root_window_.get())); if (params.opacity == Widget::InitParams::TRANSLUCENT_WINDOW) { visibility_controller_.reset(new views::corewm::VisibilityController); @@ -716,11 +717,7 @@ void DesktopNativeWidgetAura::OnWindowDestroying() { shadow_controller_.reset(); // The DesktopRootWindowHost implementation sends OnNativeWidgetDestroying(). tooltip_manager_.reset(); - if (tooltip_controller_.get()) { - root_window_->RemovePreTargetHandler(tooltip_controller_.get()); - tooltip_controller_.reset(); - aura::client::SetTooltipClient(root_window_.get(), NULL); - } + scoped_tooltip_client_.reset(); if (window_modality_controller_) { root_window_->RemovePreTargetHandler(window_modality_controller_.get()); window_modality_controller_.reset(); diff --git a/ui/views/widget/desktop_aura/desktop_native_widget_aura.h b/ui/views/widget/desktop_aura/desktop_native_widget_aura.h index ce95139529..1b25199e75 100644 --- a/ui/views/widget/desktop_aura/desktop_native_widget_aura.h +++ b/ui/views/widget/desktop_aura/desktop_native_widget_aura.h @@ -29,7 +29,6 @@ class CompoundEventFilter; class InputMethodEventFilter; class ScopedCaptureClient; class ShadowController; -class TooltipController; class VisibilityController; class WindowModalityController; } @@ -37,6 +36,7 @@ class WindowModalityController; class DesktopRootWindowHost; class DropHelper; class NativeWidgetAuraWindowObserver; +class ScopedTooltipClient; class TooltipManagerAura; class WindowReorderer; @@ -247,7 +247,7 @@ class VIEWS_EXPORT DesktopNativeWidgetAura scoped_ptr<DropHelper> drop_helper_; int last_drop_operation_; - scoped_ptr<corewm::TooltipController> tooltip_controller_; + scoped_ptr<ScopedTooltipClient> scoped_tooltip_client_; scoped_ptr<TooltipManagerAura> tooltip_manager_; scoped_ptr<views::corewm::VisibilityController> visibility_controller_; diff --git a/ui/views/widget/desktop_aura/desktop_native_widget_aura_unittest.cc b/ui/views/widget/desktop_aura/desktop_native_widget_aura_unittest.cc new file mode 100644 index 0000000000..1342abaa31 --- /dev/null +++ b/ui/views/widget/desktop_aura/desktop_native_widget_aura_unittest.cc @@ -0,0 +1,27 @@ +// Copyright 2013 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 "ui/aura/window.h" +#include "ui/views/test/views_test_base.h" +#include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" +#include "ui/views/widget/widget.h" + +namespace views { + +typedef ViewsTestBase DesktopNativeWidgetAuraTest; + +// Verifies creating a Widget with a parent that is not in a RootWindow doesn't +// crash. +TEST_F(DesktopNativeWidgetAuraTest, CreateWithParentNotInRootWindow) { + scoped_ptr<aura::Window> window(new aura::Window(NULL)); + Widget widget; + Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_WINDOW); + params.bounds = gfx::Rect(0, 0, 200, 200); + params.parent = window.get(); + params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; + params.native_widget = new DesktopNativeWidgetAura(&widget); + widget.Init(params); +} + +} // namespace views diff --git a/ui/views/widget/desktop_aura/desktop_root_window_host_ozone.cc b/ui/views/widget/desktop_aura/desktop_root_window_host_ozone.cc new file mode 100644 index 0000000000..ff905a3e58 --- /dev/null +++ b/ui/views/widget/desktop_aura/desktop_root_window_host_ozone.cc @@ -0,0 +1,22 @@ +// Copyright 2013 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 "ui/aura/root_window_host.h" +#include "ui/views/widget/desktop_aura/desktop_root_window_host.h" +#include "ui/views/widget/desktop_aura/desktop_factory_ozone.h" + +namespace views { + +DesktopRootWindowHost* DesktopRootWindowHost::Create( + internal::NativeWidgetDelegate* native_widget_delegate, + DesktopNativeWidgetAura* desktop_native_widget_aura, + const gfx::Rect& initial_bounds) { + DesktopFactoryOzone* d_factory = DesktopFactoryOzone::GetInstance(); + + return d_factory->CreateRootWindowHost(native_widget_delegate, + desktop_native_widget_aura, + initial_bounds); +} + +} // namespace views diff --git a/ui/views/widget/desktop_aura/desktop_root_window_host_win.cc b/ui/views/widget/desktop_aura/desktop_root_window_host_win.cc index 52b1b506f4..c2e2e88309 100644 --- a/ui/views/widget/desktop_aura/desktop_root_window_host_win.cc +++ b/ui/views/widget/desktop_aura/desktop_root_window_host_win.cc @@ -108,9 +108,8 @@ aura::RootWindow* DesktopRootWindowHostWin::Init( native_widget_delegate_); HWND parent_hwnd = NULL; - aura::Window* parent_window = params.parent; - if (parent_window) - parent_hwnd = parent_window->GetRootWindow()->GetAcceleratedWidget(); + if (params.parent && params.parent->GetRootWindow()) + parent_hwnd = params.parent->GetRootWindow()->GetAcceleratedWidget(); message_handler_->set_remove_standard_frame(params.remove_standard_frame); @@ -123,13 +122,7 @@ aura::RootWindow* DesktopRootWindowHostWin::Init( rw_params.host = this; root_window_ = new aura::RootWindow(rw_params); - // TODO(beng): We probably need to move these two calls to some function that - // can change depending on the native-ness of the frame. For right - // now in the hack-n-slash days of win-aura, we can just - // unilaterally turn this on. - root_window_->compositor()->SetHostHasTransparentBackground(true); - root_window_->SetTransparent(true); - + SetWindowTransparency(); root_window_->Init(); root_window_->AddChild(content_window_); @@ -345,6 +338,7 @@ bool DesktopRootWindowHostWin::ShouldUseNativeFrame() { void DesktopRootWindowHostWin::FrameTypeChanged() { message_handler_->FrameTypeChanged(); + SetWindowTransparency(); } NonClientFrameView* DesktopRootWindowHostWin::CreateNonClientFrameView() { @@ -354,6 +348,7 @@ NonClientFrameView* DesktopRootWindowHostWin::CreateNonClientFrameView() { void DesktopRootWindowHostWin::SetFullscreen(bool fullscreen) { message_handler_->fullscreen_handler()->SetFullscreen(fullscreen); + SetWindowTransparency(); } bool DesktopRootWindowHostWin::IsFullscreen() const { @@ -413,6 +408,7 @@ void DesktopRootWindowHostWin::Hide() { } void DesktopRootWindowHostWin::ToggleFullScreen() { + SetWindowTransparency(); } // GetBounds and SetBounds work in pixel coordinates, whereas other get/set @@ -864,6 +860,12 @@ HWND DesktopRootWindowHostWin::GetHWND() const { return message_handler_->hwnd(); } +void DesktopRootWindowHostWin::SetWindowTransparency() { + bool transparent = ShouldUseNativeFrame() && !IsFullscreen(); + root_window_->compositor()->SetHostHasTransparentBackground(transparent); + root_window_->SetTransparent(transparent); +} + //////////////////////////////////////////////////////////////////////////////// // DesktopRootWindowHost, public: diff --git a/ui/views/widget/desktop_aura/desktop_root_window_host_win.h b/ui/views/widget/desktop_aura/desktop_root_window_host_win.h index 59e54d83e2..028e6084d2 100644 --- a/ui/views/widget/desktop_aura/desktop_root_window_host_win.h +++ b/ui/views/widget/desktop_aura/desktop_root_window_host_win.h @@ -207,6 +207,8 @@ class VIEWS_EXPORT DesktopRootWindowHostWin HWND GetHWND() const; private: + void SetWindowTransparency(); + // We are owned by the RootWindow, but we have to have a back pointer to it. aura::RootWindow* root_window_; diff --git a/ui/views/widget/desktop_aura/desktop_screen_x11.cc b/ui/views/widget/desktop_aura/desktop_screen_x11.cc index 77dbaa497a..e581b834f8 100644 --- a/ui/views/widget/desktop_aura/desktop_screen_x11.cc +++ b/ui/views/widget/desktop_aura/desktop_screen_x11.cc @@ -38,8 +38,11 @@ class DesktopScreenX11 : public gfx::Screen { // Overridden from gfx::Screen: virtual bool IsDIPEnabled() OVERRIDE; virtual gfx::Point GetCursorScreenPoint() OVERRIDE; - virtual gfx::NativeWindow GetWindowAtCursorScreenPoint() OVERRIDE; - virtual int GetNumDisplays() OVERRIDE; + virtual gfx::NativeWindow GetWindowUnderCursor() OVERRIDE; + virtual gfx::NativeWindow GetWindowAtScreenPoint(const gfx::Point& point) + OVERRIDE; + virtual int GetNumDisplays() const OVERRIDE; + virtual std::vector<gfx::Display> GetAllDisplays() const OVERRIDE; virtual gfx::Display GetDisplayNearestWindow( gfx::NativeView window) const OVERRIDE; virtual gfx::Display GetDisplayNearestPoint( @@ -89,18 +92,29 @@ gfx::Point DesktopScreenX11::GetCursorScreenPoint() { return gfx::Point(root_x, root_y); } -gfx::NativeWindow DesktopScreenX11::GetWindowAtCursorScreenPoint() { +gfx::NativeWindow DesktopScreenX11::GetWindowUnderCursor() { // TODO(erg): Implement using the discussion at // http://codereview.chromium.org/10279005/ return NULL; } -int DesktopScreenX11::GetNumDisplays() { +gfx::NativeWindow DesktopScreenX11::GetWindowAtScreenPoint( + const gfx::Point& point) { + NOTIMPLEMENTED(); + return NULL; +} + +int DesktopScreenX11::GetNumDisplays() const { // TODO(erg): Figure this out with oshima or piman because I have no clue // about the XRandR implications here. return 1; } +std::vector<gfx::Display> DesktopScreenX11::GetAllDisplays() const { + // TODO(erg): Do the right thing once we know what that is. + return std::vector<gfx::Display>(1, GetPrimaryDisplay()); +} + gfx::Display DesktopScreenX11::GetDisplayNearestWindow( gfx::NativeView window) const { // TODO(erg): Do the right thing once we know what that is. diff --git a/ui/views/widget/desktop_aura/scoped_tooltip_client.cc b/ui/views/widget/desktop_aura/scoped_tooltip_client.cc new file mode 100644 index 0000000000..cf131022d8 --- /dev/null +++ b/ui/views/widget/desktop_aura/scoped_tooltip_client.cc @@ -0,0 +1,37 @@ +// Copyright 2013 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 "ui/views/widget/desktop_aura/scoped_tooltip_client.h" + +#include "ui/aura/root_window.h" +#include "ui/views/corewm/tooltip_controller.h" + +namespace views { + +// static +corewm::TooltipController* ScopedTooltipClient::tooltip_controller_ = NULL; + +// static +int ScopedTooltipClient::scoped_tooltip_client_count_ = 0; + +ScopedTooltipClient::ScopedTooltipClient(aura::RootWindow* root_window) + : root_window_(root_window) { + if (scoped_tooltip_client_count_++ == 0) { + tooltip_controller_ = + new corewm::TooltipController(gfx::SCREEN_TYPE_NATIVE); + } + aura::client::SetTooltipClient(root_window_, tooltip_controller_); + root_window_->AddPreTargetHandler(tooltip_controller_); +} + +ScopedTooltipClient::~ScopedTooltipClient() { + root_window_->RemovePreTargetHandler(tooltip_controller_); + aura::client::SetTooltipClient(root_window_, NULL); + if (--scoped_tooltip_client_count_ == 0) { + delete tooltip_controller_; + tooltip_controller_ = NULL; + } +} + +} // namespace views diff --git a/ui/views/widget/desktop_aura/scoped_tooltip_client.h b/ui/views/widget/desktop_aura/scoped_tooltip_client.h new file mode 100644 index 0000000000..bb3e57b9d2 --- /dev/null +++ b/ui/views/widget/desktop_aura/scoped_tooltip_client.h @@ -0,0 +1,43 @@ +// Copyright 2013 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 UI_VIEWS_WIDGET_DESKTOP_AURA_SCOPED_TOOLTIP_CLIENT_H_ +#define UI_VIEWS_WIDGET_DESKTOP_AURA_SCOPED_TOOLTIP_CLIENT_H_ + +#include "base/basictypes.h" + +namespace aura { +class RootWindow; +} + +namespace views { + +namespace corewm { +class TooltipController; +} + +// ScopedTooltipClient is responsible for installing a TooltipClient +// implementation on a RootWindow. Additionally it ensures only one +// TooltipController is only ever created. In this way all +// DesktopNativeWidgetAuras share the same TooltipClient. +class ScopedTooltipClient { + public: + explicit ScopedTooltipClient(aura::RootWindow* root_window); + ~ScopedTooltipClient(); + + private: + // Single TooltipController. + static corewm::TooltipController* tooltip_controller_; + + // Number of ScopedTooltipClients created. + static int scoped_tooltip_client_count_; + + aura::RootWindow* root_window_; + + DISALLOW_COPY_AND_ASSIGN(ScopedTooltipClient); +}; + +} // namespace views + +#endif // UI_VIEWS_WIDGET_DESKTOP_AURA_SCOPED_TOOLTIP_CLIENT_H_ diff --git a/ui/views/widget/native_widget_aura.cc b/ui/views/widget/native_widget_aura.cc index 5348f24b20..f9ebed7e85 100644 --- a/ui/views/widget/native_widget_aura.cc +++ b/ui/views/widget/native_widget_aura.cc @@ -1089,7 +1089,7 @@ void NativeWidgetPrivate::ReparentNativeView(gfx::NativeView native_view, // from their previous parent. for (Widget::Widgets::iterator it = widgets.begin(); it != widgets.end(); ++it) { - (*it)->NotifyNativeViewHierarchyChanged(false, previous_parent); + (*it)->NotifyNativeViewHierarchyWillChange(); } if (new_parent) { @@ -1114,7 +1114,7 @@ void NativeWidgetPrivate::ReparentNativeView(gfx::NativeView native_view, // And now, notify them that they have a brand new parent. for (Widget::Widgets::iterator it = widgets.begin(); it != widgets.end(); ++it) { - (*it)->NotifyNativeViewHierarchyChanged(true, new_parent); + (*it)->NotifyNativeViewHierarchyChanged(); } } diff --git a/ui/views/widget/native_widget_win.cc b/ui/views/widget/native_widget_win.cc index c0b84b600f..472ff9c089 100644 --- a/ui/views/widget/native_widget_win.cc +++ b/ui/views/widget/native_widget_win.cc @@ -1009,9 +1009,7 @@ void NativeWidgetPrivate::ReparentNativeView(gfx::NativeView native_view, // from their previous parent. for (Widget::Widgets::iterator it = widgets.begin(); it != widgets.end(); ++it) { - // TODO(beng): Rename this notification to NotifyNativeViewChanging() - // and eliminate the bool parameter. - (*it)->NotifyNativeViewHierarchyChanged(false, previous_parent); + (*it)->NotifyNativeViewHierarchyWillChange(); } ::SetParent(native_view, new_parent); @@ -1019,7 +1017,7 @@ void NativeWidgetPrivate::ReparentNativeView(gfx::NativeView native_view, // And now, notify them that they have a brand new parent. for (Widget::Widgets::iterator it = widgets.begin(); it != widgets.end(); ++it) { - (*it)->NotifyNativeViewHierarchyChanged(true, new_parent); + (*it)->NotifyNativeViewHierarchyChanged(); } } diff --git a/ui/views/widget/root_view.cc b/ui/views/widget/root_view.cc index b304c520b9..efdca920a1 100644 --- a/ui/views/widget/root_view.cc +++ b/ui/views/widget/root_view.cc @@ -102,9 +102,8 @@ View* RootView::GetContentsView() { return child_count() > 0 ? child_at(0) : NULL; } -void RootView::NotifyNativeViewHierarchyChanged(bool attached, - gfx::NativeView native_view) { - PropagateNativeViewHierarchyChanged(attached, native_view, this); +void RootView::NotifyNativeViewHierarchyChanged() { + PropagateNativeViewHierarchyChanged(); } // Input ----------------------------------------------------------------------- @@ -123,8 +122,7 @@ void RootView::DispatchKeyEvent(ui::KeyEvent* event) { return; } - for (; v && v != this && !event->handled(); v = v->parent()) - DispatchEventToTarget(v, event); + DispatchKeyEventStartAt(v, event); } void RootView::DispatchScrollEvent(ui::ScrollEvent* event) { @@ -699,6 +697,19 @@ void RootView::NotifyEnterExitOfDescendant(const ui::MouseEvent& event, } } + +void RootView::DispatchKeyEventStartAt(View* view, ui::KeyEvent* event) { + if (event->handled() || !view) + return; + + for (; view && view != this; view = view->parent()) { + DispatchEventToTarget(view, event); + // Do this check here rather than in the if as |view| may have been deleted. + if (event->handled()) + return; + } +} + bool RootView::CanDispatchToTarget(ui::EventTarget* target) { return event_dispatch_target_ == target; } diff --git a/ui/views/widget/root_view.h b/ui/views/widget/root_view.h index b89ab8fe8e..5d206b24cd 100644 --- a/ui/views/widget/root_view.h +++ b/ui/views/widget/root_view.h @@ -16,6 +16,7 @@ namespace views { namespace test { +class RootViewTestHelper; class WidgetTest; } @@ -60,8 +61,7 @@ class VIEWS_EXPORT RootView : public View, View* GetContentsView(); // Called when parent of the host changed. - void NotifyNativeViewHierarchyChanged(bool attached, - gfx::NativeView native_view); + void NotifyNativeViewHierarchyChanged(); // Input --------------------------------------------------------------------- @@ -127,6 +127,7 @@ class VIEWS_EXPORT RootView : public View, private: friend class ::views::View; friend class ::views::Widget; + friend class ::views::test::RootViewTestHelper; friend class ::views::test::WidgetTest; // Input --------------------------------------------------------------------- @@ -153,6 +154,10 @@ class VIEWS_EXPORT RootView : public View, View* view, View* sibling); + // Dispatches the KeyEvent to |view| and ancestors until the event is + // handled. + void DispatchKeyEventStartAt(View* view, ui::KeyEvent* event); + // Overridden from ui::EventDispatcherDelegate: virtual bool CanDispatchToTarget(ui::EventTarget* target) OVERRIDE; diff --git a/ui/views/widget/root_view_test_helper.h b/ui/views/widget/root_view_test_helper.h new file mode 100644 index 0000000000..a26396730b --- /dev/null +++ b/ui/views/widget/root_view_test_helper.h @@ -0,0 +1,33 @@ +// Copyright 2013 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 UI_VIEWS_WIDGET_ROOT_VIEW_TEST_HELPER_H_ +#define UI_VIEWS_WIDGET_ROOT_VIEW_TEST_HELPER_H_ + +#include "ui/views/widget/root_view.h" + +namespace views { +namespace test { + +class RootViewTestHelper { + public: + explicit RootViewTestHelper(internal::RootView* root_view) + : root_view_(root_view) { + } + ~RootViewTestHelper() {} + + void DispatchKeyEventStartAt(View* view, ui::KeyEvent* event) { + root_view_->DispatchKeyEventStartAt(view, event); + } + + private: + internal::RootView* root_view_; + + DISALLOW_COPY_AND_ASSIGN(RootViewTestHelper); +}; + +} // namespace test +} // namespace views + +#endif // UI_VIEWS_WIDGET_ROOT_VIEW_TEST_HELPER_H_ diff --git a/ui/views/widget/root_view_unittest.cc b/ui/views/widget/root_view_unittest.cc new file mode 100644 index 0000000000..ebe20d6534 --- /dev/null +++ b/ui/views/widget/root_view_unittest.cc @@ -0,0 +1,55 @@ +// Copyright 2013 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 "ui/views/test/views_test_base.h" +#include "ui/views/widget/root_view_test_helper.h" + +namespace views { +namespace test { + +typedef ViewsTestBase RootViewTest; + +class DeleteOnKeyEventView : public View { + public: + explicit DeleteOnKeyEventView(bool* set_on_key) : set_on_key_(set_on_key) {} + virtual ~DeleteOnKeyEventView() {} + + virtual bool OnKeyPressed(const ui::KeyEvent& event) OVERRIDE { + *set_on_key_ = true; + delete this; + return true; + } + + private: + // Set to true in OnKeyPressed(). + bool* set_on_key_; + + DISALLOW_COPY_AND_ASSIGN(DeleteOnKeyEventView); +}; + +// Verifies deleting a View in OnKeyPressed() doesn't crash. +TEST_F(RootViewTest, DeleteViewDuringKeyEventDispatch) { + Widget widget; + Widget::InitParams init_params = + CreateParams(Widget::InitParams::TYPE_POPUP); + init_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; + widget.Init(init_params); + + bool got_key_event = false; + + View* content = new View; + widget.SetContentsView(content); + + View* child = new DeleteOnKeyEventView(&got_key_event); + content->AddChildView(child); + + ui::KeyEvent key_event(ui::ET_KEY_PRESSED, ui::VKEY_ESCAPE, 0, false); + RootViewTestHelper test_helper( + static_cast<internal::RootView*>(widget.GetRootView())); + test_helper.DispatchKeyEventStartAt(child, &key_event); + EXPECT_TRUE(got_key_event); +} + +} // namespace test +} // namespace views diff --git a/ui/views/widget/tooltip_manager.cc b/ui/views/widget/tooltip_manager.cc index f600a12071..af51f0d0dd 100644 --- a/ui/views/widget/tooltip_manager.cc +++ b/ui/views/widget/tooltip_manager.cc @@ -9,9 +9,7 @@ #include "base/strings/string_split.h" #include "base/strings/utf_string_conversions.h" #include "ui/base/text/text_elider.h" -#include "ui/gfx/font.h" - -namespace { +#include "ui/gfx/text_utils.h" // Maximum number of characters we allow in a tooltip. const size_t kMaxTooltipLength = 1024; @@ -19,8 +17,6 @@ const size_t kMaxTooltipLength = 1024; // Maximum number of lines we allow in the tooltip. const size_t kMaxLines = 6; -} // namespace - namespace views { // static @@ -49,13 +45,14 @@ void TooltipManager::TrimTooltipToFit(string16* text, *line_count = static_cast<int>(lines.size()); // Format each line to fit. - gfx::Font font = GetDefaultFont(); + const gfx::FontList& font_list = GetDefaultFontList(); string16 result; for (std::vector<string16>::iterator i = lines.begin(); i != lines.end(); ++i) { string16 elided_text = - ui::ElideText(*i, font, available_width, ui::ELIDE_AT_END); - *max_width = std::max(*max_width, font.GetStringWidth(elided_text)); + ui::ElideText(*i, font_list, available_width, ui::ELIDE_AT_END); + *max_width = std::max(*max_width, + gfx::GetStringWidth(elided_text, font_list)); if (!result.empty()) result.push_back('\n'); result.append(elided_text); diff --git a/ui/views/widget/tooltip_manager.h b/ui/views/widget/tooltip_manager.h index f8601dd6ae..1228f5a509 100644 --- a/ui/views/widget/tooltip_manager.h +++ b/ui/views/widget/tooltip_manager.h @@ -13,7 +13,7 @@ #include "ui/views/views_export.h" namespace gfx { -class Font; +class FontList; } // namespace gfx namespace views { @@ -30,7 +30,7 @@ class VIEWS_EXPORT TooltipManager { static int GetTooltipHeight(); // Returns the default font used by tooltips. - static gfx::Font GetDefaultFont(); + static const gfx::FontList& GetDefaultFontList(); // Returns the maximum width of the tooltip. |x| and |y| give the location // the tooltip is to be displayed on in screen coordinates. |context| is diff --git a/ui/views/widget/tooltip_manager_aura.cc b/ui/views/widget/tooltip_manager_aura.cc index f7a47613fc..632946339a 100644 --- a/ui/views/widget/tooltip_manager_aura.cc +++ b/ui/views/widget/tooltip_manager_aura.cc @@ -8,7 +8,6 @@ #include "ui/aura/client/tooltip_client.h" #include "ui/aura/root_window.h" #include "ui/base/resource/resource_bundle.h" -#include "ui/gfx/font.h" #include "ui/gfx/rect.h" #include "ui/gfx/screen.h" #include "ui/views/widget/widget.h" @@ -23,8 +22,8 @@ int TooltipManager::GetTooltipHeight() { } // static -gfx::Font TooltipManager::GetDefaultFont() { - return ui::ResourceBundle::GetSharedInstance().GetFont( +const gfx::FontList& TooltipManager::GetDefaultFontList() { + return ui::ResourceBundle::GetSharedInstance().GetFontList( ui::ResourceBundle::BaseFont); } diff --git a/ui/views/widget/tooltip_manager_win.cc b/ui/views/widget/tooltip_manager_win.cc index fa0ad45d71..803fa15a73 100644 --- a/ui/views/widget/tooltip_manager_win.cc +++ b/ui/views/widget/tooltip_manager_win.cc @@ -19,7 +19,7 @@ #include "ui/base/win/dpi.h" #include "ui/base/win/hwnd_util.h" #include "ui/base/win/scoped_set_map_mode.h" -#include "ui/gfx/font.h" +#include "ui/gfx/font_list.h" #include "ui/gfx/screen.h" #include "ui/views/view.h" #include "ui/views/widget/monitor_win.h" @@ -52,11 +52,11 @@ static gfx::Font DetermineDefaultFont() { } // static -gfx::Font TooltipManager::GetDefaultFont() { - static gfx::Font* font = NULL; - if (!font) - font = new gfx::Font(DetermineDefaultFont()); - return *font; +const gfx::FontList& TooltipManager::GetDefaultFontList() { + static gfx::FontList* font_list = NULL; + if (!font_list) + font_list = new gfx::FontList(DetermineDefaultFont()); + return *font_list; } // static diff --git a/ui/views/widget/widget.cc b/ui/views/widget/widget.cc index 0de8ccf3f5..4bf2a850f0 100644 --- a/ui/views/widget/widget.cc +++ b/ui/views/widget/widget.cc @@ -427,16 +427,16 @@ void Widget::ViewHierarchyChanged( } } -void Widget::NotifyNativeViewHierarchyChanged(bool attached, - gfx::NativeView native_view) { - if (!attached) { - FocusManager* focus_manager = GetFocusManager(); - // We are being removed from a window hierarchy. Treat this as - // the root_view_ being removed. - if (focus_manager) - focus_manager->ViewRemoved(root_view_.get()); - } - root_view_->NotifyNativeViewHierarchyChanged(attached, native_view); +void Widget::NotifyNativeViewHierarchyWillChange() { + FocusManager* focus_manager = GetFocusManager(); + // We are being removed from a window hierarchy. Treat this as + // the root_view_ being removed. + if (focus_manager) + focus_manager->ViewRemoved(root_view_.get()); +} + +void Widget::NotifyNativeViewHierarchyChanged() { + root_view_->NotifyNativeViewHierarchyChanged(); } // Converted methods (see header) ---------------------------------------------- diff --git a/ui/views/widget/widget.h b/ui/views/widget/widget.h index ed64f3bdb3..e6067eba1e 100644 --- a/ui/views/widget/widget.h +++ b/ui/views/widget/widget.h @@ -331,9 +331,13 @@ class VIEWS_EXPORT Widget : public internal::NativeWidgetDelegate, // Forwarded from the RootView so that the widget can do any cleanup. void ViewHierarchyChanged(const View::ViewHierarchyChangedDetails& details); - // Performs any necessary cleanup and forwards to RootView. - void NotifyNativeViewHierarchyChanged(bool attached, - gfx::NativeView native_view); + // Called right before changing the widget's parent NativeView to do any + // cleanup. + void NotifyNativeViewHierarchyWillChange(); + + // Called after changing the widget's parent NativeView. Notifies the RootView + // about the change. + void NotifyNativeViewHierarchyChanged(); // Returns the top level widget in a hierarchy (see is_top_level() for // the definition of top level widget.) Will return NULL if called diff --git a/ui/views/widget/widget_unittest.cc b/ui/views/widget/widget_unittest.cc index e00f93de59..d21d64f056 100644 --- a/ui/views/widget/widget_unittest.cc +++ b/ui/views/widget/widget_unittest.cc @@ -1541,27 +1541,28 @@ TEST_F(WidgetTest, DesktopNativeWidgetAuraNoPaintAfterHideTest) { widget.Close(); } -// This class provides functionality to test whether the destruction of full -// screen child windows occurs correctly in desktop AURA without crashing. +// This class provides functionality to create fullscreen and top level popup +// windows. It additionally tests whether the destruction of these windows +// occurs correctly in desktop AURA without crashing. // It provides facilities to test the following cases:- // 1. Child window destroyed which should lead to the destruction of the // parent. // 2. Parent window destroyed which should lead to the child being destroyed. -class DesktopAuraFullscreenChildWindowDestructionTest +class DesktopAuraTopLevelWindowTest : public views::TestViewsDelegate, public aura::WindowObserver { public: - DesktopAuraFullscreenChildWindowDestructionTest() - : full_screen_widget_(NULL), - child_window_(NULL), - parent_destroyed_(false), - child_destroyed_(false) {} + DesktopAuraTopLevelWindowTest() + : top_level_widget_(NULL), + owned_window_(NULL), + owner_destroyed_(false), + owned_window_destroyed_(false) {} - virtual ~DesktopAuraFullscreenChildWindowDestructionTest() { - EXPECT_TRUE(parent_destroyed_); - EXPECT_TRUE(child_destroyed_); - full_screen_widget_ = NULL; - child_window_ = NULL; + virtual ~DesktopAuraTopLevelWindowTest() { + EXPECT_TRUE(owner_destroyed_); + EXPECT_TRUE(owned_window_destroyed_); + top_level_widget_ = NULL; + owned_window_ = NULL; } // views::TestViewsDelegate overrides. @@ -1572,50 +1573,55 @@ class DesktopAuraFullscreenChildWindowDestructionTest params->native_widget = new views::DesktopNativeWidgetAura(delegate); } - void CreateFullscreenChildWindow(const gfx::Rect& bounds) { + void CreateTopLevelWindow(const gfx::Rect& bounds, bool fullscreen) { Widget::InitParams init_params; init_params.type = Widget::InitParams::TYPE_WINDOW; init_params.bounds = bounds; init_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; init_params.layer_type = ui::LAYER_NOT_DRAWN; + init_params.accept_events = fullscreen; widget_.Init(init_params); - child_window_ = new aura::Window(&child_window_delegate_); - child_window_->SetType(aura::client::WINDOW_TYPE_NORMAL); - child_window_->Init(ui::LAYER_TEXTURED); - child_window_->SetName("TestFullscreenChildWindow"); - child_window_->SetProperty(aura::client::kShowStateKey, - ui::SHOW_STATE_FULLSCREEN); - child_window_->SetDefaultParentByRootWindow( + owned_window_ = new aura::Window(&child_window_delegate_); + owned_window_->SetType(aura::client::WINDOW_TYPE_NORMAL); + owned_window_->SetName("TestTopLevelWindow"); + if (fullscreen) { + owned_window_->SetProperty(aura::client::kShowStateKey, + ui::SHOW_STATE_FULLSCREEN); + } else { + owned_window_->SetType(aura::client::WINDOW_TYPE_MENU); + } + owned_window_->Init(ui::LAYER_TEXTURED); + owned_window_->SetDefaultParentByRootWindow( widget_.GetNativeView()->GetRootWindow(), gfx::Rect(0, 0, 1900, 1600)); - child_window_->Show(); - child_window_->AddObserver(this); + owned_window_->Show(); + owned_window_->AddObserver(this); - ASSERT_TRUE(child_window_->parent() != NULL); - child_window_->parent()->AddObserver(this); + ASSERT_TRUE(owned_window_->parent() != NULL); + owned_window_->parent()->AddObserver(this); - full_screen_widget_ = - views::Widget::GetWidgetForNativeView(child_window_->parent()); - ASSERT_TRUE(full_screen_widget_ != NULL); + top_level_widget_ = + views::Widget::GetWidgetForNativeView(owned_window_->parent()); + ASSERT_TRUE(top_level_widget_ != NULL); } - void DestroyChildWindow() { - ASSERT_TRUE(child_window_ != NULL); - delete child_window_; + void DestroyOwnedWindow() { + ASSERT_TRUE(owned_window_ != NULL); + delete owned_window_; } - void DestroyParentWindow() { - ASSERT_TRUE(full_screen_widget_ != NULL); - full_screen_widget_->CloseNow(); + void DestroyOwnerWindow() { + ASSERT_TRUE(top_level_widget_ != NULL); + top_level_widget_->CloseNow(); } virtual void OnWindowDestroying(aura::Window* window) OVERRIDE { window->RemoveObserver(this); - if (window == child_window_) { - child_destroyed_ = true; - } else if (window == full_screen_widget_->GetNativeView()) { - parent_destroyed_ = true; + if (window == owned_window_) { + owned_window_destroyed_ = true; + } else if (window == top_level_widget_->GetNativeView()) { + owner_destroyed_ = true; } else { ADD_FAILURE() << "Unexpected window destroyed callback: " << window; } @@ -1623,35 +1629,46 @@ class DesktopAuraFullscreenChildWindowDestructionTest private: views::Widget widget_; - views::Widget* full_screen_widget_; - aura::Window* child_window_; - bool parent_destroyed_; - bool child_destroyed_; + views::Widget* top_level_widget_; + aura::Window* owned_window_; + bool owner_destroyed_; + bool owned_window_destroyed_; aura::test::TestWindowDelegate child_window_delegate_; - DISALLOW_COPY_AND_ASSIGN(DesktopAuraFullscreenChildWindowDestructionTest); + DISALLOW_COPY_AND_ASSIGN(DesktopAuraTopLevelWindowTest); }; -TEST_F(WidgetTest, DesktopAuraFullscreenChildDestroyedBeforeParentTest) { +TEST_F(WidgetTest, DesktopAuraFullscreenWindowDestroyedBeforeOwnerTest) { ViewsDelegate::views_delegate = NULL; - DesktopAuraFullscreenChildWindowDestructionTest full_screen_child_test; - ASSERT_NO_FATAL_FAILURE(full_screen_child_test.CreateFullscreenChildWindow( - gfx::Rect(0, 0, 200, 200))); + DesktopAuraTopLevelWindowTest fullscreen_window; + ASSERT_NO_FATAL_FAILURE(fullscreen_window.CreateTopLevelWindow( + gfx::Rect(0, 0, 200, 200), true)); RunPendingMessages(); - ASSERT_NO_FATAL_FAILURE(full_screen_child_test.DestroyChildWindow()); + ASSERT_NO_FATAL_FAILURE(fullscreen_window.DestroyOwnedWindow()); RunPendingMessages(); } -TEST_F(WidgetTest, DesktopAuraFullscreenChildParentDestroyed) { +TEST_F(WidgetTest, DesktopAuraFullscreenWindowOwnerDestroyed) { ViewsDelegate::views_delegate = NULL; - DesktopAuraFullscreenChildWindowDestructionTest full_screen_child_test; - ASSERT_NO_FATAL_FAILURE(full_screen_child_test.CreateFullscreenChildWindow( - gfx::Rect(0, 0, 200, 200))); + DesktopAuraTopLevelWindowTest fullscreen_window; + ASSERT_NO_FATAL_FAILURE(fullscreen_window.CreateTopLevelWindow( + gfx::Rect(0, 0, 200, 200), true)); RunPendingMessages(); - ASSERT_NO_FATAL_FAILURE(full_screen_child_test.DestroyParentWindow()); + ASSERT_NO_FATAL_FAILURE(fullscreen_window.DestroyOwnerWindow()); + RunPendingMessages(); +} + +TEST_F(WidgetTest, DesktopAuraTopLevelOwnedPopupTest) { + ViewsDelegate::views_delegate = NULL; + DesktopAuraTopLevelWindowTest popup_window; + ASSERT_NO_FATAL_FAILURE(popup_window.CreateTopLevelWindow( + gfx::Rect(0, 0, 200, 200), false)); + + RunPendingMessages(); + ASSERT_NO_FATAL_FAILURE(popup_window.DestroyOwnedWindow()); RunPendingMessages(); } @@ -1678,6 +1695,116 @@ TEST_F(WidgetTest, TestWindowVisibilityAfterHide) { EXPECT_TRUE(widget.GetNativeView()->IsVisible()); } +// The following code verifies we can correctly destroy a Widget from a mouse +// enter/exit. We could test move/drag/enter/exit but in general we don't run +// nested message loops from such events, nor has the code ever really dealt +// with this situation. + +// Class that closes the widget (which ends up deleting it immediately) when the +// appropriate event is received. +class CloseWidgetView : public View { + public: + explicit CloseWidgetView(ui::EventType event_type) + : event_type_(event_type) { + } + + // View overrides: + virtual bool OnMousePressed(const ui::MouseEvent& event) OVERRIDE { + if (!CloseWidget(event)) + View::OnMousePressed(event); + return true; + } + virtual bool OnMouseDragged(const ui::MouseEvent& event) OVERRIDE { + if (!CloseWidget(event)) + View::OnMouseDragged(event); + return true; + } + virtual void OnMouseReleased(const ui::MouseEvent& event) OVERRIDE { + if (!CloseWidget(event)) + View::OnMouseReleased(event); + } + virtual void OnMouseMoved(const ui::MouseEvent& event) OVERRIDE { + if (!CloseWidget(event)) + View::OnMouseMoved(event); + } + virtual void OnMouseEntered(const ui::MouseEvent& event) OVERRIDE { + if (!CloseWidget(event)) + View::OnMouseEntered(event); + } + + private: + bool CloseWidget(const ui::LocatedEvent& event) { + if (event.type() == event_type_) { + // Go through NativeWidgetPrivate to simulate what happens if the OS + // deletes the NativeWindow out from under us. + GetWidget()->native_widget_private()->CloseNow(); + return true; + } + return false; + } + + const ui::EventType event_type_; + + DISALLOW_COPY_AND_ASSIGN(CloseWidgetView); +}; + +// Generates two moves (first generates enter, second real move), a press, drag +// and release stopping at |last_event_type|. +void GenerateMouseEvents(Widget* widget, ui::EventType last_event_type) { + const gfx::Rect screen_bounds(widget->GetWindowBoundsInScreen()); + ui::MouseEvent move_event(ui::ET_MOUSE_MOVED, screen_bounds.CenterPoint(), + screen_bounds.CenterPoint(), 0); + aura::RootWindowHostDelegate* rwhd = + widget->GetNativeWindow()->GetRootWindow()->AsRootWindowHostDelegate(); + rwhd->OnHostMouseEvent(&move_event); + if (last_event_type == ui::ET_MOUSE_ENTERED) + return; + rwhd->OnHostMouseEvent(&move_event); + if (last_event_type == ui::ET_MOUSE_MOVED) + return; + + ui::MouseEvent press_event(ui::ET_MOUSE_PRESSED, screen_bounds.CenterPoint(), + screen_bounds.CenterPoint(), 0); + rwhd->OnHostMouseEvent(&press_event); + if (last_event_type == ui::ET_MOUSE_PRESSED) + return; + + gfx::Point end_point(screen_bounds.CenterPoint()); + end_point.Offset(1, 1); + ui::MouseEvent drag_event(ui::ET_MOUSE_DRAGGED, end_point, end_point, 0); + rwhd->OnHostMouseEvent(&drag_event); + if (last_event_type == ui::ET_MOUSE_DRAGGED) + return; + + ui::MouseEvent release_event(ui::ET_MOUSE_RELEASED, end_point, end_point, 0); + rwhd->OnHostMouseEvent(&release_event); +} + +// Creates a widget and invokes GenerateMouseEvents() with |last_event_type|. +void RunCloseWidgetDuringDispatchTest(WidgetTest* test, + ui::EventType last_event_type) { + // |widget| is deleted by CloseWidgetView. + Widget* widget = new Widget; + Widget::InitParams params = + test->CreateParams(Widget::InitParams::TYPE_POPUP); + params.native_widget = new DesktopNativeWidgetAura(widget); + params.bounds = gfx::Rect(0, 0, 50, 100); + widget->Init(params); + widget->SetContentsView(new CloseWidgetView(last_event_type)); + widget->Show(); + GenerateMouseEvents(widget, last_event_type); +} + +// Verifies deleting the widget from a mouse pressed event doesn't crash. +TEST_F(WidgetTest, CloseWidgetDuringMousePress) { + RunCloseWidgetDuringDispatchTest(this, ui::ET_MOUSE_PRESSED); +} + +// Verifies deleting the widget from a mouse released event doesn't crash. +TEST_F(WidgetTest, CloseWidgetDuringMouseReleased) { + RunCloseWidgetDuringDispatchTest(this, ui::ET_MOUSE_RELEASED); +} + #endif // !defined(OS_CHROMEOS) // Tests that wheel events generated from scroll events are targetted to the diff --git a/ui/views/win/hwnd_message_handler.cc b/ui/views/win/hwnd_message_handler.cc index d17c84153e..6af4479cc8 100644 --- a/ui/views/win/hwnd_message_handler.cc +++ b/ui/views/win/hwnd_message_handler.cc @@ -2068,9 +2068,9 @@ LRESULT HWNDMessageHandler::OnTouchEvent(UINT message, if (touch_event_type != ui::ET_UNKNOWN) { POINT point; point.x = TOUCH_COORD_TO_PIXEL(input[i].x) / - ui::win::GetUndocumentedDPIScale(); + ui::win::GetUndocumentedDPITouchScale(); point.y = TOUCH_COORD_TO_PIXEL(input[i].y) / - ui::win::GetUndocumentedDPIScale(); + ui::win::GetUndocumentedDPITouchScale(); ScreenToClient(hwnd(), &point); diff --git a/ui/views/win/hwnd_message_handler.h b/ui/views/win/hwnd_message_handler.h index 8ae4619f4a..80ad4aa760 100644 --- a/ui/views/win/hwnd_message_handler.h +++ b/ui/views/win/hwnd_message_handler.h @@ -290,8 +290,8 @@ class VIEWS_EXPORT HWNDMessageHandler : MSG_WM_CREATE(OnCreate) MSG_WM_DESTROY(OnDestroy) MSG_WM_DISPLAYCHANGE(OnDisplayChange) - MSG_WM_ERASEBKGND(OnEraseBkgnd) MSG_WM_ENTERSIZEMOVE(OnEnterSizeMove) + MSG_WM_ERASEBKGND(OnEraseBkgnd) MSG_WM_EXITSIZEMOVE(OnExitSizeMove) MSG_WM_GETMINMAXINFO(OnGetMinMaxInfo) MSG_WM_INITMENU(OnInitMenu) @@ -311,8 +311,8 @@ class VIEWS_EXPORT HWNDMessageHandler : MSG_WM_SIZE(OnSize) MSG_WM_SYSCOMMAND(OnSysCommand) MSG_WM_THEMECHANGED(OnThemeChanged) - MSG_WM_WINDOWPOSCHANGING(OnWindowPosChanging) MSG_WM_WINDOWPOSCHANGED(OnWindowPosChanged) + MSG_WM_WINDOWPOSCHANGING(OnWindowPosChanging) END_MSG_MAP() // Message Handlers. diff --git a/ui/views/window/dialog_client_view.cc b/ui/views/window/dialog_client_view.cc index d592292ed8..9ca92275cd 100644 --- a/ui/views/window/dialog_client_view.cc +++ b/ui/views/window/dialog_client_view.cc @@ -283,6 +283,17 @@ void DialogClientView::ViewHierarchyChanged( } } +void DialogClientView::NativeViewHierarchyChanged() { + FocusManager* focus_manager = GetFocusManager(); + if (focus_manager_ != focus_manager) { + if (focus_manager_) + focus_manager_->RemoveFocusChangeListener(this); + focus_manager_ = focus_manager; + if (focus_manager_) + focus_manager_->AddFocusChangeListener(this); + } +} + //////////////////////////////////////////////////////////////////////////////// // DialogClientView, ButtonListener implementation: diff --git a/ui/views/window/dialog_client_view.h b/ui/views/window/dialog_client_view.h index 448eae7b1c..d780806094 100644 --- a/ui/views/window/dialog_client_view.h +++ b/ui/views/window/dialog_client_view.h @@ -62,6 +62,7 @@ class VIEWS_EXPORT DialogClientView : public ClientView, virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) OVERRIDE; virtual void ViewHierarchyChanged( const ViewHierarchyChangedDetails& details) OVERRIDE; + virtual void NativeViewHierarchyChanged() OVERRIDE; // ButtonListener implementation: virtual void ButtonPressed(Button* sender, const ui::Event& event) OVERRIDE; @@ -84,6 +85,8 @@ class VIEWS_EXPORT DialogClientView : public ClientView, virtual void ChildVisibilityChanged(View* child) OVERRIDE; private: + FRIEND_TEST_ALL_PREFIXES(DialogClientViewTest, FocusManager); + bool has_dialog_buttons() const { return ok_button_ || cancel_button_; } // Create a dialog button of the appropriate type. diff --git a/ui/views/window/dialog_client_view_unittest.cc b/ui/views/window/dialog_client_view_unittest.cc index 9f8c8c4a38..28b001f2d2 100644 --- a/ui/views/window/dialog_client_view_unittest.cc +++ b/ui/views/window/dialog_client_view_unittest.cc @@ -4,10 +4,11 @@ #include "base/basictypes.h" #include "base/strings/utf_string_conversions.h" -#include "testing/gtest/include/gtest/gtest.h" #include "ui/base/ui_base_types.h" #include "ui/views/controls/button/label_button.h" #include "ui/views/test/test_views.h" +#include "ui/views/test/views_test_base.h" +#include "ui/views/widget/widget.h" #include "ui/views/window/dialog_client_view.h" #include "ui/views/window/dialog_delegate.h" @@ -37,7 +38,7 @@ class TestDialogClientView : public DialogClientView { DISALLOW_COPY_AND_ASSIGN(TestDialogClientView); }; -class DialogClientViewTest : public testing::Test, +class DialogClientViewTest : public ViewsTestBase, public DialogDelegateView { public: DialogClientViewTest() @@ -51,6 +52,8 @@ class DialogClientViewTest : public testing::Test, dialog_buttons_ = ui::DIALOG_BUTTON_NONE; contents_.reset(new StaticSizedView(gfx::Size(100, 200))); client_view_.reset(new TestDialogClientView(contents_.get(), this)); + + ViewsTestBase::SetUp(); } // DialogDelegateView implementation. @@ -233,4 +236,57 @@ TEST_F(DialogClientViewTest, LayoutWithFootnoteHeightForWidth) { footnote_view->bounds().height()); } +// Test that the DialogClientView's FocusManager is properly updated when the +// DialogClientView belongs to a non top level widget and the widget is +// reparented. The DialogClientView belongs to a non top level widget in the +// case of constrained windows. The constrained window's widget is reparented +// when a browser tab is dragged to a different browser window. +TEST_F(DialogClientViewTest, FocusManager) { + scoped_ptr<Widget> toplevel1(new Widget); + Widget::InitParams toplevel1_params = + CreateParams(Widget::InitParams::TYPE_WINDOW); + toplevel1_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; + toplevel1->Init(toplevel1_params); + + scoped_ptr<Widget> toplevel2(new Widget); + Widget::InitParams toplevel2_params = + CreateParams(Widget::InitParams::TYPE_WINDOW); + toplevel2_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; + toplevel2->Init(toplevel2_params); + + Widget* dialog = new Widget; + Widget::InitParams dialog_params = + CreateParams(Widget::InitParams::TYPE_WINDOW); + dialog_params.child = true; + dialog_params.delegate = new DialogDelegateView(); + dialog_params.parent = toplevel1->GetNativeView(); + dialog->Init(dialog_params); + + // Test that the FocusManager has been properly set when the DialogClientView + // was parented to |dialog|. + DialogClientView* client_view = + static_cast<DialogClientView*>(dialog->client_view()); + EXPECT_EQ(toplevel1->GetFocusManager(), client_view->focus_manager_); + + // Test that the FocusManager is properly updated when the DialogClientView's + // top level widget is changed. + Widget::ReparentNativeView(dialog->GetNativeView(), NULL); + EXPECT_EQ(NULL, client_view->focus_manager_); + Widget::ReparentNativeView(dialog->GetNativeView(), + toplevel2->GetNativeView()); + EXPECT_EQ(toplevel2->GetFocusManager(), client_view->focus_manager_); + Widget::ReparentNativeView(dialog->GetNativeView(), + toplevel1->GetNativeView()); + EXPECT_NE(toplevel1->GetFocusManager(), toplevel2->GetFocusManager()); + EXPECT_EQ(toplevel1->GetFocusManager(), client_view->focus_manager_); + + // Test that the FocusManager is properly cleared when the DialogClientView is + // removed from |dialog| during the widget's destruction. + client_view->set_owned_by_client(); + scoped_ptr<DialogClientView> owned_client_view(client_view); + toplevel1->CloseNow(); + toplevel2->CloseNow(); + EXPECT_EQ(NULL, owned_client_view->focus_manager_); +} + } // namespace views diff --git a/ui/webui/resources/css/apps/topbutton_bar.css b/ui/webui/resources/css/apps/topbutton_bar.css index aa918753d4..35641e9d4b 100644 --- a/ui/webui/resources/css/apps/topbutton_bar.css +++ b/ui/webui/resources/css/apps/topbutton_bar.css @@ -18,6 +18,7 @@ border: 0; display: block; height: 32px; + min-width: 0; outline: none; padding: 0; width: 32px; diff --git a/ui/webui/resources/css/menu.css b/ui/webui/resources/css/menu.css index d22bcccf19..625ca1513f 100644 --- a/ui/webui/resources/css/menu.css +++ b/ui/webui/resources/css/menu.css @@ -72,7 +72,6 @@ menu > [checked]::before { display: inline-block; height: 9px; margin: 0 5px; - vertical-align: 50%; width: 9px; } diff --git a/ui/webui/resources/js/cr.js b/ui/webui/resources/js/cr.js index 2a7ab7823b..3ea3b91dd8 100644 --- a/ui/webui/resources/js/cr.js +++ b/ui/webui/resources/js/cr.js @@ -280,21 +280,26 @@ this.cr = (function() { }; } + var OriginalEvent = global.Event; + /** * Creates a new event to be used with cr.EventTarget or DOM EventTarget * objects. * @param {string} type The name of the event. * @param {boolean=} opt_bubbles Whether the event bubbles. * Default is false. - * @param {boolean=} opt_preventable Whether the default action of the event - * can be prevented. + * @param {boolean=} opt_cancelable Whether the default action of the event + * can be prevented. Unlike the DOM event constructor, this defaults to + * true. * @constructor * @extends {Event} */ - function Event(type, opt_bubbles, opt_preventable) { - var e = cr.doc.createEvent('Event'); - e.initEvent(type, !!opt_bubbles, !!opt_preventable); - e.__proto__ = global.Event.prototype; + function Event(type, opt_bubbles, opt_cancelable) { + var e = new OriginalEvent(type, { + bubbles: opt_bubbles, + cancelable: opt_cancelable === undefined ? true : opt_cancelable + }); + e.__proto__ = OriginalEvent.prototype; return e; }; @@ -319,7 +324,7 @@ this.cr = (function() { return; } - Event.prototype = {__proto__: global.Event.prototype}; + Event.prototype = {__proto__: OriginalEvent.prototype}; cr.doc = document; diff --git a/ui/webui/resources/js/cr/event_target.js b/ui/webui/resources/js/cr/event_target.js index 5bcb41d613..d9bc681c75 100644 --- a/ui/webui/resources/js/cr/event_target.js +++ b/ui/webui/resources/js/cr/event_target.js @@ -76,9 +76,6 @@ cr.define('cr', function() { event.__defineGetter__('target', function() { return self; }); - event.preventDefault = function() { - this.returnValue = false; - }; var type = event.type; var prevented = 0; @@ -93,7 +90,7 @@ cr.define('cr', function() { } } - return !prevented && event.returnValue; + return !prevented && !event.defaultPrevented; } }; |