OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/browser/ui/apps/chrome_app_delegate.h" | 5 #include "chrome/browser/ui/apps/chrome_app_delegate.h" |
6 | 6 |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
9 #include "chrome/browser/app_mode/app_mode_utils.h" | 9 #include "chrome/browser/app_mode/app_mode_utils.h" |
10 #include "chrome/browser/apps/scoped_keep_alive.h" | 10 #include "chrome/browser/apps/scoped_keep_alive.h" |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 // of asking the system to open it. | 74 // of asking the system to open it. |
75 class OpenURLFromTabBasedOnBrowserDefault | 75 class OpenURLFromTabBasedOnBrowserDefault |
76 : public ShellIntegration::DefaultWebClientObserver { | 76 : public ShellIntegration::DefaultWebClientObserver { |
77 public: | 77 public: |
78 OpenURLFromTabBasedOnBrowserDefault(scoped_ptr<content::WebContents> source, | 78 OpenURLFromTabBasedOnBrowserDefault(scoped_ptr<content::WebContents> source, |
79 const content::OpenURLParams& params) | 79 const content::OpenURLParams& params) |
80 : source_(source.Pass()), params_(params) {} | 80 : source_(source.Pass()), params_(params) {} |
81 | 81 |
82 // Opens a URL when called with the result of if this is the default system | 82 // Opens a URL when called with the result of if this is the default system |
83 // browser or not. | 83 // browser or not. |
84 virtual void SetDefaultWebClientUIState( | 84 void SetDefaultWebClientUIState( |
85 ShellIntegration::DefaultWebClientUIState state) override { | 85 ShellIntegration::DefaultWebClientUIState state) override { |
86 Profile* profile = | 86 Profile* profile = |
87 Profile::FromBrowserContext(source_->GetBrowserContext()); | 87 Profile::FromBrowserContext(source_->GetBrowserContext()); |
88 DCHECK(profile); | 88 DCHECK(profile); |
89 if (!profile) | 89 if (!profile) |
90 return; | 90 return; |
91 switch (state) { | 91 switch (state) { |
92 case ShellIntegration::STATE_PROCESSING: | 92 case ShellIntegration::STATE_PROCESSING: |
93 break; | 93 break; |
94 case ShellIntegration::STATE_IS_DEFAULT: | 94 case ShellIntegration::STATE_IS_DEFAULT: |
95 OpenURLFromTabInternal(profile, params_); | 95 OpenURLFromTabInternal(profile, params_); |
96 break; | 96 break; |
97 case ShellIntegration::STATE_NOT_DEFAULT: | 97 case ShellIntegration::STATE_NOT_DEFAULT: |
98 case ShellIntegration::STATE_UNKNOWN: | 98 case ShellIntegration::STATE_UNKNOWN: |
99 platform_util::OpenExternal(profile, params_.url); | 99 platform_util::OpenExternal(profile, params_.url); |
100 break; | 100 break; |
101 } | 101 } |
102 } | 102 } |
103 | 103 |
104 virtual bool IsOwnedByWorker() override { return true; } | 104 bool IsOwnedByWorker() override { return true; } |
105 | 105 |
106 private: | 106 private: |
107 scoped_ptr<content::WebContents> source_; | 107 scoped_ptr<content::WebContents> source_; |
108 const content::OpenURLParams params_; | 108 const content::OpenURLParams params_; |
109 }; | 109 }; |
110 | 110 |
111 } // namespace | 111 } // namespace |
112 | 112 |
113 class ChromeAppDelegate::NewWindowContentsDelegate | 113 class ChromeAppDelegate::NewWindowContentsDelegate |
114 : public content::WebContentsDelegate { | 114 : public content::WebContentsDelegate { |
115 public: | 115 public: |
116 NewWindowContentsDelegate() {} | 116 NewWindowContentsDelegate() {} |
117 virtual ~NewWindowContentsDelegate() {} | 117 ~NewWindowContentsDelegate() override {} |
118 | 118 |
119 virtual content::WebContents* OpenURLFromTab( | 119 content::WebContents* OpenURLFromTab( |
120 content::WebContents* source, | 120 content::WebContents* source, |
121 const content::OpenURLParams& params) override; | 121 const content::OpenURLParams& params) override; |
122 | 122 |
123 private: | 123 private: |
124 DISALLOW_COPY_AND_ASSIGN(NewWindowContentsDelegate); | 124 DISALLOW_COPY_AND_ASSIGN(NewWindowContentsDelegate); |
125 }; | 125 }; |
126 | 126 |
127 content::WebContents* | 127 content::WebContents* |
128 ChromeAppDelegate::NewWindowContentsDelegate::OpenURLFromTab( | 128 ChromeAppDelegate::NewWindowContentsDelegate::OpenURLFromTab( |
129 content::WebContents* source, | 129 content::WebContents* source, |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 const content::NotificationDetails& details) { | 290 const content::NotificationDetails& details) { |
291 switch (type) { | 291 switch (type) { |
292 case chrome::NOTIFICATION_APP_TERMINATING: | 292 case chrome::NOTIFICATION_APP_TERMINATING: |
293 if (!terminating_callback_.is_null()) | 293 if (!terminating_callback_.is_null()) |
294 terminating_callback_.Run(); | 294 terminating_callback_.Run(); |
295 break; | 295 break; |
296 default: | 296 default: |
297 NOTREACHED() << "Received unexpected notification"; | 297 NOTREACHED() << "Received unexpected notification"; |
298 } | 298 } |
299 } | 299 } |
OLD | NEW |