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

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

Issue 686523002: Standardize usage of virtual/override/final specifiers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 6 years, 1 month 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
« no previous file with comments | « content/shell/browser/shell_platform_data_aura.cc ('k') | content/test/image_decoder_test.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 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 "content/shell/browser/shell.h" 5 #include "content/shell/browser/shell.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "content/public/browser/context_factory.h" 9 #include "content/public/browser/context_factory.h"
10 #include "content/public/browser/render_widget_host_view.h" 10 #include "content/public/browser/render_widget_host_view.h"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 50
51 namespace content { 51 namespace content {
52 52
53 namespace { 53 namespace {
54 // ViewDelegate implementation for aura content shell 54 // ViewDelegate implementation for aura content shell
55 class ShellViewsDelegateAura : public views::DesktopTestViewsDelegate { 55 class ShellViewsDelegateAura : public views::DesktopTestViewsDelegate {
56 public: 56 public:
57 ShellViewsDelegateAura() : use_transparent_windows_(false) { 57 ShellViewsDelegateAura() : use_transparent_windows_(false) {
58 } 58 }
59 59
60 virtual ~ShellViewsDelegateAura() { 60 ~ShellViewsDelegateAura() override {}
61 }
62 61
63 void SetUseTransparentWindows(bool transparent) { 62 void SetUseTransparentWindows(bool transparent) {
64 use_transparent_windows_ = transparent; 63 use_transparent_windows_ = transparent;
65 } 64 }
66 65
67 private: 66 private:
68 bool use_transparent_windows_; 67 bool use_transparent_windows_;
69 68
70 DISALLOW_COPY_AND_ASSIGN(ShellViewsDelegateAura); 69 DISALLOW_COPY_AND_ASSIGN(ShellViewsDelegateAura);
71 }; 70 };
72 71
73 // Model for the "Debug" menu 72 // Model for the "Debug" menu
74 class ContextMenuModel : public ui::SimpleMenuModel, 73 class ContextMenuModel : public ui::SimpleMenuModel,
75 public ui::SimpleMenuModel::Delegate { 74 public ui::SimpleMenuModel::Delegate {
76 public: 75 public:
77 explicit ContextMenuModel( 76 explicit ContextMenuModel(
78 Shell* shell, const content::ContextMenuParams& params) 77 Shell* shell, const content::ContextMenuParams& params)
79 : ui::SimpleMenuModel(this), 78 : ui::SimpleMenuModel(this),
80 shell_(shell), 79 shell_(shell),
81 params_(params) { 80 params_(params) {
82 AddItem(COMMAND_OPEN_DEVTOOLS, base::ASCIIToUTF16("Inspect Element")); 81 AddItem(COMMAND_OPEN_DEVTOOLS, base::ASCIIToUTF16("Inspect Element"));
83 } 82 }
84 83
85 // ui::SimpleMenuModel::Delegate: 84 // ui::SimpleMenuModel::Delegate:
86 virtual bool IsCommandIdChecked(int command_id) const override { 85 bool IsCommandIdChecked(int command_id) const override { return false; }
86 bool IsCommandIdEnabled(int command_id) const override { return true; }
87 bool GetAcceleratorForCommandId(int command_id,
88 ui::Accelerator* accelerator) override {
87 return false; 89 return false;
88 } 90 }
89 virtual bool IsCommandIdEnabled(int command_id) const override { 91 void ExecuteCommand(int command_id, int event_flags) override {
90 return true;
91 }
92 virtual bool GetAcceleratorForCommandId(
93 int command_id,
94 ui::Accelerator* accelerator) override { return false; }
95 virtual void ExecuteCommand(int command_id, int event_flags) override {
96 switch (command_id) { 92 switch (command_id) {
97 case COMMAND_OPEN_DEVTOOLS: 93 case COMMAND_OPEN_DEVTOOLS:
98 shell_->ShowDevToolsForElementAt(params_.x, params_.y); 94 shell_->ShowDevToolsForElementAt(params_.x, params_.y);
99 break; 95 break;
100 }; 96 };
101 } 97 }
102 98
103 private: 99 private:
104 enum CommandID { 100 enum CommandID {
105 COMMAND_OPEN_DEVTOOLS 101 COMMAND_OPEN_DEVTOOLS
(...skipping 14 matching lines...) Expand all
120 BACK_BUTTON, 116 BACK_BUTTON,
121 FORWARD_BUTTON, 117 FORWARD_BUTTON,
122 STOP_BUTTON 118 STOP_BUTTON
123 }; 119 };
124 120
125 ShellWindowDelegateView(Shell* shell) 121 ShellWindowDelegateView(Shell* shell)
126 : shell_(shell), 122 : shell_(shell),
127 toolbar_view_(new View), 123 toolbar_view_(new View),
128 contents_view_(new View) { 124 contents_view_(new View) {
129 } 125 }
130 virtual ~ShellWindowDelegateView() {} 126 ~ShellWindowDelegateView() override {}
131 127
132 // Update the state of UI controls 128 // Update the state of UI controls
133 void SetAddressBarURL(const GURL& url) { 129 void SetAddressBarURL(const GURL& url) {
134 url_entry_->SetText(base::ASCIIToUTF16(url.spec())); 130 url_entry_->SetText(base::ASCIIToUTF16(url.spec()));
135 } 131 }
136 void SetWebContents(WebContents* web_contents, const gfx::Size& size) { 132 void SetWebContents(WebContents* web_contents, const gfx::Size& size) {
137 contents_view_->SetLayoutManager(new views::FillLayout()); 133 contents_view_->SetLayoutManager(new views::FillLayout());
138 web_view_ = new views::WebView(web_contents->GetBrowserContext()); 134 web_view_ = new views::WebView(web_contents->GetBrowserContext());
139 web_view_->SetWebContents(web_contents); 135 web_view_->SetWebContents(web_contents);
140 web_view_->SetPreferredSize(size); 136 web_view_->SetPreferredSize(size);
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 ui::VKEY_BROWSER_BACK, 297 ui::VKEY_BROWSER_BACK,
302 ui::VKEY_BROWSER_FORWARD }; 298 ui::VKEY_BROWSER_FORWARD };
303 for (size_t i = 0; i < arraysize(keys); ++i) { 299 for (size_t i = 0; i < arraysize(keys); ++i) {
304 GetFocusManager()->RegisterAccelerator( 300 GetFocusManager()->RegisterAccelerator(
305 ui::Accelerator(keys[i], ui::EF_NONE), 301 ui::Accelerator(keys[i], ui::EF_NONE),
306 ui::AcceleratorManager::kNormalPriority, 302 ui::AcceleratorManager::kNormalPriority,
307 this); 303 this);
308 } 304 }
309 } 305 }
310 // Overridden from TextfieldController 306 // Overridden from TextfieldController
311 virtual void ContentsChanged(views::Textfield* sender, 307 void ContentsChanged(views::Textfield* sender,
312 const base::string16& new_contents) override { 308 const base::string16& new_contents) override {}
313 } 309 bool HandleKeyEvent(views::Textfield* sender,
314 virtual bool HandleKeyEvent(views::Textfield* sender, 310 const ui::KeyEvent& key_event) override {
315 const ui::KeyEvent& key_event) override {
316 if (sender == url_entry_ && key_event.key_code() == ui::VKEY_RETURN) { 311 if (sender == url_entry_ && key_event.key_code() == ui::VKEY_RETURN) {
317 std::string text = base::UTF16ToUTF8(url_entry_->text()); 312 std::string text = base::UTF16ToUTF8(url_entry_->text());
318 GURL url(text); 313 GURL url(text);
319 if (!url.has_scheme()) { 314 if (!url.has_scheme()) {
320 url = GURL(std::string("http://") + std::string(text)); 315 url = GURL(std::string("http://") + std::string(text));
321 url_entry_->SetText(base::ASCIIToUTF16(url.spec())); 316 url_entry_->SetText(base::ASCIIToUTF16(url.spec()));
322 } 317 }
323 shell_->LoadURL(url); 318 shell_->LoadURL(url);
324 return true; 319 return true;
325 } 320 }
326 return false; 321 return false;
327 } 322 }
328 323
329 // Overridden from ButtonListener 324 // Overridden from ButtonListener
330 virtual void ButtonPressed(views::Button* sender, 325 void ButtonPressed(views::Button* sender, const ui::Event& event) override {
331 const ui::Event& event) override {
332 if (sender == back_button_) 326 if (sender == back_button_)
333 shell_->GoBackOrForward(-1); 327 shell_->GoBackOrForward(-1);
334 else if (sender == forward_button_) 328 else if (sender == forward_button_)
335 shell_->GoBackOrForward(1); 329 shell_->GoBackOrForward(1);
336 else if (sender == refresh_button_) 330 else if (sender == refresh_button_)
337 shell_->Reload(); 331 shell_->Reload();
338 else if (sender == stop_button_) 332 else if (sender == stop_button_)
339 shell_->Stop(); 333 shell_->Stop();
340 } 334 }
341 335
342 // Overridden from WidgetDelegateView 336 // Overridden from WidgetDelegateView
343 virtual bool CanResize() const override { return true; } 337 bool CanResize() const override { return true; }
344 virtual bool CanMaximize() const override { return true; } 338 bool CanMaximize() const override { return true; }
345 virtual bool CanMinimize() const override { return true; } 339 bool CanMinimize() const override { return true; }
346 virtual base::string16 GetWindowTitle() const override { 340 base::string16 GetWindowTitle() const override { return title_; }
347 return title_; 341 void WindowClosing() override {
348 }
349 virtual void WindowClosing() override {
350 if (shell_) { 342 if (shell_) {
351 delete shell_; 343 delete shell_;
352 shell_ = NULL; 344 shell_ = NULL;
353 } 345 }
354 } 346 }
355 virtual View* GetContentsView() override { return this; } 347 View* GetContentsView() override { return this; }
356 348
357 // Overridden from View 349 // Overridden from View
358 virtual gfx::Size GetMinimumSize() const override { 350 gfx::Size GetMinimumSize() const override {
359 // We want to be able to make the window smaller than its initial 351 // We want to be able to make the window smaller than its initial
360 // (preferred) size. 352 // (preferred) size.
361 return gfx::Size(); 353 return gfx::Size();
362 } 354 }
363 virtual void ViewHierarchyChanged( 355 void ViewHierarchyChanged(
364 const ViewHierarchyChangedDetails& details) override { 356 const ViewHierarchyChangedDetails& details) override {
365 if (details.is_add && details.child == this) { 357 if (details.is_add && details.child == this) {
366 InitShellWindow(); 358 InitShellWindow();
367 } 359 }
368 } 360 }
369 361
370 // Overridden from AcceleratorTarget: 362 // Overridden from AcceleratorTarget:
371 virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) override { 363 bool AcceleratorPressed(const ui::Accelerator& accelerator) override {
372 switch (accelerator.key_code()) { 364 switch (accelerator.key_code()) {
373 case ui::VKEY_F5: 365 case ui::VKEY_F5:
374 shell_->Reload(); 366 shell_->Reload();
375 return true; 367 return true;
376 case ui::VKEY_BROWSER_BACK: 368 case ui::VKEY_BROWSER_BACK:
377 shell_->GoBackOrForward(-1); 369 shell_->GoBackOrForward(-1);
378 return true; 370 return true;
379 case ui::VKEY_BROWSER_FORWARD: 371 case ui::VKEY_BROWSER_FORWARD:
380 shell_->GoBackOrForward(1); 372 shell_->GoBackOrForward(1);
381 return true; 373 return true;
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
567 559
568 void Shell::PlatformWebContentsFocused(WebContents* contents) { 560 void Shell::PlatformWebContentsFocused(WebContents* contents) {
569 if (headless_) 561 if (headless_)
570 return; 562 return;
571 ShellWindowDelegateView* delegate_view = 563 ShellWindowDelegateView* delegate_view =
572 static_cast<ShellWindowDelegateView*>(window_widget_->widget_delegate()); 564 static_cast<ShellWindowDelegateView*>(window_widget_->widget_delegate());
573 delegate_view->OnWebContentsFocused(contents); 565 delegate_view->OnWebContentsFocused(contents);
574 } 566 }
575 567
576 } // namespace content 568 } // namespace content
OLDNEW
« no previous file with comments | « content/shell/browser/shell_platform_data_aura.cc ('k') | content/test/image_decoder_test.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698