Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(346)

Side by Side Diff: chrome/browser/ui/views/base_shell_dialog_win.cc

Issue 9203001: Implement input type=color UI (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: fixed issues/removed color_select_helper/added color_chooser_id Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/ui/views/base_shell_dialog_win.h"
6
7 #include <algorithm>
8
9 // static
10 BaseShellDialogImpl::Owners BaseShellDialogImpl::owners_;
11 int BaseShellDialogImpl::instance_count_ = 0;
12
13 BaseShellDialogImpl::BaseShellDialogImpl() {
14 ++instance_count_;
15 }
16
17 BaseShellDialogImpl::~BaseShellDialogImpl() {
18 // All runs should be complete by the time this is called!
19 if (--instance_count_ == 0)
20 DCHECK(owners_.empty());
21 }
22
23 BaseShellDialogImpl::RunState BaseShellDialogImpl::BeginRun(HWND owner) {
24 // Cannot run a modal shell dialog if one is already running for this owner.
25 DCHECK(!IsRunningDialogForOwner(owner));
26 // The owner must be a top level window, otherwise we could end up with two
27 // entries in our map for the same top level window.
28 DCHECK(!owner || owner == GetAncestor(owner, GA_ROOT));
29 RunState run_state;
30 run_state.dialog_thread = CreateDialogThread();
31 run_state.owner = owner;
32 if (owner) {
33 owners_.insert(owner);
34 DisableOwner(owner);
35 }
36 return run_state;
37 }
38
39 void BaseShellDialogImpl::EndRun(RunState run_state) {
40 if (run_state.owner) {
41 DCHECK(IsRunningDialogForOwner(run_state.owner));
42 EnableOwner(run_state.owner);
43 DCHECK(owners_.find(run_state.owner) != owners_.end());
44 owners_.erase(run_state.owner);
45 }
46 DCHECK(run_state.dialog_thread);
47 delete run_state.dialog_thread;
48 }
49
50 bool BaseShellDialogImpl::IsRunningDialogForOwner(HWND owner) const {
51 return (owner && owners_.find(owner) != owners_.end());
52 }
53
54 void BaseShellDialogImpl::DisableOwner(HWND owner) {
55 if (IsWindow(owner))
56 EnableWindow(owner, FALSE);
57 }
58
59 // static
60 base::Thread* BaseShellDialogImpl::CreateDialogThread() {
61 base::Thread* thread = new ShellDialogThread;
62 bool started = thread->Start();
63 DCHECK(started);
64 return thread;
65 }
66
67 void BaseShellDialogImpl::EnableOwner(HWND owner) {
68 if (IsWindow(owner))
69 EnableWindow(owner, TRUE);
70 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698