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

Side by Side Diff: content/shell/shell.cc

Issue 10831056: Port the render_view_host_manager_browsertest.cc to content_browsertests. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 4 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) 2012 The Chromium Authors. All rights reserved. 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 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 "content/shell/shell.h" 5 #include "content/shell/shell.h"
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
(...skipping 11 matching lines...) Expand all
22 #include "content/shell/shell_switches.h" 22 #include "content/shell/shell_switches.h"
23 #include "ui/gfx/size.h" 23 #include "ui/gfx/size.h"
24 24
25 // Content area size for newly created windows. 25 // Content area size for newly created windows.
26 static const int kTestWindowWidth = 800; 26 static const int kTestWindowWidth = 800;
27 static const int kTestWindowHeight = 600; 27 static const int kTestWindowHeight = 600;
28 28
29 namespace content { 29 namespace content {
30 30
31 std::vector<Shell*> Shell::windows_; 31 std::vector<Shell*> Shell::windows_;
32 base::Callback<void(Shell*)> Shell::shell_created_callback_;
32 33
33 bool Shell::quit_message_loop_ = true; 34 bool Shell::quit_message_loop_ = true;
34 35
35 Shell::Shell(WebContents* web_contents) 36 Shell::Shell(WebContents* web_contents)
36 : window_(NULL), 37 : window_(NULL),
37 url_edit_view_(NULL) 38 url_edit_view_(NULL)
38 #if defined(OS_WIN) && !defined(USE_AURA) 39 #if defined(OS_WIN) && !defined(USE_AURA)
39 , default_edit_wnd_proc_(0) 40 , default_edit_wnd_proc_(0)
40 #endif 41 #endif
41 { 42 {
Charlie Reis 2012/07/30 16:40:01 This macro makes for an odd indent situation. I'm
jam 2012/07/30 17:03:50 I'm not sure what's recommended in this case. when
42 registrar_.Add(this, NOTIFICATION_WEB_CONTENTS_TITLE_UPDATED, 43 registrar_.Add(this, NOTIFICATION_WEB_CONTENTS_TITLE_UPDATED,
43 Source<WebContents>(web_contents)); 44 Source<WebContents>(web_contents));
44 windows_.push_back(this); 45 windows_.push_back(this);
46
47 if (!shell_created_callback_.is_null()) {
48 shell_created_callback_.Run(this);
49 shell_created_callback_.Reset();
50 }
45 } 51 }
46 52
47 Shell::~Shell() { 53 Shell::~Shell() {
48 PlatformCleanUp(); 54 PlatformCleanUp();
49 55
50 for (size_t i = 0; i < windows_.size(); ++i) { 56 for (size_t i = 0; i < windows_.size(); ++i) {
51 if (windows_[i] == this) { 57 if (windows_[i] == this) {
52 windows_.erase(windows_.begin() + i); 58 windows_.erase(windows_.begin() + i);
53 break; 59 break;
54 } 60 }
(...skipping 17 matching lines...) Expand all
72 } 78 }
73 79
74 void Shell::CloseAllWindows() { 80 void Shell::CloseAllWindows() {
75 AutoReset<bool> auto_reset(&quit_message_loop_, false); 81 AutoReset<bool> auto_reset(&quit_message_loop_, false);
76 std::vector<Shell*> open_windows(windows_); 82 std::vector<Shell*> open_windows(windows_);
77 for (size_t i = 0; i < open_windows.size(); ++i) 83 for (size_t i = 0; i < open_windows.size(); ++i)
78 open_windows[i]->Close(); 84 open_windows[i]->Close();
79 MessageLoop::current()->RunAllPending(); 85 MessageLoop::current()->RunAllPending();
80 } 86 }
81 87
88 void Shell::SetShellCreatedCallback(
89 base::Callback<void(Shell*)> shell_created_callback) {
90 DCHECK(shell_created_callback_.is_null());
91 shell_created_callback_ = shell_created_callback;
92 }
93
82 Shell* Shell::FromRenderViewHost(RenderViewHost* rvh) { 94 Shell* Shell::FromRenderViewHost(RenderViewHost* rvh) {
83 for (size_t i = 0; i < windows_.size(); ++i) { 95 for (size_t i = 0; i < windows_.size(); ++i) {
84 if (windows_[i]->web_contents() && 96 if (windows_[i]->web_contents() &&
85 windows_[i]->web_contents()->GetRenderViewHost() == rvh) { 97 windows_[i]->web_contents()->GetRenderViewHost() == rvh) {
86 return windows_[i]; 98 return windows_[i];
87 } 99 }
88 } 100 }
89 return NULL; 101 return NULL;
90 } 102 }
91 103
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 PlatformEnableUIControl(FORWARD_BUTTON, current_index < max_index); 150 PlatformEnableUIControl(FORWARD_BUTTON, current_index < max_index);
139 PlatformEnableUIControl(STOP_BUTTON, web_contents_->IsLoading()); 151 PlatformEnableUIControl(STOP_BUTTON, web_contents_->IsLoading());
140 } 152 }
141 153
142 gfx::NativeView Shell::GetContentView() { 154 gfx::NativeView Shell::GetContentView() {
143 if (!web_contents_.get()) 155 if (!web_contents_.get())
144 return NULL; 156 return NULL;
145 return web_contents_->GetNativeView(); 157 return web_contents_->GetNativeView();
146 } 158 }
147 159
160 WebContents* Shell::OpenURLFromTab(WebContents* source,
161 const OpenURLParams& params) {
162 // The only one we implement for now.
163 DCHECK(params.disposition == CURRENT_TAB);
164 source->GetController().LoadURL(
165 params.url, params.referrer, params.transition, std::string());
166 return source;
167 }
168
148 void Shell::LoadingStateChanged(WebContents* source) { 169 void Shell::LoadingStateChanged(WebContents* source) {
149 UpdateNavigationControls(); 170 UpdateNavigationControls();
150 PlatformSetIsLoading(source->IsLoading()); 171 PlatformSetIsLoading(source->IsLoading());
151 } 172 }
152 173
174 void Shell::CloseContents(WebContents* source) {
175 Close();
176 }
177
153 void Shell::WebContentsCreated(WebContents* source_contents, 178 void Shell::WebContentsCreated(WebContents* source_contents,
154 int64 source_frame_id, 179 int64 source_frame_id,
155 const GURL& target_url, 180 const GURL& target_url,
156 WebContents* new_contents) { 181 WebContents* new_contents) {
157 CreateShell(new_contents); 182 CreateShell(new_contents);
158 } 183 }
159 184
160 void Shell::DidNavigateMainFramePostCommit(WebContents* web_contents) { 185 void Shell::DidNavigateMainFramePostCommit(WebContents* web_contents) {
161 PlatformSetAddressBarURL(web_contents->GetURL()); 186 PlatformSetAddressBarURL(web_contents->GetURL());
162 } 187 }
(...skipping 27 matching lines...) Expand all
190 Details<std::pair<NavigationEntry*, bool> >(details).ptr(); 215 Details<std::pair<NavigationEntry*, bool> >(details).ptr();
191 216
192 if (title->first) { 217 if (title->first) {
193 string16 text = title->first->GetTitle(); 218 string16 text = title->first->GetTitle();
194 PlatformSetTitle(text); 219 PlatformSetTitle(text);
195 } 220 }
196 } 221 }
197 } 222 }
198 223
199 } // namespace content 224 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698