| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/first_run_bubble.h" | 5 #include "chrome/browser/views/first_run_bubble.h" |
| 6 | 6 |
| 7 #include "base/win_util.h" | 7 #include "base/win_util.h" |
| 8 #include "chrome/browser/browser.h" | 8 #include "chrome/browser/browser.h" |
| 9 #include "chrome/browser/browser_list.h" | 9 #include "chrome/browser/browser_list.h" |
| 10 #include "chrome/browser/browser_window.h" | 10 #include "chrome/browser/browser_window.h" |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 GetDefaultSearchEngineName(profile)); | 92 GetDefaultSearchEngineName(profile)); |
| 93 keep_button_ = new views::NativeButton(this, keep_str); | 93 keep_button_ = new views::NativeButton(this, keep_str); |
| 94 keep_button_->SetIsDefault(true); | 94 keep_button_->SetIsDefault(true); |
| 95 AddChildView(keep_button_); | 95 AddChildView(keep_button_); |
| 96 | 96 |
| 97 std::wstring change_str = l10n_util::GetString(IDS_FR_BUBBLE_CHANGE); | 97 std::wstring change_str = l10n_util::GetString(IDS_FR_BUBBLE_CHANGE); |
| 98 change_button_ = new views::NativeButton(this, change_str); | 98 change_button_ = new views::NativeButton(this, change_str); |
| 99 AddChildView(change_button_); | 99 AddChildView(change_button_); |
| 100 } | 100 } |
| 101 | 101 |
| 102 void BubbleShown() { |
| 103 keep_button_->RequestFocus(); |
| 104 } |
| 105 |
| 102 // Overridden from ButtonListener. | 106 // Overridden from ButtonListener. |
| 103 virtual void ButtonPressed(views::Button* sender) { | 107 virtual void ButtonPressed(views::Button* sender) { |
| 104 bubble_window_->Close(); | 108 bubble_window_->Close(); |
| 105 if (change_button_ == sender) { | 109 if (change_button_ == sender) { |
| 106 Browser* browser = BrowserList::GetLastActive(); | 110 Browser* browser = BrowserList::GetLastActive(); |
| 107 if (browser) { | 111 if (browser) { |
| 108 ShowOptionsWindow(OPTIONS_PAGE_GENERAL, OPTIONS_GROUP_DEFAULT_SEARCH, | 112 ShowOptionsWindow(OPTIONS_PAGE_GENERAL, OPTIONS_GROUP_DEFAULT_SEARCH, |
| 109 browser->profile()); | 113 browser->profile()); |
| 110 } | 114 } |
| 111 } | 115 } |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 canvas.width() - pref_size.width() - kBubblePadding, | 150 canvas.width() - pref_size.width() - kBubblePadding, |
| 147 canvas.height() - pref_size.height() - kButtonVEdgeMargin, | 151 canvas.height() - pref_size.height() - kButtonVEdgeMargin, |
| 148 pref_size.width(), pref_size.height()); | 152 pref_size.width(), pref_size.height()); |
| 149 | 153 |
| 150 pref_size = keep_button_->GetPreferredSize(); | 154 pref_size = keep_button_->GetPreferredSize(); |
| 151 keep_button_->SetBounds(change_button_->x() - pref_size.width() - | 155 keep_button_->SetBounds(change_button_->x() - pref_size.width() - |
| 152 kRelatedButtonHSpacing, change_button_->y(), | 156 kRelatedButtonHSpacing, change_button_->y(), |
| 153 pref_size.width(), pref_size.height()); | 157 pref_size.width(), pref_size.height()); |
| 154 } | 158 } |
| 155 | 159 |
| 156 virtual void ViewHierarchyChanged(bool is_add, View* parent, View* child) { | |
| 157 if (keep_button_) | |
| 158 keep_button_->RequestFocus(); | |
| 159 } | |
| 160 | |
| 161 // Overridden from views::View. | 160 // Overridden from views::View. |
| 162 virtual gfx::Size GetPreferredSize() { | 161 virtual gfx::Size GetPreferredSize() { |
| 163 return gfx::Size(views::Window::GetLocalizedContentsSize( | 162 return gfx::Size(views::Window::GetLocalizedContentsSize( |
| 164 IDS_FIRSTRUNBUBBLE_DIALOG_WIDTH_CHARS, | 163 IDS_FIRSTRUNBUBBLE_DIALOG_WIDTH_CHARS, |
| 165 IDS_FIRSTRUNBUBBLE_DIALOG_HEIGHT_LINES)); | 164 IDS_FIRSTRUNBUBBLE_DIALOG_HEIGHT_LINES)); |
| 166 } | 165 } |
| 167 | 166 |
| 168 virtual void FocusWillChange(View* focused_before, View* focused_now) { | 167 virtual void FocusWillChange(View* focused_before, View* focused_now) { |
| 169 if (focused_before && focused_before->GetClassName() == | 168 if (focused_before && focused_before->GetClassName() == |
| 170 views::NativeButton::kViewClassName) { | 169 views::NativeButton::kViewClassName) { |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 const gfx::Rect& position_relative_to) { | 229 const gfx::Rect& position_relative_to) { |
| 231 FirstRunBubble* window = new FirstRunBubble(); | 230 FirstRunBubble* window = new FirstRunBubble(); |
| 232 FirstRunBubbleView* view = new FirstRunBubbleView(window, profile); | 231 FirstRunBubbleView* view = new FirstRunBubbleView(window, profile); |
| 233 window->SetDelegate(window); | 232 window->SetDelegate(window); |
| 234 window->set_view(view); | 233 window->set_view(view); |
| 235 window->Init(parent_hwnd, position_relative_to, view); | 234 window->Init(parent_hwnd, position_relative_to, view); |
| 236 window->ShowWindow(SW_SHOW); | 235 window->ShowWindow(SW_SHOW); |
| 237 views::FocusManager* focus_manager = | 236 views::FocusManager* focus_manager = |
| 238 views::FocusManager::GetFocusManager(window->GetNativeView()); | 237 views::FocusManager::GetFocusManager(window->GetNativeView()); |
| 239 focus_manager->AddFocusChangeListener(view); | 238 focus_manager->AddFocusChangeListener(view); |
| 239 view->BubbleShown(); |
| 240 return window; | 240 return window; |
| 241 } | 241 } |
| 242 | 242 |
| 243 void FirstRunBubble::EnableParent() { | 243 void FirstRunBubble::EnableParent() { |
| 244 ::EnableWindow(GetParent(), true); | 244 ::EnableWindow(GetParent(), true); |
| 245 } | 245 } |
| OLD | NEW |