OLD | NEW |
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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 public: | 76 public: |
77 explicit ContextMenuModel( | 77 explicit ContextMenuModel( |
78 Shell* shell, const content::ContextMenuParams& params) | 78 Shell* shell, const content::ContextMenuParams& params) |
79 : ui::SimpleMenuModel(this), | 79 : ui::SimpleMenuModel(this), |
80 shell_(shell), | 80 shell_(shell), |
81 params_(params) { | 81 params_(params) { |
82 AddItem(COMMAND_OPEN_DEVTOOLS, base::ASCIIToUTF16("Inspect Element")); | 82 AddItem(COMMAND_OPEN_DEVTOOLS, base::ASCIIToUTF16("Inspect Element")); |
83 } | 83 } |
84 | 84 |
85 // ui::SimpleMenuModel::Delegate: | 85 // ui::SimpleMenuModel::Delegate: |
86 virtual bool IsCommandIdChecked(int command_id) const OVERRIDE { | 86 virtual bool IsCommandIdChecked(int command_id) const override { |
87 return false; | 87 return false; |
88 } | 88 } |
89 virtual bool IsCommandIdEnabled(int command_id) const OVERRIDE { | 89 virtual bool IsCommandIdEnabled(int command_id) const override { |
90 return true; | 90 return true; |
91 } | 91 } |
92 virtual bool GetAcceleratorForCommandId( | 92 virtual bool GetAcceleratorForCommandId( |
93 int command_id, | 93 int command_id, |
94 ui::Accelerator* accelerator) OVERRIDE { return false; } | 94 ui::Accelerator* accelerator) override { return false; } |
95 virtual void ExecuteCommand(int command_id, int event_flags) OVERRIDE { | 95 virtual void ExecuteCommand(int command_id, int event_flags) override { |
96 switch (command_id) { | 96 switch (command_id) { |
97 case COMMAND_OPEN_DEVTOOLS: | 97 case COMMAND_OPEN_DEVTOOLS: |
98 shell_->ShowDevToolsForElementAt(params_.x, params_.y); | 98 shell_->ShowDevToolsForElementAt(params_.x, params_.y); |
99 break; | 99 break; |
100 }; | 100 }; |
101 } | 101 } |
102 | 102 |
103 private: | 103 private: |
104 enum CommandID { | 104 enum CommandID { |
105 COMMAND_OPEN_DEVTOOLS | 105 COMMAND_OPEN_DEVTOOLS |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 ui::VKEY_BROWSER_FORWARD }; | 302 ui::VKEY_BROWSER_FORWARD }; |
303 for (size_t i = 0; i < arraysize(keys); ++i) { | 303 for (size_t i = 0; i < arraysize(keys); ++i) { |
304 GetFocusManager()->RegisterAccelerator( | 304 GetFocusManager()->RegisterAccelerator( |
305 ui::Accelerator(keys[i], ui::EF_NONE), | 305 ui::Accelerator(keys[i], ui::EF_NONE), |
306 ui::AcceleratorManager::kNormalPriority, | 306 ui::AcceleratorManager::kNormalPriority, |
307 this); | 307 this); |
308 } | 308 } |
309 } | 309 } |
310 // Overridden from TextfieldController | 310 // Overridden from TextfieldController |
311 virtual void ContentsChanged(views::Textfield* sender, | 311 virtual void ContentsChanged(views::Textfield* sender, |
312 const base::string16& new_contents) OVERRIDE { | 312 const base::string16& new_contents) override { |
313 } | 313 } |
314 virtual bool HandleKeyEvent(views::Textfield* sender, | 314 virtual bool HandleKeyEvent(views::Textfield* sender, |
315 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) { | 316 if (sender == url_entry_ && key_event.key_code() == ui::VKEY_RETURN) { |
317 std::string text = base::UTF16ToUTF8(url_entry_->text()); | 317 std::string text = base::UTF16ToUTF8(url_entry_->text()); |
318 GURL url(text); | 318 GURL url(text); |
319 if (!url.has_scheme()) { | 319 if (!url.has_scheme()) { |
320 url = GURL(std::string("http://") + std::string(text)); | 320 url = GURL(std::string("http://") + std::string(text)); |
321 url_entry_->SetText(base::ASCIIToUTF16(url.spec())); | 321 url_entry_->SetText(base::ASCIIToUTF16(url.spec())); |
322 } | 322 } |
323 shell_->LoadURL(url); | 323 shell_->LoadURL(url); |
324 return true; | 324 return true; |
325 } | 325 } |
326 return false; | 326 return false; |
327 } | 327 } |
328 | 328 |
329 // Overridden from ButtonListener | 329 // Overridden from ButtonListener |
330 virtual void ButtonPressed(views::Button* sender, | 330 virtual void ButtonPressed(views::Button* sender, |
331 const ui::Event& event) OVERRIDE { | 331 const ui::Event& event) override { |
332 if (sender == back_button_) | 332 if (sender == back_button_) |
333 shell_->GoBackOrForward(-1); | 333 shell_->GoBackOrForward(-1); |
334 else if (sender == forward_button_) | 334 else if (sender == forward_button_) |
335 shell_->GoBackOrForward(1); | 335 shell_->GoBackOrForward(1); |
336 else if (sender == refresh_button_) | 336 else if (sender == refresh_button_) |
337 shell_->Reload(); | 337 shell_->Reload(); |
338 else if (sender == stop_button_) | 338 else if (sender == stop_button_) |
339 shell_->Stop(); | 339 shell_->Stop(); |
340 } | 340 } |
341 | 341 |
342 // Overridden from WidgetDelegateView | 342 // Overridden from WidgetDelegateView |
343 virtual bool CanResize() const OVERRIDE { return true; } | 343 virtual bool CanResize() const override { return true; } |
344 virtual bool CanMaximize() const OVERRIDE { return true; } | 344 virtual bool CanMaximize() const override { return true; } |
345 virtual bool CanMinimize() const OVERRIDE { return true; } | 345 virtual bool CanMinimize() const override { return true; } |
346 virtual base::string16 GetWindowTitle() const OVERRIDE { | 346 virtual base::string16 GetWindowTitle() const override { |
347 return title_; | 347 return title_; |
348 } | 348 } |
349 virtual void WindowClosing() OVERRIDE { | 349 virtual void WindowClosing() override { |
350 if (shell_) { | 350 if (shell_) { |
351 delete shell_; | 351 delete shell_; |
352 shell_ = NULL; | 352 shell_ = NULL; |
353 } | 353 } |
354 } | 354 } |
355 virtual View* GetContentsView() OVERRIDE { return this; } | 355 virtual View* GetContentsView() override { return this; } |
356 | 356 |
357 // Overridden from View | 357 // Overridden from View |
358 virtual gfx::Size GetMinimumSize() const OVERRIDE { | 358 virtual gfx::Size GetMinimumSize() const override { |
359 // We want to be able to make the window smaller than its initial | 359 // We want to be able to make the window smaller than its initial |
360 // (preferred) size. | 360 // (preferred) size. |
361 return gfx::Size(); | 361 return gfx::Size(); |
362 } | 362 } |
363 virtual void ViewHierarchyChanged( | 363 virtual void ViewHierarchyChanged( |
364 const ViewHierarchyChangedDetails& details) OVERRIDE { | 364 const ViewHierarchyChangedDetails& details) override { |
365 if (details.is_add && details.child == this) { | 365 if (details.is_add && details.child == this) { |
366 InitShellWindow(); | 366 InitShellWindow(); |
367 } | 367 } |
368 } | 368 } |
369 | 369 |
370 // Overridden from AcceleratorTarget: | 370 // Overridden from AcceleratorTarget: |
371 virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) OVERRIDE { | 371 virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) override { |
372 switch (accelerator.key_code()) { | 372 switch (accelerator.key_code()) { |
373 case ui::VKEY_F5: | 373 case ui::VKEY_F5: |
374 shell_->Reload(); | 374 shell_->Reload(); |
375 return true; | 375 return true; |
376 case ui::VKEY_BROWSER_BACK: | 376 case ui::VKEY_BROWSER_BACK: |
377 shell_->GoBackOrForward(-1); | 377 shell_->GoBackOrForward(-1); |
378 return true; | 378 return true; |
379 case ui::VKEY_BROWSER_FORWARD: | 379 case ui::VKEY_BROWSER_FORWARD: |
380 shell_->GoBackOrForward(1); | 380 shell_->GoBackOrForward(1); |
381 return true; | 381 return true; |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
567 | 567 |
568 void Shell::PlatformWebContentsFocused(WebContents* contents) { | 568 void Shell::PlatformWebContentsFocused(WebContents* contents) { |
569 if (headless_) | 569 if (headless_) |
570 return; | 570 return; |
571 ShellWindowDelegateView* delegate_view = | 571 ShellWindowDelegateView* delegate_view = |
572 static_cast<ShellWindowDelegateView*>(window_widget_->widget_delegate()); | 572 static_cast<ShellWindowDelegateView*>(window_widget_->widget_delegate()); |
573 delegate_view->OnWebContentsFocused(contents); | 573 delegate_view->OnWebContentsFocused(contents); |
574 } | 574 } |
575 | 575 |
576 } // namespace content | 576 } // namespace content |
OLD | NEW |