| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/views/input_window.h" | 5 #include "chrome/browser/views/input_window.h" |
| 6 | 6 |
| 7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
| 8 #include "base/task.h" | 8 #include "base/task.h" |
| 9 #include "chrome/browser/views/standard_layout.h" | 9 #include "chrome/browser/views/standard_layout.h" |
| 10 #include "chrome/common/l10n_util.h" | 10 #include "chrome/common/l10n_util.h" |
| 11 #include "chrome/views/grid_layout.h" | 11 #include "chrome/views/grid_layout.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 38 virtual bool Cancel(); | 38 virtual bool Cancel(); |
| 39 virtual void WindowClosing(); | 39 virtual void WindowClosing(); |
| 40 virtual void DeleteDelegate(); | 40 virtual void DeleteDelegate(); |
| 41 virtual std::wstring GetWindowTitle() const; | 41 virtual std::wstring GetWindowTitle() const; |
| 42 virtual bool IsModal() const { return true; } | 42 virtual bool IsModal() const { return true; } |
| 43 virtual views::View* GetContentsView(); | 43 virtual views::View* GetContentsView(); |
| 44 | 44 |
| 45 // views::TextField::Controller overrides: | 45 // views::TextField::Controller overrides: |
| 46 virtual void ContentsChanged(views::TextField* sender, | 46 virtual void ContentsChanged(views::TextField* sender, |
| 47 const std::wstring& new_contents); | 47 const std::wstring& new_contents); |
| 48 virtual void HandleKeystroke(views::TextField*, UINT, TCHAR, UINT, UINT) {} | 48 virtual bool HandleKeystroke(views::TextField*, UINT, TCHAR, UINT, UINT) { |
| 49 return false; |
| 50 } |
| 49 | 51 |
| 50 protected: | 52 protected: |
| 51 // views::View overrides: | 53 // views::View overrides: |
| 52 virtual void ViewHierarchyChanged(bool is_add, views::View* parent, | 54 virtual void ViewHierarchyChanged(bool is_add, views::View* parent, |
| 53 views::View* child); | 55 views::View* child); |
| 54 | 56 |
| 55 private: | 57 private: |
| 56 // Set up dialog controls and layout. | 58 // Set up dialog controls and layout. |
| 57 void InitControlLayout(); | 59 void InitControlLayout(); |
| 58 | 60 |
| 59 // Sets focus to the first focusable element within the dialog. | 61 // Sets focus to the first focusable element within the dialog. |
| 60 void FocusFirstFocusableControl(); | 62 void FocusFirstFocusableControl(); |
| 61 | 63 |
| 62 // The TextField that the user can type into. | 64 // The TextField that the user can type into. |
| 63 views::TextField* text_field_; | 65 views::TextField* text_field_; |
| 64 | 66 |
| 65 // The delegate that the ContentView uses to communicate changes to the | 67 // The delegate that the ContentView uses to communicate changes to the |
| 66 // caller. | 68 // caller. |
| 67 InputWindowDelegate* delegate_; | 69 InputWindowDelegate* delegate_; |
| 68 | 70 |
| 69 // Helps us set focus to the first TextField in the window. | 71 // Helps us set focus to the first TextField in the window. |
| 70 ScopedRunnableMethodFactory<ContentView> focus_grabber_factory_; | 72 ScopedRunnableMethodFactory<ContentView> focus_grabber_factory_; |
| 71 | 73 |
| 72 DISALLOW_EVIL_CONSTRUCTORS(ContentView); | 74 DISALLOW_COPY_AND_ASSIGN(ContentView); |
| 73 }; | 75 }; |
| 74 | 76 |
| 75 /////////////////////////////////////////////////////////////////////////////// | 77 /////////////////////////////////////////////////////////////////////////////// |
| 76 // ContentView, views::DialogDelegate implementation: | 78 // ContentView, views::DialogDelegate implementation: |
| 77 | 79 |
| 78 bool ContentView::IsDialogButtonEnabled(DialogButton button) const { | 80 bool ContentView::IsDialogButtonEnabled(DialogButton button) const { |
| 79 if (button == DIALOGBUTTON_OK && !delegate_->IsValid(text_field_->GetText())) | 81 if (button == DIALOGBUTTON_OK && !delegate_->IsValid(text_field_->GetText())) |
| 80 return false; | 82 return false; |
| 81 return true; | 83 return true; |
| 82 } | 84 } |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 } | 165 } |
| 164 | 166 |
| 165 views::Window* CreateInputWindow(HWND parent_hwnd, | 167 views::Window* CreateInputWindow(HWND parent_hwnd, |
| 166 InputWindowDelegate* delegate) { | 168 InputWindowDelegate* delegate) { |
| 167 views::Window* window = | 169 views::Window* window = |
| 168 views::Window::CreateChromeWindow(parent_hwnd, gfx::Rect(), | 170 views::Window::CreateChromeWindow(parent_hwnd, gfx::Rect(), |
| 169 new ContentView(delegate)); | 171 new ContentView(delegate)); |
| 170 window->GetClientView()->AsDialogClientView()->UpdateDialogButtons(); | 172 window->GetClientView()->AsDialogClientView()->UpdateDialogButtons(); |
| 171 return window; | 173 return window; |
| 172 } | 174 } |
| OLD | NEW |