Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/options_window.h" | 5 #include "chrome/browser/options_window.h" |
| 6 | 6 |
| 7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "app/resource_bundle.h" | 8 #include "app/resource_bundle.h" |
| 9 #include "base/scoped_ptr.h" | 9 #include "base/scoped_ptr.h" |
| 10 #include "chrome/browser/browser_list.h" | 10 #include "chrome/browser/browser_list.h" |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 300 return NULL; | 300 return NULL; |
| 301 } | 301 } |
| 302 } | 302 } |
| 303 | 303 |
| 304 void CloseOptionsWindow() { | 304 void CloseOptionsWindow() { |
| 305 if (OptionsWindowView::instance_) | 305 if (OptionsWindowView::instance_) |
| 306 OptionsWindowView::instance_->window()->Close(); | 306 OptionsWindowView::instance_->window()->Close(); |
| 307 } | 307 } |
| 308 | 308 |
| 309 gfx::NativeWindow GetOptionsViewParent() { | 309 gfx::NativeWindow GetOptionsViewParent() { |
| 310 if (Browser* b = BrowserList::GetLastActive()) | 310 if (Browser* b = BrowserList::GetLastActive()) { |
| 311 return b->window()->GetNativeHandle(); | 311 if (b->type() != Browser::TYPE_NORMAL) { |
| 312 b = BrowserList::FindBrowserWithType(b->profile(), | |
|
sky
2010/06/02 17:44:12
FindBrowserWithType searches in order of activatio
xiyuan
2010/06/02 17:48:08
The reason for doing this is FindBrowserWithType e
sky
2010/06/02 17:52:22
Ah ok. That makes sense.
| |
| 313 Browser::TYPE_NORMAL, | |
| 314 true); | |
| 315 } | |
| 316 | |
| 317 if (b) | |
| 318 return b->window()->GetNativeHandle(); | |
| 319 } | |
| 312 | 320 |
| 313 return NULL; | 321 return NULL; |
| 314 } | 322 } |
| 315 | 323 |
| 316 }; // namespace chromeos | 324 }; // namespace chromeos |
| 317 | 325 |
| 318 /////////////////////////////////////////////////////////////////////////////// | 326 /////////////////////////////////////////////////////////////////////////////// |
| 319 // Factory/finder method: | 327 // Factory/finder method: |
| 320 | 328 |
| 321 void ShowOptionsWindow(OptionsPage page, | 329 void ShowOptionsWindow(OptionsPage page, |
| 322 OptionsGroup highlight_group, | 330 OptionsGroup highlight_group, |
| 323 Profile* profile) { | 331 Profile* profile) { |
| 324 DCHECK(profile); | 332 DCHECK(profile); |
| 325 | 333 |
| 326 using chromeos::OptionsWindowView; | 334 using chromeos::OptionsWindowView; |
| 327 | 335 |
| 328 // If there's already an existing options window, close it and create | 336 // If there's already an existing options window, close it and create |
| 329 // a new one for the current active browser. | 337 // a new one for the current active browser. |
| 330 chromeos::CloseOptionsWindow(); | 338 chromeos::CloseOptionsWindow(); |
| 331 | 339 |
| 332 OptionsWindowView::instance_ = new OptionsWindowView(profile); | 340 OptionsWindowView::instance_ = new OptionsWindowView(profile); |
| 333 views::Window::CreateChromeWindow(chromeos::GetOptionsViewParent(), | 341 views::Window::CreateChromeWindow(chromeos::GetOptionsViewParent(), |
| 334 gfx::Rect(), | 342 gfx::Rect(), |
| 335 OptionsWindowView::instance_); | 343 OptionsWindowView::instance_); |
| 336 | 344 |
| 337 OptionsWindowView::instance_->ShowOptionsPage(page, highlight_group); | 345 OptionsWindowView::instance_->ShowOptionsPage(page, highlight_group); |
| 338 } | 346 } |
| 339 | 347 |
| OLD | NEW |