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

Side by Side Diff: chrome_frame/turndown_prompt/turndown_prompt_content.cc

Issue 17153006: Chrome Frame turndown prompt. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase to r208076 Created 7 years, 6 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_frame/ready_mode/internal/ready_prompt_content.h" 5 #include "chrome_frame/turndown_prompt/turndown_prompt_content.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "chrome_frame/ready_mode/internal/ready_mode_state.h"
9 #include "chrome_frame/ready_mode/internal/ready_prompt_window.h"
10 #include "chrome_frame/ready_mode/internal/url_launcher.h" 8 #include "chrome_frame/ready_mode/internal/url_launcher.h"
9 #include "chrome_frame/turndown_prompt/turndown_prompt_window.h"
11 10
12 ReadyPromptContent::ReadyPromptContent(ReadyModeState* ready_mode_state, 11 TurndownPromptContent::TurndownPromptContent(
13 UrlLauncher* url_launcher) 12 UrlLauncher* url_launcher,
14 : ready_mode_state_(ready_mode_state), 13 const base::Closure& uninstall_closure)
15 url_launcher_(url_launcher) { 14 : url_launcher_(url_launcher),
15 uninstall_closure_(uninstall_closure) {
16 } 16 }
17 17
18 ReadyPromptContent::~ReadyPromptContent() { 18 TurndownPromptContent::~TurndownPromptContent() {
19 if (window_ != NULL && window_->IsWindow()) { 19 if (window_ != NULL && window_->IsWindow()) {
20 // The window must discard its ContentFrame pointer at this time. 20 // The window must discard its ContentFrame pointer at this time.
21 window_->DestroyWindow(); 21 window_->DestroyWindow();
22 window_.reset(); 22 window_.reset();
23 } 23 }
24 } 24 }
25 25
26 bool ReadyPromptContent::InstallInFrame(Frame* frame) { 26 bool TurndownPromptContent::InstallInFrame(Frame* frame) {
27 DCHECK(window_ == NULL); 27 DCHECK(window_ == NULL);
28 DCHECK(ready_mode_state_ != NULL);
29 DCHECK(url_launcher_ != NULL); 28 DCHECK(url_launcher_ != NULL);
30 29
31 // Pass ownership of our ready_mode_state_ and url_launcher_ to the window. 30 // Pass ownership of our url_launcher_ to the window.
32 window_ = ReadyPromptWindow::CreateInstance( 31 window_ = TurndownPromptWindow::CreateInstance(
33 frame, ready_mode_state_.release(), url_launcher_.release()); 32 frame, url_launcher_.release(), uninstall_closure_);
33 uninstall_closure_.Reset();
34 34
35 return window_ != NULL; 35 return window_ != NULL;
36 } 36 }
37 37
38 void ReadyPromptContent::SetDimensions(const RECT& dimensions) { 38 void TurndownPromptContent::SetDimensions(const RECT& dimensions) {
39 if (window_ != NULL && window_->IsWindow()) { 39 if (window_ != NULL && window_->IsWindow()) {
40 window_->SetWindowPos(HWND_TOP, &dimensions, 40 window_->SetWindowPos(HWND_TOP, &dimensions,
41 ::IsRectEmpty(&dimensions) ? SWP_HIDEWINDOW : 41 ::IsRectEmpty(&dimensions) ? SWP_HIDEWINDOW :
42 SWP_SHOWWINDOW); 42 SWP_SHOWWINDOW);
43 } 43 }
44 } 44 }
45 45
46 bool GetDialogTemplateDimensions(ReadyPromptWindow* window, RECT* dimensions) { 46 bool GetDialogTemplateDimensions(TurndownPromptWindow* window,
47 RECT* dimensions) {
47 HRSRC resource = ::FindResource(_AtlBaseModule.GetResourceInstance(), 48 HRSRC resource = ::FindResource(_AtlBaseModule.GetResourceInstance(),
48 MAKEINTRESOURCE(ReadyPromptWindow::IDD), 49 MAKEINTRESOURCE(TurndownPromptWindow::IDD),
49 RT_DIALOG); 50 RT_DIALOG);
50 51
51 HGLOBAL handle = NULL; 52 HGLOBAL handle = NULL;
52 DLGTEMPLATE* dlgtemplate = NULL; 53 DLGTEMPLATE* dlgtemplate = NULL;
53 _DialogSplitHelper::DLGTEMPLATEEX* dlgtemplateex = NULL; 54 _DialogSplitHelper::DLGTEMPLATEEX* dlgtemplateex = NULL;
54 55
55 if (resource == NULL) { 56 if (resource == NULL) {
56 DPLOG(ERROR) << "Failed to find resource for ReadyPromptWindow::IDD"; 57 DPLOG(ERROR) << "Failed to find resource for TurndownPromptWindow::IDD";
57 return false; 58 return false;
58 } 59 }
59 60
60 handle = ::LoadResource(_AtlBaseModule.GetResourceInstance(), resource); 61 handle = ::LoadResource(_AtlBaseModule.GetResourceInstance(), resource);
61 62
62 if (handle == NULL) { 63 if (handle == NULL) {
63 DPLOG(ERROR) << "Failed to load resource for ReadyPromptWindow::IDD"; 64 DPLOG(ERROR) << "Failed to load resource for TurndownPromptWindow::IDD";
64 return false; 65 return false;
65 } 66 }
66 67
67 dlgtemplate = reinterpret_cast<DLGTEMPLATE*>(::LockResource(handle)); 68 dlgtemplate = reinterpret_cast<DLGTEMPLATE*>(::LockResource(handle));
68 if (dlgtemplate == NULL) { 69 if (dlgtemplate == NULL) {
69 DPLOG(ERROR) << "Failed to lock resource for ReadyPromptWindow::IDD"; 70 DPLOG(ERROR) << "Failed to lock resource for TurndownPromptWindow::IDD";
70 return false; 71 return false;
71 } 72 }
72 73
73 if (!_DialogSplitHelper::IsDialogEx(dlgtemplate)) { 74 if (!_DialogSplitHelper::IsDialogEx(dlgtemplate)) {
74 DLOG(ERROR) << "Resource ReadyPromptWindow::IDD is not a DLGTEMPLATEEX"; 75 DLOG(ERROR) << "Resource TurndownPromptWindow::IDD is not a DLGTEMPLATEEX";
75 return false; 76 return false;
76 } 77 }
77 78
78 dlgtemplateex = 79 dlgtemplateex =
79 reinterpret_cast<_DialogSplitHelper::DLGTEMPLATEEX*>(dlgtemplate); 80 reinterpret_cast<_DialogSplitHelper::DLGTEMPLATEEX*>(dlgtemplate);
80 81
81 RECT dlgdimensions = {0, 0, dlgtemplateex->cx, dlgtemplateex->cy}; 82 RECT dlgdimensions = {0, 0, dlgtemplateex->cx, dlgtemplateex->cy};
82 if (!window->MapDialogRect(&dlgdimensions)) { 83 if (!window->MapDialogRect(&dlgdimensions)) {
83 DPLOG(ERROR) << "Failure in MapDialogRect"; 84 DPLOG(ERROR) << "Failure in MapDialogRect";
84 return false; 85 return false;
85 } 86 }
86 87
87 *dimensions = dlgdimensions; 88 *dimensions = dlgdimensions;
88 return true; 89 return true;
89 } 90 }
90 91
91 size_t ReadyPromptContent::GetDesiredSize(size_t width, size_t height) { 92 size_t TurndownPromptContent::GetDesiredSize(size_t width, size_t height) {
92 DCHECK(window_ != NULL && window_->IsWindow()); 93 DCHECK(window_ != NULL && window_->IsWindow());
93 94
94 if (window_ == NULL || !window_->IsWindow()) { 95 if (window_ == NULL || !window_->IsWindow()) {
95 return 0; 96 return 0;
96 } 97 }
97 RECT dialog_dimensions = {0, 0, 0, 0}; 98 RECT dialog_dimensions = {0, 0, 0, 0};
98 99
99 if (GetDialogTemplateDimensions(window_.get(), &dialog_dimensions)) 100 if (GetDialogTemplateDimensions(window_.get(), &dialog_dimensions))
100 return width == 0 ? dialog_dimensions.right : dialog_dimensions.bottom; 101 return width == 0 ? dialog_dimensions.right : dialog_dimensions.bottom;
101 else 102 else
102 return width == 0 ? 0 : 39; 103 return width == 0 ? 0 : 39;
103 } 104 }
OLDNEW
« no previous file with comments | « chrome_frame/turndown_prompt/turndown_prompt_content.h ('k') | chrome_frame/turndown_prompt/turndown_prompt_window.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698